Subj : Re: Is rhino's Codegen.generateCode() method thread safe? To : mozilla-jseng@mozilla.org From : tomi@osaka.niss.co.jp (Tomita Tomohiro) Date : Thu Mar 13 2003 05:14 am On Wed, 12 Mar 2003 14:38:40 +0100 Igor Bukanov wrote: > Tomita Tomohiro wrote: > > Hi, > > I have some question about rhino. > > What version of Rhino do you use and what is your JVM name/version/platform? I use rhino version 1_5R3. and JVM is J9 in WSDD5.0 for MontaVistaLinux3.0/XScale. It is not a FCS version,so it is supposed that the jvm have some bugs as you guess. > > > > > I'm using rhino in multi thread. > > Is the Codegen.generateCode() method thread safe? > > Codegen is not thread safe but its usage is safe since its instances are > accessed only by the single thread that creates them. I see. > > > #I have no time to trace or debug rhino source,so I ask this ML :-) > > > > in my enviroment(j9VM) the error occures very often as follows: > > java.lang.StringIndexOutOfBoundsException > > Stack trace: > > java/lang/Throwable.()V > > java/lang/String.charAt(I)C > > org/mozilla/classfile/ClassFileWriter.sizeOfParameters(Ljava/lang/String;)I > > org/mozilla/classfile/ClassFileWriter.add(BLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V > > org/mozilla/javascript/optimizer/Codegen.addStaticInvoke(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V > > org/mozilla/javascript/optimizer/Codegen.visitRegularCall(Lorg/mozilla/javascript/Node;ILorg/mozilla/javascript/Node;Z)V > > org/mozilla/javascript/optimizer/Codegen.visitCall(Lorg/mozilla/javascript/Node;ILorg/mozilla/javascript/Node;)V > > org/mozilla/javascript/optimizer/Codegen.generateCodeFromNode(Lorg/mozilla/javascript/Node;Lorg/mozilla/javascript/Node;II)V > > org/mozilla/javascript/optimizer/Codegen.generateCodeFromNode(Lorg/mozilla/javascript/Node;Lorg/mozilla/javascript/Node;II)V > > org/mozilla/javascript/optimizer/Codegen.generateCodeFromNode(Lorg/mozilla/javascript/Node;Lorg/mozilla/javascript/Node;II)V > > org/mozilla/javascript/optimizer/Codegen.generateCode(Lorg/mozilla/javascript/Node;Ljava/util/Vector;Ljava/util/Vector;Lorg/mozilla/javascript/ClassNameHelper;)Ljava/lang/String; > > org/mozilla/javascript/optimizer/Codegen.compile(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Node;Ljava/lang/Object;Lorg/mozilla/javascript/SecuritySupport;Lorg/mozilla/javascript/ClassNameHelper;)Ljava/lang/Object; > > org/mozilla/javascript/Context.compile(Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/TokenStream;Ljava/lang/Object;Ljava/io/Reader;Z)Ljava/lang/Object; > > org/mozilla/javascript/Context.compile(Lorg/mozilla/javascript/Scriptable;Ljava/io/Reader;Ljava/lang/String;ILjava/lang/Object;Z)Ljava/lang/Object; > > org/mozilla/javascript/Context.compileReader(Lorg/mozilla/javascript/Scriptable;Ljava/io/Reader;Ljava/lang/String;ILjava/lang/Object;)Lorg/mozilla/javascript/Script; > > tomi.run()V > > java/lang/Thread.run()V > > > > if compiling JavaScript in single thread, then it works good. > > The fact that org/mozilla/classfile/ClassFileWriter.sizeOfParameters() > accesses a character outside string is a bug in sizeOfParameters since > the function is supposed to check for bad method signatures and throw > exlicit exception about it. But its usage in > org/mozilla/javascript/optimizer/Codegen.java is correct, so I suspect a > bug in JVM. > > Regards, Igor > Thanks Tomohiro .