x86 interpreters in hotspot
Xin Tong
xerox.time.tech at gmail.com
Mon May 7 20:17:16 PDT 2012
On Mon, May 7, 2012 at 11:11 PM, Krystal Mok <rednaxelafx at gmail.com> wrote:
>
> On Tue, May 8, 2012 at 10:54 AM, Xin Tong <xerox.time.tech at gmail.com> wrote:
>>
>> I think the trace_bytecode() is the function i want to extend. I want
>> to get a list of all the executed and unique java bytecode PC. i.e.
>> if iconst_1 at bytecode index 1 in method foo() is executed many
>> times, it will only count as one.
>>
>
> Are you trying to implement code coverage kind of stuff? If so,
> trace_bytecode() is NOT what you want to touch. It's an overkill for your
> purpose.
>
> There are quite a few frameworks to do this, all based on instrumentation,
> noteably EMMA, Cobertura and their derivatives. I'd suggest working on that
> level.
>
> If you insist on implementing such feature in the VM itself, I was
> implementing a toy code coverage tool last night. If you could wait, I'll
> post what I've got sometime later, perhaps next week.
>
>>
>> Also, what is an easy way to get the size of the interpreter code
>> given a Java bytecode.
>
>
> Could you give an example? I don't understand the question.
>
> - Kris
>
>>
>>
>> Xin
>
>
For example, for bipush interpreter code, it is like this in x86_64
void TemplateTable::bipush() {
transition(vtos, itos);
__ load_signed_byte(rax, at_bcp(1));
}
I would like to know the size of the generated assembly by the
TemplateTable::bipush in given a bcp.
Also, btw, i traced down the trace_bytecode. it calls overloaded
traces. 1 with 1 tos and 1 with 2 toses. does that mean java opcodes
can take up to 2 tos elements ?
void BytecodeTracer::trace(methodHandle method, address bcp, uintptr_t
tos, uintptr_t tos2, outputStream* st) {
if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
ttyLocker ttyl; // 5065316: keep the following output coherent
// The ttyLocker also prevents races between two threads
// trying to use the single instance of BytecodePrinter.
// Using the ttyLocker prevents the system from coming to
// a safepoint within this code, which is sensitive to methodOop
// movement.
//
// There used to be a leaf mutex here, but the ttyLocker will
// work just as well, as long as the printing operations never block.
//
// We put the locker on the static trace method, not the
// virtual one, because the clients of this module go through
// the static method.
_closure->trace(method, bcp, tos, tos2, st);
}
}
void BytecodeTracer::trace(methodHandle method, address bcp, outputStream* st) {
ttyLocker ttyl; // 5065316: keep the following output coherent
_closure->trace(method, bcp, st);
}
Xin
More information about the hotspot-runtime-dev
mailing list