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

65378 Коммитов

Автор SHA1 Сообщение Дата
morse%netscape.com 1a9b31cf83 workaround for bug 43573, select user not working 2000-07-04 03:07:39 +00:00
cls%seawood.org ca2b0dc434 Remove generated config files on distclean. Bug #43142 2000-07-03 21:41:19 +00:00
nboyd%atg.com fdeea4b93b 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
BlakeR1234%aol.com ec875575a4 Fix for 44442. r=me 2000-07-03 05:56:58 +00:00
rbs%maths.uq.edu.au 36f65d4461 [not part of default build] Fix bug 43443, and some updates in the stretchy chars land. a:waterson@mozilla.org 2000-07-03 05:40:13 +00:00
BlakeR1234%aol.com 5c94e82446 Partial fix for bug 44442. Thanks to walk84@usa.net for catching it r=me 2000-07-03 00:41:30 +00:00
bienvenu%netscape.com 4d3c8ade88 fix OS2 build bustage 2000-07-02 23:56:10 +00:00
jband%netscape.com 53edf6e9f7 updating readme. Not part of build 2000-07-02 19:37:57 +00:00
cls%seawood.org bca014f1bb Removing last vestiges of raptor from unix build. Since some libs were renamed, a 'make distclean' is recommeneded to remove the old copies of those libs. Bug #8228 r=bryner 2000-07-02 18:44:42 +00:00
bienvenu%netscape.com 556ce644e5 fix OS2 build bustage 2000-07-02 18:16:47 +00:00
bienvenu%netscape.com 5373466ff1 fix os2 build bustage 2000-07-02 18:11:32 +00:00
ben%netscape.com 4805623c73 tweaks to classic skin for mac (make throbber normal size, make splitter the right colour) 2000-07-02 07:03:16 +00:00
morse%netscape.com 3c358ddf73 fix bug 43227, quickfill still in menu on mac 2000-07-02 04:00:02 +00:00
dbaron%fas.harvard.edu fc3dadcc58 Ignore the correct generated files (rather than the list copied from leaky). 2000-07-02 00:44:31 +00:00
dbaron%fas.harvard.edu 71dee3b6b0 Fix bug 35355 by not reading before the beginning of an array. Patch from Robert O'Callahan <roc+moz@cs.cmu.edu>.
Fix ConditionRect so really wide documents repaint correctly on Win95.
r=kmcclusk, a=waterson
2000-07-01 22:12:23 +00:00
leaf%mozilla.org 89d62a278c Automated update 2000-07-01 21:45:08 +00:00
dbaron%fas.harvard.edu da67297134 Fix leak of content from trees introduced recently. r=hyatt,waterson 2000-07-01 21:45:06 +00:00
dbaron%fas.harvard.edu a921110dbd Add Vidur's xmlextras to the list of *all* extensions (what you get with --with-extensions=all). Does not affect default build. r=vidur 2000-07-01 21:41:48 +00:00
dbaron%fas.harvard.edu 0abf789810 Allow Vidur's xmlextras to be built on Linux (not part of default build). r=vidur 2000-07-01 21:40:53 +00:00
jab%atdot.org 4677a29ea5 A typo in the Windows makefile... 2000-07-01 12:41:53 +00:00
jab%atdot.org 9cdd33f1bd The mac build was not getting my new MANIFEST file. I think this might fix it. 2000-07-01 11:05:41 +00:00
jab%atdot.org e329811f28 I had an extra tab after one of the makefile lines... 2000-07-01 10:49:06 +00:00
jab%atdot.org 3ff5cd0f65 a=brendan@mozilla.org
Bug #16103
Support for SOCKS proxies in HTTP, HTTPS, and FTP protocols.
Also includes the prefs configuration and UI bits.
2000-07-01 10:25:25 +00:00
ssu%netscape.com 4f787c64e4 fixing bug 44006 - Please don't use Windows extended dialogs in setupsrc.dll. nsbeta2+ r=sgehani 2000-07-01 08:50:44 +00:00
andreas.otte%primus-online.de 1a2a5c7fee fix bug 43659, URL bar does not accept hexadecimal domain names, r=gagan@netscape.com, a=waterson@mozilla.org 2000-07-01 06:29:13 +00:00
rpotts%netscape.com 602b139a4a Fixed a leak where child SHEntry were not being released when the parent SHEntry was deleted. 2000-07-01 05:37:40 +00:00
sspitzer%netscape.com 31e159ea1b last check in before sabbatical! fix for nsbeta2+ bugscape bug #1149.
install default templates in the case where the profile's locale
is not set.  r=mscott
2000-07-01 02:38:27 +00:00
brendan%mozilla.org b864716baa Reference-count XBL JSClass structs, and LRU-cache unreferenced ones up to some quota, to avoid bloat and shutdown crashes due to unavoidable manual delete/last-use misorder (42530, r=hyatt). 2000-07-01 02:36:18 +00:00
nisheeth%netscape.com d70a4ed2b5 Fix for nsbeta2+ bug 12152. r=vidur, pollmann. Setting the src property during document load works on <IMG> and <INPUT type="image"> elements. 2000-07-01 02:26:30 +00:00
cmanske%netscape.com 7d40913fb4 Don't include current URL when building Recent Files menu. Checking in work for Ryan Cassin, b=17502, r=cmanske 2000-07-01 02:16:04 +00:00
dougt%netscape.com 684793f190 submitted by Quy Tonthat <quy@igelaus.com.au>
a=waterson@netscape.com
2000-07-01 02:12:52 +00:00
javi%netscape.com e9987aeb54 Get the CRL dialog window to properly close and refresh the Signers pane
when no more CRL's are left.
2000-07-01 01:26:42 +00:00
javi%netscape.com 628ab13451 First shot at having UI for deleting CRLs. 2000-07-01 01:19:22 +00:00
javi%netscape.com b5b2f5d3cd Remove an unused button from dialog. 2000-07-01 01:15:28 +00:00
javi%netscape.com 303eb4dbb0 Changes for having a dialog that does CRL deleting. 2000-07-01 01:14:22 +00:00
morse%netscape.com d39a733631 fix bug 42550, unable to delete single-signon database, r=dveditz 2000-07-01 00:43:42 +00:00
jst%netscape.com bbc5b3f11f Checking in patch from timelesss@bemail.org, add access keys to javascript console menus, r=me, a=brendan@mozilla.org 2000-07-01 00:43:03 +00:00
tao%netscape.com e609f5ec1f Fix the broken localeSwitcher in "QA|Languages->". a=ben 2000-07-01 00:41:20 +00:00
cmanske%netscape.com 7e2764c3d9 Table Properties dialog and UI commands work. b=20973, r=sfraser 2000-07-01 00:37:38 +00:00
cmanske%netscape.com 99c3bfe78d Changed Composer test because of added parameter for JoinTableCells in connection with work for bug 20973. r=jfrancis 2000-07-01 00:37:23 +00:00
cmanske%netscape.com e50d57138a Table editing work. b=20973, r=jfrancis 2000-07-01 00:37:12 +00:00
hangas%netscape.com 5ce5924431 Fixing stop and print buttons in Classic skin. Wirtten by German r=hangas 2000-06-30 23:53:00 +00:00
hangas%netscape.com 0ac0d09e4e First Checked In. 2000-06-30 23:50:37 +00:00
tor%cs.brown.edu 71ffb779d0 Update libmng snapshot. Not in default build. 2000-06-30 23:41:12 +00:00
valeski%netscape.com c38f04faf9 39474. r=rpotts,mscott. We now can load a stream directly into the uri loader (bypassing necko). built and pre-checkin tested on linux and win 2000-06-30 23:39:30 +00:00
vidur%netscape.com bbd0c263ca Simple posting tests. This is not part of the Seamonkey build. 2000-06-30 23:10:56 +00:00
vidur%netscape.com bb95d0ddd1 Added support for synchronous posting. Got rid of unbreakable circular reference in the abort case. This is not part of the Seamonkey build. 2000-06-30 23:09:26 +00:00
rpotts%netscape.com 31ffea0b7d Fixed the nsIWebNavigation methods on the docshell when SH_IN_FRAMES is defined... 2000-06-30 22:05:32 +00:00
edburns%acm.org e9e8cd3ece Automatically_generate_JAVAH_headers 2000-06-30 21:08:30 +00:00
edburns%acm.org 162827ca7a Finally_make_use_of_Sherry_Shen_changes 2000-06-30 19:03:27 +00:00