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

3088 Коммитов

Автор SHA1 Сообщение Дата
nboyd%atg.com 82bd85bfce Fix for problem:
Subject:
             Rhino Exception Handling: Inconsistency btw Old/New Versions of 1.5
        Date:
             Mon, 05 Feb 2001 06:07:07 -0800
       From:
             Timothy Bergeron <bergeron@resumerabbit.com>
 Organization:
             Another Netscape Collabra Server User
 Newsgroups:
             netscape.public.mozilla.jseng




I've been using Rhino for about a year with almost no problems. However,
I downloaded the latest Rhino tip (rhino15R2pre) and discovered a
significant difference in exception handling.

I rely heavily on JavaScript code like the following:

try {
   var em  = new ExceptionMaker();
   em.npe();  // method throws a java.lang.NullPointerException
   //em.ae();  // method throws a Packages.AutomationException
}
catch (e if (e instanceof java.lang.NullPointerException)) {
   java.lang.System.out.println("Caught a NullPointerException");
   e.printStackTrace();
}
catch (e if (e instanceof Packages.AutomationException)) {
   java.lang.System.out.println("Caught an AutomationException");
}
catch (e) {
   java.lang.System.out.println("Caught an unexpected exception: "+e);
}
finally {
   java.lang.System.out.println("Finally!");
}

Previous Rhino versions worked as expected. The exception thrown from
within the host object would be caught and the appropriate actions could
be taken.

With the most recent tip, the thrown exceptions simply are not caught
within the JavaScript. They propagate back to the Java function invoking
the (in my case) Context.evaluateReader() method.

Running the above JS fragement with the older tip displayed the
following stack trace (when the NullPointerException was caught):

Rhino Version: JavaScript-Java 1.5 release 1 2000 03 15
Caught a NullPointerException
java.lang.NullPointerException
        at java.lang.Throwable.<init>(Throwable.java:84)
        at java.lang.Exception.<init>(Exception.java:35)
        at java.lang.RuntimeException.<init>(RuntimeException.java:39)
        at
java.lang.NullPointerException.<init>(NullPointerException.java:45)
        at ExceptionMaker.jsFunction_npe(ExceptionMaker.java:13)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:497)
        at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1205)
        at org.mozilla.javascript.gen.c1.call(exception.js:3)
        at org.mozilla.javascript.gen.c1.exec(exception.js)
        at
org.mozilla.javascript.Context.evaluateReader(Context.java:739)
        at js.main(js.java:14)
Finally!

When run with the latest tip, the output is:

Rhino Version: JavaScript-Java 1.5 release 1 2000 03
15                                          Finally!
Exception in thread "main" java.lang.NullPointerException
        at java.lang.Throwable.<init>(Throwable.java:84)
        at java.lang.Exception.<init>(Exception.java:35)
        at java.lang.RuntimeException.<init>(RuntimeException.java:39)
        at
java.lang.NullPointerException.<init>(NullPointerException.java:45)
        at ExceptionMaker.jsFunction_npe(ExceptionMaker.java:13)
        at inv2.invoke()
        at
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:843)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:486)
        at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1199)
        at org.mozilla.javascript.gen.c1.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.exec(Unknown Source)
        at
org.mozilla.javascript.Context.evaluateReader(Context.java:778)
        at js.main(js.java:14)

Curiously, both Rhino versions seem to be returning the same string from
Context.getImplementionVerison();

Anyway, the results from the two runs are clearly different: In the
first case, the exception is thown, the correct catch block is invoked
(hence the stace trace), and the finally block is invoked. In the second
case, the exception is thrown, the finally block is invoked, and the
exception is handled by the calling Java method rather than being
handled by the JavaScript code.

After some research, it appears this change was introducted by a
modification to FunctionObject.call()  (See
http://bugzilla.mozilla.org/show_bug.cgi?id=64788) which used to have:

       try {
            Object result = (method != null)
                            ? method.invoke(thisObj, invokeArgs)
                            : ctor.newInstance(invokeArgs);
            return hasVoidReturn ? Undefined.instance : result;
        }

but now has:

            Object result = method == null ?
ctor.newInstance(invokeArgs)
                                           : doInvoke(thisObj,
invokeArgs);

If I comment out the new code and replace it with the old, the expected
exception handling returns. Is this just an oversight or the new
expected behavior? Are there any negative side effects (other then the
speed decrease in method invocation) if I use the latest tip but use the
old method invocation procedure in FunctionObject.call() rather than the
new?
2001-02-08 18:56:58 +00:00
pschwartau%netscape.com 106efc7817 Exported functionality common to RegExp tests to new file js/tests/ecma_3/RegExp/shell.js 2001-02-08 04:04:48 +00:00
pschwartau%netscape.com 5cc9cfb919 Exported functionality common to RegExp testing to new file js/tests/ecma_3/RegExp/shell.js 2001-02-08 04:03:02 +00:00
pschwartau%netscape.com 766e838c4f Initial add. Contains functionality common to RegExp testing 2001-02-08 03:58:58 +00:00
pschwartau%netscape.com f65b30a051 Whitespace cleanup 2001-02-08 01:32:58 +00:00
pschwartau%netscape.com ad6952fe99 *** empty log message *** 2001-02-08 01:30:15 +00:00
pschwartau%netscape.com a4c1795cc3 More minor adjustments - 2001-02-08 01:18:55 +00:00
pschwartau%netscape.com e3608c31cf Minor adjustments - 2001-02-08 01:05:23 +00:00
pschwartau%netscape.com 39d6604a1c Initial add. Regression test for bug 67773 2001-02-07 23:19:12 +00:00
waldemar%netscape.com 8f98bed0e7 Added more semantics 2001-02-07 05:08:44 +00:00
waldemar%netscape.com d341117db6 Added read-eval-print loop 2001-02-07 05:08:09 +00:00
waldemar%netscape.com ae3e51a0c2 Updated to correspond to js2 site 2001-02-07 05:07:37 +00:00
waldemar%netscape.com d0363e3b99 Added :semantic-comment and :vector-construct. 2001-02-07 05:07:05 +00:00
waldemar%netscape.com 42217499f5 Added vector comprehensions. Changed compiler to emit globals of functional type into the lisp function rather than value slots of symbols; this simplifies debugging. 2001-02-07 05:06:22 +00:00
waldemar%netscape.com ffce7baf94 Added vector comprehensions and extra mode parameter for %section, %subsection, and %text. 2001-02-07 05:05:39 +00:00
brendan%mozilla.org e23a1be36f Fix for bug 44009 (r=rogerl, sr=shaver)
- Remove bogus JS_ASSERT(!outermost) from the code that deals with a "#n="
  type string being returned from js_EnterSharpObject, where the hash entry
  is not yet sharp (because we haven't seen the object twice during depth
  first search).  This case trivially arises for the outermost object in,
  e.g., 'o={}; o.foo=o; uneval(o)'.
- Avoid parenthesizing #n={...} object initializers for uneval, as they are
  not ambiguous (whereas {foo:1}, e.g., is ambiguous because it could be a
  block statement containing a labeled expression statement, or it could be
  an object initializer).
- Death to tabs!
2001-02-06 23:19:44 +00:00
pschwartau%netscape.com 4cd5b867fb Made this testcase acknowledge that indirect eval is LEGAL; see bug 38512. 2001-02-06 07:57:17 +00:00
pschwartau%netscape.com 8e1d1ab4d9 Made this testcase acknowledge that indirect eval is LEGAL; see bug 38512. 2001-02-06 07:33:28 +00:00
pschwartau%netscape.com 8ab3095a6c Made this testase acknowledge that indirect eval is LEGAL; see bug 38512. 2001-02-06 06:52:59 +00:00
pschwartau%netscape.com 8097b07638 Deleting this testcase. It expected indirect eval to throw an exception. Wrong - this is legal: see bug 38512. 2001-02-06 06:06:18 +00:00
brendan%mozilla.org b28624e231 Fix compile-statements-as-we-go to work with warn-about-missing-final-return (66928, r=jband, sr=shaver). 2001-02-06 01:23:29 +00:00
pschwartau%netscape.com 44623057a1 Deleting this testcase, which expected this.eval() to throw an exception. On the contrary: indirect eval is LEGAL; see Bugzilla bug 38512. 2001-02-05 18:27:36 +00:00
pschwartau%netscape.com d84d79d43e Changed comma expresions in this testcase from trivial to non-trivial. Explanation is in the introduction. 2001-02-05 04:58:39 +00:00
jband%netscape.com ab1f2436af fix bug 67557 - bad use of NS_LITERAL_STRING to initialize static const PRUnichar* literals. r=jag sr=brendan 2001-02-04 06:47:44 +00:00
cls%seawood.org 02d1ad6807 Fix fdlibm/mozjs dependency problem by making sure that fdlibm is always built before mozjs. 2001-02-04 06:27:59 +00:00
brendan%mozilla.org eabd8c6171 Include function total size in JS profiler output (67467, r=hyatt, sr=jband). 2001-02-02 20:52:06 +00:00
nboyd%atg.com e5473d8fda Subject:
Re: [Rhino in Java] compiling .js to class file gives "bad local" error
        Date:
             Wed, 31 Jan 2001 09:41:45 +0100
       From:
             "Sylvia E. Schleutermann" <ses@h-m-s.com>
 Organization:
             .hms Health Management Systems
 Newsgroups:
             netscape.public.mozilla.jseng
  References:
             1 , 2




I have found out some more. Looking really quickly over the JVM specs, I
found that
indeed the astore-command requires that the variables index be below 128.
However,
the book also said that if more index space is needed, a "wide" command can
be used to
be able to address up to 65xxx variables.
Question: is there a possibility to integrate this "wide"-command into the
class compiler?
Some option, that can be set?  Or am I on the wrong tracks?

Please help, since I want to avoid spreading the script over many classes to
avoid the
size limitation. Cheers, Sylvia


Sylvia E. Schleutermann <ses@h-m-s.com> wrote in message
news:956sv9$9g53@secnews.netscape.com...
> I have found out that it is definitely the number of variables.
> I removed all variables and then the script compiled into class files
> with one base class and inner classes for each function in the script.
>
> What is the limitation exactly, i.e. does anyone know how many (global)
> variables
> I can use? Or is there some other kind of work around?
>
> Cheers, Sylvia
>
>
> Sylvia E. Schleutermann <ses@h-m-s.com> wrote in message
> news:956qtv$6kh3@secnews.netscape.com...
> > Hello,
> > when compiling a *.js file to class file, I get a "bad local" runtime
> > exception.
> > Stepping through the source, the following happens in reverse order:
> >
> > Codegen.xstore (75, 58, 209)
> >     -> in the switch - default case, there is a comparison
> >         for local (=209), which is compared to Byte.MAX_VALUE (=127).
> >         When greater, the above exception is thrown.
> >
> > Codegen.astore (209)
> >     -> calls Codegen.xstore (ByteCode.ASTORE_0, ByteCode.ASTORE, 209)
> >
> > Codegen.generatePrologue (<context>, <tree>, true, -1) // -1 is
> > directParameterCount
> >     -> sets itsZeroArgArray = getNewWordLocal(); // here, the 209 is
> > produced
> >     -> calls astore (itsZeroArgArray)
> >
> > From what I can read from the source code, the 209 seems to be a counter
> for
> > "locals", perhaps
> > local variables?? The function that is being compiled does initialize
many
> > variables - would it help
> > to move the initialize code out of the function into separate code
blocks?
> >
> > The function looks like this
> >
> > function rule_Disclaimer()
> > {
> >     try { VAR1 = <init code 1>;} catch (exception) { VAR1 = <default
init
> > code 1>; }
> >     try { VAR2 = <init code 2>;} catch (exception) { VAR2 = <default
init
> > code 2>;}
> >         ... (about 58 such variables)
> >
> >     var cond = true;
> >
> >     < rest of code>
> > }
> >
> > When I compile the script for interpreted mode, all works well. The
> > variables VAR1 to VAR58 are to be global
> > variables (global to the whole script).
> >
> > I appreciate any help! Thanks, Sylvia
> >
> >
>
>
2001-02-02 15:20:03 +00:00
mkaply%us.ibm.com a36df8834a OS/2 TB breakage
Need cast to pass C++ function
2001-02-02 13:54:03 +00:00
jband%netscape.com bd58ec8cea the rest of the fix for bug 66950 to add nsISupportsWeakReference support of xpconnect wrapped JSObjects. r=rogerl sr=brendan 2001-02-02 10:01:56 +00:00
jband%netscape.com e7fcc8fd7f the rest of the fix for bug 67258 to avoid empry Components.results and the similar pattern in nsJSIID. r=dmose sr=brendan 2001-02-02 08:57:47 +00:00
jband%netscape.com 8ccfada88a backing out two changed inadvertantly committed! 2001-02-02 08:52:22 +00:00
jband%netscape.com 1d263ae630 part of the fix for bug 67258 to avoid empry Components.results. r=dmose sr=brendan xpccomponents.cpp 2001-02-02 08:48:28 +00:00
jband%netscape.com 39d156eef0 part of the fix to bug 66950. Add support for cheaply tracking the lifetime of arbitrary JSObject by extending the GC callback mechanism to notify after marking is done but before sweeping, and by providing an api function that can be called at that point to determine if any given gcthing is about to be finalized. r=rogerl sr=brendan 2001-02-02 08:44:24 +00:00
rogerl%netscape.com cb289ae2e2 Fixed case, sorry 2001-02-02 01:08:06 +00:00
rogerl%netscape.com 5276f5b818 Added ICodeEmitter 2001-02-02 01:06:30 +00:00
rogerl%netscape.com 7ea0f3cbba Added icodeEmitter to VC++ build 2001-02-02 01:05:38 +00:00
rogerl%netscape.com 61579b22f3 Re-structuring some ICG details. 2001-02-02 01:04:22 +00:00
mkaply%us.ibm.com 63b9a9f4be OS/2 TB break
Need JS_STATIC_DLL_CALLBACK
2001-02-01 18:39:38 +00:00
disttsc%bart.nl 91a08f8c82 Fix senna bustage, add REQUIRES line. r=mkaply 2001-02-01 18:07:08 +00:00
sspitzer%netscape.com e21ba186fe fix for #67205. get --enable-xpctools to work again.
it will build the JS profiler.  r=leaf,bryner, sr=cls
2001-02-01 15:36:59 +00:00
waldemar%netscape.com 76e61d873f Fixed comment 2001-02-01 03:42:25 +00:00
waldemar%netscape.com f2ae41c491 Added make-and-compile-grammar cache 2001-02-01 03:41:54 +00:00
waldemar%netscape.com 0bcf6402f0 Added hash-table-= 2001-02-01 03:41:18 +00:00
waldemar%netscape.com 76d55e8bc2 Added the id type 2001-02-01 03:40:56 +00:00
waldemar%netscape.com a53b1af653 Removed namespace inheritance. Begun implementing semantics. 2001-02-01 03:39:26 +00:00
rogerl%netscape.com 23fda0a73e Removed unused parameter. 2001-02-01 01:06:53 +00:00
rogerl%netscape.com f13e0741a0 Changed Cast to take a JSValue containing a type instead of type directly.
Added LoadType to help support that. Also added LoadNull.
2001-02-01 00:59:21 +00:00
mkaply%us.ibm.com 77c253f1d3 Putting it back until I figure out the bustage 2001-02-01 00:03:12 +00:00
mkaply%us.ibm.com 1c00ee937b OS/2 only
r=dbaron
Add static to OS/2 JS_STATIC_CALLBACK so I don't break the build like I did yesterday
2001-01-31 23:40:42 +00:00
mkaply%us.ibm.com 2ae966c468 #59855
r=mccabe, sr=brendan
Proper building of fdlibm standalone
2001-01-31 23:26:00 +00:00