756 Commits

Author SHA1 Message Date
igor%mir2.org
15cacee8fd From my email:
I think recent Christopher suggestions about tail call elimination is worth
to consider, as it would allow to cut invocation cost of script functions
quite nicely in many cases. Plus I am thinking of not creating Object[] array
to pass arguments to callee if it is another interpreted function as it can
directly access the caller stack. But first I decided to make some
preparation work to simplify an implementation of these features later. The
attached patch includes:

1. Moving all code to setup scope from
InterpretedFunction.call/InterpretedFunction.call to Interpreter.interpret so
the call method simply calls Interpreter.interpret. It would make tail call
elimination code much simple. I also hope this simplifies changes Christopher
needs for the continuations support (but I have strong reservation about
possibility to implement it corectly).

2. Moving all declaration of temporary variables used only during processing
of the single ICODE to the case blocks.

3. Interpreter loop termination only in RETURN icodes, not when pc exceeds
icode size, so there is no need to check for this condition on each icode.
(Scripts are handled via the special END_ICODE token).


git-svn-id: svn://10.0.0.236/trunk@116986 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-20 20:00:32 +00:00
timeless%mac.com
69ae314807 Bug 106386 rid source of misspellings
r=db48x sr=blake a=asa


git-svn-id: svn://10.0.0.236/trunk@116832 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-19 04:30:17 +00:00
igor%mir2.org
6c4d9c6001 IdScriptable.maxInstanceId/IdScriptable.activateIdMap is replaced by getMaxId/setMaxId to have more flexible and simple id map initialization.
git-svn-id: svn://10.0.0.236/trunk@116769 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-18 01:26:01 +00:00
igor%mir2.org
d18abf02e1 Code to setup/restore security domain is moved to single place in Interpreter.interpret to make checking for correctness easy.
git-svn-id: svn://10.0.0.236/trunk@116753 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-17 20:10:31 +00:00
igor%mir2.org
3bb105309c cosmetics: change layout of Interpreter.interpret main switch from
switch (...)
    case LABEL:
        code
to
switch (...)
case LABEL:
    code

to has less problems with fitting to 80-character lines


git-svn-id: svn://10.0.0.236/trunk@116752 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-17 18:40:11 +00:00
igor%mir2.org
1a044d7dfe Activate support for getting token names if debugging interpreter icode, not only when debugging parsing trees. Not to depend in TokenStream on Interpreter, printICode debug flag is moved to Context, as with printTrees definition.
Fixing debug printing of icode which are not defined in TokenStream


git-svn-id: svn://10.0.0.236/trunk@116731 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-17 03:34:43 +00:00
igor%mir2.org
c04519684b Fixing serialization problem reported by Todd Trimmer (babyduck@usa.com):
...

>I did some tinkering and found there are pure java.lang.Object
>instantiations deep inside all the "standard objects" added to the
>ImporterTopLevel with Context.initStandardObject(). This is what is keeping
>it from serializing.

This is due to presence of Scriptable.NOT_FOUND and IdScriptable.NULL_VALUE tags in the data to serialize.

I replaced the type for the tags from Object to UniqueTag which is serializable ad knows how to make restored tags the same objects as Scriptable.NOT_FOUND and IdScriptable.NULL_VALUE.

Similarly Undefined was made serializable and to restore to Undefined.instance upon reading.


git-svn-id: svn://10.0.0.236/trunk@116729 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-16 23:31:04 +00:00
nboyd%atg.com
614e29e599 Patch from Christopher Olivier:
While looking into optimizing the modifications I've
made, I noticed that one of the bottlenecks seemed to be calls to the Java
instanceof operator, particularly if the class argument to instanceof isn't
final. Based on this observation I tweaked ScriptRuntime.java to attempt to avoid
some of the many "instanceof Scriptable" calls in it (which I've attached). In
particular I optimized the comparison operators for the case where the arguments
are Number's. This seems to provide some significant performance improvement in
many cases particularly in compiled mode.  See below (note the tests were
performed with today's rhinoLatest.zip code patched with the attached
ScriptRuntime.java and didn't include any of my other modifications).


git-svn-id: svn://10.0.0.236/trunk@116725 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-16 19:33:46 +00:00
igor%mir2.org
6a7c0622bb 1. Implementing Externalizable interface in ObjToIntMap and UintMap to allow for efficient storage of internal hash table data. For ObjToIntMap it allows to restore correctly cached values of object's hash codes and do not store internal DELETED mark.
2. ObjToIntMap.clear and UintMap.clear now do not discard internal buffers, but clears references to external objects to match behavior of Java Vector.clear and Hashtable.clear.


git-svn-id: svn://10.0.0.236/trunk@116633 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-15 07:13:33 +00:00
igor%mir2.org
d1f9023a1d ObjToIntMap was added to map Objects to int in a memory wise way and VariableTable was modified to use ObjToIntMap for itsVariableNames
git-svn-id: svn://10.0.0.236/trunk@116571 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-14 20:37:15 +00:00
nboyd%atg.com
c4cd199282 Turn on debug info in class files by default.
git-svn-id: svn://10.0.0.236/trunk@116482 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-13 19:34:23 +00:00
nboyd%atg.com
2309ae693d Fix problem reported in newsgroup:
If I have a Java class with a normal method that throws an exception, Rhino
(1.5pre4) will let JavaScript catch the exception. If the Java class has a
getter method, Rhino will NOT let JavaScript catch the exception. Very
disturbing.

Here's a console dump to show you what I'm talking about:

D:\jsSandbox>cat GIJoe.java
public class GIJoe
{
        // Getter
        public static int getYoJoe()
                throws Exception
        {
                throw new Exception("Please catch me!");
        }

        // Normal
        public static int rebel()
                throws Exception
        {
                throw new Exception("Please catch me too!");
        }
}
D:\jsSandbox>javac GIJoe.java

D:\jsSandbox>cat gi.js
var gi = new Packages.GIJoe();

try
{
        var i = gi.rebel();
        java.lang.System.err.println("rebel(): uncaught");
}
catch(e1)
{
        java.lang.System.err.println("rebel(): caught");
}


try
{
        var i = gi.yoJoe;
        java.lang.System.err.println("yoJoe: uncaught");
}
catch(e2)
{
        java.lang.System.err.println("yoJoe: caught");
}


D:\jsSandbox>java -cp .;e:\javas\rhino1_5R4pre\js.jar
org.mozilla.javascript.too
ls.shell.Main
js> load("gi.js");
rebel(): caught
java.lang.Exception: Please catch me!
org.mozilla.javascript.WrappedException: WrappedException of Please catch
me!
        at org.mozilla.javascript.JavaMembers.get(JavaMembers.java:105)
        at
org.mozilla.javascript.NativeJavaObject.get(NativeJavaObject.java:93)

        at
org.mozilla.javascript.ScriptRuntime.getProp(ScriptRuntime.java:691)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1591)
        at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:
63)
        at
org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:
54)
        at org.mozilla.javascript.Context.evaluateReader(Context.java:741)
        at
org.mozilla.javascript.tools.shell.Main.evaluateReader(Main.java:347)

        at
org.mozilla.javascript.tools.shell.Main.processSource(Main.java:336)
        at org.mozilla.javascript.tools.shell.Global.load(Global.java:169)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.mozilla.javascript.FunctionObject.callVarargs(FunctionObject.java
:586)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:460)
        at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1216)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1679)
        at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:
63)
        at
org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:
54)
        at org.mozilla.javascript.Context.evaluateReader(Context.java:741)
        at
org.mozilla.javascript.tools.shell.Main.evaluateReader(Main.java:347)

        at
org.mozilla.javascript.tools.shell.Main.processSource(Main.java:284)
        at org.mozilla.javascript.tools.shell.Main.exec(Main.java:146)
        at org.mozilla.javascript.tools.shell.Main.main(Main.java:74)
js>



Due to a lack of an "uncaught" statement in the output, we see that the
exception from GIJoe::getYoJoe() was indeed thrown, but not caught by the
JavaScript.

Do any nightly builds past 1.5pre4 address this issue?


Todd Trimmer


git-svn-id: svn://10.0.0.236/trunk@116477 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-13 13:33:40 +00:00
igor%mir2.org
dfc19c66e1 Rename catchStack to tryStack and allocate it only when required
git-svn-id: svn://10.0.0.236/trunk@116429 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-12 22:02:55 +00:00
igor%mir2.org
36790db5a9 Move definitions of interpreter bytecode specific tokens like BREAKPOINT or INTNUMBER to Interpreter.java.
Use switch instead of string array to return token names not to depend on token oder.


git-svn-id: svn://10.0.0.236/trunk@116428 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-12 22:00:56 +00:00
gerv%gerv.net
43afcdc139 Replacing original licensing text from C version of this file.
git-svn-id: svn://10.0.0.236/trunk@116351 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-11 23:11:55 +00:00
nboyd%atg.com
fbff40cd74 Enter context if need be; JavaAdapters may have callbacks on threads unassociated
with contexts.


git-svn-id: svn://10.0.0.236/trunk@115678 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-03 16:16:07 +00:00
igor%mir2.org
8970e0cb2c Use ClassFileWriter.toByteArray to get class file bytes in place of calling ClassFileWriter with ByteArrayStream argument
git-svn-id: svn://10.0.0.236/trunk@115300 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-24 19:18:44 +00:00
igor%mir2.org
00c87cda17 1. Added toByteArray to get class file as a byte array. Implementation first calculates the resulting array size to minimize number of allocations.
2. Set DEBUG to true to activate usage checks


git-svn-id: svn://10.0.0.236/trunk@115299 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-24 19:15:19 +00:00
nboyd%atg.com
dd8e3dd5a8 Missed one codepath in previous fix for 126722. This should complete the fix.
git-svn-id: svn://10.0.0.236/trunk@115232 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-22 17:40:32 +00:00
nboyd%atg.com
ad685a20c2 Fix bug 126722
git-svn-id: svn://10.0.0.236/trunk@115156 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-21 15:53:50 +00:00
nboyd%atg.com
c73c521f6c Fix more broken links.
git-svn-id: svn://10.0.0.236/trunk@114805 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-18 16:25:26 +00:00
nboyd%atg.com
2a09e3e01f Fix broken link.
git-svn-id: svn://10.0.0.236/trunk@114796 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-18 15:20:39 +00:00
nboyd%atg.com
d9c6ed0fb7 Fix build problem in batik:
[javac] Compiling 1427 source files to /data/gump/xml-batik/classes
 [javac] /data/gump/xml-batik/sources/org/apache/batik/script/rhino/EventTargetWrapper.java:81:
coerceType(java.lang.Class,java.lang.Object,boolean)
in org.mozilla.javascript.NativeJavaObject cannot be applied to
(java.lang.Class,java.lang.Object)


git-svn-id: svn://10.0.0.236/trunk@114372 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-13 03:07:31 +00:00
igor%mir2.org
285c1ecdc7 Making final for performance reasons
git-svn-id: svn://10.0.0.236/trunk@114358 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-13 01:41:11 +00:00
nboyd%atg.com
dfb329185b Add new Context method "toType" to convert to a specified Java type
git-svn-id: svn://10.0.0.236/trunk@114279 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-12 14:30:27 +00:00
nboyd%atg.com
58eb99d8c8 Fix 124900
git-svn-id: svn://10.0.0.236/trunk@114278 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-12 14:29:30 +00:00
igor%mir2.org
22b17f25a3 cosmetics: end-of-line whitespace removal
git-svn-id: svn://10.0.0.236/trunk@114181 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-11 01:33:23 +00:00
igor%mir2.org
1e2ff3541f tabs -> spaces
git-svn-id: svn://10.0.0.236/trunk@114180 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-11 00:02:14 +00:00
igor%mir2.org
80394faf09 Avoid unnecessary calls to Context.getContext() by passing Context directly as an argument
git-svn-id: svn://10.0.0.236/trunk@114170 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-10 21:10:35 +00:00
igor%mir2.org
1cf75d9d93 Always use try/finally to wrap Context.exit
git-svn-id: svn://10.0.0.236/trunk@114169 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-10 21:09:42 +00:00
nboyd%atg.com
2394f41311 * Avoid creating a ClassNameHelper when turning caching off.
* When turning debug generation on, don't change opt level from -1 to 0.


git-svn-id: svn://10.0.0.236/trunk@113903 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-07 17:54:57 +00:00
nboyd%atg.com
7c8814ac5e Have ClassNameHelper object be allocated lazily
git-svn-id: svn://10.0.0.236/trunk@113701 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-05 13:47:16 +00:00
nboyd%atg.com
6546deedfa Don't hold a static reference to a ClassLoader that will prevent JavaAdapter classes
from being unloaded.


git-svn-id: svn://10.0.0.236/trunk@113700 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-05 13:37:50 +00:00
nboyd%atg.com
ccd738333b Clean up formatting.
git-svn-id: svn://10.0.0.236/trunk@113613 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-04 18:58:03 +00:00
nboyd%atg.com
8ba4f03273 Change version to 1.5R4pre.
git-svn-id: svn://10.0.0.236/trunk@113605 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-04 15:26:31 +00:00
igor%mir2.org
172a122344 Use heapsort instead of qsort for Array.sort to follow JS for reasons described in http://bugzilla.mozilla.org/show_bug.cgi?id=99120
git-svn-id: svn://10.0.0.236/trunk@113309 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-31 10:08:17 +00:00
igor%mir2.org
041da0a0b6 Stricter enter/exit: enter performs sanity checks on supplied Context and the exit requires previous enter.
git-svn-id: svn://10.0.0.236/trunk@113162 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-29 22:58:22 +00:00
igor%mir2.org
316733af9e Few Native* classes are made package private and final. They had been public only for implementation reasons.
git-svn-id: svn://10.0.0.236/trunk@113124 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-29 18:40:13 +00:00
igor%mir2.org
b28d6ac14b Use ScriptRuntime.toString(double) to convert double to string. Easier to follow version of getElem/setElem
git-svn-id: svn://10.0.0.236/trunk@113114 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-29 09:44:24 +00:00
nboyd%atg.com
b55ba3f3bb Update implementation version.
git-svn-id: svn://10.0.0.236/trunk@113016 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-28 00:52:12 +00:00
nboyd%atg.com
cd6b463349 Clean up formatting.
git-svn-id: svn://10.0.0.236/trunk@112961 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-26 20:07:49 +00:00
nboyd%atg.com
c5eb49df96 Fix bug 121790
git-svn-id: svn://10.0.0.236/trunk@112957 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-26 19:15:06 +00:00
nboyd%atg.com
045cba9433 Fix formatting
git-svn-id: svn://10.0.0.236/trunk@112956 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-26 19:13:22 +00:00
nboyd%atg.com
b2a77430fe UPdate implementation version
git-svn-id: svn://10.0.0.236/trunk@112721 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-24 20:17:05 +00:00
nboyd%atg.com
04382ca085 Fix out-of-date javadoc.
git-svn-id: svn://10.0.0.236/trunk@112720 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-24 19:57:52 +00:00
nboyd%atg.com
2c5197ddf5 Fix the following problem:
Thanks!

As promised, I tried the debugger this afternoon and I had a problem with the '-f' option.
  We use -f to run a standard "startup" script before executing the "main" script.  For
example, we run the Rhino shell with the options "-f startup.js main.js".

When running the debugger's shell with the same options the debugger exits after the
startup.js completes; i.e., I can single step starting from startup.js but the debugger
exits at the end of startup.js without letting me single step into main.js.  This worked
fine in the 1.5R2 release of Rhino and the debugger.

I have not had a chance to look into the problem closely, but a cursory look at the code
suggests (to me) that the problem can be in either the debugger or the shell (since the
debugger basically runs the shell after creating the right "hooks".)  Of course, it could
also be a problem with my embedding.

So ... my question is, has anyone tried single stepping when the options to the debugger
include a '-f' option.  If so, I'll continue to look for a problem in my embedding.

Any suggestions would be appreciated.

Thanks,

dave


git-svn-id: svn://10.0.0.236/trunk@112719 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-24 19:57:01 +00:00
nboyd%atg.com
6e634bb933 Fix bug:
Norris,

I realize this is probably a nuisance, but the following problem causes our
regression test suite to fail:

    js> foo = new Error("bar")
    undefined: bar
    js> foo.name Error
    js> foo.toString()
    undefined: bar

Our test suite expects:

    js> foo = new Error("bar")
    Error: bar
    js> foo.name Error
    js> foo.toString()
    Error: bar

I have not yet tried the debugger with the RC2 release, but I expect to get
to that later today.

I hope I'm not to late to influence the 1.5R3 release.

Thanks,

dave


git-svn-id: svn://10.0.0.236/trunk@112485 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-19 17:43:26 +00:00
nboyd%atg.com
2867e3c9b7 Add link to article with Rhino.
git-svn-id: svn://10.0.0.236/trunk@112346 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-16 16:07:12 +00:00
nboyd%atg.com
d4a092d480 Update for 1.5R3.
git-svn-id: svn://10.0.0.236/trunk@112187 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-15 17:35:09 +00:00
nboyd%atg.com
2c2291ce22 Fix bug 118636: Date format
git-svn-id: svn://10.0.0.236/trunk@111687 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-09 15:21:31 +00:00