Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1x/c1x_CodeInstaller.cpp @ 1434:72cfb36c6bb2
* enabled all jtt tests
* added proxy that counts jni calls
* honor hotspot stackshadowpages
* constant pool caching
* monitor enter/exit
* arithmetic stubs (frem, drem, ...)
* create stack values for debug info
* some doc
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 30 Sep 2010 17:19:48 -0700 |
parents | efba53f86c4f |
children | 20a3896518ac |
comparison
equal
deleted
inserted
replaced
1433:efba53f86c4f | 1434:72cfb36c6bb2 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 # include "incls/_precompiled.incl" | 25 # include "incls/_precompiled.incl" |
26 # include "incls/_c1x_CodeInstaller.cpp.incl" | 26 # include "incls/_c1x_CodeInstaller.cpp.incl" |
27 | 27 |
28 | |
28 // TODO this should be handled in a more robust way - not hard coded... | 29 // TODO this should be handled in a more robust way - not hard coded... |
29 Register CPU_REGS[] = { rax, rbx, rcx, rdx, rsi, rdi, r11, r12, r13, r14 }; | 30 Register CPU_REGS[] = { rax, rbx, rcx, rdx, rsi, rdi, r8, r9, r11, r12, r13, r14 }; |
30 const static int NUM_CPU_REGS = 10; | 31 const static int NUM_CPU_REGS = 10; |
31 XMMRegister XMM_REGS[] = { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 }; | 32 XMMRegister XMM_REGS[] = { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 }; |
32 const static int NUM_XMM_REGS = 16; | 33 const static int NUM_XMM_REGS = 16; |
33 const static int NUM_REGS = NUM_CPU_REGS + NUM_XMM_REGS; | 34 const static int NUM_REGS = NUM_CPU_REGS + NUM_XMM_REGS; |
34 | 35 |
82 | 83 |
83 return map; | 84 return map; |
84 } | 85 } |
85 | 86 |
86 // TODO: finish this - c1x doesn't provide any scope values at the moment | 87 // TODO: finish this - c1x doesn't provide any scope values at the moment |
87 static ScopeValue* get_hotspot_value(oop value) { | 88 static ScopeValue* get_hotspot_value(oop value, int frame_size) { |
88 fatal("not implemented"); | 89 if (value == CiValue::IllegalValue()) { |
90 return new LocationValue(Location::new_stk_loc(Location::invalid, 0)); | |
91 } | |
92 | |
93 BasicType type = C1XCompiler::kindToBasicType(CiKind::typeChar(CiValue::kind(value))); | |
89 if (value->is_a(CiRegisterValue::klass())) { | 94 if (value->is_a(CiRegisterValue::klass())) { |
90 TRACE_C1X_4("register value"); | 95 jint number = CiRegister::number(CiRegisterValue::_register(value)); |
91 IF_TRACE_C1X_4 value->print(); | 96 |
97 if (number < 16) { | |
98 return new LocationValue(Location::new_reg_loc(Location::normal, as_Register(number)->as_VMReg())); | |
99 } else { | |
100 return new LocationValue(Location::new_reg_loc(Location::normal, as_XMMRegister(number - 16)->as_VMReg())); | |
101 } | |
92 } else if (value->is_a(CiStackSlot::klass())) { | 102 } else if (value->is_a(CiStackSlot::klass())) { |
93 TRACE_C1X_4("stack value"); | 103 jint index = CiStackSlot::index(value); |
94 IF_TRACE_C1X_4 value->print(); | 104 if (index >= 0) { |
105 return new LocationValue(Location::new_stk_loc(Location::normal, index * HeapWordSize)); | |
106 } else { | |
107 int frame_size_bytes = frame_size + 2 * HeapWordSize; | |
108 return new LocationValue(Location::new_stk_loc(Location::normal, -(index * HeapWordSize) + frame_size_bytes)); | |
109 } | |
110 } else if (value->is_a(CiConstant::klass())){ | |
111 oop obj = CiConstant::object(value); | |
112 jlong prim = CiConstant::primitive(value); | |
113 if (type == T_INT || type == T_FLOAT) { | |
114 return new ConstantIntValue(*(jint*)&prim); | |
115 } else if (type == T_LONG || type == T_DOUBLE) { | |
116 return new ConstantLongValue(prim); | |
117 } else if (type == T_OBJECT) { | |
118 oop obj = CiConstant::object(value); | |
119 if (obj == NULL) { | |
120 return new ConstantOopWriteValue(NULL); | |
121 } else { | |
122 obj->print(); | |
123 ShouldNotReachHere(); | |
124 } | |
125 //return new ConstantOopWriteValue() | |
126 } | |
127 tty->print("%i", type); | |
128 ShouldNotReachHere(); | |
95 } else { | 129 } else { |
130 value->klass()->print(); | |
96 ShouldNotReachHere(); | 131 ShouldNotReachHere(); |
97 } | 132 } |
98 } | 133 } |
99 | 134 |
100 // constructor used to create a method | 135 // constructor used to create a method |
275 record_scope(pc_offset, caller_pos, caller_frame); | 310 record_scope(pc_offset, caller_pos, caller_frame); |
276 } else { | 311 } else { |
277 assert(frame == NULL || CiDebugInfo_Frame::caller(frame) == NULL, "unexpected layout - mismatching nesting of Frame and CiCodePos"); | 312 assert(frame == NULL || CiDebugInfo_Frame::caller(frame) == NULL, "unexpected layout - mismatching nesting of Frame and CiCodePos"); |
278 } | 313 } |
279 | 314 |
280 assert(frame == NULL || code_pos == CiDebugInfo_Frame::codePos(frame), "unexpected CiCodePos layout"); | 315 if (frame != NULL) { |
316 assert(CiCodePos::bci(code_pos) == CiCodePos::bci(CiDebugInfo_Frame::codePos(frame)), "unexpected CiCodePos layout"); | |
317 assert(CiCodePos::method(code_pos) == CiCodePos::method(CiDebugInfo_Frame::codePos(frame)), "unexpected CiCodePos layout"); | |
318 } | |
281 | 319 |
282 oop hotspot_method = CiCodePos::method(code_pos); | 320 oop hotspot_method = CiCodePos::method(code_pos); |
283 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotMethodResolved::klass()), "unexpected hotspot method"); | 321 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotMethodResolved::klass()), "unexpected hotspot method"); |
284 methodOop method = VmIds::get<methodOop>(HotSpotMethodResolved::vmId(hotspot_method)); | 322 methodOop method = VmIds::get<methodOop>(HotSpotMethodResolved::vmId(hotspot_method)); |
285 ciMethod *cimethod = (ciMethod *) _env->get_object(method); | 323 ciMethod *cimethod = (ciMethod *) _env->get_object(method); |
286 jint bci = CiCodePos::bci(code_pos); | 324 jint bci = CiCodePos::bci(code_pos); |
325 bool reexecute; | |
326 if (bci == -1) { | |
327 reexecute = false; | |
328 } else { | |
329 Bytecodes::Code code = Bytecodes::java_code_at(method->bcp_from(bci)); | |
330 reexecute = Interpreter::bytecode_should_reexecute(code); | |
331 } | |
332 | |
287 | 333 |
288 if (frame != NULL) { | 334 if (frame != NULL) { |
289 jint local_count = CiDebugInfo_Frame::numLocals(frame); | 335 jint local_count = CiDebugInfo_Frame::numLocals(frame); |
290 jint expression_count = CiDebugInfo_Frame::numStack(frame); | 336 jint expression_count = CiDebugInfo_Frame::numStack(frame); |
291 jint monitor_count = CiDebugInfo_Frame::numLocks(frame); | 337 jint monitor_count = CiDebugInfo_Frame::numLocks(frame); |
292 arrayOop values = (arrayOop) CiDebugInfo_Frame::values(frame); | 338 arrayOop values = (arrayOop) CiDebugInfo_Frame::values(frame); |
293 | 339 |
294 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); | 340 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); |
295 assert(monitor_count == 0, "monitors not supported"); | |
296 | 341 |
297 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); | 342 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> (); |
298 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); | 343 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> (); |
299 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> (); | 344 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> (); |
300 | 345 |
301 for (jint i = 0; i < values->length(); i++) { | 346 for (jint i = 0; i < values->length(); i++) { |
302 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i]); | 347 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], _frame_size); |
303 | 348 |
304 if (i < local_count) { | 349 if (i < local_count) { |
305 locals->append(value); | 350 locals->append(value); |
306 } else if (i < local_count + expression_count) { | 351 } else if (i < local_count + expression_count) { |
307 expressions->append(value); | 352 expressions->append(value); |
308 } else { | 353 } else { |
309 ShouldNotReachHere(); | 354 assert(value->is_location(), "invalid monitor location"); |
310 // monitors->append(value); | 355 LocationValue* loc = (LocationValue*)value; |
356 LocationValue* obj = new LocationValue(Location::new_stk_loc(Location::oop, loc->location().stack_offset() + HeapWordSize)); | |
357 monitors->append(new MonitorValue(obj, Location::new_stk_loc(Location::normal, loc->location().stack_offset()))); | |
311 } | 358 } |
312 } | 359 } |
313 DebugToken* locals_token = _debug_recorder->create_scope_values(locals); | 360 DebugToken* locals_token = _debug_recorder->create_scope_values(locals); |
314 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions); | 361 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions); |
315 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors); | 362 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors); |
316 | 363 |
317 _debug_recorder->describe_scope(pc_offset, cimethod, bci, false, false, false, locals_token, expressions_token, monitors_token); | 364 _debug_recorder->describe_scope(pc_offset, cimethod, bci, reexecute, false, false, locals_token, expressions_token, monitors_token); |
318 } else { | 365 } else { |
319 _debug_recorder->describe_scope(pc_offset, cimethod, bci, false, false, false, NULL, NULL, NULL); | 366 _debug_recorder->describe_scope(pc_offset, cimethod, bci, reexecute, false, false, NULL, NULL, NULL); |
320 } | 367 } |
321 } | 368 } |
322 | 369 |
323 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { | 370 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { |
324 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site); | 371 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site); |
375 TRACE_C1X_3("CiRuntimeCall::JavaTimeMillis()"); | 422 TRACE_C1X_3("CiRuntimeCall::JavaTimeMillis()"); |
376 } else if (runtime_call == CiRuntimeCall::JavaTimeNanos()) { | 423 } else if (runtime_call == CiRuntimeCall::JavaTimeNanos()) { |
377 call->set_destination((address)os::javaTimeNanos); | 424 call->set_destination((address)os::javaTimeNanos); |
378 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); | 425 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); |
379 TRACE_C1X_3("CiRuntimeCall::JavaTimeNanos()"); | 426 TRACE_C1X_3("CiRuntimeCall::JavaTimeNanos()"); |
427 } else if (runtime_call == CiRuntimeCall::ArithmeticFrem()) { | |
428 call->set_destination(Runtime1::entry_for(Runtime1::c1x_arithmetic_frem_id)); | |
429 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); | |
430 TRACE_C1X_3("CiRuntimeCall::ArithmeticFrem()"); | |
431 } else if (runtime_call == CiRuntimeCall::ArithmeticDrem()) { | |
432 call->set_destination(Runtime1::entry_for(Runtime1::c1x_arithmetic_drem_id)); | |
433 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); | |
434 TRACE_C1X_3("CiRuntimeCall::ArithmeticDrem()"); | |
380 } else { | 435 } else { |
381 TRACE_C1X_1("runtime_call not implemented: "); | 436 TRACE_C1X_1("runtime_call not implemented: "); |
382 IF_TRACE_C1X_1 runtime_call->print(); | 437 IF_TRACE_C1X_1 runtime_call->print(); |
383 } | 438 } |
384 } else if (global_stub != NULL) { | 439 } else if (global_stub != NULL) { |