src/share/vm/interpreter/bytecodeInterpreter.cpp

Print this page
rev 4869 : 8019517: PPC64 (part 102): cppInterpreter: implement G1 support


  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 // no precompiled headers
  26 #include "classfile/vmSymbols.hpp"
  27 #include "gc_interface/collectedHeap.hpp"
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/bytecodeInterpreter.hpp"
  30 #include "interpreter/bytecodeInterpreter.inline.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"
  33 #include "memory/cardTableModRefBS.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "oops/methodCounters.hpp"
  36 #include "oops/objArrayKlass.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jvmtiExport.hpp"
  39 #include "runtime/biasedLocking.hpp"
  40 #include "runtime/frame.inline.hpp"
  41 #include "runtime/handles.inline.hpp"
  42 #include "runtime/interfaceSupport.hpp"
  43 #include "runtime/sharedRuntime.hpp"
  44 #include "runtime/threadCritical.hpp"
  45 #include "utilities/exceptions.hpp"
  46 #ifdef TARGET_OS_ARCH_linux_x86
  47 # include "orderAccess_linux_x86.inline.hpp"
  48 #endif
  49 #ifdef TARGET_OS_ARCH_linux_sparc
  50 # include "orderAccess_linux_sparc.inline.hpp"
  51 #endif
  52 #ifdef TARGET_OS_ARCH_linux_zero
  53 # include "orderAccess_linux_zero.inline.hpp"


 486     } else {
 487       const int extra_stack_entries = Method::extra_stack_entries_for_indy;
 488       assert(labs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + extra_stack_entries
 489                                                                                                + 1), "bad stack limit");
 490     }
 491 #ifndef SHARK
 492     IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong"));
 493 #endif // !SHARK
 494   }
 495   // Verify linkages.
 496   interpreterState l = istate;
 497   do {
 498     assert(l == l->_self_link, "bad link");
 499     l = l->_prev_link;
 500   } while (l != NULL);
 501   // Screwups with stack management usually cause us to overwrite istate
 502   // save a copy so we can verify it.
 503   interpreterState orig = istate;
 504 #endif
 505 
 506   static volatile jbyte* _byte_map_base; // adjusted card table base for oop store barrier
 507 
 508   register intptr_t*        topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */
 509   register address          pc = istate->bcp();
 510   register jubyte opcode;
 511   register intptr_t*        locals = istate->locals();
 512   register ConstantPoolCache*    cp = istate->constants(); // method()->constants()->cache()
 513 #ifdef LOTS_OF_REGS
 514   register JavaThread*      THREAD = istate->thread();
 515   register volatile jbyte*  BYTE_MAP_BASE = _byte_map_base;
 516 #else
 517 #undef THREAD
 518 #define THREAD istate->thread()
 519 #undef BYTE_MAP_BASE
 520 #define BYTE_MAP_BASE _byte_map_base
 521 #endif
 522 
 523 #ifdef USELABELS
 524   const static void* const opclabels_data[256] = {
 525 /* 0x00 */ &&opc_nop,     &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0,
 526 /* 0x04 */ &&opc_iconst_1,&&opc_iconst_2,   &&opc_iconst_3, &&opc_iconst_4,
 527 /* 0x08 */ &&opc_iconst_5,&&opc_lconst_0,   &&opc_lconst_1, &&opc_fconst_0,
 528 /* 0x0C */ &&opc_fconst_1,&&opc_fconst_2,   &&opc_dconst_0, &&opc_dconst_1,
 529 
 530 /* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc,    &&opc_ldc_w,
 531 /* 0x14 */ &&opc_ldc2_w, &&opc_iload,  &&opc_lload,  &&opc_fload,
 532 /* 0x18 */ &&opc_dload,  &&opc_aload,  &&opc_iload_0,&&opc_iload_1,
 533 /* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1,
 534 
 535 /* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1,
 536 /* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1,
 537 /* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1,
 538 /* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload,
 539 
 540 /* 0x30 */ &&opc_faload,  &&opc_daload,  &&opc_aaload,  &&opc_baload,


 613   }
 614 #endif
 615 // #define HACK
 616 #ifdef HACK
 617   bool interesting = false;
 618 #endif // HACK
 619 
 620   /* QQQ this should be a stack method so we don't know actual direction */
 621   guarantee(istate->msg() == initialize ||
 622          topOfStack >= istate->stack_limit() &&
 623          topOfStack < istate->stack_base(),
 624          "Stack top out of range");
 625 
 626   switch (istate->msg()) {
 627     case initialize: {
 628       if (initialized++) ShouldNotReachHere(); // Only one initialize call
 629       _compiling = (UseCompiler || CountCompiledCalls);
 630 #ifdef VM_JVMTI
 631       _jvmti_interp_events = JvmtiExport::can_post_interpreter_events();
 632 #endif
 633       BarrierSet* bs = Universe::heap()->barrier_set();
 634       assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
 635       _byte_map_base = (volatile jbyte*)(((CardTableModRefBS*)bs)->byte_map_base);
 636       return;
 637     }
 638     break;
 639     case method_entry: {
 640       THREAD->set_do_not_unlock();
 641       // count invocations
 642       assert(initialized, "Interpreter not initialized");
 643       if (_compiling) {
 644         MethodCounters* mcs;
 645         GET_METHOD_COUNTERS(mcs);
 646         if (ProfileInterpreter) {
 647           METHOD->increment_interpreter_invocation_count(THREAD);
 648         }
 649         mcs->invocation_counter()->increment();
 650         if (mcs->invocation_counter()->reached_InvocationLimit()) {
 651             CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception);
 652 
 653             // We no longer retry on a counter overflow
 654 
 655             // istate->set_msg(retry_method);


1691       /*
1692        * This one looks different because of the assignability check
1693        */
1694       CASE(_aastore): {
1695           oop rhsObject = STACK_OBJECT(-1);
1696           VERIFY_OOP(rhsObject);
1697           ARRAY_INTRO( -3);
1698           // arrObj, index are set
1699           if (rhsObject != NULL) {
1700             /* Check assignability of rhsObject into arrObj */
1701             Klass* rhsKlassOop = rhsObject->klass(); // EBX (subclass)
1702             Klass* elemKlassOop = ObjArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX
1703             //
1704             // Check for compatibilty. This check must not GC!!
1705             // Seems way more expensive now that we must dispatch
1706             //
1707             if (rhsKlassOop != elemKlassOop && !rhsKlassOop->is_subtype_of(elemKlassOop)) { // ebx->is...
1708               VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), "");
1709             }
1710           }
1711           oop* elem_loc = (oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop));
1712           // *(oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)) = rhsObject;
1713           *elem_loc = rhsObject;
1714           // Mark the card
1715           OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)elem_loc >> CardTableModRefBS::card_shift], 0);
1716           UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
1717       }
1718       CASE(_bastore):
1719           ARRAY_STOREFROM32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
1720       CASE(_castore):
1721           ARRAY_STOREFROM32(T_CHAR, jchar,  "%d",   STACK_INT, 0);
1722       CASE(_sastore):
1723           ARRAY_STOREFROM32(T_SHORT, jshort, "%d",   STACK_INT, 0);
1724       CASE(_lastore):
1725           ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0);
1726       CASE(_dastore):
1727           ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
1728 
1729       CASE(_arraylength):
1730       {
1731           arrayOop ary = (arrayOop) STACK_OBJECT(-1);
1732           CHECK_NULL(ary);
1733           SET_STACK_INT(ary->length(), -1);
1734           UPDATE_PC_AND_CONTINUE(1);
1735       }


2035           }
2036           if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
2037             Klass* k = cache->f1_as_klass();
2038             obj = k->java_mirror();
2039           } else {
2040             --count;
2041             obj = (oop) STACK_OBJECT(count);
2042             CHECK_NULL(obj);
2043           }
2044 
2045           //
2046           // Now store the result
2047           //
2048           int field_offset = cache->f2_as_index();
2049           if (cache->is_volatile()) {
2050             if (tos_type == itos) {
2051               obj->release_int_field_put(field_offset, STACK_INT(-1));
2052             } else if (tos_type == atos) {
2053               VERIFY_OOP(STACK_OBJECT(-1));
2054               obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
2055               OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0);
2056             } else if (tos_type == btos) {
2057               obj->release_byte_field_put(field_offset, STACK_INT(-1));
2058             } else if (tos_type == ltos) {
2059               obj->release_long_field_put(field_offset, STACK_LONG(-1));
2060             } else if (tos_type == ctos) {
2061               obj->release_char_field_put(field_offset, STACK_INT(-1));
2062             } else if (tos_type == stos) {
2063               obj->release_short_field_put(field_offset, STACK_INT(-1));
2064             } else if (tos_type == ftos) {
2065               obj->release_float_field_put(field_offset, STACK_FLOAT(-1));
2066             } else {
2067               obj->release_double_field_put(field_offset, STACK_DOUBLE(-1));
2068             }
2069             OrderAccess::storeload();
2070           } else {
2071             if (tos_type == itos) {
2072               obj->int_field_put(field_offset, STACK_INT(-1));
2073             } else if (tos_type == atos) {
2074               VERIFY_OOP(STACK_OBJECT(-1));
2075               obj->obj_field_put(field_offset, STACK_OBJECT(-1));
2076               OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0);
2077             } else if (tos_type == btos) {
2078               obj->byte_field_put(field_offset, STACK_INT(-1));
2079             } else if (tos_type == ltos) {
2080               obj->long_field_put(field_offset, STACK_LONG(-1));
2081             } else if (tos_type == ctos) {
2082               obj->char_field_put(field_offset, STACK_INT(-1));
2083             } else if (tos_type == stos) {
2084               obj->short_field_put(field_offset, STACK_INT(-1));
2085             } else if (tos_type == ftos) {
2086               obj->float_field_put(field_offset, STACK_FLOAT(-1));
2087             } else {
2088               obj->double_field_put(field_offset, STACK_DOUBLE(-1));
2089             }
2090           }
2091 
2092           UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
2093         }
2094 
2095       CASE(_new): {
2096         u2 index = Bytes::get_Java_u2(pc+1);




  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 // no precompiled headers
  26 #include "classfile/vmSymbols.hpp"
  27 #include "gc_interface/collectedHeap.hpp"
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/bytecodeInterpreter.hpp"
  30 #include "interpreter/bytecodeInterpreter.inline.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"

  33 #include "memory/resourceArea.hpp"
  34 #include "oops/methodCounters.hpp"
  35 #include "oops/objArrayKlass.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/jvmtiExport.hpp"
  38 #include "runtime/biasedLocking.hpp"
  39 #include "runtime/frame.inline.hpp"
  40 #include "runtime/handles.inline.hpp"
  41 #include "runtime/interfaceSupport.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "runtime/threadCritical.hpp"
  44 #include "utilities/exceptions.hpp"
  45 #ifdef TARGET_OS_ARCH_linux_x86
  46 # include "orderAccess_linux_x86.inline.hpp"
  47 #endif
  48 #ifdef TARGET_OS_ARCH_linux_sparc
  49 # include "orderAccess_linux_sparc.inline.hpp"
  50 #endif
  51 #ifdef TARGET_OS_ARCH_linux_zero
  52 # include "orderAccess_linux_zero.inline.hpp"


 485     } else {
 486       const int extra_stack_entries = Method::extra_stack_entries_for_indy;
 487       assert(labs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + extra_stack_entries
 488                                                                                                + 1), "bad stack limit");
 489     }
 490 #ifndef SHARK
 491     IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong"));
 492 #endif // !SHARK
 493   }
 494   // Verify linkages.
 495   interpreterState l = istate;
 496   do {
 497     assert(l == l->_self_link, "bad link");
 498     l = l->_prev_link;
 499   } while (l != NULL);
 500   // Screwups with stack management usually cause us to overwrite istate
 501   // save a copy so we can verify it.
 502   interpreterState orig = istate;
 503 #endif
 504 


 505   register intptr_t*        topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */
 506   register address          pc = istate->bcp();
 507   register jubyte opcode;
 508   register intptr_t*        locals = istate->locals();
 509   register ConstantPoolCache*    cp = istate->constants(); // method()->constants()->cache()
 510 #ifdef LOTS_OF_REGS
 511   register JavaThread*      THREAD = istate->thread();

 512 #else
 513 #undef THREAD
 514 #define THREAD istate->thread()


 515 #endif
 516 
 517 #ifdef USELABELS
 518   const static void* const opclabels_data[256] = {
 519 /* 0x00 */ &&opc_nop,     &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0,
 520 /* 0x04 */ &&opc_iconst_1,&&opc_iconst_2,   &&opc_iconst_3, &&opc_iconst_4,
 521 /* 0x08 */ &&opc_iconst_5,&&opc_lconst_0,   &&opc_lconst_1, &&opc_fconst_0,
 522 /* 0x0C */ &&opc_fconst_1,&&opc_fconst_2,   &&opc_dconst_0, &&opc_dconst_1,
 523 
 524 /* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc,    &&opc_ldc_w,
 525 /* 0x14 */ &&opc_ldc2_w, &&opc_iload,  &&opc_lload,  &&opc_fload,
 526 /* 0x18 */ &&opc_dload,  &&opc_aload,  &&opc_iload_0,&&opc_iload_1,
 527 /* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1,
 528 
 529 /* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1,
 530 /* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1,
 531 /* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1,
 532 /* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload,
 533 
 534 /* 0x30 */ &&opc_faload,  &&opc_daload,  &&opc_aaload,  &&opc_baload,


 607   }
 608 #endif
 609 // #define HACK
 610 #ifdef HACK
 611   bool interesting = false;
 612 #endif // HACK
 613 
 614   /* QQQ this should be a stack method so we don't know actual direction */
 615   guarantee(istate->msg() == initialize ||
 616          topOfStack >= istate->stack_limit() &&
 617          topOfStack < istate->stack_base(),
 618          "Stack top out of range");
 619 
 620   switch (istate->msg()) {
 621     case initialize: {
 622       if (initialized++) ShouldNotReachHere(); // Only one initialize call
 623       _compiling = (UseCompiler || CountCompiledCalls);
 624 #ifdef VM_JVMTI
 625       _jvmti_interp_events = JvmtiExport::can_post_interpreter_events();
 626 #endif



 627       return;
 628     }
 629     break;
 630     case method_entry: {
 631       THREAD->set_do_not_unlock();
 632       // count invocations
 633       assert(initialized, "Interpreter not initialized");
 634       if (_compiling) {
 635         MethodCounters* mcs;
 636         GET_METHOD_COUNTERS(mcs);
 637         if (ProfileInterpreter) {
 638           METHOD->increment_interpreter_invocation_count(THREAD);
 639         }
 640         mcs->invocation_counter()->increment();
 641         if (mcs->invocation_counter()->reached_InvocationLimit()) {
 642             CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception);
 643 
 644             // We no longer retry on a counter overflow
 645 
 646             // istate->set_msg(retry_method);


1682       /*
1683        * This one looks different because of the assignability check
1684        */
1685       CASE(_aastore): {
1686           oop rhsObject = STACK_OBJECT(-1);
1687           VERIFY_OOP(rhsObject);
1688           ARRAY_INTRO( -3);
1689           // arrObj, index are set
1690           if (rhsObject != NULL) {
1691             /* Check assignability of rhsObject into arrObj */
1692             Klass* rhsKlassOop = rhsObject->klass(); // EBX (subclass)
1693             Klass* elemKlassOop = ObjArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX
1694             //
1695             // Check for compatibilty. This check must not GC!!
1696             // Seems way more expensive now that we must dispatch
1697             //
1698             if (rhsKlassOop != elemKlassOop && !rhsKlassOop->is_subtype_of(elemKlassOop)) { // ebx->is...
1699               VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), "");
1700             }
1701           }
1702           ((objArrayOopDesc *) arrObj)->obj_at_put(index, rhsObject);




1703           UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
1704       }
1705       CASE(_bastore):
1706           ARRAY_STOREFROM32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
1707       CASE(_castore):
1708           ARRAY_STOREFROM32(T_CHAR, jchar,  "%d",   STACK_INT, 0);
1709       CASE(_sastore):
1710           ARRAY_STOREFROM32(T_SHORT, jshort, "%d",   STACK_INT, 0);
1711       CASE(_lastore):
1712           ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0);
1713       CASE(_dastore):
1714           ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
1715 
1716       CASE(_arraylength):
1717       {
1718           arrayOop ary = (arrayOop) STACK_OBJECT(-1);
1719           CHECK_NULL(ary);
1720           SET_STACK_INT(ary->length(), -1);
1721           UPDATE_PC_AND_CONTINUE(1);
1722       }


2022           }
2023           if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
2024             Klass* k = cache->f1_as_klass();
2025             obj = k->java_mirror();
2026           } else {
2027             --count;
2028             obj = (oop) STACK_OBJECT(count);
2029             CHECK_NULL(obj);
2030           }
2031 
2032           //
2033           // Now store the result
2034           //
2035           int field_offset = cache->f2_as_index();
2036           if (cache->is_volatile()) {
2037             if (tos_type == itos) {
2038               obj->release_int_field_put(field_offset, STACK_INT(-1));
2039             } else if (tos_type == atos) {
2040               VERIFY_OOP(STACK_OBJECT(-1));
2041               obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));

2042             } else if (tos_type == btos) {
2043               obj->release_byte_field_put(field_offset, STACK_INT(-1));
2044             } else if (tos_type == ltos) {
2045               obj->release_long_field_put(field_offset, STACK_LONG(-1));
2046             } else if (tos_type == ctos) {
2047               obj->release_char_field_put(field_offset, STACK_INT(-1));
2048             } else if (tos_type == stos) {
2049               obj->release_short_field_put(field_offset, STACK_INT(-1));
2050             } else if (tos_type == ftos) {
2051               obj->release_float_field_put(field_offset, STACK_FLOAT(-1));
2052             } else {
2053               obj->release_double_field_put(field_offset, STACK_DOUBLE(-1));
2054             }
2055             OrderAccess::storeload();
2056           } else {
2057             if (tos_type == itos) {
2058               obj->int_field_put(field_offset, STACK_INT(-1));
2059             } else if (tos_type == atos) {
2060               VERIFY_OOP(STACK_OBJECT(-1));
2061               obj->obj_field_put(field_offset, STACK_OBJECT(-1));

2062             } else if (tos_type == btos) {
2063               obj->byte_field_put(field_offset, STACK_INT(-1));
2064             } else if (tos_type == ltos) {
2065               obj->long_field_put(field_offset, STACK_LONG(-1));
2066             } else if (tos_type == ctos) {
2067               obj->char_field_put(field_offset, STACK_INT(-1));
2068             } else if (tos_type == stos) {
2069               obj->short_field_put(field_offset, STACK_INT(-1));
2070             } else if (tos_type == ftos) {
2071               obj->float_field_put(field_offset, STACK_FLOAT(-1));
2072             } else {
2073               obj->double_field_put(field_offset, STACK_DOUBLE(-1));
2074             }
2075           }
2076 
2077           UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
2078         }
2079 
2080       CASE(_new): {
2081         u2 index = Bytes::get_Java_u2(pc+1);