comparison src/cpu/x86/vm/cppInterpreter_x86.cpp @ 10408:836a62f43af9

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Jun 2013 10:45:56 +0200
parents 603ca7e51354
children bd3237e0e18d
comparison
equal deleted inserted replaced
10086:e0fb8a213650 10408:836a62f43af9
1 /* 1 /*
2 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
537 __ subptr(rsp, wordSize); // pre-push stack 537 __ subptr(rsp, wordSize); // pre-push stack
538 __ movptr(STATE(_stack), rsp); // set current expression stack tos 538 __ movptr(STATE(_stack), rsp); // set current expression stack tos
539 539
540 // compute full expression stack limit 540 // compute full expression stack limit
541 541
542 const int extra_stack = 0; //6815692//Method::extra_stack_words();
543 __ movptr(rdx, Address(rbx, Method::const_offset())); 542 __ movptr(rdx, Address(rbx, Method::const_offset()));
544 __ load_unsigned_short(rdx, Address(rdx, ConstMethod::max_stack_offset())); // get size of expression stack in words 543 __ load_unsigned_short(rdx, Address(rdx, ConstMethod::max_stack_offset())); // get size of expression stack in words
545 __ negptr(rdx); // so we can subtract in next step 544 __ negptr(rdx); // so we can subtract in next step
546 // Allocate expression stack 545 // Allocate expression stack
547 __ lea(rsp, Address(rsp, rdx, Address::times_ptr, -extra_stack)); 546 __ lea(rsp, Address(rsp, rdx, Address::times_ptr, -Method::extra_stack_words()));
548 __ movptr(STATE(_stack_limit), rsp); 547 __ movptr(STATE(_stack_limit), rsp);
549 } 548 }
550 549
551 #ifdef _LP64 550 #ifdef _LP64
552 // Make sure stack is properly aligned and sized for the abi 551 // Make sure stack is properly aligned and sized for the abi
568 // 567 //
569 // rbx,: method 568 // rbx,: method
570 // rcx: invocation counter 569 // rcx: invocation counter
571 // 570 //
572 void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) { 571 void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
573 572 Label done;
574 const Address invocation_counter(rbx, Method::invocation_counter_offset() + InvocationCounter::counter_offset()); 573 const Address invocation_counter(rax,
575 const Address backedge_counter (rbx, Method::backedge_counter_offset() + InvocationCounter::counter_offset()); 574 MethodCounters::invocation_counter_offset() +
576 575 InvocationCounter::counter_offset());
577 if (ProfileInterpreter) { // %%% Merge this into MethodData* 576 const Address backedge_counter (rax,
578 __ incrementl(Address(rbx,Method::interpreter_invocation_counter_offset())); 577 MethodCounter::backedge_counter_offset() +
578 InvocationCounter::counter_offset());
579
580 __ get_method_counters(rbx, rax, done);
581
582 if (ProfileInterpreter) {
583 __ incrementl(Address(rax,
584 MethodCounters::interpreter_invocation_counter_offset()));
579 } 585 }
580 // Update standard invocation counters 586 // Update standard invocation counters
587 __ movl(rcx, invocation_counter);
588 __ increment(rcx, InvocationCounter::count_increment);
589 __ movl(invocation_counter, rcx); // save invocation count
590
581 __ movl(rax, backedge_counter); // load backedge counter 591 __ movl(rax, backedge_counter); // load backedge counter
582
583 __ increment(rcx, InvocationCounter::count_increment);
584 __ andl(rax, InvocationCounter::count_mask_value); // mask out the status bits 592 __ andl(rax, InvocationCounter::count_mask_value); // mask out the status bits
585 593
586 __ movl(invocation_counter, rcx); // save invocation count
587 __ addl(rcx, rax); // add both counters 594 __ addl(rcx, rax); // add both counters
588 595
589 // profile_method is non-null only for interpreted method so 596 // profile_method is non-null only for interpreted method so
590 // profile_method != NULL == !native_call 597 // profile_method != NULL == !native_call
591 // BytecodeInterpreter only calls for native so code is elided. 598 // BytecodeInterpreter only calls for native so code is elided.
592 599
593 __ cmp32(rcx, 600 __ cmp32(rcx,
594 ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit)); 601 ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit));
595 __ jcc(Assembler::aboveEqual, *overflow); 602 __ jcc(Assembler::aboveEqual, *overflow);
596 603 __ bind(done);
597 } 604 }
598 605
599 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { 606 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) {
600 607
601 // C++ interpreter on entry 608 // C++ interpreter on entry
682 689
683 // locals + overhead, in bytes 690 // locals + overhead, in bytes
684 // Always give one monitor to allow us to start interp if sync method. 691 // Always give one monitor to allow us to start interp if sync method.
685 // Any additional monitors need a check when moving the expression stack 692 // Any additional monitors need a check when moving the expression stack
686 const int one_monitor = frame::interpreter_frame_monitor_size() * wordSize; 693 const int one_monitor = frame::interpreter_frame_monitor_size() * wordSize;
687 const int extra_stack = 0; //6815692//Method::extra_stack_entries();
688 __ movptr(rax, Address(rbx, Method::const_offset())); 694 __ movptr(rax, Address(rbx, Method::const_offset()));
689 __ load_unsigned_short(rax, Address(rax, ConstMethod::max_stack_offset())); // get size of expression stack in words 695 __ load_unsigned_short(rax, Address(rax, ConstMethod::max_stack_offset())); // get size of expression stack in words
690 __ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), extra_stack + one_monitor)); 696 __ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), one_monitor+Method::extra_stack_words()));
691 __ lea(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size)); 697 __ lea(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size));
692 698
693 #ifdef ASSERT 699 #ifdef ASSERT
694 Label stack_base_okay, stack_size_okay; 700 Label stack_base_okay, stack_size_okay;
695 // verify that thread stack base is non-zero 701 // verify that thread stack base is non-zero
975 // in any case. If called via c1/c2/call_stub rsi/r13 is junk (to use) but harmless 981 // in any case. If called via c1/c2/call_stub rsi/r13 is junk (to use) but harmless
976 // to save/restore. 982 // to save/restore.
977 address entry_point = __ pc(); 983 address entry_point = __ pc();
978 984
979 const Address constMethod (rbx, Method::const_offset()); 985 const Address constMethod (rbx, Method::const_offset());
980 const Address invocation_counter(rbx, Method::invocation_counter_offset() + InvocationCounter::counter_offset());
981 const Address access_flags (rbx, Method::access_flags_offset()); 986 const Address access_flags (rbx, Method::access_flags_offset());
982 const Address size_of_parameters(rcx, ConstMethod::size_of_parameters_offset()); 987 const Address size_of_parameters(rcx, ConstMethod::size_of_parameters_offset());
983 988
984 // rsi/r13 == state/locals rdi == prevstate 989 // rsi/r13 == state/locals rdi == prevstate
985 const Register locals = rdi; 990 const Register locals = rdi;
1026 __ jcc(Assembler::equal, L); 1031 __ jcc(Assembler::equal, L);
1027 __ stop("broken stack frame setup in interpreter"); 1032 __ stop("broken stack frame setup in interpreter");
1028 __ bind(L); 1033 __ bind(L);
1029 } 1034 }
1030 #endif 1035 #endif
1031
1032 if (inc_counter) __ movl(rcx, invocation_counter); // (pre-)fetch invocation count
1033 1036
1034 const Register unlock_thread = LP64_ONLY(r15_thread) NOT_LP64(rax); 1037 const Register unlock_thread = LP64_ONLY(r15_thread) NOT_LP64(rax);
1035 NOT_LP64(__ movptr(unlock_thread, STATE(_thread));) // get thread 1038 NOT_LP64(__ movptr(unlock_thread, STATE(_thread));) // get thread
1036 // Since at this point in the method invocation the exception handler 1039 // Since at this point in the method invocation the exception handler
1037 // would try to exit the monitor of synchronized methods which hasn't 1040 // would try to exit the monitor of synchronized methods which hasn't
2258 // address, saved rbp and 2 words for a "static long no_params() method" issue. 2261 // address, saved rbp and 2 words for a "static long no_params() method" issue.
2259 2262
2260 const int overhead_size = sizeof(BytecodeInterpreter)/wordSize + 2263 const int overhead_size = sizeof(BytecodeInterpreter)/wordSize +
2261 ( frame::sender_sp_offset - frame::link_offset) + 2; 2264 ( frame::sender_sp_offset - frame::link_offset) + 2;
2262 2265
2263 const int extra_stack = 0; //6815692//Method::extra_stack_entries(); 2266 const int method_stack = (method->max_locals() + method->max_stack()) *
2264 const int method_stack = (method->max_locals() + method->max_stack() + extra_stack) *
2265 Interpreter::stackElementWords; 2267 Interpreter::stackElementWords;
2266 return overhead_size + method_stack + stub_code; 2268 return overhead_size + method_stack + stub_code;
2267 } 2269 }
2268 2270
2269 // returns the activation size. 2271 // returns the activation size.
2324 to_fill->_oop_temp = NULL; 2326 to_fill->_oop_temp = NULL;
2325 to_fill->_stack_base = stack_base; 2327 to_fill->_stack_base = stack_base;
2326 // Need +1 here because stack_base points to the word just above the first expr stack entry 2328 // Need +1 here because stack_base points to the word just above the first expr stack entry
2327 // and stack_limit is supposed to point to the word just below the last expr stack entry. 2329 // and stack_limit is supposed to point to the word just below the last expr stack entry.
2328 // See generate_compute_interpreter_state. 2330 // See generate_compute_interpreter_state.
2329 int extra_stack = 0; //6815692//Method::extra_stack_entries(); 2331 to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
2330 to_fill->_stack_limit = stack_base - (method->max_stack() + extra_stack + 1);
2331 to_fill->_monitor_base = (BasicObjectLock*) monitor_base; 2332 to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2332 2333
2333 to_fill->_self_link = to_fill; 2334 to_fill->_self_link = to_fill;
2334 assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base, 2335 assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
2335 "Stack top out of range"); 2336 "Stack top out of range");
2373 // First calculate the frame size without any java expression stack 2374 // First calculate the frame size without any java expression stack
2374 int short_frame_size = size_activation_helper(extra_locals_size, 2375 int short_frame_size = size_activation_helper(extra_locals_size,
2375 monitor_size); 2376 monitor_size);
2376 2377
2377 // Now with full size expression stack 2378 // Now with full size expression stack
2378 int extra_stack = 0; //6815692//Method::extra_stack_entries(); 2379 int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;
2379 int full_frame_size = short_frame_size + (method->max_stack() + extra_stack) * BytesPerWord;
2380 2380
2381 // and now with only live portion of the expression stack 2381 // and now with only live portion of the expression stack
2382 short_frame_size = short_frame_size + tempcount * BytesPerWord; 2382 short_frame_size = short_frame_size + tempcount * BytesPerWord;
2383 2383
2384 // the size the activation is right now. Only top frame is full size 2384 // the size the activation is right now. Only top frame is full size