The default bug view has changed. See this FAQ.

Need to support Context.observeInstructionCount for compiled mode

RESOLVED FIXED

Status

Rhino
Compiler
--
enhancement
RESOLVED FIXED
10 years ago
10 years ago

People

(Reporter: Norris Boyd, Unassigned)

Tracking

Details

Attachments

(4 attachments)

(Reporter)

Description

10 years ago
from mozilla.dev.tech.js-engine:

> 3. stopping the script in higher optimized code is impossible under
> the current rhino conditions. I can use the Thread.stop() method but
> am reluctant to do so as it is unsafe. Is it possible to have a stop()
> or interrupt() function to stop execution of a malicious script thats
> running in highly optimized  context ?

You're right that this is a feature request and a good one. The right
way to do this is to implement Context.observeInstructionCount for
compiled mode. There would need to be some way to indicate to the
compiler that you'd like to observe the count, and then compile in
callbacks from the generated Java classes at key points (backwards
jumps, function returns) that increment a counter by some value that
approximates the count of executed Java instructions. The runtime
could then monitor these like is already done for interpreted scripts.

Comment 1

10 years ago
http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/3211633206991a7e
Severity: normal → enhancement
OS: Linux → All

Comment 2

10 years ago
Created attachment 283434 [details] [diff] [review]
A Patch for Codegen.java

the function addInstructionCount adds a call in the compiled call to ScriptRuntime to append the number of instructions that is appropriate

Comment 3

10 years ago
Created attachment 283435 [details] [diff] [review]
Patch to ScriptRuntime.java

Added the function that is being called by the compiled class - and adds the instruction count that is given by the argument.

Comment 4

10 years ago
Created attachment 283437 [details] [diff] [review]
PAtch to compilerEnviros.java

Comment 5

10 years ago
Created attachment 283438 [details]
PAtch to Context.java
(Reporter)

Comment 6

10 years ago
I changed the approach a bit and added some additional supporting code. 

Committed:

Checking in src/org/mozilla/javascript/CompilerEnvirons.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/CompilerEnvirons.java,v  <--  CompilerEnvirons.java
new revision: 1.17; previous revision: 1.16
done
Checking in src/org/mozilla/javascript/Context.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Context.java,v  <--  Context.java
new revision: 1.261; previous revision: 1.260
done
Checking in src/org/mozilla/javascript/ScriptRuntime.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java,v  <--  ScriptRuntime.java
new revision: 1.278; previous revision: 1.277
done
Checking in src/org/mozilla/javascript/optimizer/Codegen.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/optimizer/Codegen.java,v  <--  Codegen.java
new revision: 1.256; previous revision: 1.255
done
Checking in toolsrc/org/mozilla/javascript/tools/jsc/Main.java;
/cvsroot/mozilla/js/rhino/toolsrc/org/mozilla/javascript/tools/jsc/Main.java,v  <--  Main.java
new revision: 1.14; previous revision: 1.13
done
Checking in toolsrc/org/mozilla/javascript/tools/resources/Messages.properties;
/cvsroot/mozilla/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties,v  <--  Messages.properties
new revision: 1.32; previous revision: 1.31
done
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.