Граф коммитов

1338 Коммитов

Автор SHA1 Сообщение Дата
igor%mir2.org 3aafae2f86 1. Consistently use ScriptRutime.<ClassName>Class instead of Classname.class to decrease code size and loading time
2. Small optimization in ScriptRuntime.toNuber
2003-04-26 12:01:38 +00:00
igor%mir2.org 8113ba21d9 Deprecation of toObject in Context and ScriptRuntime forms that takes a static type argument.
The static type argument to toObject is effectively never used since it always assumes that instances of String, Number and Boolean represent primitive JS values and handled via ScriptRuntime.newObject and in the rest of cases static type was not checked by WrapFactory.
2003-04-25 10:08:44 +00:00
igor%mir2.org 38b60c25d7 More comments about NativeJavaMethod.findFunction requirements 2003-04-24 17:16:21 +00:00
igor%mir2.org f87766bec4 Changing NativeJavaClass.construct and NativeJavaMethod.call not to modify passed argument array with unwrapped values. Instead a new array is allocated if any unwrapped value would be different from the original JS argument. 2003-04-24 17:13:57 +00:00
nboyd%atg.com 4b1dee847c Add new document on scripting java. 2003-04-24 13:14:00 +00:00
igor%mir2.org adbcef8ac9 Resolving http://bugzilla.mozilla.org/show_bug.cgi?id=203013 :
Changing semantics of a sealed object to mean that all its properties are ReadOnly in addition to DontDelete.
2003-04-24 12:15:30 +00:00
igor%mir2.org b2420d4dec Resolving http://bugzilla.mozilla.org/show_bug.cgi?id=202872 :
public static Method[] findMethods(Class clazz, String name)

is replaced by

static Method findSingleMethod(Method[] methods, String name)
2003-04-24 12:08:23 +00:00
igor%mir2.org 3f7db604b7 Replacing try { cast } catch (ClassCastException ex) { action if not instance } by if (instanceof) { } else { action if not instance }.
Such optimization wins very little with modern JVMs if cast succeeds and produces very big overhead if cast fails. Moreover, it may prevent jits from doing more aggressive optimizations and makes class files bigger.

The change also made code in many places smaller since insanceof check take ensure that object is not null as well and with ClassCastException such check had to be done explicitly.
2003-04-23 14:47:09 +00:00
igor%mir2.org 27f1930196 Removal of support for special handling of this for read-only methods exposed by IdScriptable under dynamic scoping. It was never used and its semantic had little to do with dynamic scoping itself. 2003-04-22 16:09:40 +00:00
nboyd%atg.com 6dad9c8e6d Update for 1.5R4.1. 2003-04-22 00:27:10 +00:00
igor%mir2.org d7e2bd92bd Resolving http://bugzilla.mozilla.org/show_bug.cgi?id=202255 :
Support for pre 1.5R1 rules for defining JS classes by ScriptableObject.defineClass is removed.
2003-04-21 23:53:24 +00:00
nboyd%atg.com a35bc69e51 Fix bug 202344 (which was not fully fixed by the previous change.) 2003-04-21 19:43:45 +00:00
nboyd%atg.com 9bf962a79e Fix bug 202344. 2003-04-21 14:59:22 +00:00
nboyd%atg.com 13da7c74ae Restore method used by Batik. 2003-04-21 13:38:49 +00:00
igor%mir2.org 393606bb3f FunctionObject changes:
1. Disable invoker optimization for methods with variable number of arguments since currently to call optimized invoker a new argument array has to be allocated in any case which makes the optimization irrelevant.

2. Never modify elements of the args array in constructor, instead avoid allocation of the new argument array iff all js argument can be passed to java without type conversion.
2003-04-16 13:05:48 +00:00
igor%mir2.org d37001ed6e In NativeString.js_concat in the case of single argument call target.concat(arg) to avoid allocating StringBuffer instance. 2003-04-16 12:51:20 +00:00
igor%mir2.org f5bea75e19 In callVarargs to test if it is called from construct use thisObj==null condition instead of using separated flag. 2003-04-15 18:45:57 +00:00
igor%mir2.org fe0dcfe65f Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=200551 :
I added Context.getApplicationClassLoader() that is now used in all
cases as a parent loader for generated classes and as the default class loader
for NativeJavaPackage. The default implementation tries to use
Thread.getContextClassLoader, but only when it is available and if Rhino
classes is available through it. Otherwise the loader for Context instance is
used. In this way if Rhino is loaded through a custom loader, it will be used,
and if Rhino classes are placed in lib/ext,  Thread.getContextClassLoader still
give the application loader.

And if this default policy would not work in a particular application,
Context.getApplicationClassLoader() can be overridden to in that application.
2003-04-15 07:48:18 +00:00
igor%mir2.org 8c7fe87c7e Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=201989 :
use IdFunction.initAsConstructor to initialize Error constructors in
NativeGlobal.init and remove setFunctionType and corresponding getFunctionType in IdFunction and use a simple private boolean field there to mark functions that can be called as constructors since NativeGlobal.init was the only place that used that.
2003-04-15 07:43:30 +00:00
igor%mir2.org 99d83af296 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=201987 :
Use toObject() in ScriptRuntime.delete to convert non-Scriptable delete target to Object which required to pass Context and scope to the method and update Interpreter and optimizer/Codegen accordingly.
2003-04-15 07:33:17 +00:00
igor%mir2.org fedeaf5b90 Duplicated code from IdFunction and FunctionObject to initialize prototype and scope of the result of call invocation when it is used as a part of constructor code is moved to a utility method initCallResultAsNewObject in BaseFunction. 2003-04-14 14:38:04 +00:00
igor%mir2.org 1771cf5e7c Replace code to generate:
if (val != null && val != Undefined.instance && val instanceof Scriptable) ...

by code to generate:

if (val instanceof Scriptable && val != Undefined.instance) ...

since (val instanceof Scriptable) => (val != null)
2003-04-14 13:53:18 +00:00
igor%mir2.org a29c7a81fa Instead of using the special _packages_ properties to store imported packages, use a field in ImporterTopLevel for simpler code. 2003-04-13 10:57:06 +00:00
igor%mir2.org c012edd6f6 Switch to use IdFunction to define ImporterTopLevel script methods. A separated class is used to implement IdFunctionMaster interface to avoid interface clashes with possible ImporterTopLevel subclasses implementing the same interface. 2003-04-13 08:57:57 +00:00
igor%mir2.org ca7b131ae5 1. In NativeJavaPackage.init define global properties only when NativeJavaPackage instance is fully initialized.
2. Memory optimization: instead of string array for predefined known packages, use single string which is split into substrings when necessary.
2003-04-13 08:54:09 +00:00
igor%mir2.org ef61833bb1 Switch to use the new utility IdFunction.define() method to define function properties instead of explicit code for function initialization and inlining of getMethod call since it is used only once to make code smaller. 2003-04-13 08:47:19 +00:00
igor%mir2.org b0a14f7279 I added static IdFunction.define utility method to define IdFunction instances as properties in the given scope. 2003-04-13 08:40:43 +00:00
igor%mir2.org 8b1123e397 Switch to use ClassFileWriter.addInvoke() taking full method signature including the result part as a single argument instead of deprecated 4-argument ClassFileWriter.add(). 2003-04-13 08:38:52 +00:00
igor%mir2.org f426f26c1d Commiting Hannes Wallnoefer patch to allow LiveConnect to convert JS Date to Java Data, see http://bugzilla.mozilla.org/show_bug.cgi?id=201326 2003-04-12 10:48:39 +00:00
igor%mir2.org 729a139dc3 Working on http://bugzilla.mozilla.org/show_bug.cgi?id=198208 :
I removed deprecated methods to access ClassNameHelper functionality through Context instance.
2003-04-01 14:52:27 +00:00
igor%mir2.org 64af9c759b Work for http://bugzilla.mozilla.org/show_bug.cgi?id=198208 :
I removed deprecated since 1.5R3 omj.ClassOutput and moved some of code from omj/ClassNameHelper.java to omj/optimizer/OptClassNameHelper so if one does not need the optimizer package, the jar will be smaller.
2003-04-01 11:39:08 +00:00
igor%mir2.org 9e16916a56 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=199051 :
Initialize invoker in FunctionObject constructor, not during first call and catch possible SecurityException. In this way initialization will happen without script code on java stack which may not have permissions to create class loaders.
2003-03-31 13:18:04 +00:00
igor%mir2.org 2c0d284a12 Removal of deprecated SecuritySupport as a part of work on 198208. 2003-03-31 08:43:40 +00:00
nboyd%atg.com 0d0a9b51e2 change to 1.5R5 prerelease 2003-03-25 19:13:29 +00:00
nboyd%atg.com 3532c8b351 Switch to 1.5R5pre. 2003-03-25 19:11:58 +00:00
igor%mir2.org 9a1096723f Added ScriptRuntime.newInstanceOrNull to call class.newInstance() and return null if it fails. It allows to replace in few places try/3 different catch by a simple method call. 2003-03-20 15:46:37 +00:00
igor%mir2.org 591352c0ed Make ScriptRuntime.getClassOrNull() package private and use it in place of Class.forName() to avoid ever catching ClassNotFind and Security exceptions. 2003-03-19 19:04:24 +00:00
igor%mir2.org 071e6626a2 Removal of deprecated classes from the list of API docs 2003-03-19 14:14:29 +00:00
igor%mir2.org d8a4f2b19c Fixing JavaSoc documentation tag usage 2003-03-19 14:13:41 +00:00
igor%mir2.org cdf7a42c64 For concatenation of 2 strings that are not null use str1.concat(str2) instead of str1+str2 to avoid construction of temporary StringBuffer all together. 2003-03-19 12:36:48 +00:00
igor%mir2.org ec1028b7f8 Use ClassFileWriter.addInvoke to add method invocation code instead of deprecated 4-argument ClassFileWriter.add() to avoid unnecessary string concatenation to build full method signature from parameter and result signatures. 2003-03-19 11:19:21 +00:00
igor%mir2.org fde8484707 Use ClassFileWriter.addInvoke() instead of ClassFileWriter.add() to add method calls to avoid string concatenation when constructing full method signature from separated parameter and return signatures. 2003-03-17 12:39:19 +00:00
igor%mir2.org 11821416bb A version of the add method to add an invoke bytecode is deprectaed in favor of addInvoke that takes a full method signature in place of separated parameter and result signatures. It allow not use a string concatenination to build a full signature. 2003-03-16 17:45:34 +00:00
igor%mir2.org f05f484947 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=197682 :
replace static fields to hold targets of direct call optimization by an instance fields in the class representing the main script object.
2003-03-16 13:53:41 +00:00
igor%mir2.org 52b3708d95 1. When generating various support methods like script main, function constructor etc., use classFile.startMethod instead of startNewMethod since the later is intended for generation of main code for script/function.
2. Do not use trivialInit optimization for scripts since the following changes makes generation of initScript function mandatory.
2003-03-14 10:05:01 +00:00
igor%mir2.org c40f2bfc54 Inlinning of generateRegExpLiterals into generateInit for simple code 2003-03-13 22:50:04 +00:00
igor%mir2.org 203b0ffbd9 I changes ClassFileField to store its attribute as simple short fields to avoid allocation of short[4] array for each field. 2003-03-13 14:03:03 +00:00
igor%mir2.org bc7b9d73d8 I replaced explicit encoding of int, long and short values into byte arrays by new utility methods putInt16, putInt32, putInt64 2003-03-13 13:59:02 +00:00
igor%mir2.org 514bf87a5c 1.More checks are added for bad usage of ClassFileWriter methods.
2. Hashtable is replaced by ObjToIntMap or UintMap to minimize memory usage.

3. Converting of strings to utf8 encoding is coded  explicitly to avoid overhead  of creating many objects.
2003-03-13 09:31:01 +00:00
igor%mir2.org ec5530c862 Making class public 2003-03-13 07:52:07 +00:00
igor%mir2.org c157c1a306 Removal of generation of non-operational dup/pop when creating function objects for function statements. 2003-03-12 09:39:16 +00:00
igor%mir2.org bb0cf4e75a Fixing a regression in Codegen.transform which effectively disabled direct call optimization: FunctionNode.FUNCTION_STATEMENT should be compared against fn.getFunctionType(), not fn.getType() 2003-03-11 17:17:57 +00:00
igor%mir2.org 30a59ec178 Introduction of Codegen.mainCodegen to hold the main generator object and layout cosmetics. 2003-03-11 10:01:32 +00:00
igor%mir2.org 546ec4d6df Use (size + 31) >> 5, not (size >> 5) + 1 as a size for int array buffer so in the case when size % 32 == 0 array would not hold a never used tail element. 2003-03-11 09:59:39 +00:00
igor%mir2.org 6d4df4405d 1. Consistently use Context.inFunction and Context.fnCurrent instead of calling instanceof/cast for OptFunctionNode on Context.scriptOrFn
2. Removal of Codegen.superClassSlashName field since Codegen.superSlashName since it is never used as a part of a signature and ClassFileWriter converts . into / in type name automatically.
2003-03-11 07:25:13 +00:00
igor%mir2.org 9be8d46c8f Since NodeTransformer.transform(tree) never replaces tree, change its signature to return void which allows to eliminate ScriptOrFnNode.replaceFunctionNode. 2003-03-10 20:26:58 +00:00
igor%mir2.org d64c42ff29 Simplification of optimized node transformer: search for direct call optimization targets in Codegen.transform before constructing ObjTransformer instance to avoid additional checks for top-level script in ObjTransformer.transform 2003-03-10 20:24:06 +00:00
igor%mir2.org 51de1c8d84 Added API to make array read only, after which any attempt to modify it will trigger RuntimeException 2003-03-10 20:19:22 +00:00
igor%mir2.org 1acdc5f2f0 1. Removal of unused fields and methods:
Codegen.java:
-    private int ordinal;
-    private short scriptRuntimeIndex;
-    private short debug_pcLocal;
-    private short debugStopSubRetLocal;

OptFunctionNode.java
-    private ObjArray itsDirectCallTargets;
-    void addDirectCallTarget(FunctionNode target) {
-    ObjArray getDirectCallTargets() {

2. Better naming and method moves in Codegen.java for better readability
2003-03-10 17:46:32 +00:00
igor%mir2.org 4540bdf06a Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=196017 :
Use Thread.getContextClassLoader() as the last resort when searching for classes.
2003-03-06 09:29:00 +00:00
igor%mir2.org 39dbbb0550 Integration of VariableTable into ScriptOrFnNode to avoid the need to have a separated wrapper class around ObjArray/ObjToIntMap 2003-03-04 15:10:20 +00:00
igor%mir2.org c63cb1b35a Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=96270 :
proper implementation of Scriptable.has in ImporterTopLevel and NativeJavaPackages
2003-02-25 09:17:43 +00:00
igor%mir2.org 8ebcc7f9af Fix http://bugzilla.mozilla.org/show_bug.cgi?id=194364:
no assignment of function expression statements to script result
2003-02-25 09:15:08 +00:00
igor%mir2.org e12bd87db4 Parsing changes: for regular expression literals construct a tree node with regular expression number during parsing instead of generating a special subtree that is converted to such node during tree transformation. 2003-02-20 13:11:21 +00:00
igor%mir2.org dc46d02971 Praising changes: remove direct access to VariableTable in ScriptOrFnNode and instead provide methods to access its functionality. In this way VariableTable can be changed without affecting the rest of code. 2003-02-20 09:18:12 +00:00
igor%mir2.org 1af98b56aa More parser internal changes: move all logic to initialize variable table to ScriptOrFnNode.finishParsing and its overrides in FunctionNode/OptFunctionNode so it will be constructed during parsing to avoid checks for function types in NodeTransformer. 2003-02-19 23:50:42 +00:00
igor%mir2.org 69801b0254 During parsing collect all nested function in script or function directly into array in ScriptOrFnNode. In this way there is no need to walk over tree to find nested functions during tree transformation since the function nodes are available directly. 2003-02-19 14:50:30 +00:00
igor%mir2.org 449d35d64e Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=193700 :
Attempts to access/modify properties of null or undefined are explicitly checked to include in error messages the property name so it would be possible on error in x.y.z to know if it is x or y that was undefined or null.

Inspired by suggestion from Russell Gold.
2003-02-19 08:51:51 +00:00
igor%mir2.org f015d87d5f Allow to set null for sourceName, encodedSource and originalSource 2003-02-18 00:52:34 +00:00
igor%mir2.org 3f0b27bbf6 Store number of locals as a field in ScriptOrFnNode and not as int node property. 2003-02-17 17:41:04 +00:00
igor%mir2.org 93721f0a59 Store function array inside ScriptOrFnNode as field, not as a node property. 2003-02-17 17:39:26 +00:00
igor%mir2.org fc20f85a8f Pass ScriptOrFnNode explicitly to function expecting script or function top node and fix OptTransformer problem where it marked nested functions of function as suitable for direct call optimization which was caused by removal of parameter name subtree in FunctionNode. 2003-02-17 17:34:20 +00:00
igor%mir2.org e6090539e4 Introduction of ScriptOrFnNode as a Node to represent scripts and a base class for FunctionNode so it can be used to store variable tables, line information, regular expressions etc. instead of using special Node properties. 2003-02-17 08:51:00 +00:00
igor%mir2.org 50ba7d1f8c Removal of a separated tree walking phase in NodeTransformer to collect variables as this is done now during parsing 2003-02-17 00:10:24 +00:00
igor%mir2.org 7ed732d3bf Adjusted to refer to 1.5R4 as the last release 2003-02-17 00:06:06 +00:00
igor%mir2.org ef2778d047 Fixing links 2003-02-17 00:05:27 +00:00
igor%mir2.org b3bb2de24a Remove code duplication when reporting syntax errors in NodeTransformer, ToekStream, IRFactory and Parser and add a method to create FunctionNode to Interpreter/Codegen to remove the need to have OptIRFactory. 2003-02-16 20:28:56 +00:00
igor%mir2.org 6d98f1ebc6 *** empty log message *** 2003-02-16 20:28:55 +00:00
igor%mir2.org 714bc85d53 Creating and filling VariableTable directly during parsing phase and then accessing it in NodeTransformer. It still does not remove the need to have a separated walk through the tree for variables but now it only checks for function name / variable name clashes.
And http://bugzilla.mozilla.org/show_bug.cgi?id=193555 is now fixed as well.
2003-02-16 11:34:54 +00:00
igor%mir2.org c62a606a26 Do explicit parsing of function expression statements so a correct function type will be passed to IRFactory during node creation and fix incorrect code generation when FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME is true.
I also added explicit flags to Parser: languageVersion and allowMemberExprAsFunctionName and set them from Context. In this way Parser can be used without Context which is useful for debugging.
2003-02-15 23:30:02 +00:00
igor%mir2.org aab18156df VariableTable changes toward removal of a separated NodeTransformer pass over the parser tree for variable initialization: the code to support a table of optimized variables for functions in the optimizer is moved to optimizer/OptFunctionNode and VariableTable holds only parameters/variables names now. It allowed to simplify VariableTable initialization in NodeTransformer. 2003-02-15 21:35:58 +00:00
igor%mir2.org 90c8869435 Remove synchronization on Context instances as Context should only be accessed from one thread. 2003-02-15 21:23:54 +00:00
igor%mir2.org 01cfb2bc49 Decoupling JavaAdapter from ClassRepository logic: JavaAdapter.createAdapterClass is replaced by JavaAdapter.createAdapterCode which just generates byte array with the adapter class file code and Codegen then passes this array to ClassRepository to save the class if necessary. In this way if repository do not need to load classes, adapter class will not be loaded at all. 2003-02-15 17:47:13 +00:00
igor%mir2.org a1914aa7a0 ClassNameHelper cleanup:
1. It is not passed as a parameter to Interpreter/Codegen, instead Codegen access it directly when necessary.

2. ClassNameHelper.reset method is removed as inherently thread unsafe and data that should be used during compilation of single script is stored in Codegen itself.

3. Instead of a special DefaultClassRepository null is used to indicate that generated classes should not be stored and JavaAdapter is modified to take ClassRepository as a parameter, not ClassNameHelper.
2003-02-15 14:21:33 +00:00
igor%mir2.org cae3ab647d When parsing function parameters, collect all parameters names into array instead of generating a separated syntax subtree for them. 2003-02-15 13:54:22 +00:00
igor%mir2.org 4e715dcffc Remove the last argument "args" from generateInit as it is never used. 2003-02-15 13:05:38 +00:00
igor%mir2.org 5539dfbf29 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 2e4cd83bf8 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 7eb47250fe 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 c0bc03b5bf 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 41b3e5345d 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 23e626144d 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 fa68d2fa82 I made Context.codeBug public so optimizer can use it. 2003-02-14 23:47:11 +00:00
igor%mir2.org 7f8725b63d 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 448e323877 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 9245b512bf 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 13732c460e 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 edac1d4aee 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 cd30738141 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 ed08275994 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 3d8356af78 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 6e07b50784 Remove language about "release candidate" now that we have a final. 2003-02-11 15:04:12 +00:00
nboyd%atg.com 8954cfc5cd Update for final release 2003-02-11 01:50:26 +00:00
nboyd%atg.com 69902644af Update release date. 2003-02-10 15:36:42 +00:00
igor%mir2.org 08597a3128 More info on new security interfaces 2003-02-07 20:44:47 +00:00
nboyd%atg.com 6258e019ce fix bug 106831 2003-02-03 01:17:44 +00:00
rogerl%netscape.com 9eafe44563 Fixing bug #190685, re-allowing '{' as un-quantifier literal. 2003-01-27 21:13:15 +00:00
igor%mir2.org 31bbfe30dd Added log for more fixed bugs 2003-01-27 20:04:13 +00:00
igor%mir2.org d116b752fb Do not call setSelectedIndex on frame JList if there are no frames. 2003-01-26 18:33:30 +00:00
igor%mir2.org b869da1525 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 1e22de7bf6 Documentation about runCommand in shell 2003-01-26 18:01:43 +00:00
igor%mir2.org 1e2468a7fc Added runCommand to execute external processes 2003-01-26 15:43:50 +00:00
igor%mir2.org 77021f2325 Added list of resolved Bugzilla reports 2003-01-26 14:30:47 +00:00
rogerl%netscape.com 1c5429c960 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 2081b5922b 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 6e95a8f71f Small fixes in links 2003-01-17 16:40:45 +00:00
nboyd%atg.com 0631478dd4 UPdate to rc 3 2003-01-16 20:29:43 +00:00
igor%mir2.org b4fd495c94 Note about scripting of classes from any class loader 2003-01-16 17:22:40 +00:00
nboyd%atg.com fa159104bb Add implmentation version date. 2003-01-16 14:24:03 +00:00
igor%mir2.org 9cf41eb233 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 61e4970b2a Update to R4. 2003-01-14 16:42:16 +00:00
igor%mir2.org 1fdf60d476 Fixing mnemonics shortcuts for Debug menu 2003-01-14 14:44:46 +00:00
igor%mir2.org 2b475ccedd 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 cce6a656a9 Update for RC2 2003-01-01 20:17:17 +00:00
igor%mir2.org 251c25a5c3 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 517a191c91 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 d76cc2c78f 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 2907a50485 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 d530d25fb5 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 e6a341b490 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 1eab2d8d61 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 c376184557 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 e4c61f1f60 In createInvoker I replaced classLoader.loadClass by classLoader.linkClass to remove catching ClassNotFoundException 2002-12-29 10:52:10 +00:00
igor%mir2.org bbb8216d37 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 265cc938cc Preparations for 1.5R4 release 2002-12-24 01:34:45 +00:00
igor%mir2.org bc8cf2ec2c 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 556bf1547d Mostly cosmetics: use consistent naming for new API for function object initialization. 2002-12-23 14:56:58 +00:00
igor%mir2.org 8bede8d38b 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 f4d9cbcb9e 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 0e61cfe41a 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 e4f92d4b98 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 4ca1e42665 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 740cb754dc 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 6c35405455 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 de12281a35 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 e2396df076 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 4b60a96846 I removed debug_level and debug_srcName fields as they are never used. 2002-12-20 12:12:41 +00:00
igor%mir2.org d0a8a8ff9c 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 8c7e5dc265 Cosmetics: expanding tabs 2002-12-17 20:56:08 +00:00
igor%mir2.org 2fbe052b90 Cosmetics: removal of junk white-space at line end 2002-12-17 20:48:35 +00:00
igor%mir2.org b5a37b538c I replaced all ScriptableObject.getClassPrototype(scope, "Function") by ScriptableObject.getFunctionPrototype(scope) 2002-12-17 16:36:23 +00:00
igor%mir2.org bbb7ddba42 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 02d69352ae Add link to release candidate. 2002-12-16 16:51:33 +00:00
igor%mir2.org be3d62d882 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 ad78fea1cf *** empty log message *** 2002-12-13 18:26:31 +00:00
igor%mir2.org 756b2e0885 *** empty log message *** 2002-12-13 18:16:12 +00:00
igor%mir2.org 2c4ee7b4e5 Document update 2002-12-13 14:21:38 +00:00
igor%mir2.org 1208207c71 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 f4cfc98e4d 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 d652c3179a 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 257dba7ca7 Fixed link 2002-12-10 11:19:02 +00:00
igor%mir2.org 15866816e2 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 908a8ed8b5 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 febcbadf03 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 69c1384530 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 559c58d034 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 bbd9c6e220 Cosmetics: layout fix 2002-12-06 16:38:38 +00:00
igor%mir2.org bac1e710a5 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 88ad54171f 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 87b0cf6408 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 663dff2a7a 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 d676aa578a 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 b4cf6c06fc 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 e081e489da 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 3f7f541282 Wrap restoring of the original optimization level into finally block 2002-11-25 16:46:16 +00:00
igor%mir2.org 7226fda62b 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 8223942873 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 5d1d7ed31a Fixing in Interpreter.dumpICode reading of index from a wrong offset 2002-11-13 10:22:46 +00:00
igor%mir2.org 4e4f06390c Fixing misspellings comments 2002-11-13 10:13:40 +00:00
igor%mir2.org c19e43d0d6 Call NativeArray.getLength() instead of deprecated NativeArray.jsGet_length() 2002-11-12 09:41:09 +00:00
igor%mir2.org d8a693fc56 Cosmetics: use consistent naming and layout for internal methods providing JS library implementation. 2002-11-12 09:37:43 +00:00
igor%mir2.org bb604c8dd8 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 e2b3906c85 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 ef5115e651 Cosmetics: use consistent naming and layout for internal methods providing JS library implementation 2002-11-12 09:29:57 +00:00
igor%mir2.org 710f9f5c64 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 b85ee6ab63 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 1d647c70a9 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 49661822bb 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 c27bf53f4e 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 00fbdbeb1f 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 39c11eb5ff Cosmetics: use uniform indentation in switch statements 2002-11-02 14:54:35 +00:00
igor%mir2.org 542ef1dbaf 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 70475da4ec 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 cbf53f2e8f 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 d67e88e84d 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 2b7d0e47c2 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 3b79862ea3 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 ba3a798e63 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 d7a9329429 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 8bd679943a 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 735058d371 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 32cc308b30 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 fcaecf752d 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 772d42aff7 In getClassPrototype replace ScriptRuntime.getTopLevelProp by getProperty to avoid double call to getTopLevelScope 2002-09-24 14:10:53 +00:00
igor%mir2.org 0e22f177f1 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 0b6e1ef741 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 846c9cdfd3 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 11edce55c2 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 6bd97db281 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 bfc5c0bbee C relics removal: no need to check for null after "new X" 2002-09-18 12:50:51 +00:00
igor%mir2.org 1748a34490 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 2647231ce4 Use Node subclass to represent number literals to avoid creation of Double object. 2002-09-03 12:34:56 +00:00
igor%mir2.org eeb5fecca0 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 b1503f7570 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 bc8622a010 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 db9026be35 Renaming the TokenStream.OBJECT constant to TokenStream.REGEXP for better reflection of semantics. 2002-08-26 08:06:27 +00:00
igor%mir2.org 2809a2cb52 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 89b8e4b265 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 c437701852 Changed decimal escape handling to backward compatible rather than ECMA3
conforming. (Bug#158159)
2002-07-23 21:38:03 +00:00
igor%mir2.org 7f84dd1785 Serialization fixes to correctly restore members and related fields in NativeJavaClass. 2002-07-16 21:17:09 +00:00
igor%mir2.org 05d4e426a8 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 b0651090a1 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 31a00f4fbb 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 339b48088d 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 212dbaa899 Call to InterpretedFunction.construct is inlined to avoid argument array allocation. 2002-07-12 19:40:49 +00:00
igor%mir2.org 0f91e59231 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 290f7f1a46 Added ObjToIntMap.intern() 2002-07-12 19:37:20 +00:00
igor%mir2.org ede2d28ac2 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 52990d1b21 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 6dd42762fe 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 40b7178ec8 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 aa1f6e4345 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 a14335e198 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 3815049c3a New security implementation. 2002-07-04 21:40:12 +00:00
rogerl%netscape.com 355e24f593 Fixed matching of un-matched paren contents (e.g. /(a)\1/("x") ). 2002-06-28 23:04:55 +00:00
rogerl%netscape.com 9508cae65d Fixed whitespace testing. Fixed bug 122167 - $nn handling in replace. 2002-06-22 19:38:02 +00:00
rogerl%netscape.com 27af23800b 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 8d4b102f83 New RegExp engine implementation. 2002-06-19 21:57:57 +00:00
nboyd%atg.com 33086d8fc5 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 a9bd55a1ce Update last qualified release statement. 2002-06-16 23:51:15 +00:00
igor%mir2.org fa1b6e8b1b 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 09a13f7ec3 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 0e81293d62 Add to log of changes. 2002-06-10 17:44:44 +00:00
nboyd%atg.com f597bef5b2 Add new API class WrapFactory. 2002-06-10 14:28:37 +00:00
nboyd%atg.com 79cf50094d Update javadoc. 2002-06-10 14:27:43 +00:00
nboyd%atg.com 77686394b4 Add PrimitiveWrapHandler example. 2002-06-10 14:23:32 +00:00
nboyd%atg.com cdfc8a39a9 Add example of the use of a WrapFactory. 2002-06-10 14:19:09 +00:00
nboyd%atg.com bc8e896198 Fix javadoc. 2002-06-10 14:09:26 +00:00
igor%mir2.org 8e3b79791f Deprecating NativeJavaObject.wrap and using Context.getWrapFactory().wrap() instead. 2002-06-09 15:58:15 +00:00
igor%mir2.org e91fcea61e More comments 2002-06-09 15:57:03 +00:00
igor%mir2.org a8942006ea Documentation: points to watch when upgrading to WrapFactory 2002-06-09 15:56:12 +00:00
igor%mir2.org 44bf267c33 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 f5b045f5e5 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 3e7f7632a9 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 27af2c5e8a 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 a9022fa595 Fix ClassCastException. 2002-06-04 18:37:21 +00:00
nboyd%atg.com 8026a2bd2f 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 b1f6b58c02 Back-indent the interpreter main loop to ease code following 2002-05-22 18:42:40 +00:00
igor%mir2.org a036547bcd 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 7317a7e130 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 6f9f5d5e21 Optimization in toInt32/toUint32/toUint16 for common case of integer argument. 2002-05-21 20:18:15 +00:00
igor%mir2.org 3e5edd8a09 Added indexOf and lastIndexOf 2002-05-21 20:14:10 +00:00
igor%mir2.org 76a770d612 In getElements return ScriptRuntime.emptyArgs when array length is 0 2002-05-21 20:13:30 +00:00
igor%mir2.org 1b4079d0c1 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 683f0b4ca7 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 3b94c8d2f9 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 a559e378b3 In jsConstructor use single StringBuffer to build function source 2002-05-16 04:17:04 +00:00
igor%mir2.org 06f223b799 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 a56ed683ab 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 35997ed96a 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 11cd032a9c 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 b15d8e908f 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 417ef274c7 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 514db9985d 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 a7a9d2d975 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 52fa3848f7 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 f458de53ca Fix broken link 2002-05-01 19:21:51 +00:00
igor%mir2.org 8da10d64be 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 f8f19e8815 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 a5f83f7e8c 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 d11c722d61 Patch from Igor to fix 120194 2002-04-29 00:56:30 +00:00
igor%mir2.org 1faf10a430 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 47bb60c12d 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 933b6749a9 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 189226474a Refactoring interpreter initialization to follow code more easily 2002-04-26 23:18:08 +00:00
igor%mir2.org 7247d7ca26 Tab removal 2002-04-26 23:14:50 +00:00
igor%mir2.org 058f6ca146 I changed VariableTable to store arbitrary Object as variable data to avoid allocation of LocalVariable in the interpreter mode as in this case only the variable name is used and it can be stored directly. It allows to remove omj.LocalVariable and omj.optimizer.OptVariableTable for the cost of having omc.JavaVariable which omj.optimizer.OptLocalVariable implement to pass to omc.ClassFileWriter debug information about the variable. 2002-04-26 08:01:29 +00:00
igor%mir2.org c9141d85fe Links update 2002-04-25 06:46:47 +00:00
igor%mir2.org 65c51ba40f I replaced Vector by ObjArray when it was used from the single thread and similarly replaced Hashatble by ObjToIntMap when it was used from the single thread to mark keys presence ignoring values. It avoids unnecessary synchronization and save memory. To simplify the replacement I added to ObjArray and ObjToIntMap few utility methods. 2002-04-24 21:37:36 +00:00
igor%mir2.org bd97bc5dc4 Initial version 2002-04-24 07:44:52 +00:00
igor%mir2.org 0fd57cc8e2 Serialization change: implement only Serializable with custom readObject/writeObject instead of Externalizable not to invent own versioning support. 2002-04-23 22:39:25 +00:00
igor%mir2.org d85e3c8435 Updating the debugger to reflect changes in Rhino debug API. 2002-04-22 20:47:51 +00:00
igor%mir2.org 293ec8ac77 Debugger interface changes:
1. Replacing omj.debug.Debugger.enterFrame() by omj.debug.Debugger.getFrame() and omj.debug.DebugFrame.onEnter() to allow to return null from omj.debug.Debugger.getFrame to enable full optimization with debugger set if it is not interested in monitoring a particular frame

2. Changing type for the source argument in omj.debug.Debugger.handleCompilationDone from StringBuffer to String as Debugger instances should not be able to modify source even by chance.
2002-04-22 20:46:43 +00:00
nboyd%atg.com c78edeb78c Implement support for new Package(<classLoader>) 2002-04-21 01:50:43 +00:00
igor%mir2.org 96c9c4a60b Removing one more time creating of bogus activation for InterpretedScript added with the previous change 2002-04-19 20:58:03 +00:00
igor%mir2.org 77589e0e41 Making interpreter bytecode independent from Context.isGeneratingDebug so debugger can handle scripts compiled without Context.isGeneratingDebug: if itsNeedsActivation is false with debugger present, Interpreter.interpret creates activation scope and check in variable queries/assignments if they should be made against activation object and not stack[VAR_SHIFT+...] array. 2002-04-19 07:19:07 +00:00
igor%mir2.org 5427ff0d5c Fixing bug 137181 so after delete arguments[i], arguments[i] and corresponding function parameter in activation are not shared:
The patch uses the special NOT_FOUND value to flag deleted indexes. It also
make sure that original array object passed to Function.call is not modified,
as all changes goes to cloned copy. It is not necessary for the fix, but it is
the only place in the current Rhino that can alter Object[] array passed to
Function.call and I think it is better to remove this exceptional case.
2002-04-16 07:28:40 +00:00
igor%mir2.org 4aafc80db4 In setAttributes(int,...) mask out unused attributes bits in the same as setAttributes(String,...) does 2002-04-16 07:24:50 +00:00
igor%mir2.org 5864247424 Replace VariableTable.getVariable(name) != null by VariableTable.hasVariable(name) and use ObjToIntMap in place of Hashtable 2002-04-14 21:32:19 +00:00
igor%mir2.org d4ef7bfe3b Make all fields in VariableTable private and use access API to get them in optimizer/OptVariableTable to allow to change VariableTable implementation without changing its usage 2002-04-14 21:29:35 +00:00