7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.hpp"
27 #include "interpreter/bytecodeHistogram.hpp"
28 #include "interpreter/cppInterpreter.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "interpreter/interpreterGenerator.hpp"
31 #include "interpreter/interpreterRuntime.hpp"
32 #include "oops/arrayOop.hpp"
33 #include "oops/methodData.hpp"
34 #include "oops/method.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "prims/jvmtiExport.hpp"
37 #include "prims/jvmtiThreadState.hpp"
38 #include "runtime/arguments.hpp"
39 #include "runtime/deoptimization.hpp"
40 #include "runtime/frame.inline.hpp"
41 #include "runtime/interfaceSupport.hpp"
42 #include "runtime/sharedRuntime.hpp"
43 #include "runtime/stubRoutines.hpp"
44 #include "runtime/synchronizer.hpp"
45 #include "runtime/timer.hpp"
46 #include "runtime/vframeArray.hpp"
2325 prev->_result._to_call._callee = method;
2326 if (*prev->_bcp == Bytecodes::_invokeinterface) {
2327 prev->_result._to_call._bcp_advance = 5;
2328 } else {
2329 prev->_result._to_call._bcp_advance = 3;
2330 }
2331 }
2332 to_fill->_oop_temp = NULL;
2333 to_fill->_stack_base = stack_base;
2334 // Need +1 here because stack_base points to the word just above the first expr stack entry
2335 // and stack_limit is supposed to point to the word just below the last expr stack entry.
2336 // See generate_compute_interpreter_state.
2337 to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
2338 to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2339
2340 to_fill->_self_link = to_fill;
2341 assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
2342 "Stack top out of range");
2343 }
2344
2345 int AbstractInterpreter::layout_activation(Method* method,
2346 int tempcount, //
2347 int popframe_extra_args,
2348 int moncount,
2349 int caller_actual_parameters,
2350 int callee_param_count,
2351 int callee_locals,
2352 frame* caller,
2353 frame* interpreter_frame,
2354 bool is_top_frame,
2355 bool is_bottom_frame) {
2356
2357 assert(popframe_extra_args == 0, "FIX ME");
2358 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
2359 // does as far as allocating an interpreter frame.
2360 // If interpreter_frame!=NULL, set up the method, locals, and monitors.
2361 // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
2362 // as determined by a previous call to this method.
2363 // It is also guaranteed to be walkable even though it is in a skeletal state
2364 // NOTE: return size is in words not bytes
2365 // NOTE: tempcount is the current size of the java expression stack. For top most
2366 // frames we will allocate a full sized expression stack and not the curback
2367 // version that non-top frames have.
2368
2369 // Calculate the amount our frame will be adjust by the callee. For top frame
2370 // this is zero.
2371
2372 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
2373 // calculates the extra locals based on itself. Not what the callee does
2374 // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2375 // as getting sender_sp correct.
2376
2377 int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
2378 int monitor_size = sizeof(BasicObjectLock) * moncount;
2379
2380 // First calculate the frame size without any java expression stack
2381 int short_frame_size = size_activation_helper(extra_locals_size,
2382 monitor_size);
2383
2384 // Now with full size expression stack
2385 int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;
2386
2387 // and now with only live portion of the expression stack
2388 short_frame_size = short_frame_size + tempcount * BytesPerWord;
2389
2390 // the size the activation is right now. Only top frame is full size
2391 int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
2392
2393 if (interpreter_frame != NULL) {
2394 #ifdef ASSERT
2395 assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
2396 #endif
2397
2398 // MUCHO HACK
2399
2400 intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
2401
2402 /* Now fillin the interpreterState object */
2403
2404 // The state object is the first thing on the frame and easily located
2405
2406 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2407
2408
2409 // Find the locals pointer. This is rather simple on x86 because there is no
2410 // confusing rounding at the callee to account for. We can trivially locate
2411 // our locals based on the current fp().
2412 // Note: the + 2 is for handling the "static long no_params() method" issue.
2413 // (too bad I don't really remember that issue well...)
2436 }
2437
2438 intptr_t* monitor_base = (intptr_t*) cur_state;
2439 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
2440 /* +1 because stack is always prepushed */
2441 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
2442
2443
2444 BytecodeInterpreter::layout_interpreterState(cur_state,
2445 caller,
2446 interpreter_frame,
2447 method,
2448 locals,
2449 stack,
2450 stack_base,
2451 monitor_base,
2452 frame_bottom,
2453 is_top_frame);
2454
2455 // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
2456 }
2457 return frame_size/BytesPerWord;
2458 }
2459
2460 bool AbstractInterpreter::can_be_compiled(methodHandle m) {
2461 switch (method_kind(m)) {
2462 case Interpreter::java_lang_math_sin : // fall thru
2463 case Interpreter::java_lang_math_cos : // fall thru
2464 case Interpreter::java_lang_math_tan : // fall thru
2465 case Interpreter::java_lang_math_abs : // fall thru
2466 case Interpreter::java_lang_math_log : // fall thru
2467 case Interpreter::java_lang_math_log10 : // fall thru
2468 case Interpreter::java_lang_math_sqrt : // fall thru
2469 case Interpreter::java_lang_math_pow : // fall thru
2470 case Interpreter::java_lang_math_exp :
2471 return false;
2472 default:
2473 return true;
2474 }
2475 }
2476
2477
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.hpp"
27 #include "ci/ciMethod.hpp"
28 #include "interpreter/bytecodeHistogram.hpp"
29 #include "interpreter/cppInterpreter.hpp"
30 #include "interpreter/interpreter.hpp"
31 #include "interpreter/interpreterGenerator.hpp"
32 #include "interpreter/interpreterRuntime.hpp"
33 #include "oops/arrayOop.hpp"
34 #include "oops/methodData.hpp"
35 #include "oops/method.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "prims/jvmtiExport.hpp"
38 #include "prims/jvmtiThreadState.hpp"
39 #include "runtime/arguments.hpp"
40 #include "runtime/deoptimization.hpp"
41 #include "runtime/frame.inline.hpp"
42 #include "runtime/interfaceSupport.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "runtime/stubRoutines.hpp"
45 #include "runtime/synchronizer.hpp"
46 #include "runtime/timer.hpp"
47 #include "runtime/vframeArray.hpp"
2326 prev->_result._to_call._callee = method;
2327 if (*prev->_bcp == Bytecodes::_invokeinterface) {
2328 prev->_result._to_call._bcp_advance = 5;
2329 } else {
2330 prev->_result._to_call._bcp_advance = 3;
2331 }
2332 }
2333 to_fill->_oop_temp = NULL;
2334 to_fill->_stack_base = stack_base;
2335 // Need +1 here because stack_base points to the word just above the first expr stack entry
2336 // and stack_limit is supposed to point to the word just below the last expr stack entry.
2337 // See generate_compute_interpreter_state.
2338 to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
2339 to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2340
2341 to_fill->_self_link = to_fill;
2342 assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
2343 "Stack top out of range");
2344 }
2345
2346
2347 template<class M> static int frame_size_helper(M* method,
2348 int tempcount,
2349 int moncount,
2350 int callee_param_count,
2351 int callee_locals,
2352 bool is_top_frame,
2353 int& monitor_size,
2354 int& full_frame_size) {
2355 int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
2356 monitor_size = sizeof(BasicObjectLock) * moncount;
2357
2358 // First calculate the frame size without any java expression stack
2359 int short_frame_size = size_activation_helper(extra_locals_size,
2360 monitor_size);
2361
2362 // Now with full size expression stack
2363 full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;
2364
2365 // and now with only live portion of the expression stack
2366 short_frame_size = short_frame_size + tempcount * BytesPerWord;
2367
2368 // the size the activation is right now. Only top frame is full size
2369 int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
2370 return frame_size;
2371 }
2372
2373 template<class M> int AbstractInterpreter::size_activation(M* method,
2374 int tempcount,
2375 int popframe_extra_args,
2376 int moncount,
2377 int callee_param_count,
2378 int callee_locals,
2379 bool is_top_frame) {
2380 assert(popframe_extra_args == 0, "FIX ME");
2381 // NOTE: return size is in words not bytes
2382
2383 // Calculate the amount our frame will be adjust by the callee. For top frame
2384 // this is zero.
2385
2386 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
2387 // calculates the extra locals based on itself. Not what the callee does
2388 // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2389 // as getting sender_sp correct.
2390
2391 int unused_monitor_size = 0;
2392 int unused_full_frame_size = 0;
2393 return frame_size_helper(method, tempcount, moncount, callee_param_count, callee_locals,
2394 is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
2395 }
2396
2397 template int AbstractInterpreter::size_activation<Method>(Method* method,
2398 int temps,
2399 int popframe_args,
2400 int monitors,
2401 int callee_params,
2402 int callee_locals,
2403 bool is_top_frame);
2404
2405 template int AbstractInterpreter::size_activation<ciMethod>(ciMethod* method,
2406 int temps,
2407 int popframe_args,
2408 int monitors,
2409 int callee_params,
2410 int callee_locals,
2411 bool is_top_frame);
2412
2413 void AbstractInterpreter::layout_activation(Method* method,
2414 int tempcount, //
2415 int popframe_extra_args,
2416 int moncount,
2417 int caller_actual_parameters,
2418 int callee_param_count,
2419 int callee_locals,
2420 frame* caller,
2421 frame* interpreter_frame,
2422 bool is_top_frame,
2423 bool is_bottom_frame) {
2424
2425 assert(popframe_extra_args == 0, "FIX ME");
2426 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
2427 // does as far as allocating an interpreter frame.
2428 // Set up the method, locals, and monitors.
2429 // The frame interpreter_frame is guaranteed to be the right size,
2430 // as determined by a previous call to the size_activation() method.
2431 // It is also guaranteed to be walkable even though it is in a skeletal state
2432 // NOTE: tempcount is the current size of the java expression stack. For top most
2433 // frames we will allocate a full sized expression stack and not the curback
2434 // version that non-top frames have.
2435
2436 int monitor_size = 0;
2437 int full_frame_size = 0;
2438 int frame_size = frame_size_helper<Method>(method, tempcount, moncount, callee_param_count, callee_locals,
2439 is_top_frame, monitor_size, full_frame_size);
2440
2441 #ifdef ASSERT
2442 assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
2443 #endif
2444
2445 // MUCHO HACK
2446
2447 intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
2448
2449 /* Now fillin the interpreterState object */
2450
2451 // The state object is the first thing on the frame and easily located
2452
2453 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2454
2455
2456 // Find the locals pointer. This is rather simple on x86 because there is no
2457 // confusing rounding at the callee to account for. We can trivially locate
2458 // our locals based on the current fp().
2459 // Note: the + 2 is for handling the "static long no_params() method" issue.
2460 // (too bad I don't really remember that issue well...)
2483 }
2484
2485 intptr_t* monitor_base = (intptr_t*) cur_state;
2486 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
2487 /* +1 because stack is always prepushed */
2488 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
2489
2490
2491 BytecodeInterpreter::layout_interpreterState(cur_state,
2492 caller,
2493 interpreter_frame,
2494 method,
2495 locals,
2496 stack,
2497 stack_base,
2498 monitor_base,
2499 frame_bottom,
2500 is_top_frame);
2501
2502 // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
2503 }
2504
2505 bool AbstractInterpreter::can_be_compiled(methodHandle m) {
2506 switch (method_kind(m)) {
2507 case Interpreter::java_lang_math_sin : // fall thru
2508 case Interpreter::java_lang_math_cos : // fall thru
2509 case Interpreter::java_lang_math_tan : // fall thru
2510 case Interpreter::java_lang_math_abs : // fall thru
2511 case Interpreter::java_lang_math_log : // fall thru
2512 case Interpreter::java_lang_math_log10 : // fall thru
2513 case Interpreter::java_lang_math_sqrt : // fall thru
2514 case Interpreter::java_lang_math_pow : // fall thru
2515 case Interpreter::java_lang_math_exp :
2516 return false;
2517 default:
2518 return true;
2519 }
2520 }
2521
2522
|