Commit Graph

1152 Commits

Author SHA1 Message Date
igor%mir2.org
c386a1cc35 Make Optimizer class a package private and turn most of its methods into private ones. 2003-02-15 12:56:21 +00:00
igor%mir2.org
9f52d081d9 I changed PreorderNodeIterator so a pattern for its usage will be:
PreorderNodeIterator iter = new PreorderNodeIterator();
for (iter.start(tree); !iter.done(); iter.next()) {
    Node node = iter.getCurrent();
    ...
}

instead of

PreorderNodeIterator iter = tree.getPreorderIterator();
Node node;
while ((node = iter.nextNode()) != null) {
}

to allow for more flexible usage and added PreorderNodeIterator.nextSkipSubtree to skip iteration of the last visited node subtree which allows to have simple code  in Optimizer.buildStatementList when iterating over statements.
2003-02-15 12:47:45 +00:00
igor%mir2.org
ade76dc700 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=193418 :
The bug caused by a missed check in StmtNodeIterator.nextNode for a possible null result of findFirstInterestingNode inside the search loop which made search to stop preliminary with non-empty stack.

The changes fixe this and integrate StmtNodeIterator into
Optimizer.buildStatementList as StmtNodeIterator was used only by
buildStatementList and the new version is simpler.
2003-02-15 10:33:31 +00:00
igor%mir2.org
2660547dee Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=191276 :
The reason for the bug was that omj/optimizer/Optimizer.java when optimizing code for this[name] (see GETELEM switch, line 665) assumed a number context for GETELEM index node unconditionally which is wrong.

The fix uses number context only if [] argument is known for sure to be a number.
2003-02-14 23:56:34 +00:00
igor%mir2.org
ca577aa247 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=192288 :
The bug was caused by a double call to Codegen.addNumberConstant, the first
time correctly from Codegen.visitLiteral and the second time wrongfully from
the loop in emitConstantDudeInitializers where loop index should be used
instead of calling addNumberConstant. As addNumberConstant would return the
same index for same numbers, the bug surfaces only with NaN as
addNumberConstant does not recognizes already added NaN. The bug also visible
only with optimization set to 1 or higher since only then constant folding can
produce NaN literal.

The fix removes the second call to addNumberConstant and uses
ScriptRuntime.NaNobj for NaNs.
2003-02-14 23:53:32 +00:00
igor%mir2.org
ef55bade16 Make ScriptRuntime.NaN, ScriptRuntime.NaNobj and ScriptRuntime.negativeZero static final again as now a workaround for MS JVM uses Double.longBitsToDouble to get the necessary values. 2003-02-14 23:51:28 +00:00
igor%mir2.org
d42d684b62 I made Context.codeBug public so optimizer can use it. 2003-02-14 23:47:11 +00:00
igor%mir2.org
485f42581c Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=192105 :
The reason for the bug is that emitDirectConstructor generates code to call
setPrototype twice instead of setPrototype/setParentScope pair during new JS
object construction. The fix replaces that setup by a single call to
BaseFunction.createObject which is used by Interpreter as well.
2003-02-14 22:38:49 +00:00
igor%mir2.org
65842b334f Optimization: In OptFunctionNode.getDirectCallParameterSignature use static strings for common cases of 0, 1 and 2 direct parameters. 2003-02-14 22:36:58 +00:00
igor%mir2.org
788b2b2adf Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=191633 :
Replace tail recursion in TokenStream.getToken by a loop.
2003-02-14 20:20:46 +00:00
igor%mir2.org
b1de655726 Mostly cosmetics: use consistent layout for case statements and add additional {} block around main code in TokenStream.getToken() so the following patch to fix http://bugzilla.mozilla.org/show_bug.cgi?id=191633 will be small. 2003-02-14 20:19:07 +00:00
igor%mir2.org
8d78476dde Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=191668 :
Integration of LineBuffer into TokenStream code which now uses a special buffer for unreading of several chars to follow SM more closely. In this way there is no problem with a possible backtracking of 3 chars on failed attempt to match <!-- at the last minus.

TokenStream is also modified to accept a string with a source directly which avoids the need to construct intermediate StringReader in Context and allows to remove DebugReader class which is replaced by a simple function to read all Reader data into string.
2003-02-14 17:09:19 +00:00
igor%mir2.org
16f9ecfd66 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=192226 :
Codegen.visitRegularCall should not try to apply the simple call optimization
when firstArgDone is true indicating directly called function. The patch also
replaces generation of code to call new Object[0] by loading the
ScripRuntime.emptyArgs field.
2003-02-14 16:55:40 +00:00
igor%mir2.org
55fc9c878b Use x instanceof Type checks in place of x.getClass() = TypeClass as instanceof is significantly faster then calling getClass. 2003-02-14 16:53:14 +00:00
igor%mir2.org
58a609ac23 Patch from Steven Beal fixing a bug due to my changes:
I just noticed that the changes introduced with
v1.29 of Main.java broke the ability to do hot
reloads of scripts.  To be more explicit, the script
is actually reloaded but the source in the debugger
is not updated to reflect the newly loaded code.
...
Attached is a patch that restores the original behavior.
The refactorings are preserved but the handling of
previously loaded SourceInfo objects is restored and the
check for previously loaded ScriptItem instances
removed.
2003-02-13 03:01:09 +00:00
nboyd%atg.com
01d701f40f Remove language about "release candidate" now that we have a final. 2003-02-11 15:04:12 +00:00
nboyd%atg.com
a14de23839 Update for final release 2003-02-11 01:50:26 +00:00
nboyd%atg.com
ccf0277131 Update release date. 2003-02-10 15:36:42 +00:00
igor%mir2.org
c5d1277e24 More info on new security interfaces 2003-02-07 20:44:47 +00:00
nboyd%atg.com
0e45793abd fix bug 106831 2003-02-03 01:17:44 +00:00
rogerl%netscape.com
62d53e10d0 Fixing bug #190685, re-allowing '{' as un-quantifier literal. 2003-01-27 21:13:15 +00:00
igor%mir2.org
314a1c1c1f Added log for more fixed bugs 2003-01-27 20:04:13 +00:00
igor%mir2.org
615d6d6623 Do not call setSelectedIndex on frame JList if there are no frames. 2003-01-26 18:33:30 +00:00
igor%mir2.org
ae4b000c3f Added documentation strings for runCommnad and spawn is changed to pass empty argument array instead of null if function arguments are not specified to avoid a null pointer exception in InterpretedFunction.call 2003-01-26 18:28:26 +00:00
igor%mir2.org
7129e5491a Documentation about runCommand in shell 2003-01-26 18:01:43 +00:00
igor%mir2.org
7b5c64a220 Added runCommand to execute external processes 2003-01-26 15:43:50 +00:00
igor%mir2.org
47d2d76ac2 Added list of resolved Bugzilla reports 2003-01-26 14:30:47 +00:00
rogerl%netscape.com
517e75d112 Fixed bug #189898, replace not working with string argument. Also added
error checking for bad quantifiers (see bug 188206)
2003-01-22 18:55:41 +00:00
igor%mir2.org
3b9a6fe0ef Patch from Christopher Oliver to fix http://bugzilla.mozilla.org/show_bug.cgi?id=189183 2003-01-20 15:09:45 +00:00
igor%mir2.org
03a23cff39 Small fixes in links 2003-01-17 16:40:45 +00:00
nboyd%atg.com
72250520e9 UPdate to rc 3 2003-01-16 20:29:43 +00:00
igor%mir2.org
44acf1e60b Note about scripting of classes from any class loader 2003-01-16 17:22:40 +00:00
nboyd%atg.com
e6bc4eccae Add implmentation version date. 2003-01-16 14:24:03 +00:00
igor%mir2.org
d8492658bb Committing patch from Steven Beal:
Have you considered adding a "Go" method to Main.java with
public visibility (same behavior as pressing the "Go" button in the debugger UI).

This would be a big help in a system where the debugger has been
embedded.  Being able to close the debugger and ensure that any
breakpoints were removed and any blocked threads notified would
be a nice feature.  Without this, closing the debugger can either
a) halt the application or b) destroy the debugger leaving blocked
threads in a permanent wait state.  Note that the debugger is
not actually destroyed in this case because the waiting threads
prevent it from being wholly GCed.
2003-01-15 10:42:56 +00:00
nboyd%atg.com
7418e4b7de Update to R4. 2003-01-14 16:42:16 +00:00
igor%mir2.org
71741a82b8 Fixing mnemonics shortcuts for Debug menu 2003-01-14 14:44:46 +00:00
igor%mir2.org
b9e26a25cb From Steaven Beal:
This looks like a simple case of using the Hashtable key
instead of the value...

    public void clearAllBreakpoints() {
        // Igor - Use of keys() is inappropriate here.  It produces
        // a ClassCastException on the assignment below.  The
        // keys are String instances, not SourceInfo instances...
        //
        //Enumeration e = sourceNames.keys();
        Enumeration e = sourceNames.elements();
	...
    }
2003-01-14 11:24:47 +00:00
nboyd%atg.com
9134e7185d Update for RC2 2003-01-01 20:17:17 +00:00
igor%mir2.org
b0dd32ca85 Deprecating ClassOutput in favor of ClassRepository and Context methods to access ClassNameHelper functionality in favor of directly calling ClassNameHelper methods. For that I changed ClassNameHelper from interface to abstract class and added ClassNameHelper.get(Context cx) method to get name helper object that is used for the given Context object. 2002-12-31 18:21:32 +00:00
igor%mir2.org
34427cc0a9 Allow application to customize class loader used for loading generated code.
For that I added new method createClasssLoader to Context, which by default returns new instance of DefiningClassLoader and changed the code to use this method instead of creating DefiningClassLoader directly. I moved DefiningClassLoader to org.mozilla.javascript package so core Rhino classes would not depend on org.mozilla.classfile package. I also changed SecurityController.createClasssLoader to take additional parentLoader argument to explicitly specify which class loader should be parent for generated code.
2002-12-31 09:42:42 +00:00
igor%mir2.org
0499c96033 Eliminating calls to Thread.getContextClassLoader().
From my mail to Norris Boyd:

When considering http://bugzilla.mozilla.org/show_bug.cgi?id=166530 I realized that my 2 years old suggestion to use Thread.getContextClassLoader() in org.mozilla.classfile.DefiningClassLoader was wrong, as it does not follow class loader chain pattern Rhino embeddings can use. Moreover, it is wrong to use Thread.getContextClassLoader() when searching for Rhino classes as if Rhino is available via the system class loader and an application uses its copy from another loader, Thread.getContextClassLoader() would return incompatible class while simple Class.forName() would do proper job of loading the requested class from a loader of Class.forName() caller.

The only place where Thread.getContextClassLoader() can be useful is when searching for classes in NativeJavaPackage, but even there with a new option to use Package with an explicit class loader argument it is not necessary as one can write in a script
Packages(java.lang.Thread.contextClassLoader) to get necessary behavior.
2002-12-30 18:22:58 +00:00
igor%mir2.org
c1bd6caf06 Replace ScriptRuntime#main(String scriptClassName, String[] args) by ScriptRuntime#main(Class scriptClass, String[] args) and to optimizer.Codegen#generateMain code to generate call to Class.forName before calling ScriptRuntime#main. In this way script byte code can access Class object if generated script is loaded via different class loader then Rhino classes. 2002-12-30 06:49:10 +00:00
igor%mir2.org
5cb276ce94 When checking for a nested class, try to load it from class loader for the parent class, not from the loader for Rhino classes. 2002-12-30 00:50:57 +00:00
igor%mir2.org
25a4f559fd Move code to try to load a class from getPkgProperty to the separated findClass method and add catching of SecurityException there. 2002-12-30 00:49:11 +00:00
igor%mir2.org
6c08e83f5d Change FunctionObject to extends BaseFunction, not NativeFunction as the later is more tailored for function representing JavaScript code. 2002-12-30 00:43:33 +00:00
igor%mir2.org
7aa9281947 To map a class name to the corresponding Class instance from the adapter code generate code to call Class.forName instead of calling ScriptRuntime.loadClassName so a class loader for the generated code will be used to access the Class instance, not the loader for the Rhino classes. 2002-12-29 20:21:06 +00:00
igor%mir2.org
1f5d46210d In createInvoker I replaced classLoader.loadClass by classLoader.linkClass to remove catching ClassNotFoundException 2002-12-29 10:52:10 +00:00
igor%mir2.org
d90d743307 Fixing design flaw in SecurityController:
The new SecurityController in its current form does not allow to define more then one generated class class in the same class loader effectively preventing to use optimizer which needs to define classes that refer each other and should be defined in the same loader.

To fix this I replaced the defineClass method in SecurityController by
    public GeneratedClassLoader createClassLoader(Object securityDomain);
which returns instance of the new GeneratedClassLoader interface which can be used to define several classes. I also made DefiningClassLoader to implement this interface to simplify code in JavaAdapter.java and optimizer/Codegen.java.
2002-12-28 05:37:43 +00:00
igor%mir2.org
4c56bf59de Preparations for 1.5R4 release 2002-12-24 01:34:45 +00:00
igor%mir2.org
7183ecda1e Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=184107
Always put function expression statements into initial activation object ignoring the with statement to follow SpiderMonkey
2002-12-23 15:01:53 +00:00
igor%mir2.org
453a0563cf Mostly cosmetics: use consistent naming for new API for function object initialization. 2002-12-23 14:56:58 +00:00
igor%mir2.org
508aa98e62 Eliminate double creation of Function objects representing nested functions in scripts/functions and use ScriptRutime.putFunction to bind function objects with activation scope. 2002-12-22 22:39:10 +00:00
igor%mir2.org
13ec8a642c Use Context.enter() try { } finally { Context.exit() } instead of try { Context.enter() } finally { Context.exit() } as Context.exit should only be called if Context.enter() returns successfully. 2002-12-22 19:12:50 +00:00
igor%mir2.org
0815885549 Move code to put functions as properties of activation object to ScriptRuntime.putFunction so it can reused by optimizer. 2002-12-22 19:08:52 +00:00
igor%mir2.org
dc573f11eb Do not put "anonymous" into BaseFunction.functionName for functions created via new Function. Instead NativeFunction.getFunctionName() returns "anonymous" for function name for such functions which allows to assume that BaseFunction.functionName always holds real name. 2002-12-22 19:06:26 +00:00
igor%mir2.org
f0e7977473 I replaced exception handlers for InstantiationException and friends during Class/Constructor.newInstance calls to construct NativeFunction/NativeScript instances via single catch (Exception ex) as the handlers rethrow exceptions as RuntimeException in any case. As it reduces OptRuntime.newOptFunction to few lines, its single usage in Codegen is inlined. 2002-12-22 02:51:16 +00:00
igor%mir2.org
89e660e85e I removed constants denoting _QUICK bytecodes as valid bytecode can not contain them. To catch possible bugs with passing invalid opcode I also replaced extra, opcodeCount and stackChange arrays by functions with switch statements that throws IllegalArgumentException on bad opcode. It also has an advantage of reducing class file size due to lack of support in JVM for efficient array initialization. 2002-12-22 02:42:40 +00:00
igor%mir2.org
ac9e2f79e3 I removed dependency of Parser.decompile on NativeFunction. Now Parser.decompile takes as argument a tree structure describing encoded source for script or function and their nested functions. In case of interpreter the tree is built from interpreter runtime data while the optimizer puts a static function to construct tree into the class file representing compiled script or function. This function is called via reflection.
The change removes the need to have instances of NativeFunction representing nested functions constructed before they are needed as a part of script execution.
2002-12-21 12:43:55 +00:00
igor%mir2.org
3cf3b9f6e4 I removed code to add EmptyArray field to generated field in Codegen.generateInit as it was redundant to ScriptRuntime.emptyArgs 2002-12-20 16:14:51 +00:00
igor%mir2.org
56e0e5ae51 In Codegen.visitFunction I replaced code generating call to createFunctionObject that would use reflection to instantiate function object by a direct calling of function constructor and a separated call to function initialization in OptRuntime.setupFunction. 2002-12-20 12:21:35 +00:00
igor%mir2.org
ecb7dc469e I removed debug_level and debug_srcName fields as they are never used. 2002-12-20 12:12:41 +00:00
igor%mir2.org
da6403bcf0 I moved optimizer related code to initialize a function from ScriptRuntime to optimizer/OptRuntime and replaced common code to initialize function prototype and scope in few places by ScriptRuntime.initFunction 2002-12-19 19:48:55 +00:00
igor%mir2.org
ec811806ab Cosmetics: expanding tabs 2002-12-17 20:56:08 +00:00
igor%mir2.org
b99f98d8e9 Cosmetics: removal of junk white-space at line end 2002-12-17 20:48:35 +00:00
igor%mir2.org
4dc361a246 I replaced all ScriptableObject.getClassPrototype(scope, "Function") by ScriptableObject.getFunctionPrototype(scope) 2002-12-17 16:36:23 +00:00
igor%mir2.org
2fbbcfd7f1 I moved details of debugger API changes since 1.5R3 to a separated document. 2002-12-17 09:26:48 +00:00
nboyd%atg.com
56dba39300 Add link to release candidate. 2002-12-16 16:51:33 +00:00
igor%mir2.org
3adfa94f2f Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=181834
Ignore dynamic scope flag for nested functions and functions defined inside with statements
2002-12-14 18:56:27 +00:00
igor%mir2.org
34357b4eb8 *** empty log message *** 2002-12-13 18:26:31 +00:00
igor%mir2.org
7141e33a06 *** empty log message *** 2002-12-13 18:16:12 +00:00
igor%mir2.org
9906757830 Document update 2002-12-13 14:21:38 +00:00
igor%mir2.org
8ba20cee09 Fix for http://bugzilla.mozilla.org/show_bug.cgi?id=185165
I made ScriptRuntime.escapeString to escape \ and remove code to escape single quote ' as it is unreachable due to if (' ' <= c && c <= '~' && c != '"' && c != '\\') check as ' should not be escaped.
2002-12-13 11:56:54 +00:00
igor%mir2.org
3b3f720f15 I removed InterpretedFunction.itsClosure as it was effectively used only itsClosure != null test and the effect can be done via setting InterpretedFunction.useDynamicScope to false. 2002-12-12 10:46:52 +00:00
igor%mir2.org
d99c560f50 I moved itsUseDynamicScope from InterpreterData to InterpretedFunction as this flag affects only functions, not scripts and to initialize this flag not during script compilation but during function creation which happens at the start of script execution. It allows to alter the flag for already compiled scripts before their execution. 2002-12-11 22:28:00 +00:00
igor%mir2.org
47bee26159 Fixed link 2002-12-10 11:19:02 +00:00
igor%mir2.org
784105585e I changed InterpreterData.itsNestedFunctions from InterpretedFunction[] to InterpreterData[] because due recent changes/fixes InterpreterData.itsNestedFunctions was used effectively only to get information already available InterpreterData. 2002-12-09 17:50:20 +00:00
igor%mir2.org
2d1bf652ef Move creation of InterpretedFunction instances to createFunction (former createFunctionObject) to have function initialization at one place. 2002-12-09 13:37:13 +00:00
igor%mir2.org
8ae4899263 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=184111
Patch from Marcus Crafter:
...
After speaking with Christopher Oliver, the problem seems to be a general JDK
1.4 bug that caches selected values in JComboBox, even after removeAllItems() is
called. Since its a general defect Christopher and I thought we'd report and get
it fixed in the main CVS tree.
...
2002-12-08 21:06:45 +00:00
igor%mir2.org
50029c37e2 If debugger does not get function or script source via handleCompilationDone, try to read it from supplied URL. 2002-12-08 20:49:39 +00:00
igor%mir2.org
cea6846352 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=154693
On function/script start create and initialize instance of InterpretedFunction for each function statement.
2002-12-07 14:15:27 +00:00
igor%mir2.org
1b4064c81d Cosmetics: layout fix 2002-12-06 16:38:38 +00:00
igor%mir2.org
650a6e1763 isJavaPrimitiveWrap/setJavaPrimitiveWrap are made final as sublasses should not be override them when customizing WrapFactory 2002-12-06 16:36:25 +00:00
igor%mir2.org
30863897ad Remove generation of closure icode for function statements as they are initialized at script/function start, not at point of declaration. This redundant closure icodes were effectively no-operation but caused bigger stack to be allocated then necessary. 2002-12-05 21:04:30 +00:00
igor%mir2.org
8e6db6ff11 Remove closure constructor from InterpretedFunction and initialize InterpretedFunction.itsClosure constructor in Interpreter directly. This besides reducing code size will help to make fix for http://bugzilla.mozilla.org/show_bug.cgi?id=154693 smaller 2002-12-04 09:49:07 +00:00
igor%mir2.org
1e2bf2efec To allow straightforward detection of functions created via Function(...) constructor, I added the fromFunctionConstructor boolean flag to NativeFunction which allows to simplify code dealing with the EcmaScript requirement to return anonymous as a name for such functions. 2002-12-03 12:43:14 +00:00
igor%mir2.org
5aa3180827 1. Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=182028
Now caching of the last access slot covers GetterSlot instances as well and getter is always called for such slots

2. Fixing a potential race condition in setBySetter when a setter slot becomes an ordinary slot in response to a setter returning a value.

During execution of setBySetter a different thread can see initial null value in slot.value instead of the result of setter call as it is possible that JVM will first update slot.flags and only then slot.value for that thread. The fix replaces the old getter slot  by an ordinary one under synchronized block for that I added new getSlotPosition method and updated the rest of code accordingly.
2002-12-03 12:38:55 +00:00
igor%mir2.org
fa14609cd7 I moved decompilation code from NativeFunction to Parser so changes in compressed source structure will affect only one file. 2002-11-26 08:00:44 +00:00
igor%mir2.org
3626a138ec Add args and argCount to InterpreterData to emphasize that InterpretedScript/InterpretedFunction are just runtime wrappers around InterpreterData 2002-11-25 21:33:56 +00:00
igor%mir2.org
1e02010066 Wrap restoring of the original optimization level into finally block 2002-11-25 16:46:16 +00:00
igor%mir2.org
8f8ec48385 Fixing 181654: Error.prototype.toString is a generic function now
printing this.name + ": " + this.message for any this.
2002-11-25 16:44:30 +00:00
igor%mir2.org
9be5d10e5c Replace getScriptable() by getFunctionName() in omj/debug/DebuggableScript.java as the debugger used DebuggableScript.getScriptable() only to query function names.
It allows to implement the DebuggableScript interface only  by omj/InterpreterData instead of 2 identical implementations by InterpretedFunction and InterpretedScript.
2002-11-14 21:12:36 +00:00
igor%mir2.org
cd8a03eb8a Fixing in Interpreter.dumpICode reading of index from a wrong offset 2002-11-13 10:22:46 +00:00
igor%mir2.org
b09ef875a4 Fixing misspellings comments 2002-11-13 10:13:40 +00:00
igor%mir2.org
efd9f298ab Call NativeArray.getLength() instead of deprecated NativeArray.jsGet_length() 2002-11-12 09:41:09 +00:00
igor%mir2.org
6e859f553a Cosmetics: use consistent naming and layout for internal methods providing JS library implementation. 2002-11-12 09:37:43 +00:00
igor%mir2.org
8cd90d6557 1. Deprecation jsGet_length in favour of getLength
2. Cosmetics: use consistent naming and layout for internal methods providing JS library implementation.
2002-11-12 09:36:40 +00:00
igor%mir2.org
594696279f 1. In js_concat determine the the size of the resulting string to avoid reallocations in StringBuffer .
2. Cosmetics: use consistent naming and layout for internal methods providing JS library implementation.
2002-11-12 09:33:48 +00:00
igor%mir2.org
82ea401577 Cosmetics: use consistent naming and layout for internal methods providing JS library implementation 2002-11-12 09:29:57 +00:00
igor%mir2.org
99c0da59df Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=179068
Allow to use char sequences exceeding 64K when storing source for decompilation

The current 64K limit for string literals comes from omj/Parser.java where it constructs the internal script presentation for future decompilation. The patch extends this form to allow string sequences with more then 64K characters and modifes decompilation code in omj/NativeFunction.java accordingly.
2002-11-12 09:24:54 +00:00
igor%mir2.org
f8386f2604 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=179366
Assume --> after a possible whitespace after line start means comments to end-of-line. The change follows the SpiderMonkey solution.
2002-11-12 09:20:09 +00:00
igor%mir2.org
7ef61113d0 Cosmetics: refactor decompile without changing its functionality so a possible future patch to allow literal strings greater then 64K would be less intrusive. 2002-11-08 12:08:52 +00:00
igor%mir2.org
af3cca93fd I made FunctionNode to inherit from Node instead of Node.StringNode as FunctionNode is never used as a string source. 2002-11-03 01:26:29 +00:00
igor%mir2.org
e33d132a12 I removed method duplication in Node where getNext() was duplicated as getNextSibling() and code was using both of them and similarly for getFirstChild()/getFirst(). 2002-11-02 22:08:00 +00:00
igor%mir2.org
9b6ae7fdf7 Allow for TokenStream.COMMA node in the parsed tree to contain more then 2 children to avoid too-deep recursion during code generation for long array and object initialization lists. 2002-11-02 18:01:26 +00:00
igor%mir2.org
6c91eb5274 Cosmetics: use uniform indentation in switch statements 2002-11-02 14:54:35 +00:00
igor%mir2.org
9c88f342b2 Avoid potentially expensive calls to Node.addChildBefore which may need to traverse a long child list to find the previous child when a reference to the previous child is available from context. 2002-11-02 12:52:11 +00:00
igor%mir2.org
498ccb82fe Clear reference to sourceBuffer array as soon as it is no longer needed to allow its earlier GC. 2002-11-02 12:46:28 +00:00
igor%mir2.org
85132aacd6 Fixing 159334: store bytecode indexes as uint16 to extend limit on maximum number of different strings to 64K 2002-11-01 14:43:34 +00:00
igor%mir2.org
b9a8bd50ee Fixing regression introduced by 1.93: during generation of code for NEW and CALL do not assume that function name index would be the index of the last string in the string table as due to name sharing it can be any index. Instead NEW and CALL generator uses lastStringIndex which is updated in addString and holds the last used string index. 2002-10-31 01:19:53 +00:00
igor%mir2.org
902aee2f8d Fixing 177314:
TokenStream.java: third octal digit is a part of the octal escape in strings only if the result is <= 0377.

resources/Messages.properties: removal of unused msg.oct.esc.too.large
2002-10-30 09:20:00 +00:00
igor%mir2.org
86a5bceb04 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=173906: change Codegen.visitCall to check for dynamic scope flag when calling
direct call target
2002-10-24 10:05:36 +00:00
igor%mir2.org
a086d887a9 Using ThreadLocal under JDK >= 1.2 in Context.enter/Context.exit so they do not need to synchronize on global Context.threadContexts object as java.lang.ThreadLocal allows to associate a Context instance with the current thread in a completely synchronization-free way.
When ThreadLocal is not available (JDK 1.1), the old way of doing things is used.
2002-10-24 10:04:30 +00:00
igor%mir2.org
32dcd895ba I modified Context.enter/Context.exit to remove explicit synchronization on threadContexts as implicit implicit synchronization when calling threadContexts.get/threadContexts.put/threadContexts.remove is enough to ensure thread safety. It reduces time spend in synchronized code so Context.enter/Context.exit is less problematic with script execution on many threads.
The change also allows with simple modifications of Context.getCurrentContext and Context.setThreadContext to use java.lang.ThreadLocal from JDK 1.2 to remove any synchronization on global data structures during Context.enter/Context.exit/Context.getCurrentContext.
2002-10-23 09:56:26 +00:00
igor%mir2.org
7fe4fdbc33 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=173180
Merges utf8ToOneUcs4Char body into the decode method and adds checks
for overlongs to follow SpiderMonkey.
2002-10-22 21:22:44 +00:00
igor%mir2.org
5c85c4f1ae Add isGeneratedScript to DebuggableScript and its implementations to allow debuger to distinguish between scripts and functions coming from external files or ones defined vvia exec or new Function() 2002-09-26 20:19:39 +00:00
igor%mir2.org
984ec2e982 Fixing 169830: I replaced in jsFunction_concat calls to hasLengthPropert by ScriptRuntime.instanceOf and as hasLengthPropert is no longer used, I removed it as well. 2002-09-24 15:57:58 +00:00
igor%mir2.org
a63ccf0cc5 In newObject pass top level scope to the constructor, not ctor.getParentScope() to take into account hasCompileFunctionsWithDynamicScope() 2002-09-24 14:14:00 +00:00
igor%mir2.org
6f4b833c59 In getClassPrototype replace ScriptRuntime.getTopLevelProp by getProperty to avoid double call to getTopLevelScope 2002-09-24 14:10:53 +00:00
igor%mir2.org
e3402dd61f In jsFunction_concat inline ScriptRuntime.newObject to throw JavaScriptException if array constructor throws one and avoid double call to ScriptableObject.getTopLevelScope() 2002-09-24 14:08:22 +00:00
igor%mir2.org
0a4b0ef2af Change ScriptRuntime.getTopLevelPropery to call ScriptableObject.getProperty in place of explicit loop over the prototype chain. It makes sure that all Scriptable.get(property, start) on the prototype chain are called with a proper start value.
Add getExistingCtor to get existing constructor property or throw an exception.
2002-09-24 14:05:24 +00:00
igor%mir2.org
8e32c0c8a1 Remove the minimalAllocation field and instead pre-allocate data array in the constructor if necessary. 2002-09-24 11:21:19 +00:00
igor%mir2.org
5f6a565762 Change NativeArray.getLengthProperty to return long instead of double as its results are always uint32 and adjust its usage accordingly . Fix Context.getElements documentation to state that it returns empty array, not null, if object does not have a reasonable length property. 2002-09-24 09:29:27 +00:00
igor%mir2.org
6c61080e81 Reduce "new X" usage by inlining few classes or packing their members into long field 2002-09-18 12:57:09 +00:00
igor%mir2.org
afd43edcb3 C relics removal: no need to check for null after "new X" 2002-09-18 12:50:51 +00:00
igor%mir2.org
c0c5171c48 Store line number and operation type as int field instead of wrapping them into Integer; use Node subclass for nodes with string data; add few explicit checks about node structure assumptions. 2002-09-04 09:28:58 +00:00
igor%mir2.org
9068084e6a Use Node subclass to represent number literals to avoid creation of Double object. 2002-09-03 12:34:56 +00:00
igor%mir2.org
5381cd9877 Workaround in JS Math.pow implementation for java.lang.Math.pow brokeness in some JVM. 2002-08-27 08:14:49 +00:00
igor%mir2.org
21946b7034 Fixing a bug reported by Steven Beal where Interpreter.icodeTokenLength() and In
terpreter.dumpICode() used wrong size for CLOSURE opcode arguments.
2002-08-27 08:12:25 +00:00
igor%mir2.org
265a588aaf Fixing a bug reported by Steven Beal where Interpreter.icodeTokenLength() and Interpreter.dumpICode() used wrong size for REGEXP opcode arguments. 2002-08-26 09:11:54 +00:00
igor%mir2.org
dd4a08ede4 Renaming the TokenStream.OBJECT constant to TokenStream.REGEXP for better reflection of semantics. 2002-08-26 08:06:27 +00:00
igor%mir2.org
b481986e42 Fixing line number generation for the empty return statement which was reported by Steven Beal. It was caused by missed update of lineno in statementHelper when dealing with return;. 2002-08-16 06:42:27 +00:00
igor%mir2.org
7ad5c25d66 Fixing ArrayIndexOutOfBoundsException reported by Steven Beal caused by broken code to setup endLine in SourceInfo.updateLineInfo. 2002-08-15 06:42:45 +00:00
rogerl%netscape.com
fd5470f403 Changed decimal escape handling to backward compatible rather than ECMA3
conforming. (Bug#158159)
2002-07-23 21:38:03 +00:00
igor%mir2.org
012b28330e Serialization fixes to correctly restore members and related fields in NativeJavaClass. 2002-07-16 21:17:09 +00:00
igor%mir2.org
0257e231a5 Fixing the bug 157196: custom serialization of ScriptableObject not to save deleted/empty slot. 2002-07-16 21:15:51 +00:00
igor%mir2.org
5335225a4e Checking for 1.2 version in toString for objects and arrays is replaced by calling cx.hasFeature(Context.FEATURE_TO_STRING_AS_SOURCE) to allow to control toString from applications without switching on other JS 1.2 features. 2002-07-16 17:42:18 +00:00
igor%mir2.org
091a93a0a4 I removed startString/getString and their support code as TokenStream uses its own buffer and fixed the bug 151337 which was cause by incorrect getLine 2002-07-16 17:37:46 +00:00
igor%mir2.org
307d75e312 I changed TokenStream to use internal buffer in place of LineBuffer#startString/getString to store currently read characters for identifiers, strings and numbers. For the price of yet another character coping it allows to simplify code logic especially regarding interaction with LineBuffer.
I also fixed http://bugzilla.mozilla.org/show_bug.cgi?id=157509
2002-07-15 18:49:42 +00:00
igor%mir2.org
c725147d07 Call to InterpretedFunction.construct is inlined to avoid argument array allocation. 2002-07-12 19:40:49 +00:00
igor%mir2.org
a45b576bee Creation and initialization of new object in BaseFunction.construct is moved to a separated function createObject to simplify inlining of InterpretedFunction.construct in Interpreter 2002-07-12 19:39:57 +00:00
igor%mir2.org
017b616d0b Added ObjToIntMap.intern() 2002-07-12 19:37:20 +00:00
igor%mir2.org
9896d08d55 When calling interpreted functions from Interpreter.interpret, pass current stack arrays to the callee to avoid creation of temporary argument arrays and wrapping double numbers into Double objects. 2002-07-11 21:17:34 +00:00
igor%mir2.org
8c98718cd4 Optimizing encode/decode not to allocate temporary buffers if the result equals the original string 2002-07-11 21:10:36 +00:00
igor%mir2.org
b8b54c75b5 Optimizing NativeGlobal.js_escape, ScriptRuntime.escapeString not to create StringBuffer if there are no character to escape in the initial string. Workaround for JDK 1.1 compiler bug in the initialization of ScriptRuntime.ComparableClass. 2002-07-11 18:45:16 +00:00
igor%mir2.org
ed6e3066d3 Fixing 136893: for(i in undefined), for(i in null) do not throw TypeError but treated as for(i in {}) 2002-07-11 18:39:24 +00:00
rogerl%netscape.com
e76a9bdf17 Fixes for bugs #155285 - Array.join(undefined) should use ','
#155289 - String.prototype.XXX.length has some wrong values
 #155291 - RegExp properties should be DontEnum
Plus fix for matching against RegEXp captures with undefined value.
2002-07-09 22:28:52 +00:00
igor%mir2.org
1cf0bd8a05 Examples now uses try {} finally { Context.exit(); } to release Context even in case of errors 2002-07-09 17:49:16 +00:00
igor%mir2.org
988587183a New security implementation. 2002-07-04 21:40:12 +00:00
rogerl%netscape.com
d4cc22a21f Fixed matching of un-matched paren contents (e.g. /(a)\1/("x") ). 2002-06-28 23:04:55 +00:00
rogerl%netscape.com
a270823871 Fixed whitespace testing. Fixed bug 122167 - $nn handling in replace. 2002-06-22 19:38:02 +00:00
rogerl%netscape.com
17b4a2e105 Fixing bug 153223; - 'flat' input may be null. 'isWhiteSpace' does not
return true for non-break spaces, use 'isSpaceChar' instead. Bytes are
signed so needed to extract char values more carefully.
2002-06-21 18:19:25 +00:00
rogerl%netscape.com
9160462278 New RegExp engine implementation. 2002-06-19 21:57:57 +00:00
nboyd%atg.com
a4cf45ee33 Patch from morten@nvg.org :
I keep getting syntax errors with no line numbers as well.

That happens when I use Context.compileReader(..) to compile the script. The
DefaultErrorReporter will throw an exception with only the message and not the
line it happened on.

It is of course easy to workaround using your own error reporter, but I've
attached a patch to add on the line and source name so the DefaultErrorReporter
gives the similar output as EcmaError if that is wanted.
2002-06-17 00:49:47 +00:00
nboyd%atg.com
a8fcbf98a8 Update last qualified release statement. 2002-06-16 23:51:15 +00:00
igor%mir2.org
f14fa81202 Added get/setJavaPrimitiveWrap to WrapFactory to get/set if instances of String, Number should be wrapped or not. 2002-06-12 19:11:50 +00:00
igor%mir2.org
558b670d29 Removal of unused code for explicit JSObject support:
> Norris Boyd wrote:
>
> Igor Bukaniv wrote:
> >
> > I am curios, why there is a need to have a special JSObject support in Rhino? Was it used for anything? The implementation in the ICEbrowser does not use it as in rare cases where conversion from JSObject to/from JS type may be needed (like calling JSObject.getWindow from a script), it seems that WrapHandler (or similar modifications to pre Rhino 1.5R2 sources) and Wrapper are enough to cover all the cases.
> Yes, we should probably just remove the JSObject code. We added it early on when Rhino was first written and we thought we might need JSObject compatibility with the JS + Java implementation in Navigator 4.x. That's not important now, so we should just remove this code (which likely doesn't work at this point anyway).
2002-06-12 05:32:35 +00:00
nboyd%atg.com
ace017b83d Add to log of changes. 2002-06-10 17:44:44 +00:00
nboyd%atg.com
1260918102 Add new API class WrapFactory. 2002-06-10 14:28:37 +00:00
nboyd%atg.com
a69e72afaf Update javadoc. 2002-06-10 14:27:43 +00:00
nboyd%atg.com
55ef80a864 Add PrimitiveWrapHandler example. 2002-06-10 14:23:32 +00:00
nboyd%atg.com
ae9ac3fc7e Add example of the use of a WrapFactory. 2002-06-10 14:19:09 +00:00
nboyd%atg.com
cc0bee4d2f Fix javadoc. 2002-06-10 14:09:26 +00:00
igor%mir2.org
3ba6e39e98 Deprecating NativeJavaObject.wrap and using Context.getWrapFactory().wrap() instead. 2002-06-09 15:58:15 +00:00
igor%mir2.org
2900073823 More comments 2002-06-09 15:57:03 +00:00
igor%mir2.org
35054857bd Documentation: points to watch when upgrading to WrapFactory 2002-06-09 15:56:12 +00:00
igor%mir2.org
01bf42fa82 Fixing broken logic in emulating custom WrapFactory via deprecated WrapHandler:
the code should not call setWrapFactory with null argument, but use new WrapFactory to restore default behaviour
2002-06-09 15:54:30 +00:00
igor%mir2.org
23b2b0a6e5 Introducing the WrapFactory class that should be used in place of the deprecated WrapHandler interface. 2002-06-09 09:23:00 +00:00
nboyd%atg.com
d99804ee87 Fix for bug 149285: Complier does not report the correct line number on
SyntaxError:Invalid assignment left-hand side.
2002-06-06 15:01:57 +00:00
igor%mir2.org
2e9219f6d7 Replacing check for unescaped characters in encode/decode from searching in a string to doing switch. It provides a noticeable speedup during encoding/decoding of long strings where almost all characters should be encoded. 2002-06-05 20:40:57 +00:00
nboyd%atg.com
005f83880e Fix ClassCastException. 2002-06-04 18:37:21 +00:00
nboyd%atg.com
88e610fce6 Fix bug found by felix.meschberger@day.com:
given the following object :

----------------------------------------------
function SomeObject() {}
SomeObject.prototype.exec = function() {
  var local = this.someField;
}
----------------------------------------------

i create an 'instance', set a field and call the exec method :

----------------------------------------------
var someField = "global field value";
var anInstance = new SomeObject();
anInstance.someField = "instance field value";
anInstance.exec();
----------------------------------------------

then the local variable 'local' in the exec() method is assigned the value
of the global 'someField' variable instead of the instance field value.

the problem seems to be in the ScriptRuntime.callOrNewSpecial() method,
which is called, because the parser treats the name 'exec' specially. in
this method the exec() method gets called with

   return call(cx, fun, thisArg, args, scope);

where the 'thisArg' parameter really is the global this value instead of
the dynamic this value, which is in the jsThis variable and which would be
the one needed...

is it legitimate to replace the above call in callOrNewSpecial() with the
following line :

   return call(cx, fun, jsThis, args, scope);

this seems to only happen for methods named 'exec', which are identified as
special in the NodeTransformer.isSpecialCallName() method.

any help is appreciated. thank you very much for your time.

kind regards,
felix
2002-05-30 13:41:16 +00:00
igor%mir2.org
9dd700b9b8 Back-indent the interpreter main loop to ease code following 2002-05-22 18:42:40 +00:00
igor%mir2.org
d1f2443a48 Fixing bug 145791: apply and call with null and undefined arguments behaves as required and Function.prototype.apply.length returns 2. 2002-05-22 16:46:28 +00:00
igor%mir2.org
47da51e506 Making HTML tag helper functions to convert thisObj to string to match SpiderMonkey and user expectations (was reported by Steven Beal <steven.beal@peregrine.com>) 2002-05-21 22:00:08 +00:00
igor%mir2.org
f45acbc9ee Optimization in toInt32/toUint32/toUint16 for common case of integer argument. 2002-05-21 20:18:15 +00:00
igor%mir2.org
c8e2d56fca Added indexOf and lastIndexOf 2002-05-21 20:14:10 +00:00
igor%mir2.org
9dadadad3e In getElements return ScriptRuntime.emptyArgs when array length is 0 2002-05-21 20:13:30 +00:00
igor%mir2.org
77af40f3ba From the email:
The attached patch adds support for debugging eval and Function code transparently. It changes omj.NativeGlobal and omj.BaseFunction to embed  line number of origin of eval and Function scripts into source name and pass 1 as base line for script code. In this way a debugger implementation can treat eval and Function code in the same way as scripts loaded from some url while giving more information about error location in case of an error in eval code as the error source would contain both line number of eval origin and line number in eval code itself.
I chose to embed line numbers via patterns like

sourcefile#<line-number>(eval)
sourcefile#<line-number>(Function)

just to be able to to pass the constructed name to URL constructor if the original sourcefile is a valid URL but it is pretty arbitrary.
2002-05-20 11:40:17 +00:00
nboyd%atg.com
e7a091bc74 Fix bug:
I have noticed that attempting to call a java method like this:

public void foo(String foo, Serializable bar)
{
	// un-important details
}

from script using foo("foo", "bar"); fails because the second argument
is not deemed coercable to Serializable.  A preliminary look at the
coercion code shows that no check is made in this case with
isAssignableFrom().
The to type is only tested against StringClass and ObjectClass (non
primitive case).
(See NativeJavaObject.getConversionWeight())
2002-05-18 01:57:52 +00:00
igor%mir2.org
e2ae944398 In evalSpecial do not allocate int[] buffer Context.getSourcePositionFromStack if line number is already known 2002-05-16 04:18:56 +00:00
igor%mir2.org
f7a3211e91 In jsConstructor use single StringBuffer to build function source 2002-05-16 04:17:04 +00:00
igor%mir2.org
e7988e8b2e Check in generateFunctionICode for own source to pass to debugger to cover new Function(...) case where top level function is not part of surrounding script 2002-05-15 21:27:46 +00:00
igor%mir2.org
4bb3f8ada0 Elimination of FileWindow.breakpoints and Main.breakpointsMap as reference to SourceInfo provides all necessary information 2002-05-11 18:28:44 +00:00
igor%mir2.org
ba0661c493 Removing itsFirstLine and itsEndLine from InterpreterData and replacing in DebuggableScript getFirstLine, getEndLine and getIntructionLines by getLineNumbers as Debugger imlementation can get all the necessary information from single call to getLineNumbers 2002-05-11 16:15:50 +00:00
igor%mir2.org
8cb98c5dfa Implementing DebuggableScript.getInstructionLines via scanning icode array for line number icode tokens thus removing the need to call Context.setGeneratingDebug(true) to get brekable lines in the script. 2002-05-10 21:33:51 +00:00
igor%mir2.org
6d860f39e3 From email about moving breakpoint support away from Rhino core:
I attach the patch to move away setting/quering for breakpoints from the Rhino core to application as a debugger implementation can check if a particular line has a breakpoint or not. The changes to omj/tools/debugger takes more then few lines I initially thought but they are mostly caused by refactoring to implement different view to set/query breakpoints.

The patch replaces getLineNumbers, placeBreakpoint and removeBreakpoint in DebuggableScript by getFirstLine, getEndLine and getInstructionLines where the last function fills a boolean array to indicate which script lines can ever occur in DebugFrame.onLineChange. These are read-only functions so InterpeterData are never mdofied by the debugger.

omj/tools/debugger/Main uses this information to check whether it is possible to place breakpoint at a particular line, and if possible, it sets to true entry at the boolean breakpoint array. In this way testing for break in onLineChange is simple and fast as it just needs to check if breakpoint array holds true at the given line number position.
2002-05-10 16:17:33 +00:00
igor%mir2.org
aa545a86e2 Replace when possible usage of API available only since JDK 1.2 by their JDK 1.1 analogous or by classes available in the Rhino core to make port to JDK 1.1 easier. 2002-05-03 19:42:36 +00:00
igor%mir2.org
122f8247c5 Store only single instance of any string in InterpreterData.itsStringTable and remove itsStringTableIndex and itsDoubleTableIndex from InterpreterData as they are used only during code generation 2002-05-02 21:19:43 +00:00
igor%mir2.org
43c6776e19 Allow to put null keys to ObjToIntMap and optimize Iterator not to search through key array tail after processing the last key. 2002-05-02 21:15:33 +00:00
igor%mir2.org
462217172b In remove set int key value to 0 so a new key with the same slot would get initial 0 after put(int, Object) 2002-05-02 21:11:05 +00:00
nboyd%atg.com
91b5becea4 Fix broken link 2002-05-01 19:21:51 +00:00
igor%mir2.org
416882ec3a Allow in UintMap for any key to hold int and object values simultaneously, as the old code could only detect that the key is allowed to hold an object value only if there are no other keys with int values. In the new version, if the key is present, it always has both int and object values, but they default to 0 or int if not specified in put. It is effectively the old behavior when the map contained at least one int key, but at least it is documented. 2002-05-01 14:10:41 +00:00
igor%mir2.org
b4d17bfe98 LabelTable cleanup:
1. Targeting of labels with 0x80000000 biscuits is moved from LabelTable to ClassFileWriter as this is classfile specific and is not necessary in Interpreter.
2. LabelTable allows for pc > Short.MAX_VALUE as this restriction is classfile specific. The only requirement is for jump offsets to stay within short range.
3. LabelTable is made private member of Interpreter and ClassFileWriter instead of being classes' superclass to avoid API leakage that forced optimizer.Codegen to declare few utility methods public as they got the same signature as LabelTable methods visible throw Interpreter inheritance.
2002-04-29 19:21:57 +00:00
igor%mir2.org
ff45d81768 I replaced java.util.Enumeration type for result and arguments of ScriptRuntime.initEnum/ScriptRuntime.nextEnum by Object to allow for greater flexibility in for (...in...) implementation. 2002-04-29 17:31:11 +00:00
nboyd%atg.com
4509cada43 Patch from Igor to fix 120194 2002-04-29 00:56:30 +00:00
igor%mir2.org
b41bc47f81 Do not call acquireLabel/addLabelFixup/markLabel if label is not stored in parse tree and can be resolved immediately after node subtree generation (see new addForwardsGoto and resolveForwardGoto methods) 2002-04-28 15:17:24 +00:00
igor%mir2.org
90d91c1e22 Do not allocate Label object and instead store label's PC and fixups in itsFixupTable and itsFixupTable arrays 2002-04-27 12:27:14 +00:00
igor%mir2.org
59fedca6b1 Hiding details of omj.LabelTable implementation behind new getLabelPC, addLabelFixup, fixLabelGotos and clearLabels methods and making all its fields private. 2002-04-27 09:13:28 +00:00
igor%mir2.org
2c519e3fb5 Refactoring interpreter initialization to follow code more easily 2002-04-26 23:18:08 +00:00
igor%mir2.org
d8b73f2048 Tab removal 2002-04-26 23:14:50 +00:00