This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static modules and local vars


62945 wrote:

I have doubts concerning static modules and thread safety:

There are some issues with thread safety of global variables, which I plan on redesigning.

However, as Chris explains in his reply:  I don't believe there
are any thread-safety issues for local variables.

are local (inner-scope) variables in a static module
transformed (after compilation) to static class variables ?

No.


If a local variable is captured by an inner function, it
may get assigned to a *non-static* field, and I guess there
could be thread safety issues if you tried to save an inner
function globally so it could be accessed from multiple threads.
But then you have to from one thread store a function into the
global environment, and access it from multiple threads.
Doesn't seem like a sensible thing to do or worry about.

public static java.lang.Object f(java.lang.Object);
  Code:
   0:   aload_0
   1:   astore_1
   2:   getstatic       #18; //Field
gnu/kawa/functions/AddOp.$Pl:Lgnu/kawa/functions/AddOp;
   5:   getstatic       #24; //Field Lit0:Lgnu/math/IntNum;
   8:   aload_1
   9:   invokevirtual   #30; //Method
gnu/mapping/Procedure.apply2:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
   12:  areturn

So is the "y" in the "let" transformed to static class
var "Lit0" ?

No, it is transformed to local variable 1. Instruction 0 loads x, and instruction 1 stores it in y.

If not I imagine it would be much better if
"y" was trasformed to a local var in method "f".

As it is. -- --Per Bothner per@bothner.com http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]