comparison src/cpu/sparc/vm/cppInterpreter_sparc.cpp @ 14676:d3f14809b051

8036146: make CPP interpreter build again Summary: fix build of CPP interpreter on x86 and sparc Reviewed-by: kvn
author roland
date Wed, 05 Mar 2014 15:14:25 +0100
parents bd3237e0e18d
children 92aa6797d639
comparison
equal deleted inserted replaced
14675:bb4db06fd36f 14676:d3f14809b051
411 __ get_method_counters(G5_method, Rcounters, done); 411 __ get_method_counters(G5_method, Rcounters, done);
412 412
413 // Update standard invocation counters 413 // Update standard invocation counters
414 __ increment_invocation_counter(Rcounters, O0, G4_scratch); 414 __ increment_invocation_counter(Rcounters, O0, G4_scratch);
415 if (ProfileInterpreter) { 415 if (ProfileInterpreter) {
416 Address interpreter_invocation_counter(Rcounters, 0, 416 Address interpreter_invocation_counter(Rcounters,
417 in_bytes(MethodCounters::interpreter_invocation_counter_offset())); 417 in_bytes(MethodCounters::interpreter_invocation_counter_offset()));
418 __ ld(interpreter_invocation_counter, G4_scratch); 418 __ ld(interpreter_invocation_counter, G4_scratch);
419 __ inc(G4_scratch); 419 __ inc(G4_scratch);
420 __ st(G4_scratch, interpreter_invocation_counter); 420 __ st(G4_scratch, interpreter_invocation_counter);
421 } 421 }
422 422
423 Address invocation_limit(G3_scratch, (address)&InvocationCounter::InterpreterInvocationLimit); 423 AddressLiteral invocation_limit((address)&InvocationCounter::InterpreterInvocationLimit);
424 __ sethi(invocation_limit); 424 __ load_contents(invocation_limit, G3_scratch);
425 __ ld(invocation_limit, G3_scratch);
426 __ cmp(O0, G3_scratch); 425 __ cmp(O0, G3_scratch);
427 __ br(Assembler::greaterEqualUnsigned, false, Assembler::pn, *overflow); 426 __ br(Assembler::greaterEqualUnsigned, false, Assembler::pn, *overflow);
428 __ delayed()->nop(); 427 __ delayed()->nop();
429 __ bind(done); 428 __ bind(done);
430 } 429 }
437 Label slow_path; 436 Label slow_path;
438 437
439 // do nothing for empty methods (do not even increment invocation counter) 438 // do nothing for empty methods (do not even increment invocation counter)
440 if ( UseFastEmptyMethods) { 439 if ( UseFastEmptyMethods) {
441 // If we need a safepoint check, generate full interpreter entry. 440 // If we need a safepoint check, generate full interpreter entry.
442 Address sync_state(G3_scratch, SafepointSynchronize::address_of_state()); 441 AddressLiteral sync_state(SafepointSynchronize::address_of_state());
443 __ load_contents(sync_state, G3_scratch); 442 __ load_contents(sync_state, G3_scratch);
444 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); 443 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized);
445 __ br(Assembler::notEqual, false, Assembler::pn, frame_manager_entry); 444 __ br(Assembler::notEqual, false, Assembler::pn, frame_manager_entry);
446 __ delayed()->nop(); 445 __ delayed()->nop();
447 446
469 Label slow_path; 468 Label slow_path;
470 469
471 if ( UseFastAccessorMethods) { 470 if ( UseFastAccessorMethods) {
472 // Check if we need to reach a safepoint and generate full interpreter 471 // Check if we need to reach a safepoint and generate full interpreter
473 // frame if so. 472 // frame if so.
474 Address sync_state(G3_scratch, SafepointSynchronize::address_of_state()); 473 AddressLiteral sync_state(SafepointSynchronize::address_of_state());
475 __ load_contents(sync_state, G3_scratch); 474 __ load_contents(sync_state, G3_scratch);
476 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); 475 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized);
477 __ br(Assembler::notEqual, false, Assembler::pn, slow_path); 476 __ br(Assembler::notEqual, false, Assembler::pn, slow_path);
478 __ delayed()->nop(); 477 __ delayed()->nop();
479 478
484 __ delayed()->nop(); 483 __ delayed()->nop();
485 484
486 485
487 // read first instruction word and extract bytecode @ 1 and index @ 2 486 // read first instruction word and extract bytecode @ 1 and index @ 2
488 // get first 4 bytes of the bytecodes (big endian!) 487 // get first 4 bytes of the bytecodes (big endian!)
489 __ ld_ptr(Address(G5_method, 0, in_bytes(Method::const_offset())), G1_scratch); 488 __ ld_ptr(Address(G5_method, in_bytes(Method::const_offset())), G1_scratch);
490 __ ld(Address(G1_scratch, 0, in_bytes(ConstMethod::codes_offset())), G1_scratch); 489 __ ld(Address(G1_scratch, in_bytes(ConstMethod::codes_offset())), G1_scratch);
491 490
492 // move index @ 2 far left then to the right most two bytes. 491 // move index @ 2 far left then to the right most two bytes.
493 __ sll(G1_scratch, 2*BitsPerByte, G1_scratch); 492 __ sll(G1_scratch, 2*BitsPerByte, G1_scratch);
494 __ srl(G1_scratch, 2*BitsPerByte - exact_log2(in_words( 493 __ srl(G1_scratch, 2*BitsPerByte - exact_log2(in_words(
495 ConstantPoolCacheEntry::size()) * BytesPerWord), G1_scratch); 494 ConstantPoolCacheEntry::size()) * BytesPerWord), G1_scratch);
588 587
589 // the following temporary registers are used during frame creation 588 // the following temporary registers are used during frame creation
590 const Register Gtmp1 = G3_scratch ; 589 const Register Gtmp1 = G3_scratch ;
591 const Register Gtmp2 = G1_scratch; 590 const Register Gtmp2 = G1_scratch;
592 const Register RconstMethod = Gtmp1; 591 const Register RconstMethod = Gtmp1;
593 const Address constMethod(G5_method, 0, in_bytes(Method::const_offset())); 592 const Address constMethod(G5_method, in_bytes(Method::const_offset()));
594 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); 593 const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
595 594
596 bool inc_counter = UseCompiler || CountCompiledCalls; 595 bool inc_counter = UseCompiler || CountCompiledCalls;
597 596
598 // make sure registers are different! 597 // make sure registers are different!
599 assert_different_registers(G2_thread, G5_method, Gargs, Gtmp1, Gtmp2); 598 assert_different_registers(G2_thread, G5_method, Gargs, Gtmp1, Gtmp2);
600 599
601 const Address access_flags (G5_method, 0, in_bytes(Method::access_flags_offset())); 600 const Address access_flags (G5_method, in_bytes(Method::access_flags_offset()));
602 601
603 Label Lentry; 602 Label Lentry;
604 __ bind(Lentry); 603 __ bind(Lentry);
605 604
606 const Register Glocals_size = G3; 605 const Register Glocals_size = G3;
641 generate_compute_interpreter_state(Lstate, G0, true); 640 generate_compute_interpreter_state(Lstate, G0, true);
642 641
643 // At this point Lstate points to new interpreter state 642 // At this point Lstate points to new interpreter state
644 // 643 //
645 644
646 const Address do_not_unlock_if_synchronized(G2_thread, 0, 645 const Address do_not_unlock_if_synchronized(G2_thread,
647 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); 646 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
648 // Since at this point in the method invocation the exception handler 647 // Since at this point in the method invocation the exception handler
649 // would try to exit the monitor of synchronized methods which hasn't 648 // would try to exit the monitor of synchronized methods which hasn't
650 // been entered yet, we set the thread local variable 649 // been entered yet, we set the thread local variable
651 // _do_not_unlock_if_synchronized to true. If any exception was thrown by 650 // _do_not_unlock_if_synchronized to true. If any exception was thrown by
715 714
716 Label pending_exception_present; 715 Label pending_exception_present;
717 716
718 { Label L; 717 { Label L;
719 __ ld_ptr(STATE(_method), G5_method); 718 __ ld_ptr(STATE(_method), G5_method);
720 __ ld_ptr(Address(G5_method, 0, in_bytes(Method::signature_handler_offset())), G3_scratch); 719 __ ld_ptr(Address(G5_method, in_bytes(Method::signature_handler_offset())), G3_scratch);
721 __ tst(G3_scratch); 720 __ tst(G3_scratch);
722 __ brx(Assembler::notZero, false, Assembler::pt, L); 721 __ brx(Assembler::notZero, false, Assembler::pt, L);
723 __ delayed()->nop(); 722 __ delayed()->nop();
724 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), G5_method, false); 723 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), G5_method, false);
725 __ ld_ptr(STATE(_method), G5_method); 724 __ ld_ptr(STATE(_method), G5_method);
726 725
727 Address exception_addr(G2_thread, 0, in_bytes(Thread::pending_exception_offset())); 726 Address exception_addr(G2_thread, in_bytes(Thread::pending_exception_offset()));
728 __ ld_ptr(exception_addr, G3_scratch); 727 __ ld_ptr(exception_addr, G3_scratch);
729 __ br_notnull_short(G3_scratch, Assembler::pn, pending_exception_present); 728 __ br_notnull_short(G3_scratch, Assembler::pn, pending_exception_present);
730 __ ld_ptr(Address(G5_method, 0, in_bytes(Method::signature_handler_offset())), G3_scratch); 729 __ ld_ptr(Address(G5_method, in_bytes(Method::signature_handler_offset())), G3_scratch);
731 __ bind(L); 730 __ bind(L);
732 } 731 }
733 732
734 // Push a new frame so that the args will really be stored in 733 // Push a new frame so that the args will really be stored in
735 // Copy a few locals across so the new frame has the variables 734 // Copy a few locals across so the new frame has the variables
769 __ ld(access_flags, O0); 768 __ ld(access_flags, O0);
770 __ btst(JVM_ACC_STATIC, O0); 769 __ btst(JVM_ACC_STATIC, O0);
771 __ br( Assembler::zero, false, Assembler::pt, not_static); 770 __ br( Assembler::zero, false, Assembler::pt, not_static);
772 __ delayed()-> 771 __ delayed()->
773 // get native function entry point(O0 is a good temp until the very end) 772 // get native function entry point(O0 is a good temp until the very end)
774 ld_ptr(Address(G5_method, 0, in_bytes(Method::native_function_offset())), O0); 773 ld_ptr(Address(G5_method, in_bytes(Method::native_function_offset())), O0);
775 // for static methods insert the mirror argument 774 // for static methods insert the mirror argument
776 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); 775 const int mirror_offset = in_bytes(Klass::java_mirror_offset());
777 776
778 __ ld_ptr(Address(G5_method, 0, in_bytes(Method:: const_offset())), O1); 777 __ ld_ptr(Address(G5_method, in_bytes(Method:: const_offset())), O1);
779 __ ld_ptr(Address(O1, 0, in_bytes(ConstMethod::constants_offset())), O1); 778 __ ld_ptr(Address(O1, in_bytes(ConstMethod::constants_offset())), O1);
780 __ ld_ptr(Address(O1, 0, ConstantPool::pool_holder_offset_in_bytes()), O1); 779 __ ld_ptr(Address(O1, ConstantPool::pool_holder_offset_in_bytes()), O1);
781 __ ld_ptr(O1, mirror_offset, O1); 780 __ ld_ptr(O1, mirror_offset, O1);
782 // where the mirror handle body is allocated: 781 // where the mirror handle body is allocated:
783 #ifdef ASSERT 782 #ifdef ASSERT
784 if (!PrintSignatureHandlers) // do not dirty the output with this 783 if (!PrintSignatureHandlers) // do not dirty the output with this
785 { Label L; 784 { Label L;
829 // not meaningless information that'll confuse me. 828 // not meaningless information that'll confuse me.
830 829
831 // flush the windows now. We don't care about the current (protection) frame 830 // flush the windows now. We don't care about the current (protection) frame
832 // only the outer frames 831 // only the outer frames
833 832
834 __ flush_windows(); 833 __ flushw();
835 834
836 // mark windows as flushed 835 // mark windows as flushed
837 Address flags(G2_thread, 836 Address flags(G2_thread,
838 0,
839 in_bytes(JavaThread::frame_anchor_offset()) + in_bytes(JavaFrameAnchor::flags_offset())); 837 in_bytes(JavaThread::frame_anchor_offset()) + in_bytes(JavaFrameAnchor::flags_offset()));
840 __ set(JavaFrameAnchor::flushed, G3_scratch); 838 __ set(JavaFrameAnchor::flushed, G3_scratch);
841 __ st(G3_scratch, flags); 839 __ st(G3_scratch, flags);
842 840
843 // Transition from _thread_in_Java to _thread_in_native. We are already safepoint ready. 841 // Transition from _thread_in_Java to _thread_in_native. We are already safepoint ready.
844 842
845 Address thread_state(G2_thread, 0, in_bytes(JavaThread::thread_state_offset())); 843 Address thread_state(G2_thread, in_bytes(JavaThread::thread_state_offset()));
846 #ifdef ASSERT 844 #ifdef ASSERT
847 { Label L; 845 { Label L;
848 __ ld(thread_state, G3_scratch); 846 __ ld(thread_state, G3_scratch);
849 __ cmp(G3_scratch, _thread_in_Java); 847 __ cmp(G3_scratch, _thread_in_Java);
850 __ br(Assembler::equal, false, Assembler::pt, L); 848 __ br(Assembler::equal, false, Assembler::pt, L);
865 // must we block? 863 // must we block?
866 864
867 // Block, if necessary, before resuming in _thread_in_Java state. 865 // Block, if necessary, before resuming in _thread_in_Java state.
868 // In order for GC to work, don't clear the last_Java_sp until after blocking. 866 // In order for GC to work, don't clear the last_Java_sp until after blocking.
869 { Label no_block; 867 { Label no_block;
870 Address sync_state(G3_scratch, SafepointSynchronize::address_of_state()); 868 AddressLiteral sync_state(SafepointSynchronize::address_of_state());
871 869
872 // Switch thread to "native transition" state before reading the synchronization state. 870 // Switch thread to "native transition" state before reading the synchronization state.
873 // This additional state is necessary because reading and testing the synchronization 871 // This additional state is necessary because reading and testing the synchronization
874 // state is not atomic w.r.t. GC, as this scenario demonstrates: 872 // state is not atomic w.r.t. GC, as this scenario demonstrates:
875 // Java thread A, in _thread_in_native state, loads _not_synchronized and is preempted. 873 // Java thread A, in _thread_in_native state, loads _not_synchronized and is preempted.
888 __ load_contents(sync_state, G3_scratch); 886 __ load_contents(sync_state, G3_scratch);
889 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); 887 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized);
890 888
891 889
892 Label L; 890 Label L;
893 Address suspend_state(G2_thread, 0, in_bytes(JavaThread::suspend_flags_offset())); 891 Address suspend_state(G2_thread, in_bytes(JavaThread::suspend_flags_offset()));
894 __ br(Assembler::notEqual, false, Assembler::pn, L); 892 __ br(Assembler::notEqual, false, Assembler::pn, L);
895 __ delayed()-> 893 __ delayed()->
896 ld(suspend_state, G3_scratch); 894 ld(suspend_state, G3_scratch);
897 __ cmp(G3_scratch, 0); 895 __ cmp(G3_scratch, 0);
898 __ br(Assembler::equal, false, Assembler::pt, no_block); 896 __ br(Assembler::equal, false, Assembler::pt, no_block);
963 __ st_ptr(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes()); 961 __ st_ptr(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
964 962
965 963
966 // handle exceptions (exception handling will handle unlocking!) 964 // handle exceptions (exception handling will handle unlocking!)
967 { Label L; 965 { Label L;
968 Address exception_addr (G2_thread, 0, in_bytes(Thread::pending_exception_offset())); 966 Address exception_addr (G2_thread, in_bytes(Thread::pending_exception_offset()));
969 967
970 __ ld_ptr(exception_addr, Gtemp); 968 __ ld_ptr(exception_addr, Gtemp);
971 __ tst(Gtemp); 969 __ tst(Gtemp);
972 __ brx(Assembler::equal, false, Assembler::pt, L); 970 __ brx(Assembler::equal, false, Assembler::pt, L);
973 __ delayed()->nop(); 971 __ delayed()->nop();
1053 // a new interpretState object and the method expression stack. 1051 // a new interpretState object and the method expression stack.
1054 1052
1055 assert_different_registers(state, prev_state); 1053 assert_different_registers(state, prev_state);
1056 assert_different_registers(prev_state, G3_scratch); 1054 assert_different_registers(prev_state, G3_scratch);
1057 const Register Gtmp = G3_scratch; 1055 const Register Gtmp = G3_scratch;
1058 const Address constMethod (G5_method, 0, in_bytes(Method::const_offset())); 1056 const Address constMethod (G5_method, in_bytes(Method::const_offset()));
1059 const Address access_flags (G5_method, 0, in_bytes(Method::access_flags_offset())); 1057 const Address access_flags (G5_method, in_bytes(Method::access_flags_offset()));
1060 1058
1061 // slop factor is two extra slots on the expression stack so that 1059 // slop factor is two extra slots on the expression stack so that
1062 // we always have room to store a result when returning from a call without parameters 1060 // we always have room to store a result when returning from a call without parameters
1063 // that returns a result. 1061 // that returns a result.
1064 1062
1073 1071
1074 // Now compute new frame size 1072 // Now compute new frame size
1075 1073
1076 if (native) { 1074 if (native) {
1077 const Register RconstMethod = Gtmp; 1075 const Register RconstMethod = Gtmp;
1078 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); 1076 const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
1079 __ ld_ptr(constMethod, RconstMethod); 1077 __ ld_ptr(constMethod, RconstMethod);
1080 __ lduh( size_of_parameters, Gtmp ); 1078 __ lduh( size_of_parameters, Gtmp );
1081 __ calc_mem_param_words(Gtmp, Gtmp); // space for native call parameters passed on the stack in words 1079 __ calc_mem_param_words(Gtmp, Gtmp); // space for native call parameters passed on the stack in words
1082 } else { 1080 } else {
1083 // Full size expression stack 1081 // Full size expression stack
1244 #endif // ASSERT 1242 #endif // ASSERT
1245 } 1243 }
1246 if (init_value != noreg) { 1244 if (init_value != noreg) {
1247 Label clear_loop; 1245 Label clear_loop;
1248 const Register RconstMethod = O1; 1246 const Register RconstMethod = O1;
1249 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); 1247 const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
1250 const Address size_of_locals (RconstMethod, 0, in_bytes(ConstMethod::size_of_locals_offset())); 1248 const Address size_of_locals (RconstMethod, in_bytes(ConstMethod::size_of_locals_offset()));
1251 1249
1252 // NOTE: If you change the frame layout, this code will need to 1250 // NOTE: If you change the frame layout, this code will need to
1253 // be updated! 1251 // be updated!
1254 __ ld_ptr( constMethod, RconstMethod ); 1252 __ ld_ptr( constMethod, RconstMethod );
1255 __ lduh( size_of_locals, O2 ); 1253 __ lduh( size_of_locals, O2 );
1494 // Destroys args, G3_scratch, G3_scratch 1492 // Destroys args, G3_scratch, G3_scratch
1495 // In/Out O5_savedSP (sender's original SP) 1493 // In/Out O5_savedSP (sender's original SP)
1496 // 1494 //
1497 // assert_different_registers(state, prev_state); 1495 // assert_different_registers(state, prev_state);
1498 const Register Gtmp = G3_scratch; 1496 const Register Gtmp = G3_scratch;
1499 const RconstMethod = G3_scratch; 1497 const Register RconstMethod = G3_scratch;
1500 const Register tmp = O2; 1498 const Register tmp = O2;
1501 const Address constMethod(G5_method, 0, in_bytes(Method::const_offset())); 1499 const Address constMethod(G5_method, in_bytes(Method::const_offset()));
1502 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); 1500 const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
1503 const Address size_of_locals (RconstMethod, 0, in_bytes(ConstMethod::size_of_locals_offset())); 1501 const Address size_of_locals (RconstMethod, in_bytes(ConstMethod::size_of_locals_offset()));
1504 1502
1505 __ ld_ptr(constMethod, RconstMethod); 1503 __ ld_ptr(constMethod, RconstMethod);
1506 __ lduh(size_of_parameters, tmp); 1504 __ lduh(size_of_parameters, tmp);
1507 __ sll(tmp, LogBytesPerWord, Gargs); // parameter size in bytes 1505 __ sll(tmp, LogBytesPerWord, Gargs); // parameter size in bytes
1508 __ add(args, Gargs, Gargs); // points to first local + BytesPerWord 1506 __ add(args, Gargs, Gargs); // points to first local + BytesPerWord
1553 1551
1554 // the following temporary registers are used during frame creation 1552 // the following temporary registers are used during frame creation
1555 const Register Gtmp1 = G3_scratch; 1553 const Register Gtmp1 = G3_scratch;
1556 // const Register Lmirror = L1; // native mirror (native calls only) 1554 // const Register Lmirror = L1; // native mirror (native calls only)
1557 1555
1558 const Address constMethod (G5_method, 0, in_bytes(Method::const_offset())); 1556 const Address constMethod (G5_method, in_bytes(Method::const_offset()));
1559 const Address access_flags (G5_method, 0, in_bytes(Method::access_flags_offset())); 1557 const Address access_flags (G5_method, in_bytes(Method::access_flags_offset()));
1560 1558
1561 address entry_point = __ pc(); 1559 address entry_point = __ pc();
1562 __ mov(G0, prevState); // no current activation 1560 __ mov(G0, prevState); // no current activation
1563 1561
1564 1562
1707 // O0: exception 1705 // O0: exception
1708 // O7: throwing pc 1706 // O7: throwing pc
1709 1707
1710 // We want exception in the thread no matter what we ultimately decide about frame type. 1708 // We want exception in the thread no matter what we ultimately decide about frame type.
1711 1709
1712 Address exception_addr (G2_thread, 0, in_bytes(Thread::pending_exception_offset())); 1710 Address exception_addr (G2_thread, in_bytes(Thread::pending_exception_offset()));
1713 __ verify_thread(); 1711 __ verify_thread();
1714 __ st_ptr(O0, exception_addr); 1712 __ st_ptr(O0, exception_addr);
1715 1713
1716 // get the Method* 1714 // get the Method*
1717 __ ld_ptr(STATE(_method), G5_method); 1715 __ ld_ptr(STATE(_method), G5_method);