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

421 Коммитов

Автор SHA1 Сообщение Дата
nboyd%atg.com 0e8b09b0b6 Add javadoc. 2000-10-27 20:17:56 +00:00
nboyd%atg.com 466695f1aa Fix tree and icode printing. 2000-10-27 20:17:19 +00:00
nboyd%atg.com cbdf39c92e Subject:
[Rhino] Optimization for OptRuntime.thisGet
        Date:
             Mon, 23 Oct 2000 17:50:53 +0200
       From:
             Hannes Wallnoefer <hannes@helma.at>
 Organization:
             Another Netscape Collabra Server User
 Newsgroups:
             netscape.public.mozilla.jseng




I found a little oddity in
org.mozilla.javascript.optimizer.OptRuntime.thisGet().

get() is called twice on thisObj, once right at the beginning, and once
when starting to walk down the prototype chain. Below is what I think
this should look like - the prototype walk now begins with thisObj's
prototype, if it exists.

Also, (thisObj == null) was checked only after thisObj.get() was called,
so I moved that up in front.

Hannes
PS: I just made the changes in the news msg editor, so there may be
stupid mistakes.
2000-10-23 17:48:27 +00:00
nboyd%atg.com b1266792b7 Subject:
updated Global, Main and ImporterTopLevel
   Date:
        Mon, 23 Oct 2000 14:37:45 +0100
   From:
        Matthias Radestock <matthias@lshift.net>
     To:
        nboyd@atg.com




Norris,

I've made some more changes to shell.Main and shell.Global in order to
reduce their mutual dependency, enable "quit" and get "load" to operate
in the local scope.

see attachments for updated .diffs.


Matthias.
2000-10-23 15:55:42 +00:00
beard%netscape.com 3c21b0ca58 Fixed typo in package target. 2000-10-23 15:44:05 +00:00
nboyd%atg.com bcfdcd3e36 Fix 56883. 2000-10-23 14:31:05 +00:00
nboyd%atg.com 210c869cd5 Patch from beard@netscape.com to fix 56879. 2000-10-23 14:30:40 +00:00
nboyd%atg.com 1d9b17f17b Fix bug 56185. 2000-10-12 16:10:55 +00:00
nboyd%atg.com 908350121b Fix bug 56158 2000-10-12 14:59:19 +00:00
beard%netscape.com ee2e996d8a Outer class loader support, using ClassManager. 2000-10-12 06:30:29 +00:00
beard%netscape.com 5a1f437267 Map all exceptions to just return null. 2000-10-10 18:14:20 +00:00
nboyd%atg.com 2a806a1b13 More javadoc. 2000-10-10 14:58:47 +00:00
beard%netscape.com 848d0b5817 Added ClassManager.java. 2000-10-09 18:16:06 +00:00
beard%netscape.com cdae200b86 Manages interactions with outer class loaders. 2000-10-09 17:43:51 +00:00
nboyd%atg.com 297522e053 Add support for new Ant-based buildfile. 2000-10-06 16:26:17 +00:00
nboyd%atg.com 1623d01e8f Remove reference that javadoc couldn't find 2000-10-06 16:25:36 +00:00
nboyd%atg.com 4e15c42226 Reformat code. 2000-10-06 16:25:14 +00:00
nboyd%atg.com 1114de0a19 Allow superclass to appear anywhere in the list of classes in the JavaAdapter argument list. 2000-10-03 18:34:02 +00:00
beard%netscape.com 646b2ea55c avoid an infinite loop on EOF. 2000-10-03 06:23:11 +00:00
nboyd%atg.com 2307ef527d Avoid creating multiple wrappers. 2000-10-02 20:46:08 +00:00
nboyd%atg.com 10bd56f484 Do cheap test first. 2000-10-02 17:10:00 +00:00
nboyd%atg.com 42b2d478cd Allow null returns from SecuritySupport methods if someone only
wants to implement LiveConnect filtering
2000-09-29 13:49:47 +00:00
nboyd%atg.com 7f2239a2c4 Miscellaneous formatting changes. 2000-09-25 14:07:45 +00:00
nboyd%atg.com 142af94b8f Drop unneeded references. 2000-09-25 14:06:47 +00:00
nboyd%atg.com adc731c1e6 Fix enum.js regression. 2000-09-25 14:04:20 +00:00
nboyd%atg.com b8f186828a Expand javadoc. 2000-09-18 18:38:02 +00:00
nboyd%atg.com 7457687f89 Remove old-style debug codegen. 2000-09-18 17:57:02 +00:00
nboyd%atg.com a6150b9fff Better error message for common error. 2000-09-18 17:28:59 +00:00
nboyd%atg.com b192d90466 Fix infinite loop in new code. 2000-09-12 17:06:15 +00:00
nboyd%atg.com cd2482f9f2 Fix bug 49350 2000-09-11 15:12:04 +00:00
nboyd%atg.com 4c70d53d5e version with debugger directories 2000-09-11 14:10:23 +00:00
nboyd%atg.com 13689ccca6 Better javadoc 2000-08-30 13:41:15 +00:00
nboyd%atg.com 98027f7ff1 Fix bug 48930: work around a MS JIT bug. 2000-08-22 17:04:21 +00:00
nboyd%atg.com c1c435731a Fix bug 49325. 2000-08-21 15:56:15 +00:00
nboyd%atg.com d55dd0cde5 Fix class path 2000-08-21 15:51:57 +00:00
beard%netscape.com e0bf09d5b8 added debugger classes. 2000-08-19 02:42:05 +00:00
nboyd%atg.com 3f0f44cc1a Fix for bug 49302 2000-08-17 12:37:32 +00:00
nboyd%atg.com 29f3436810 Fix 49301. 2000-08-17 12:28:46 +00:00
nboyd%atg.com 426c97af16 Merge changes from EXP_DEBUGGER branch into tip.
Implements simple command-line debugger for scripts.
2000-08-15 15:54:46 +00:00
nboyd%atg.com 067dbf82fb fix 47859 2000-08-09 20:23:50 +00:00
nboyd%atg.com 6505531063 Fix 47859 2000-08-09 20:22:37 +00:00
nboyd%atg.com dcf4e1e9e4 Fix javadoc. 2000-07-31 21:19:05 +00:00
nboyd%atg.com 057fb2785e Experimental changes for debugger. 2000-07-27 14:54:13 +00:00
rogerl%netscape.com 16e74e371a Patch from Norris :
A Rhino user has complained about concurrency problems in the interpreter,
and I think the attached diff fixes some problems that could be caused if
the same interpreted function or script was called simultaneously from
two different threads.
2000-07-26 23:04:14 +00:00
nboyd%atg.com f452ceaa23 Fix 45928 NativeDate uses getDeclaredConstructor instead of getConstructor 2000-07-21 17:13:09 +00:00
beard%netscape.com 0a43ce9109 Added ClassOutput.java, WrapHandler.java. 2000-07-18 01:29:34 +00:00
nboyd%atg.com c0a575bf5b Fix javadoc error. 2000-07-17 14:08:28 +00:00
nboyd%atg.com 81838e4e1f Deprecate FlattenedObject. 2000-07-07 14:41:35 +00:00
nboyd%atg.com 434558cabc Remove obsolete references to NodeFactory. 2000-07-05 17:08:26 +00:00
nboyd%atg.com 0dd0718a81 Subject:
Re: Rhino1.5.R1: problems with multithreaded embedded application.
        Date:
             Mon, 03 Jul 2000 14:38:56 -0400
       From:
             Norris Boyd <nboyd@atg.com>
 Organization:
             Art Technology Group
         To:
             Fergus Gallagher <Fergus.Gallagher@orbisuk.com>
 Newsgroups:
             netscape.public.mozilla.jseng
  References:
             1




You found a bug in Rhino; I wonder if others have been running into the same thing.

The problem is with a class called LazilyLoadedCtor. I wrote this class to reduce the
time
required by initStandardObjects by only creating standard objects when the associated
constructors are first accessed. The problem is that this class was not threadsafe.
I've
made changes to that class, and to ScriptableObject as well. The design of dynamic
properties calling getters and setters (which LazilyLoadedCtor uses) didn't really
allow
any way for the getter/setter to replace itself without a thread hazard. I've now
extended
setters so that they can return a value which replaces the getter/setter to avoid this
problem.

Thanks for finding this problem. There have been a couple of other reports of problems
in
this area, so I hope this will fix them.

The patch follows.

--N

Index: LazilyLoadedCtor.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/org/mozilla/javascript/LazilyLoadedCtor.java,v
retrieving revision 1.1
diff -u -r1.1 LazilyLoadedCtor.java
--- LazilyLoadedCtor.java 2000/02/29 21:34:37 1.1
+++ LazilyLoadedCtor.java 2000/07/03 18:31:03
@@ -58,9 +58,12 @@
     }

     public Object getProperty(ScriptableObject obj) {
-        obj.delete(ctorName);
         try {
-            ScriptableObject.defineClass(obj, Class.forName(className));
+            synchronized (obj) {
+                if (!isReplaced)
+                    ScriptableObject.defineClass(obj, Class.forName(className));
+                isReplaced = true;
+            }
         }
         catch (ClassNotFoundException e) {
             throw WrappedException.wrapException(e);
@@ -83,11 +86,14 @@
         return obj.get(ctorName, obj);
     }

-    public void setProperty(ScriptableObject obj, Object val) {
-        obj.delete(ctorName);
-        obj.put(ctorName, obj, val);
+    public Object setProperty(ScriptableObject obj, Object val) {
+        synchronized (obj) {
+            isReplaced = true;
+            return val;
+        }
     }

     private String ctorName;
     private String className;
+    private boolean isReplaced;
 }
Index: ScriptableObject.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/org/mozilla/javascript/ScriptableObject.java,v
retrieving revision 1.17
diff -u -r1.17 ScriptableObject.java
--- ScriptableObject.java 2000/03/13 17:12:36 1.17
+++ ScriptableObject.java 2000/07/03 18:31:04
@@ -246,11 +246,21 @@
                             break;
                         }
                     }
-                    getterSlot.setter.invoke(start, arg);
+                    Object v = getterSlot.setter.invoke(start, arg);
+                    if (getterSlot.setterReturnsValue) {
+                        slots[slotIndex].value = v;
+                        if (!(v instanceof Method))
+                            slots[slotIndex].flags = 0;
+                    }
                     return;
                 }
                 Object[] args = { this, actualArg };
-                getterSlot.setter.invoke(getterSlot.delegateTo, args);
+                Object v = getterSlot.setter.invoke(getterSlot.delegateTo, args);
+                if (getterSlot.setterReturnsValue) {
+                    slots[slotIndex].value = v;
+                    if (!(v instanceof Method))
+                        slots[slotIndex].flags = 0;
+                }
                 return;
             }
             catch (InvocationTargetException e) {
@@ -1183,6 +1193,7 @@
         slot.delegateTo = delegateTo;
         slot.getter = getter;
         slot.setter = setter;
+        slot.setterReturnsValue = setter != null && setter.getReturnType() !=
Void.TYPE;
         slot.value = null;
         slot.attributes = (short) attributes;
         slot.flags = flags;
@@ -1551,6 +1562,7 @@
     Object delegateTo;  // OPT: merge with "value"
     Method getter;
     Method setter;
+    boolean setterReturnsValue;
 }




Fergus Gallagher wrote:

> I am having problems getting my head around contexts and scopes and my
> multi-threaded application fall over.
>
> If I set "global=false" the following code used a per-thread
> initStandardObject() and this seems to work.  But when I set
> "global=true", the global "parentScope" is used and I get some wierd
> errors.
>
> If I change "__CODE__.slice(0,5)" to
> 1. "__CODE__" - works
> 2. "__CODE__.substring(0,5)" - fails
> 3. "__CODE__.toString()" - works
>
> Any help appreciated.
>
> Fergus
>
> ===== Test.java =========================================
> import java.io.*;
> import org.mozilla.javascript.*;
>
> public class Test implements Runnable {
>         private Script script;
>         private Scriptable parentScope;
>         private String __CODE__="ABCDEFGHIJK";
>         private boolean global = true;
>         private static Context globalContext = null;
>         public Test() throws Exception {
>                 String js= "java.lang.System.out.println(__CODE__.slice(0,5));";
>                 globalContext.setCompileFunctionsWithDynamicScope(false);
>                 parentScope = globalContext.initStandardObjects(null);
>                 StringReader sr = new StringReader(js);
>                 script = globalContext.compileReader(parentScope, sr, "(compiled)",
> 1,null);
>         }
>
>         public void run() {
>                 try {
>                         Context context = Context.enter();
>                         Scriptable threadScope;
>                         if (global) {
>                                 threadScope = context.newObject(parentScope);
>                                 threadScope.setPrototype(parentScope);
>                                 threadScope.setParentScope(null);
>                         } else {
>                                 threadScope = context.initStandardObjects(null);
>                         }
>                         threadScope.put("__CODE__",threadScope,__CODE__);
>                         script.exec(context,threadScope);
>                 }
>                 catch (Exception e) {
>                         System.err.println(e.getClass().getName()+":
"+e.getMessage());
>                 }
>                 finally {
>                         Context.exit();
>                 }
>         }
>
>         public static void main(String args[]) throws Exception {
>         globalContext = Context.enter();
>                 Test me = new Test();
>                 int count=10;
>                 Thread[] threads = new Thread[count];
>                 for (int i=0; i<count; i++) {
>                         Thread t = new Thread(me);
>                         threads[i] = t;
>                         t.start();
>                 }
>                 for (int i=0; i<count; i++) {
>                         threads[i].join();
>                 }
>                 Context.exit();
>         }
> }
>
> ==== OUTPUT ===============================================
> ABCDE
> ABCDE
> org.mozilla.javascript.EcmaError: undefined is not a function.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> org.mozilla.javascript.EvaluatorException: Constructor for "String" not
> found.
> ===========================================================
>
> The number and type of exceptions is highly variable from run to run -
> anywhere from 1-9 out of 10.
> The EcmaError in particular only happens occasionally.
>
> --
> Fergus Gallagher          Tel: +44 (20) 8 987 0717
> Orbis                     Fax: +44 (20) 8 742 2649
> The Swan Centre           email: Fergus.Gallagher@orbisuk.com
> Fishers Lane              Web: http://www.orbisuk.com
> London W4 1RX / UK
2000-07-03 18:40:35 +00:00