[Java Spec Report] Re: for of array quickly

"Pat LaVarre" <[email protected]> Thu, 11 Mar 2004 14:12:14 -0000
Newsgroups gmane.comp.java.spec-report
Message-ID <[email protected]>
> > > ... I look forward to seeing 
> > > the `javap -c` disassembly of
> > > a for Iterable loop ...
>
> compilers can follow the as-if rule ...

Yes.

So far as we can judge from the javap -c of that jsr 14 proto found
...

//// JDK 1.4

The fragment:

for (int ix = 0; ix < args.length; ++ix) { String st = args[ix]; ...

reaches .class as written, with the op xBE arraylength inside the
loop, with slots 1 2 = ix st.

//// JDK 1.5

The fragment:

for (String st : args) { ... }

reaches .class as if written:

String[] things = args;
int things_length = things.length;
for (int ix = 0; ix < things_length; ++ix) { String st = things[ix];

with the op xBE arraylength outside the loop, with slots 1 2 3 4 =
things things_lengths ix st.

Pat LaVarre



To unsubscribe from this mailing list, send an email to:
[email protected]
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/java-spec-report/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/