--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Sun Apr 15 15:37:20 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Tue Mar 06 12:36:59 2012 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2879,6 +2879,50 @@
__ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
}
+void LIRGenerator::do_RuntimeCall(address routine, int expected_arguments, Intrinsic* x) {
+ assert(x->number_of_arguments() == expected_arguments, "wrong type");
+ LIR_Opr reg = result_register_for(x->type());
+ __ call_runtime_leaf(routine, getThreadTemp(),
+ reg, new LIR_OprList());
+ LIR_Opr result = rlock_result(x);
+ __ move(reg, result);
+}
+
+#ifdef TRACE_HAVE_INTRINSICS
+void LIRGenerator::do_ThreadIDIntrinsic(Intrinsic* x) {
+ LIR_Opr thread = getThreadPointer();
+ LIR_Opr osthread = new_pointer_register();
+ __ move(new LIR_Address(thread, in_bytes(JavaThread::osthread_offset()), osthread->type()), osthread);
+ size_t thread_id_size = OSThread::thread_id_size();
+ if (thread_id_size == (size_t) BytesPerLong) {
+ LIR_Opr id = new_register(T_LONG);
+ __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_LONG), id);
+ __ convert(Bytecodes::_l2i, id, rlock_result(x));
+ } else if (thread_id_size == (size_t) BytesPerInt) {
+ __ move(new LIR_Address(osthread, in_bytes(OSThread::thread_id_offset()), T_INT), rlock_result(x));
+ } else {
+ ShouldNotReachHere();
+ }
+}
+
+void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
+ CodeEmitInfo* info = state_for(x);
+ CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check
+ assert(info != NULL, "must have info");
+ LIRItem arg(x->argument_at(1), this);
+ arg.load_item();
+ LIR_Opr klass = new_register(T_OBJECT);
+ __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_OBJECT), klass, info);
+ LIR_Opr id = new_register(T_LONG);
+ ByteSize offset = TRACE_ID_OFFSET;
+ LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
+ __ move(trace_id_addr, id);
+ __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
+ __ store(id, trace_id_addr);
+ __ logical_and(id, LIR_OprFact::longConst(~0x3l), id);
+ __ move(id, rlock_result(x));
+}
+#endif
void LIRGenerator::do_Intrinsic(Intrinsic* x) {
switch (x->id()) {
@@ -2890,25 +2934,21 @@
break;
}
- case vmIntrinsics::_currentTimeMillis: {
- assert(x->number_of_arguments() == 0, "wrong type");
- LIR_Opr reg = result_register_for(x->type());
- __ call_runtime_leaf(CAST_FROM_FN_PTR(address, os::javaTimeMillis), getThreadTemp(),
- reg, new LIR_OprList());
- LIR_Opr result = rlock_result(x);
- __ move(reg, result);
+#ifdef TRACE_HAVE_INTRINSICS
+ case vmIntrinsics::_threadID: do_ThreadIDIntrinsic(x); break;
+ case vmIntrinsics::_classID: do_ClassIDIntrinsic(x); break;
+ case vmIntrinsics::_counterTime:
+ do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), 0, x);
break;
- }
-
- case vmIntrinsics::_nanoTime: {
- assert(x->number_of_arguments() == 0, "wrong type");
- LIR_Opr reg = result_register_for(x->type());
- __ call_runtime_leaf(CAST_FROM_FN_PTR(address, os::javaTimeNanos), getThreadTemp(),
- reg, new LIR_OprList());
- LIR_Opr result = rlock_result(x);
- __ move(reg, result);
+#endif
+
+ case vmIntrinsics::_currentTimeMillis:
+ do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), 0, x);
break;
- }
+
+ case vmIntrinsics::_nanoTime:
+ do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), 0, x);
+ break;
case vmIntrinsics::_Object_init: do_RegisterFinalizer(x); break;
case vmIntrinsics::_getClass: do_getClass(x); break;