harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregory Shimansky <gshiman...@apache.org>
Subject Re: [drlvm]Help understanding string literal creation
Date Sat, 12 Apr 2008 20:36:53 GMT
On 11 апреля 2008 Megha Chauhan wrote:
> "I think this translates into ldc bytecode that loads a string from a
> constant. This bytecode requires to load a string from class' constant pool
> and JIT inserts a call to a VM helper class_get_const_string_intern_addr
> (see file C_Interface.cpp in DRLVM sources).
> This helper executes Java code for String.intern and returns the reference
> to the interned string back to the code generated for "ldc" bytecode. The
> String.intern code in class library actually calls VM.intern which calls
> InternMap.intern code from VM, but it is still pure Java code."
>
>  When I try to debug this using eclipse why does the breakpoint at
> String.intern() or VM.intern() never get hit? Could it be bceacue the
> control goes to the VM helper class C_interface.cpp first and then comes
> back to the Java Code? I am trying to find a way to understand the control
> flow here by basic debugging.
> Thanks a lot for helping me with this.

Are you sure that you use Harmony VM when you debug your program?

I can't think of a reason why this breakpoint is not hit, usually Java code 
that is called through VM is reachable by simple StepIn in debugging. Maybe 
you've found some regression in JVMTI support...

> On Thu, Apr 10, 2008 at 9:43 AM, Gregory Shimansky <gshimansky@apache.org>
>
> wrote:
> > Megha Chauhan said the following on 10.04.2008 18:16:
> > > I am not sure that String literal creation is done from java code. Any
> > > other
> > > String object is done from java code but String literal creation is
> > > something special. The object is instantiated at compile time only. I
> > > am sure that no string constructor is called when a string literal is
> > > created(but there might be some other way). Eclipse debugger is not
> > > able to
> > > step into any code when a breakpoint is set at :
> > > String str = "Test String" ;
> >
> > I think this translates into ldc bytecode that loads a string from a
> > constant. This bytecode requires to load a string from class' constant
> > pool and JIT inserts a call to a VM helper
> > class_get_const_string_intern_addr (see file C_Interface.cpp in DRLVM
> > sources).
> >
> > This helper executes Java code for String.intern and returns the
> > reference to the interned string back to the code generated for "ldc"
> > bytecode. The String.intern code in class library actually calls
> > VM.intern which calls InternMap.intern code from VM, but it is still pure
> > Java code.
> >
> >  So I am assuming that there is no java code involved.
> >
> >
> > There is actually almost no VM native code involved.
> >
> >  Again, I am not sure.
> >
> > > Gregory : Can you point me to the java code that might be called during
> > > string literal creation?
> >
> > See file InternMap.java in DRLVM sources.
> >
> >
> >  Thanks
> >
> > > Megha
> > >
> > > On Thu, Apr 10, 2008 at 9:07 AM, Gregory Shimansky <
> > > gshimansky@apache.org>
> > > wrote:
> > >
> > >  Megha Chauhan said the following on 10.04.2008 16:39:
> > > >  Hello everyone,
> > > >
> > > > > Thanks a lot for the response. Now, since I have a very small
> > > > > change in
> > > > > the
> > > > > String class is it possible for me to just add that extra field in
> > > > > the
> > > > > init_fields method of vm_string.cpp and somehow recompile the DLL?
> > > > > Basically I am not sure what kind of setup I need to do this
> > > > > change? I am still not very clear as to what classes are involved
> > > > > in a String
> > > > > Literal creation.
> > > > > As far as I understand there are no Java methods involved. For
> > > > > example
> > > > > when
> > > > > we write something like :
> > > > > String str ="Test String" ;
> > > > > The VM automatically calls the native methods and instantiates a
> > > > > String
> > > > > object at compile time itself.
> > > > > The String.intern() method can be called on already existing String
> > > > > objects
> > > > > and not during string literal creation.
> > > > >
> > > > >  AFAIK when a string is created in Java no VM code is executed, all
> > > >
> > > > of the
> > > > stuff is done in Java only. The vm_strings.cpp code is used for
> > > > creating
> > > > string objects from native code. If you grep for "string_create" you
> > > > will
> > > > see that it is used only in JNI and in VM initialization code.
> > > >
> > > > The String.intern is also implemented in Java code since HARMONY-1016
> > > > was
> > > > integrated.
> > > >
> > > >  Can someone point me to any documentation that tells about the
> > > > sequence
> > > >
> > > > > of
> > > > > methods that are called for a string literal creation?
> > > > > And what sort of setup would I need to make the changes to
> > > > > vm_strings.cpp
> > > > > class and recompile the DLL.
> > > > >
> > > > >  For recompiling the VM you need the standard setup for building
> > > >
> > > > DRLVM. See
> > > > the URL that Aleksey Shipilev gave in his reply.
> > > >
> > > > --
> > > > Gregory
> >
> > --
> > Gregory



-- 
Gregory

Mime
View raw message