Mercurial > hg > truffle
comparison src/share/vm/interpreter/bytecodeInterpreter.cpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 1d7922586cf6 |
children | d8ce2825b193 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2002, 2012, 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. |
488 | 488 |
489 register intptr_t* topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */ | 489 register intptr_t* topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */ |
490 register address pc = istate->bcp(); | 490 register address pc = istate->bcp(); |
491 register jubyte opcode; | 491 register jubyte opcode; |
492 register intptr_t* locals = istate->locals(); | 492 register intptr_t* locals = istate->locals(); |
493 register constantPoolCacheOop cp = istate->constants(); // method()->constants()->cache() | 493 register ConstantPoolCache* cp = istate->constants(); // method()->constants()->cache() |
494 #ifdef LOTS_OF_REGS | 494 #ifdef LOTS_OF_REGS |
495 register JavaThread* THREAD = istate->thread(); | 495 register JavaThread* THREAD = istate->thread(); |
496 register volatile jbyte* BYTE_MAP_BASE = _byte_map_base; | 496 register volatile jbyte* BYTE_MAP_BASE = _byte_map_base; |
497 #else | 497 #else |
498 #undef THREAD | 498 #undef THREAD |
677 markOop mark = rcvr->mark(); | 677 markOop mark = rcvr->mark(); |
678 if (mark->has_bias_pattern()) { | 678 if (mark->has_bias_pattern()) { |
679 // The bias pattern is present in the object's header. Need to check | 679 // The bias pattern is present in the object's header. Need to check |
680 // whether the bias owner and the epoch are both still current. | 680 // whether the bias owner and the epoch are both still current. |
681 intptr_t xx = ((intptr_t) THREAD) ^ (intptr_t) mark; | 681 intptr_t xx = ((intptr_t) THREAD) ^ (intptr_t) mark; |
682 xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() ^ xx; | 682 xx = (intptr_t) rcvr->klass()->prototype_header() ^ xx; |
683 intptr_t yy = (xx & ~((int) markOopDesc::age_mask_in_place)); | 683 intptr_t yy = (xx & ~((int) markOopDesc::age_mask_in_place)); |
684 if (yy != 0 ) { | 684 if (yy != 0 ) { |
685 // At this point we know that the header has the bias pattern and | 685 // At this point we know that the header has the bias pattern and |
686 // that we are not the bias owner in the current epoch. We need to | 686 // that we are not the bias owner in the current epoch. We need to |
687 // figure out more details about the state of the header in order to | 687 // figure out more details about the state of the header in order to |
721 // current "bias owner", if any, is actually invalid. Under these | 721 // current "bias owner", if any, is actually invalid. Under these |
722 // circumstances _only_, we are allowed to use the current header's | 722 // circumstances _only_, we are allowed to use the current header's |
723 // value as the comparison value when doing the cas to acquire the | 723 // value as the comparison value when doing the cas to acquire the |
724 // bias in the current epoch. In other words, we allow transfer of | 724 // bias in the current epoch. In other words, we allow transfer of |
725 // the bias from one thread to another directly in this situation. | 725 // the bias from one thread to another directly in this situation. |
726 xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD; | 726 xx = (intptr_t) rcvr->klass()->prototype_header() | (intptr_t) THREAD; |
727 if (Atomic::cmpxchg_ptr((intptr_t)THREAD | (intptr_t) rcvr->klass()->klass_part()->prototype_header(), | 727 if (Atomic::cmpxchg_ptr((intptr_t)THREAD | (intptr_t) rcvr->klass()->prototype_header(), |
728 (intptr_t*) rcvr->mark_addr(), | 728 (intptr_t*) rcvr->mark_addr(), |
729 (intptr_t) mark) != (intptr_t) mark) { | 729 (intptr_t) mark) != (intptr_t) mark) { |
730 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); | 730 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); |
731 } | 731 } |
732 } | 732 } |
739 // CAS-based locking scheme. Note that if our CAS fails, it means | 739 // CAS-based locking scheme. Note that if our CAS fails, it means |
740 // that another thread raced us for the privilege of revoking the | 740 // that another thread raced us for the privilege of revoking the |
741 // bias of this particular object, so it's okay to continue in the | 741 // bias of this particular object, so it's okay to continue in the |
742 // normal locking code. | 742 // normal locking code. |
743 // | 743 // |
744 xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD; | 744 xx = (intptr_t) rcvr->klass()->prototype_header() | (intptr_t) THREAD; |
745 if (Atomic::cmpxchg_ptr(rcvr->klass()->klass_part()->prototype_header(), | 745 if (Atomic::cmpxchg_ptr(rcvr->klass()->prototype_header(), |
746 (intptr_t*) rcvr->mark_addr(), | 746 (intptr_t*) rcvr->mark_addr(), |
747 mark) == mark) { | 747 mark) == mark) { |
748 // (*counters->revoked_lock_entry_count_addr())++; | 748 // (*counters->revoked_lock_entry_count_addr())++; |
749 success = false; | 749 success = false; |
750 } | 750 } |
1528 | 1528 |
1529 CASE(_return_register_finalizer): { | 1529 CASE(_return_register_finalizer): { |
1530 | 1530 |
1531 oop rcvr = LOCALS_OBJECT(0); | 1531 oop rcvr = LOCALS_OBJECT(0); |
1532 VERIFY_OOP(rcvr); | 1532 VERIFY_OOP(rcvr); |
1533 if (rcvr->klass()->klass_part()->has_finalizer()) { | 1533 if (rcvr->klass()->has_finalizer()) { |
1534 CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception); | 1534 CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception); |
1535 } | 1535 } |
1536 goto handle_return; | 1536 goto handle_return; |
1537 } | 1537 } |
1538 CASE(_return): { | 1538 CASE(_return): { |
1623 VERIFY_OOP(rhsObject); | 1623 VERIFY_OOP(rhsObject); |
1624 ARRAY_INTRO( -3); | 1624 ARRAY_INTRO( -3); |
1625 // arrObj, index are set | 1625 // arrObj, index are set |
1626 if (rhsObject != NULL) { | 1626 if (rhsObject != NULL) { |
1627 /* Check assignability of rhsObject into arrObj */ | 1627 /* Check assignability of rhsObject into arrObj */ |
1628 klassOop rhsKlassOop = rhsObject->klass(); // EBX (subclass) | 1628 Klass* rhsKlassOop = rhsObject->klass(); // EBX (subclass) |
1629 assert(arrObj->klass()->klass()->klass_part()->oop_is_objArrayKlass(), "Ack not an objArrayKlass"); | 1629 Klass* elemKlassOop = objArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX |
1630 klassOop elemKlassOop = ((objArrayKlass*) arrObj->klass()->klass_part())->element_klass(); // superklass EAX | |
1631 // | 1630 // |
1632 // Check for compatibilty. This check must not GC!! | 1631 // Check for compatibilty. This check must not GC!! |
1633 // Seems way more expensive now that we must dispatch | 1632 // Seems way more expensive now that we must dispatch |
1634 // | 1633 // |
1635 if (rhsKlassOop != elemKlassOop && !rhsKlassOop->klass_part()->is_subtype_of(elemKlassOop)) { // ebx->is... | 1634 if (rhsKlassOop != elemKlassOop && !rhsKlassOop->is_subtype_of(elemKlassOop)) { // ebx->is... |
1636 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), ""); | 1635 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), ""); |
1637 } | 1636 } |
1638 } | 1637 } |
1639 oop* elem_loc = (oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)); | 1638 oop* elem_loc = (oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)); |
1640 // *(oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)) = rhsObject; | 1639 // *(oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)) = rhsObject; |
1772 } | 1771 } |
1773 #endif /* VM_JVMTI */ | 1772 #endif /* VM_JVMTI */ |
1774 | 1773 |
1775 oop obj; | 1774 oop obj; |
1776 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { | 1775 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { |
1777 obj = (oop) cache->f1_as_instance(); | 1776 Klass* k = (Klass*) cache->f1(); |
1777 obj = k->java_mirror(); | |
1778 MORE_STACK(1); // Assume single slot push | 1778 MORE_STACK(1); // Assume single slot push |
1779 } else { | 1779 } else { |
1780 obj = (oop) STACK_OBJECT(-1); | 1780 obj = (oop) STACK_OBJECT(-1); |
1781 CHECK_NULL(obj); | 1781 CHECK_NULL(obj); |
1782 } | 1782 } |
1883 count = -1; | 1883 count = -1; |
1884 if (tos_type == ltos || tos_type == dtos) { | 1884 if (tos_type == ltos || tos_type == dtos) { |
1885 --count; | 1885 --count; |
1886 } | 1886 } |
1887 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { | 1887 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { |
1888 obj = (oop) cache->f1_as_instance(); | 1888 Klass* k = (Klass*) cache->f1(); |
1889 obj = k->java_mirror(); | |
1889 } else { | 1890 } else { |
1890 --count; | 1891 --count; |
1891 obj = (oop) STACK_OBJECT(count); | 1892 obj = (oop) STACK_OBJECT(count); |
1892 CHECK_NULL(obj); | 1893 CHECK_NULL(obj); |
1893 } | 1894 } |
1942 UPDATE_PC_AND_TOS_AND_CONTINUE(3, count); | 1943 UPDATE_PC_AND_TOS_AND_CONTINUE(3, count); |
1943 } | 1944 } |
1944 | 1945 |
1945 CASE(_new): { | 1946 CASE(_new): { |
1946 u2 index = Bytes::get_Java_u2(pc+1); | 1947 u2 index = Bytes::get_Java_u2(pc+1); |
1947 constantPoolOop constants = istate->method()->constants(); | 1948 ConstantPool* constants = istate->method()->constants(); |
1948 if (!constants->tag_at(index).is_unresolved_klass()) { | 1949 if (!constants->tag_at(index).is_unresolved_klass()) { |
1949 // Make sure klass is initialized and doesn't have a finalizer | 1950 // Make sure klass is initialized and doesn't have a finalizer |
1950 oop entry = constants->slot_at(index).get_oop(); | 1951 Klass* entry = constants->slot_at(index).get_klass(); |
1951 assert(entry->is_klass(), "Should be resolved klass"); | 1952 assert(entry->is_klass(), "Should be resolved klass"); |
1952 klassOop k_entry = (klassOop) entry; | 1953 Klass* k_entry = (Klass*) entry; |
1953 assert(k_entry->klass_part()->oop_is_instance(), "Should be instanceKlass"); | 1954 assert(k_entry->oop_is_instance(), "Should be InstanceKlass"); |
1954 instanceKlass* ik = (instanceKlass*) k_entry->klass_part(); | 1955 InstanceKlass* ik = (InstanceKlass*) k_entry; |
1955 if ( ik->is_initialized() && ik->can_be_fastpath_allocated() ) { | 1956 if ( ik->is_initialized() && ik->can_be_fastpath_allocated() ) { |
1956 size_t obj_size = ik->size_helper(); | 1957 size_t obj_size = ik->size_helper(); |
1957 oop result = NULL; | 1958 oop result = NULL; |
1958 // If the TLAB isn't pre-zeroed then we'll have to do it | 1959 // If the TLAB isn't pre-zeroed then we'll have to do it |
1959 bool need_zero = !ZeroTLAB; | 1960 bool need_zero = !ZeroTLAB; |
2035 // Constant pool may have actual klass or unresolved klass. If it is | 2036 // Constant pool may have actual klass or unresolved klass. If it is |
2036 // unresolved we must resolve it | 2037 // unresolved we must resolve it |
2037 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { | 2038 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { |
2038 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); | 2039 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); |
2039 } | 2040 } |
2040 klassOop klassOf = (klassOop) METHOD->constants()->slot_at(index).get_oop(); | 2041 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
2041 klassOop objKlassOop = STACK_OBJECT(-1)->klass(); //ebx | 2042 Klass* objKlassOop = STACK_OBJECT(-1)->klass(); //ebx |
2042 // | 2043 // |
2043 // Check for compatibilty. This check must not GC!! | 2044 // Check for compatibilty. This check must not GC!! |
2044 // Seems way more expensive now that we must dispatch | 2045 // Seems way more expensive now that we must dispatch |
2045 // | 2046 // |
2046 if (objKlassOop != klassOf && | 2047 if (objKlassOop != klassOf && |
2047 !objKlassOop->klass_part()->is_subtype_of(klassOf)) { | 2048 !objKlassOop->is_subtype_of(klassOf)) { |
2048 ResourceMark rm(THREAD); | 2049 ResourceMark rm(THREAD); |
2049 const char* objName = Klass::cast(objKlassOop)->external_name(); | 2050 const char* objName = Klass::cast(objKlassOop)->external_name(); |
2050 const char* klassName = Klass::cast(klassOf)->external_name(); | 2051 const char* klassName = Klass::cast(klassOf)->external_name(); |
2051 char* message = SharedRuntime::generate_class_cast_message( | 2052 char* message = SharedRuntime::generate_class_cast_message( |
2052 objName, klassName); | 2053 objName, klassName); |
2070 // Constant pool may have actual klass or unresolved klass. If it is | 2071 // Constant pool may have actual klass or unresolved klass. If it is |
2071 // unresolved we must resolve it | 2072 // unresolved we must resolve it |
2072 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { | 2073 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { |
2073 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); | 2074 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); |
2074 } | 2075 } |
2075 klassOop klassOf = (klassOop) METHOD->constants()->slot_at(index).get_oop(); | 2076 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
2076 klassOop objKlassOop = STACK_OBJECT(-1)->klass(); | 2077 Klass* objKlassOop = STACK_OBJECT(-1)->klass(); |
2077 // | 2078 // |
2078 // Check for compatibilty. This check must not GC!! | 2079 // Check for compatibilty. This check must not GC!! |
2079 // Seems way more expensive now that we must dispatch | 2080 // Seems way more expensive now that we must dispatch |
2080 // | 2081 // |
2081 if ( objKlassOop == klassOf || objKlassOop->klass_part()->is_subtype_of(klassOf)) { | 2082 if ( objKlassOop == klassOf || objKlassOop->is_subtype_of(klassOf)) { |
2082 SET_STACK_INT(1, -1); | 2083 SET_STACK_INT(1, -1); |
2083 } else { | 2084 } else { |
2084 SET_STACK_INT(0, -1); | 2085 SET_STACK_INT(0, -1); |
2085 } | 2086 } |
2086 } | 2087 } |
2098 index = Bytes::get_Java_u2(pc+1); | 2099 index = Bytes::get_Java_u2(pc+1); |
2099 incr = 3; | 2100 incr = 3; |
2100 wide = true; | 2101 wide = true; |
2101 } | 2102 } |
2102 | 2103 |
2103 constantPoolOop constants = METHOD->constants(); | 2104 ConstantPool* constants = METHOD->constants(); |
2104 switch (constants->tag_at(index).value()) { | 2105 switch (constants->tag_at(index).value()) { |
2105 case JVM_CONSTANT_Integer: | 2106 case JVM_CONSTANT_Integer: |
2106 SET_STACK_INT(constants->int_at(index), 0); | 2107 SET_STACK_INT(constants->int_at(index), 0); |
2107 break; | 2108 break; |
2108 | 2109 |
2109 case JVM_CONSTANT_Float: | 2110 case JVM_CONSTANT_Float: |
2110 SET_STACK_FLOAT(constants->float_at(index), 0); | 2111 SET_STACK_FLOAT(constants->float_at(index), 0); |
2111 break; | 2112 break; |
2112 | 2113 |
2113 case JVM_CONSTANT_String: | 2114 case JVM_CONSTANT_String: |
2114 VERIFY_OOP(constants->resolved_string_at(index)); | 2115 { |
2115 SET_STACK_OBJECT(constants->resolved_string_at(index), 0); | 2116 oop result = constants->resolved_references()->obj_at(index); |
2117 if (result == NULL) { | |
2118 CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception); | |
2119 SET_STACK_OBJECT(THREAD->vm_result(), 0); | |
2120 THREAD->set_vm_result(NULL); | |
2121 } else { | |
2122 VERIFY_OOP(result); | |
2123 SET_STACK_OBJECT(result, 0); | |
2124 } | |
2116 break; | 2125 break; |
2126 } | |
2117 | 2127 |
2118 case JVM_CONSTANT_Class: | 2128 case JVM_CONSTANT_Class: |
2119 VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror()); | 2129 VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror()); |
2120 SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0); | 2130 SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0); |
2121 break; | 2131 break; |
2122 | 2132 |
2123 case JVM_CONSTANT_UnresolvedString: | |
2124 case JVM_CONSTANT_UnresolvedClass: | 2133 case JVM_CONSTANT_UnresolvedClass: |
2125 case JVM_CONSTANT_UnresolvedClassInError: | 2134 case JVM_CONSTANT_UnresolvedClassInError: |
2126 CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception); | 2135 CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception); |
2127 SET_STACK_OBJECT(THREAD->vm_result(), 0); | 2136 SET_STACK_OBJECT(THREAD->vm_result(), 0); |
2128 THREAD->set_vm_result(NULL); | 2137 THREAD->set_vm_result(NULL); |
2135 | 2144 |
2136 CASE(_ldc2_w): | 2145 CASE(_ldc2_w): |
2137 { | 2146 { |
2138 u2 index = Bytes::get_Java_u2(pc+1); | 2147 u2 index = Bytes::get_Java_u2(pc+1); |
2139 | 2148 |
2140 constantPoolOop constants = METHOD->constants(); | 2149 ConstantPool* constants = METHOD->constants(); |
2141 switch (constants->tag_at(index).value()) { | 2150 switch (constants->tag_at(index).value()) { |
2142 | 2151 |
2143 case JVM_CONSTANT_Long: | 2152 case JVM_CONSTANT_Long: |
2144 SET_STACK_LONG(constants->long_at(index), 1); | 2153 SET_STACK_LONG(constants->long_at(index), 1); |
2145 break; | 2154 break; |
2152 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2); | 2161 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2); |
2153 } | 2162 } |
2154 | 2163 |
2155 CASE(_fast_aldc_w): | 2164 CASE(_fast_aldc_w): |
2156 CASE(_fast_aldc): { | 2165 CASE(_fast_aldc): { |
2157 if (!EnableInvokeDynamic) { | |
2158 // We should not encounter this bytecode if !EnableInvokeDynamic. | |
2159 // The verifier will stop it. However, if we get past the verifier, | |
2160 // this will stop the thread in a reasonable way, without crashing the JVM. | |
2161 CALL_VM(InterpreterRuntime::throw_IncompatibleClassChangeError(THREAD), | |
2162 handle_exception); | |
2163 ShouldNotReachHere(); | |
2164 } | |
2165 | |
2166 u2 index; | 2166 u2 index; |
2167 int incr; | 2167 int incr; |
2168 if (opcode == Bytecodes::_fast_aldc) { | 2168 if (opcode == Bytecodes::_fast_aldc) { |
2169 index = pc[1]; | 2169 index = pc[1]; |
2170 incr = 2; | 2170 incr = 2; |
2174 } | 2174 } |
2175 | 2175 |
2176 // We are resolved if the f1 field contains a non-null object (CallSite, etc.) | 2176 // We are resolved if the f1 field contains a non-null object (CallSite, etc.) |
2177 // This kind of CP cache entry does not need to match the flags byte, because | 2177 // This kind of CP cache entry does not need to match the flags byte, because |
2178 // there is a 1-1 relation between bytecode type and CP entry type. | 2178 // there is a 1-1 relation between bytecode type and CP entry type. |
2179 ConstantPoolCacheEntry* cache = cp->entry_at(index); | 2179 ConstantPool* constants = METHOD->constants(); |
2180 oop result = cache->f1_as_instance(); | 2180 oop result = constants->resolved_references()->obj_at(index); |
2181 if (result == NULL) { | 2181 if (result == NULL) { |
2182 CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), | 2182 CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), |
2183 handle_exception); | 2183 handle_exception); |
2184 result = cache->f1_as_instance(); | 2184 result = THREAD->vm_result(); |
2185 } | 2185 } |
2186 | 2186 |
2187 VERIFY_OOP(result); | 2187 VERIFY_OOP(result); |
2188 SET_STACK_OBJECT(result, 0); | 2188 SET_STACK_OBJECT(result, 0); |
2189 UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1); | 2189 UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1); |
2199 ShouldNotReachHere(); | 2199 ShouldNotReachHere(); |
2200 } | 2200 } |
2201 | 2201 |
2202 int index = Bytes::get_native_u4(pc+1); | 2202 int index = Bytes::get_native_u4(pc+1); |
2203 | 2203 |
2204 // We are resolved if the f1 field contains a non-null object (CallSite, etc.) | 2204 // We are resolved if the resolved_references field contains a non-null object (CallSite, etc.) |
2205 // This kind of CP cache entry does not need to match the flags byte, because | 2205 // This kind of CP cache entry does not need to match the flags byte, because |
2206 // there is a 1-1 relation between bytecode type and CP entry type. | 2206 // there is a 1-1 relation between bytecode type and CP entry type. |
2207 assert(constantPoolCacheOopDesc::is_secondary_index(index), "incorrect format"); | 2207 ConstantPool* constants = METHOD->constants(); |
2208 ConstantPoolCacheEntry* cache = cp->secondary_entry_at(index); | 2208 oop result = constants->resolved_references()->obj_at(index); |
2209 oop result = cache->f1_as_instance(); | |
2210 if (result == NULL) { | 2209 if (result == NULL) { |
2211 CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD), | 2210 CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD), |
2212 handle_exception); | 2211 handle_exception); |
2213 result = cache->f1_as_instance(); | 2212 result = THREAD->vm_result(); |
2214 } | 2213 } |
2215 | 2214 |
2216 VERIFY_OOP(result); | 2215 VERIFY_OOP(result); |
2217 oop method_handle = java_lang_invoke_CallSite::target(result); | 2216 oop method_handle = java_lang_invoke_CallSite::target(result); |
2218 CHECK_NULL(method_handle); | 2217 CHECK_NULL(method_handle); |
2219 | 2218 |
2220 istate->set_msg(call_method_handle); | 2219 istate->set_msg(call_method_handle); |
2221 istate->set_callee((methodOop) method_handle); | 2220 istate->set_callee((Method*) method_handle); |
2222 istate->set_bcp_advance(5); | 2221 istate->set_bcp_advance(5); |
2223 | 2222 |
2224 UPDATE_PC_AND_RETURN(0); // I'll be back... | 2223 UPDATE_PC_AND_RETURN(0); // I'll be back... |
2225 } | 2224 } |
2226 | 2225 |
2242 // Special case of invokeinterface called for virtual method of | 2241 // Special case of invokeinterface called for virtual method of |
2243 // java.lang.Object. See cpCacheOop.cpp for details. | 2242 // java.lang.Object. See cpCacheOop.cpp for details. |
2244 // This code isn't produced by javac, but could be produced by | 2243 // This code isn't produced by javac, but could be produced by |
2245 // another compliant java compiler. | 2244 // another compliant java compiler. |
2246 if (cache->is_forced_virtual()) { | 2245 if (cache->is_forced_virtual()) { |
2247 methodOop callee; | 2246 Method* callee; |
2248 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); | 2247 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2249 if (cache->is_vfinal()) { | 2248 if (cache->is_vfinal()) { |
2250 callee = cache->f2_as_vfinal_method(); | 2249 callee = cache->f2_as_vfinal_method(); |
2251 } else { | 2250 } else { |
2252 // get receiver | 2251 // get receiver |
2253 int parms = cache->parameter_size(); | 2252 int parms = cache->parameter_size(); |
2254 // Same comments as invokevirtual apply here | 2253 // Same comments as invokevirtual apply here |
2255 VERIFY_OOP(STACK_OBJECT(-parms)); | 2254 VERIFY_OOP(STACK_OBJECT(-parms)); |
2256 instanceKlass* rcvrKlass = (instanceKlass*) | 2255 InstanceKlass* rcvrKlass = (InstanceKlass*) |
2257 STACK_OBJECT(-parms)->klass()->klass_part(); | 2256 STACK_OBJECT(-parms)->klass(); |
2258 callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; | 2257 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
2259 } | 2258 } |
2260 istate->set_callee(callee); | 2259 istate->set_callee(callee); |
2261 istate->set_callee_entry_point(callee->from_interpreted_entry()); | 2260 istate->set_callee_entry_point(callee->from_interpreted_entry()); |
2262 #ifdef VM_JVMTI | 2261 #ifdef VM_JVMTI |
2263 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { | 2262 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { |
2267 istate->set_bcp_advance(5); | 2266 istate->set_bcp_advance(5); |
2268 UPDATE_PC_AND_RETURN(0); // I'll be back... | 2267 UPDATE_PC_AND_RETURN(0); // I'll be back... |
2269 } | 2268 } |
2270 | 2269 |
2271 // this could definitely be cleaned up QQQ | 2270 // this could definitely be cleaned up QQQ |
2272 methodOop callee; | 2271 Method* callee; |
2273 klassOop iclass = cache->f1_as_klass(); | 2272 Klass* iclass = cache->f1_as_klass(); |
2274 // instanceKlass* interface = (instanceKlass*) iclass->klass_part(); | 2273 // InstanceKlass* interface = (InstanceKlass*) iclass; |
2275 // get receiver | 2274 // get receiver |
2276 int parms = cache->parameter_size(); | 2275 int parms = cache->parameter_size(); |
2277 oop rcvr = STACK_OBJECT(-parms); | 2276 oop rcvr = STACK_OBJECT(-parms); |
2278 CHECK_NULL(rcvr); | 2277 CHECK_NULL(rcvr); |
2279 instanceKlass* int2 = (instanceKlass*) rcvr->klass()->klass_part(); | 2278 InstanceKlass* int2 = (InstanceKlass*) rcvr->klass(); |
2280 itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable(); | 2279 itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable(); |
2281 int i; | 2280 int i; |
2282 for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) { | 2281 for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) { |
2283 if (ki->interface_klass() == iclass) break; | 2282 if (ki->interface_klass() == iclass) break; |
2284 } | 2283 } |
2321 cache = cp->entry_at(index); | 2320 cache = cp->entry_at(index); |
2322 } | 2321 } |
2323 | 2322 |
2324 istate->set_msg(call_method); | 2323 istate->set_msg(call_method); |
2325 { | 2324 { |
2326 methodOop callee; | 2325 Method* callee; |
2327 if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { | 2326 if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { |
2328 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); | 2327 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2329 if (cache->is_vfinal()) callee = cache->f2_as_vfinal_method(); | 2328 if (cache->is_vfinal()) callee = cache->f2_as_vfinal_method(); |
2330 else { | 2329 else { |
2331 // get receiver | 2330 // get receiver |
2332 int parms = cache->parameter_size(); | 2331 int parms = cache->parameter_size(); |
2333 // this works but needs a resourcemark and seems to create a vtable on every call: | 2332 // this works but needs a resourcemark and seems to create a vtable on every call: |
2334 // methodOop callee = rcvr->klass()->klass_part()->vtable()->method_at(cache->f2_as_index()); | 2333 // Method* callee = rcvr->klass()->vtable()->method_at(cache->f2_as_index()); |
2335 // | 2334 // |
2336 // this fails with an assert | 2335 // this fails with an assert |
2337 // instanceKlass* rcvrKlass = instanceKlass::cast(STACK_OBJECT(-parms)->klass()); | 2336 // InstanceKlass* rcvrKlass = InstanceKlass::cast(STACK_OBJECT(-parms)->klass()); |
2338 // but this works | 2337 // but this works |
2339 VERIFY_OOP(STACK_OBJECT(-parms)); | 2338 VERIFY_OOP(STACK_OBJECT(-parms)); |
2340 instanceKlass* rcvrKlass = (instanceKlass*) STACK_OBJECT(-parms)->klass()->klass_part(); | 2339 InstanceKlass* rcvrKlass = (InstanceKlass*) STACK_OBJECT(-parms)->klass(); |
2341 /* | 2340 /* |
2342 Executing this code in java.lang.String: | 2341 Executing this code in java.lang.String: |
2343 public String(char value[]) { | 2342 public String(char value[]) { |
2344 this.count = value.length; | 2343 this.count = value.length; |
2345 this.value = (char[])value.clone(); | 2344 this.value = (char[])value.clone(); |
2346 } | 2345 } |
2347 | 2346 |
2348 a find on rcvr->klass()->klass_part() reports: | 2347 a find on rcvr->klass() reports: |
2349 {type array char}{type array class} | 2348 {type array char}{type array class} |
2350 - klass: {other class} | 2349 - klass: {other class} |
2351 | 2350 |
2352 but using instanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure | 2351 but using InstanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure |
2353 because rcvr->klass()->klass_part()->oop_is_instance() == 0 | 2352 because rcvr->klass()->oop_is_instance() == 0 |
2354 However it seems to have a vtable in the right location. Huh? | 2353 However it seems to have a vtable in the right location. Huh? |
2355 | 2354 |
2356 */ | 2355 */ |
2357 callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; | 2356 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
2358 } | 2357 } |
2359 } else { | 2358 } else { |
2360 if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { | 2359 if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { |
2361 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); | 2360 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2362 } | 2361 } |
2498 // expression stack is emptied | 2497 // expression stack is emptied |
2499 topOfStack = istate->stack_base() - Interpreter::stackElementWords; | 2498 topOfStack = istate->stack_base() - Interpreter::stackElementWords; |
2500 CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()), | 2499 CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()), |
2501 handle_exception); | 2500 handle_exception); |
2502 | 2501 |
2503 except_oop = (oop) THREAD->vm_result(); | 2502 except_oop = THREAD->vm_result(); |
2504 THREAD->set_vm_result(NULL); | 2503 THREAD->set_vm_result(NULL); |
2505 if (continuation_bci >= 0) { | 2504 if (continuation_bci >= 0) { |
2506 // Place exception on top of stack | 2505 // Place exception on top of stack |
2507 SET_STACK_OBJECT(except_oop(), 0); | 2506 SET_STACK_OBJECT(except_oop(), 0); |
2508 MORE_STACK(1); | 2507 MORE_STACK(1); |