This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: static modules and local vars
- From: Per Bothner <per at bothner dot com>
- To: 62945 <62945 at bol dot com dot br>
- Cc: kawa <kawa at sources dot redhat dot com>
- Date: Sat, 07 Aug 2004 11:35:13 -0700
- Subject: Re: static modules and local vars
- References: <I2383J$BE4FDC0790DF34D12AFF43642905FE2F@bol.com.br>
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/