src/cpu/x86/vm/cppInterpreter_x86.cpp

changeset 6723
0bf37f737702
parent 6558
2100bf712e2a
child 6876
710a3c8b516e
child 8368
32b682649973
equal deleted inserted replaced
6721:ad51f24671c2 6723:0bf37f737702
2334 to_fill->_self_link = to_fill; 2334 to_fill->_self_link = to_fill;
2335 assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base, 2335 assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
2336 "Stack top out of range"); 2336 "Stack top out of range");
2337 } 2337 }
2338 2338
2339 int AbstractInterpreter::layout_activation(Method* method, 2339
2340 int tempcount, // 2340 static int frame_size_helper(int max_stack,
2341 int popframe_extra_args, 2341 int tempcount,
2342 int moncount, 2342 int moncount,
2343 int caller_actual_parameters, 2343 int callee_param_count,
2344 int callee_param_count, 2344 int callee_locals,
2345 int callee_locals, 2345 bool is_top_frame,
2346 frame* caller, 2346 int& monitor_size,
2347 frame* interpreter_frame, 2347 int& full_frame_size) {
2348 bool is_top_frame, 2348 int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
2349 bool is_bottom_frame) { 2349 monitor_size = sizeof(BasicObjectLock) * moncount;
2350 2350
2351 assert(popframe_extra_args == 0, "FIX ME"); 2351 // First calculate the frame size without any java expression stack
2352 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state() 2352 int short_frame_size = size_activation_helper(extra_locals_size,
2353 // does as far as allocating an interpreter frame. 2353 monitor_size);
2354 // If interpreter_frame!=NULL, set up the method, locals, and monitors. 2354
2355 // The frame interpreter_frame, if not NULL, is guaranteed to be the right size, 2355 // Now with full size expression stack
2356 // as determined by a previous call to this method. 2356 full_frame_size = short_frame_size + max_stack * BytesPerWord;
2357 // It is also guaranteed to be walkable even though it is in a skeletal state 2357
2358 // and now with only live portion of the expression stack
2359 short_frame_size = short_frame_size + tempcount * BytesPerWord;
2360
2361 // the size the activation is right now. Only top frame is full size
2362 int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
2363 return frame_size;
2364 }
2365
2366 int AbstractInterpreter::size_activation(int max_stack,
2367 int tempcount,
2368 int extra_args,
2369 int moncount,
2370 int callee_param_count,
2371 int callee_locals,
2372 bool is_top_frame) {
2373 assert(extra_args == 0, "FIX ME");
2358 // NOTE: return size is in words not bytes 2374 // NOTE: return size is in words not bytes
2359 // NOTE: tempcount is the current size of the java expression stack. For top most
2360 // frames we will allocate a full sized expression stack and not the curback
2361 // version that non-top frames have.
2362 2375
2363 // Calculate the amount our frame will be adjust by the callee. For top frame 2376 // Calculate the amount our frame will be adjust by the callee. For top frame
2364 // this is zero. 2377 // this is zero.
2365 2378
2366 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it 2379 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
2367 // calculates the extra locals based on itself. Not what the callee does 2380 // calculates the extra locals based on itself. Not what the callee does
2368 // to it. So it ignores last_frame_adjust value. Seems suspicious as far 2381 // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2369 // as getting sender_sp correct. 2382 // as getting sender_sp correct.
2370 2383
2371 int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord; 2384 int unused_monitor_size = 0;
2372 int monitor_size = sizeof(BasicObjectLock) * moncount; 2385 int unused_full_frame_size = 0;
2373 2386 return frame_size_helper(max_stack, tempcount, moncount, callee_param_count, callee_locals,
2374 // First calculate the frame size without any java expression stack 2387 is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
2375 int short_frame_size = size_activation_helper(extra_locals_size, 2388 }
2376 monitor_size); 2389
2377 2390 void AbstractInterpreter::layout_activation(Method* method,
2378 // Now with full size expression stack 2391 int tempcount, //
2379 int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord; 2392 int popframe_extra_args,
2380 2393 int moncount,
2381 // and now with only live portion of the expression stack 2394 int caller_actual_parameters,
2382 short_frame_size = short_frame_size + tempcount * BytesPerWord; 2395 int callee_param_count,
2383 2396 int callee_locals,
2384 // the size the activation is right now. Only top frame is full size 2397 frame* caller,
2385 int frame_size = (is_top_frame ? full_frame_size : short_frame_size); 2398 frame* interpreter_frame,
2386 2399 bool is_top_frame,
2387 if (interpreter_frame != NULL) { 2400 bool is_bottom_frame) {
2401
2402 assert(popframe_extra_args == 0, "FIX ME");
2403 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
2404 // does as far as allocating an interpreter frame.
2405 // Set up the method, locals, and monitors.
2406 // The frame interpreter_frame is guaranteed to be the right size,
2407 // as determined by a previous call to the size_activation() method.
2408 // It is also guaranteed to be walkable even though it is in a skeletal state
2409 // NOTE: tempcount is the current size of the java expression stack. For top most
2410 // frames we will allocate a full sized expression stack and not the curback
2411 // version that non-top frames have.
2412
2413 int monitor_size = 0;
2414 int full_frame_size = 0;
2415 int frame_size = frame_size_helper(method->max_stack(), tempcount, moncount, callee_param_count, callee_locals,
2416 is_top_frame, monitor_size, full_frame_size);
2417
2388 #ifdef ASSERT 2418 #ifdef ASSERT
2389 assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable"); 2419 assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
2390 #endif 2420 #endif
2391 2421
2392 // MUCHO HACK 2422 // MUCHO HACK
2393 2423
2394 intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size)); 2424 intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
2395 2425
2396 /* Now fillin the interpreterState object */ 2426 /* Now fillin the interpreterState object */
2397 2427
2398 // The state object is the first thing on the frame and easily located 2428 // The state object is the first thing on the frame and easily located
2399 2429
2400 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter)); 2430 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2401 2431
2402 2432
2403 // Find the locals pointer. This is rather simple on x86 because there is no 2433 // Find the locals pointer. This is rather simple on x86 because there is no
2404 // confusing rounding at the callee to account for. We can trivially locate 2434 // confusing rounding at the callee to account for. We can trivially locate
2405 // our locals based on the current fp(). 2435 // our locals based on the current fp().
2406 // Note: the + 2 is for handling the "static long no_params() method" issue. 2436 // Note: the + 2 is for handling the "static long no_params() method" issue.
2407 // (too bad I don't really remember that issue well...) 2437 // (too bad I don't really remember that issue well...)
2408 2438
2409 intptr_t* locals; 2439 intptr_t* locals;
2410 // If the caller is interpreted we need to make sure that locals points to the first 2440 // If the caller is interpreted we need to make sure that locals points to the first
2411 // argument that the caller passed and not in an area where the stack might have been extended. 2441 // argument that the caller passed and not in an area where the stack might have been extended.
2412 // because the stack to stack to converter needs a proper locals value in order to remove the 2442 // because the stack to stack to converter needs a proper locals value in order to remove the
2413 // arguments from the caller and place the result in the proper location. Hmm maybe it'd be 2443 // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
2414 // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code 2444 // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
2415 // adjust the stack?? HMMM QQQ 2445 // adjust the stack?? HMMM QQQ
2416 // 2446 //
2417 if (caller->is_interpreted_frame()) { 2447 if (caller->is_interpreted_frame()) {
2418 // locals must agree with the caller because it will be used to set the 2448 // locals must agree with the caller because it will be used to set the
2419 // caller's tos when we return. 2449 // caller's tos when we return.
2420 interpreterState prev = caller->get_interpreterState(); 2450 interpreterState prev = caller->get_interpreterState();
2421 // stack() is prepushed. 2451 // stack() is prepushed.
2422 locals = prev->stack() + method->size_of_parameters(); 2452 locals = prev->stack() + method->size_of_parameters();
2423 // locals = caller->unextended_sp() + (method->size_of_parameters() - 1); 2453 // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
2424 if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) { 2454 if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
2425 // os::breakpoint(); 2455 // os::breakpoint();
2426 }
2427 } else {
2428 // this is where a c2i would have placed locals (except for the +2)
2429 locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
2430 } 2456 }
2431 2457 } else {
2432 intptr_t* monitor_base = (intptr_t*) cur_state; 2458 // this is where a c2i would have placed locals (except for the +2)
2433 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size); 2459 locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
2434 /* +1 because stack is always prepushed */ 2460 }
2435 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord); 2461
2436 2462 intptr_t* monitor_base = (intptr_t*) cur_state;
2437 2463 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
2438 BytecodeInterpreter::layout_interpreterState(cur_state, 2464 /* +1 because stack is always prepushed */
2439 caller, 2465 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
2440 interpreter_frame, 2466
2441 method, 2467
2442 locals, 2468 BytecodeInterpreter::layout_interpreterState(cur_state,
2443 stack, 2469 caller,
2444 stack_base, 2470 interpreter_frame,
2445 monitor_base, 2471 method,
2446 frame_bottom, 2472 locals,
2447 is_top_frame); 2473 stack,
2448 2474 stack_base,
2449 // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp()); 2475 monitor_base,
2450 } 2476 frame_bottom,
2451 return frame_size/BytesPerWord; 2477 is_top_frame);
2478
2479 // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
2452 } 2480 }
2453 2481
2454 #endif // CC_INTERP (all) 2482 #endif // CC_INTERP (all)

mercurial