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 "classfile/javaClasses.inline.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "classfile/vmClasses.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "code/codeCache.hpp"
31 #include "compiler/compilationPolicy.hpp"
32 #include "compiler/compileBroker.hpp"
33 #include "compiler/disassembler.hpp"
34 #include "gc/shared/barrierSetNMethod.hpp"
35 #include "gc/shared/collectedHeap.hpp"
36 #include "interpreter/bytecodeTracer.hpp"
37 #include "interpreter/interpreter.hpp"
38 #include "interpreter/interpreterRuntime.hpp"
39 #include "interpreter/linkResolver.hpp"
40 #include "interpreter/templateTable.hpp"
41 #include "jvm_io.h"
42 #include "logging/log.hpp"
43 #include "memory/oopFactory.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "memory/universe.hpp"
46 #include "oops/constantPool.inline.hpp"
47 #include "oops/cpCache.inline.hpp"
48 #include "oops/instanceKlass.inline.hpp"
49 #include "oops/klass.inline.hpp"
50 #include "oops/methodData.hpp"
51 #include "oops/method.inline.hpp"
52 #include "oops/objArrayKlass.hpp"
53 #include "oops/objArrayOop.inline.hpp"
54 #include "oops/oop.inline.hpp"
55 #include "oops/symbol.hpp"
56 #include "prims/jvmtiExport.hpp"
57 #include "prims/methodHandles.hpp"
58 #include "prims/nativeLookup.hpp"
59 #include "runtime/atomic.hpp"
60 #include "runtime/continuation.hpp"
61 #include "runtime/deoptimization.hpp"
62 #include "runtime/fieldDescriptor.inline.hpp"
63 #include "runtime/frame.inline.hpp"
64 #include "runtime/handles.inline.hpp"
65 #include "runtime/icache.hpp"
66 #include "runtime/interfaceSupport.inline.hpp"
67 #include "runtime/java.hpp"
68 #include "runtime/javaCalls.hpp"
69 #include "runtime/jfieldIDWorkaround.hpp"
70 #include "runtime/osThread.hpp"
71 #include "runtime/sharedRuntime.hpp"
72 #include "runtime/stackWatermarkSet.hpp"
73 #include "runtime/stubRoutines.hpp"
74 #include "runtime/synchronizer.inline.hpp"
75 #include "runtime/threadCritical.hpp"
76 #include "utilities/align.hpp"
77 #include "utilities/checkedCast.hpp"
78 #include "utilities/copy.hpp"
79 #include "utilities/events.hpp"
80 #ifdef COMPILER2
81 #include "opto/runtime.hpp"
82 #endif
83
84 // Helper class to access current interpreter state
85 class LastFrameAccessor : public StackObj {
86 frame _last_frame;
87 public:
88 LastFrameAccessor(JavaThread* current) {
89 assert(current == Thread::current(), "sanity");
90 _last_frame = current->last_frame();
91 }
92 bool is_interpreted_frame() const { return _last_frame.is_interpreted_frame(); }
93 Method* method() const { return _last_frame.interpreter_frame_method(); }
94 address bcp() const { return _last_frame.interpreter_frame_bcp(); }
95 int bci() const { return _last_frame.interpreter_frame_bci(); }
96 address mdp() const { return _last_frame.interpreter_frame_mdp(); }
97
98 void set_bcp(address bcp) { _last_frame.interpreter_frame_set_bcp(bcp); }
99 void set_mdp(address dp) { _last_frame.interpreter_frame_set_mdp(dp); }
210 JRT_END
211
212
213 //------------------------------------------------------------------------------------------------------------------------
214 // Allocation
215
216 JRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* current, ConstantPool* pool, int index))
217 Klass* k = pool->klass_at(index, CHECK);
218 InstanceKlass* klass = InstanceKlass::cast(k);
219
220 // Make sure we are not instantiating an abstract klass
221 klass->check_valid_for_instantiation(true, CHECK);
222
223 // Make sure klass is initialized
224 klass->initialize(CHECK);
225
226 oop obj = klass->allocate_instance(CHECK);
227 current->set_vm_result(obj);
228 JRT_END
229
230
231 JRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* current, BasicType type, jint size))
232 oop obj = oopFactory::new_typeArray(type, size, CHECK);
233 current->set_vm_result(obj);
234 JRT_END
235
236
237 JRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* current, ConstantPool* pool, int index, jint size))
238 Klass* klass = pool->klass_at(index, CHECK);
239 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
240 current->set_vm_result(obj);
241 JRT_END
242
243
244 JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* current, jint* first_size_address))
245 // We may want to pass in more arguments - could make this slightly faster
246 LastFrameAccessor last_frame(current);
247 ConstantPool* constants = last_frame.method()->constants();
248 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
249 Klass* klass = constants->klass_at(i, CHECK);
250 int nof_dims = last_frame.number_of_dimensions();
251 assert(klass->is_klass(), "not a class");
252 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
253
254 // We must create an array of jints to pass to multi_allocate.
255 ResourceMark rm(current);
256 const int small_dims = 10;
257 jint dim_array[small_dims];
258 jint *dims = &dim_array[0];
259 if (nof_dims > small_dims) {
260 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
261 }
262 for (int index = 0; index < nof_dims; index++) {
263 // offset from first_size_address is addressed as local[index]
264 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
265 dims[index] = first_size_address[n];
266 }
267 oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
268 current->set_vm_result(obj);
269 JRT_END
270
271
272 JRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* current, oopDesc* obj))
273 assert(oopDesc::is_oop(obj), "must be a valid oop");
274 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
275 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
276 JRT_END
277
278
279 // Quicken instance-of and check-cast bytecodes
280 JRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* current))
281 // Force resolving; quicken the bytecode
282 LastFrameAccessor last_frame(current);
283 int which = last_frame.get_index_u2(Bytecodes::_checkcast);
284 ConstantPool* cpool = last_frame.method()->constants();
285 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded
286 // program we might have seen an unquick'd bytecode in the interpreter but have another
287 // thread quicken the bytecode before we get here.
288 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
289 Klass* klass = cpool->klass_at(which, CHECK);
290 current->set_vm_result_2(klass);
291 JRT_END
292
293
294 //------------------------------------------------------------------------------------------------------------------------
295 // Exceptions
296
297 void InterpreterRuntime::note_trap_inner(JavaThread* current, int reason,
601 // and therefore we don't have the receiver object at our fingertips. (Though,
602 // on some platforms the receiver still resides in a register...). Thus,
603 // we have no choice but print an error message not containing the receiver
604 // type.
605 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* current,
606 Method* missingMethod))
607 ResourceMark rm(current);
608 assert(missingMethod != nullptr, "sanity");
609 methodHandle m(current, missingMethod);
610 LinkResolver::throw_abstract_method_error(m, THREAD);
611 JRT_END
612
613 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* current,
614 Klass* recvKlass,
615 Method* missingMethod))
616 ResourceMark rm(current);
617 methodHandle mh = methodHandle(current, missingMethod);
618 LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
619 JRT_END
620
621
622 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* current))
623 THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
624 JRT_END
625
626 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* current,
627 Klass* recvKlass,
628 Klass* interfaceKlass))
629 ResourceMark rm(current);
630 char buf[1000];
631 buf[0] = '\0';
632 jio_snprintf(buf, sizeof(buf),
633 "Class %s does not implement the requested interface %s",
634 recvKlass ? recvKlass->external_name() : "nullptr",
635 interfaceKlass ? interfaceKlass->external_name() : "nullptr");
636 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
637 JRT_END
638
639 JRT_ENTRY(void, InterpreterRuntime::throw_NullPointerException(JavaThread* current))
640 THROW(vmSymbols::java_lang_NullPointerException());
685 // initializer method <init>. If resolution were not inhibited, a putfield
686 // in an initializer method could be resolved in the initializer. Subsequent
687 // putfield instructions to the same field would then use cached information.
688 // As a result, those instructions would not pass through the VM. That is,
689 // checks in resolve_field_access() would not be executed for those instructions
690 // and the required IllegalAccessError would not be thrown.
691 //
692 // Also, we need to delay resolving getstatic and putstatic instructions until the
693 // class is initialized. This is required so that access to the static
694 // field will call the initialization function every time until the class
695 // is completely initialized ala. in 2.17.5 in JVM Specification.
696 InstanceKlass* klass = info.field_holder();
697 bool uninitialized_static = is_static && !klass->is_initialized();
698 bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&
699 info.has_initialized_final_update();
700 assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final");
701
702 Bytecodes::Code get_code = (Bytecodes::Code)0;
703 Bytecodes::Code put_code = (Bytecodes::Code)0;
704 if (!uninitialized_static) {
705 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
706 if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) {
707 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
708 }
709 }
710
711 ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
712 entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile());
713 entry->fill_in(info.field_holder(), info.offset(),
714 checked_cast<u2>(info.index()), checked_cast<u1>(state),
715 static_cast<u1>(get_code), static_cast<u1>(put_code));
716 }
717
718
719 //------------------------------------------------------------------------------------------------------------------------
720 // Synchronization
721 //
722 // The interpreter's synchronization code is factored out so that it can
723 // be shared by method invocation and synchronized blocks.
724 //%note synchronization_3
725
726 //%note monitor_1
727 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
728 #ifdef ASSERT
729 current->last_frame().interpreter_frame_verify_monitor(elem);
730 #endif
731 Handle h_obj(current, elem->obj());
732 assert(Universe::heap()->is_in_or_null(h_obj()),
739 #endif
740 JRT_END
741
742 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
743 oop obj = elem->obj();
744 assert(Universe::heap()->is_in(obj), "must be an object");
745 // The object could become unlocked through a JNI call, which we have no other checks for.
746 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
747 if (obj->is_unlocked()) {
748 if (CheckJNICalls) {
749 fatal("Object has been unlocked by JNI");
750 }
751 return;
752 }
753 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
754 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
755 // again at method exit or in the case of an exception.
756 elem->set_obj(nullptr);
757 JRT_END
758
759
760 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))
761 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
762 JRT_END
763
764
765 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* current))
766 // Returns an illegal exception to install into the current thread. The
767 // pending_exception flag is cleared so normal exception handling does not
768 // trigger. Any current installed exception will be overwritten. This
769 // method will be called during an exception unwind.
770
771 assert(!HAS_PENDING_EXCEPTION, "no pending exception");
772 Handle exception(current, current->vm_result());
773 assert(exception() != nullptr, "vm result should be set");
774 current->set_vm_result(nullptr); // clear vm result before continuing (may cause memory leaks and assert failures)
775 exception = get_preinitialized_exception(vmClasses::IllegalMonitorStateException_klass(), CATCH);
776 current->set_vm_result(exception());
777 JRT_END
778
779
780 //------------------------------------------------------------------------------------------------------------------------
781 // Invokes
782
783 JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* current, Method* method, address bcp))
784 return method->orig_bytecode_at(method->bci_from(bcp));
785 JRT_END
786
787 JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code))
788 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
789 JRT_END
790
791 JRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* current, Method* method, address bcp))
792 JvmtiExport::post_raw_breakpoint(current, method, bcp);
793 JRT_END
794
795 void InterpreterRuntime::resolve_invoke(JavaThread* current, Bytecodes::Code bytecode) {
796 LastFrameAccessor last_frame(current);
797 // extract receiver from the outgoing argument list if necessary
798 Handle receiver(current, nullptr);
1151 LastFrameAccessor last_frame(current);
1152 JvmtiExport::at_single_stepping_point(current, last_frame.method(), last_frame.bcp());
1153 }
1154 JRT_END
1155
1156 JRT_LEAF(void, InterpreterRuntime::at_unwind(JavaThread* current))
1157 assert(current == JavaThread::current(), "pre-condition");
1158 // This function is called by the interpreter when the return poll found a reason
1159 // to call the VM. The reason could be that we are returning into a not yet safe
1160 // to access frame. We handle that below.
1161 // Note that this path does not check for single stepping, because we do not want
1162 // to single step when unwinding frames for an exception being thrown. Instead,
1163 // such single stepping code will use the safepoint table, which will use the
1164 // InterpreterRuntime::at_safepoint callback.
1165 StackWatermarkSet::before_unwind(current);
1166 JRT_END
1167
1168 JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDesc* obj,
1169 ResolvedFieldEntry *entry))
1170
1171 // check the access_flags for the field in the klass
1172
1173 InstanceKlass* ik = entry->field_holder();
1174 int index = entry->field_index();
1175 if (!ik->field_status(index).is_access_watched()) return;
1176
1177 bool is_static = (obj == nullptr);
1178 HandleMark hm(current);
1179
1180 Handle h_obj;
1181 if (!is_static) {
1182 // non-static field accessors have an object, but we need a handle
1183 h_obj = Handle(current, obj);
1184 }
1185 InstanceKlass* field_holder = entry->field_holder(); // HERE
1186 jfieldID fid = jfieldIDWorkaround::to_jfieldID(field_holder, entry->field_offset(), is_static);
1187 LastFrameAccessor last_frame(current);
1188 JvmtiExport::post_field_access(current, last_frame.method(), last_frame.bcp(), field_holder, h_obj, fid);
1189 JRT_END
1190
1191 JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread* current, oopDesc* obj,
1192 ResolvedFieldEntry *entry, jvalue *value))
1193
1194 InstanceKlass* ik = entry->field_holder();
1195
1196 // check the access_flags for the field in the klass
1197 int index = entry->field_index();
1198 // bail out if field modifications are not watched
1199 if (!ik->field_status(index).is_modification_watched()) return;
1200
1201 char sig_type = '\0';
1202
1203 switch((TosState)entry->tos_state()) {
1204 case btos: sig_type = JVM_SIGNATURE_BYTE; break;
1205 case ztos: sig_type = JVM_SIGNATURE_BOOLEAN; break;
1206 case ctos: sig_type = JVM_SIGNATURE_CHAR; break;
1207 case stos: sig_type = JVM_SIGNATURE_SHORT; break;
1208 case itos: sig_type = JVM_SIGNATURE_INT; break;
1209 case ftos: sig_type = JVM_SIGNATURE_FLOAT; break;
1210 case atos: sig_type = JVM_SIGNATURE_CLASS; break;
1211 case ltos: sig_type = JVM_SIGNATURE_LONG; break;
1212 case dtos: sig_type = JVM_SIGNATURE_DOUBLE; break;
1213 default: ShouldNotReachHere(); return;
1214 }
1215 bool is_static = (obj == nullptr);
1216
1217 HandleMark hm(current);
1218 jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, entry->field_offset(), is_static);
1219 jvalue fvalue;
1220 #ifdef _LP64
1221 fvalue = *value;
1222 #else
1223 // Long/double values are stored unaligned and also noncontiguously with
1224 // tagged stacks. We can't just do a simple assignment even in the non-
1225 // J/D cases because a C++ compiler is allowed to assume that a jvalue is
1226 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned.
1227 // We assume that the two halves of longs/doubles are stored in interpreter
1228 // stack slots in platform-endian order.
1229 jlong_accessor u;
1230 jint* newval = (jint*)value;
1231 u.words[0] = newval[0];
1232 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag
1233 fvalue.j = u.long_value;
1234 #endif // _LP64
1235
1236 Handle h_obj;
1237 if (!is_static) {
1238 // non-static field accessors have an object, but we need a handle
|
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 "classfile/javaClasses.inline.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/vmClasses.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "code/codeCache.hpp"
32 #include "compiler/compilationPolicy.hpp"
33 #include "compiler/compileBroker.hpp"
34 #include "compiler/disassembler.hpp"
35 #include "gc/shared/barrierSetNMethod.hpp"
36 #include "gc/shared/collectedHeap.hpp"
37 #include "interpreter/bytecodeTracer.hpp"
38 #include "interpreter/interpreter.hpp"
39 #include "interpreter/interpreterRuntime.hpp"
40 #include "interpreter/linkResolver.hpp"
41 #include "interpreter/templateTable.hpp"
42 #include "jvm_io.h"
43 #include "logging/log.hpp"
44 #include "memory/oopFactory.hpp"
45 #include "memory/resourceArea.hpp"
46 #include "memory/universe.hpp"
47 #include "oops/constantPool.inline.hpp"
48 #include "oops/cpCache.inline.hpp"
49 #include "oops/flatArrayKlass.hpp"
50 #include "oops/flatArrayOop.inline.hpp"
51 #include "oops/inlineKlass.inline.hpp"
52 #include "oops/instanceKlass.inline.hpp"
53 #include "oops/klass.inline.hpp"
54 #include "oops/methodData.hpp"
55 #include "oops/method.inline.hpp"
56 #include "oops/objArrayKlass.hpp"
57 #include "oops/objArrayOop.inline.hpp"
58 #include "oops/oop.inline.hpp"
59 #include "oops/symbol.hpp"
60 #include "prims/jvmtiExport.hpp"
61 #include "prims/methodHandles.hpp"
62 #include "prims/nativeLookup.hpp"
63 #include "runtime/atomic.hpp"
64 #include "runtime/continuation.hpp"
65 #include "runtime/deoptimization.hpp"
66 #include "runtime/fieldDescriptor.inline.hpp"
67 #include "runtime/frame.inline.hpp"
68 #include "runtime/handles.inline.hpp"
69 #include "runtime/icache.hpp"
70 #include "runtime/interfaceSupport.inline.hpp"
71 #include "runtime/java.hpp"
72 #include "runtime/javaCalls.hpp"
73 #include "runtime/jfieldIDWorkaround.hpp"
74 #include "runtime/osThread.hpp"
75 #include "runtime/sharedRuntime.hpp"
76 #include "runtime/stackWatermarkSet.hpp"
77 #include "runtime/stubRoutines.hpp"
78 #include "runtime/synchronizer.inline.hpp"
79 #include "runtime/threadCritical.hpp"
80 #include "utilities/align.hpp"
81 #include "utilities/checkedCast.hpp"
82 #include "utilities/copy.hpp"
83 #include "utilities/events.hpp"
84 #include "utilities/globalDefinitions.hpp"
85 #ifdef COMPILER2
86 #include "opto/runtime.hpp"
87 #endif
88
89 // Helper class to access current interpreter state
90 class LastFrameAccessor : public StackObj {
91 frame _last_frame;
92 public:
93 LastFrameAccessor(JavaThread* current) {
94 assert(current == Thread::current(), "sanity");
95 _last_frame = current->last_frame();
96 }
97 bool is_interpreted_frame() const { return _last_frame.is_interpreted_frame(); }
98 Method* method() const { return _last_frame.interpreter_frame_method(); }
99 address bcp() const { return _last_frame.interpreter_frame_bcp(); }
100 int bci() const { return _last_frame.interpreter_frame_bci(); }
101 address mdp() const { return _last_frame.interpreter_frame_mdp(); }
102
103 void set_bcp(address bcp) { _last_frame.interpreter_frame_set_bcp(bcp); }
104 void set_mdp(address dp) { _last_frame.interpreter_frame_set_mdp(dp); }
215 JRT_END
216
217
218 //------------------------------------------------------------------------------------------------------------------------
219 // Allocation
220
221 JRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* current, ConstantPool* pool, int index))
222 Klass* k = pool->klass_at(index, CHECK);
223 InstanceKlass* klass = InstanceKlass::cast(k);
224
225 // Make sure we are not instantiating an abstract klass
226 klass->check_valid_for_instantiation(true, CHECK);
227
228 // Make sure klass is initialized
229 klass->initialize(CHECK);
230
231 oop obj = klass->allocate_instance(CHECK);
232 current->set_vm_result(obj);
233 JRT_END
234
235 JRT_ENTRY(void, InterpreterRuntime::uninitialized_static_inline_type_field(JavaThread* current, oopDesc* mirror, ResolvedFieldEntry* entry))
236 // The interpreter tries to access an inline static field that has not been initialized.
237 // This situation can happen in different scenarios:
238 // 1 - if the load or initialization of the field failed during step 8 of
239 // the initialization of the holder of the field, in this case the access to the field
240 // must fail
241 // 2 - it can also happen when the initialization of the holder class triggered the initialization of
242 // another class which accesses this field in its static initializer, in this case the
243 // access must succeed to allow circularity
244 // The code below tries to load and initialize the field's class again before returning the default value.
245 // If the field was not initialized because of an error, an exception should be thrown.
246 // If the class is being initialized, the default value is returned.
247 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
248 instanceHandle mirror_h(THREAD, (instanceOop)mirror);
249 InstanceKlass* klass = entry->field_holder();
250 u2 index = entry->field_index();
251 assert(klass == java_lang_Class::as_Klass(mirror), "Not the field holder klass");
252 assert(klass->field_is_null_free_inline_type(index), "Sanity check");
253 if (klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD)) {
254 int offset = klass->field_offset(index);
255 Klass* field_k = klass->get_inline_type_field_klass_or_null(index);
256 if (field_k == nullptr) {
257 field_k = SystemDictionary::resolve_or_fail(klass->field_signature(index)->fundamental_name(THREAD),
258 Handle(THREAD, klass->class_loader()),
259 Handle(THREAD, klass->protection_domain()),
260 true, CHECK);
261 assert(field_k != nullptr, "Should have been loaded or an exception thrown above");
262 klass->set_inline_type_field_klass(index, InlineKlass::cast(field_k));
263 }
264 field_k->initialize(CHECK);
265 oop defaultvalue = InlineKlass::cast(field_k)->default_value();
266 // It is safe to initialize the static field because 1) the current thread is the initializing thread
267 // and is the only one that can access it, and 2) the field is actually not initialized (i.e. null)
268 // otherwise the JVM should not be executing this code.
269 mirror_h()->obj_field_put(offset, defaultvalue);
270 current->set_vm_result(defaultvalue);
271 } else {
272 assert(klass->is_in_error_state(), "If not initializing, initialization must have failed to get there");
273 ResourceMark rm(THREAD);
274 const char* desc = "Could not initialize class ";
275 const char* className = klass->external_name();
276 size_t msglen = strlen(desc) + strlen(className) + 1;
277 char* message = NEW_RESOURCE_ARRAY(char, msglen);
278 if (nullptr == message) {
279 // Out of memory: can't create detailed error message
280 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), className);
281 } else {
282 jio_snprintf(message, msglen, "%s%s", desc, className);
283 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), message);
284 }
285 }
286 JRT_END
287
288 JRT_ENTRY(void, InterpreterRuntime::read_flat_field(JavaThread* current, oopDesc* obj, int index, Klass* field_holder))
289 Handle obj_h(THREAD, obj);
290
291 assert(oopDesc::is_oop(obj), "Sanity check");
292
293 assert(field_holder->is_instance_klass(), "Sanity check");
294 InstanceKlass* klass = InstanceKlass::cast(field_holder);
295
296 assert(klass->field_is_flat(index), "Sanity check");
297
298 InlineKlass* field_vklass = InlineKlass::cast(klass->get_inline_type_field_klass(index));
299
300 oop res = field_vklass->read_flat_field(obj_h(), klass->field_offset(index), CHECK);
301 current->set_vm_result(res);
302 JRT_END
303
304 // The protocol to read a nullable flat field is:
305 // Step 1: read the null marker with an load_acquire barrier to ensure that
306 // reordered loads won't try to load the value before the null marker is read
307 // Step 2: if the null marker value is zero, the field's value is null
308 // otherwise the flat field value can be read like a regular flat field
309 JRT_ENTRY(void, InterpreterRuntime::read_nullable_flat_field(JavaThread* current, oopDesc* obj, ResolvedFieldEntry* entry))
310 assert(oopDesc::is_oop(obj), "Sanity check");
311 assert(entry->has_null_marker(), "Otherwise should not get there");
312 Handle obj_h(THREAD, obj);
313
314 InstanceKlass* ik = InstanceKlass::cast(obj_h()->klass());
315 int field_index = entry->field_index();
316 int nm_offset = ik->null_marker_offsets_array()->at(field_index);
317 if (obj_h()->byte_field_acquire(nm_offset) == 0) {
318 current->set_vm_result(nullptr);
319 } else {
320 InlineKlass* field_vklass = InlineKlass::cast(ik->get_inline_type_field_klass(field_index));
321 oop res = field_vklass->read_flat_field(obj_h(), ik->field_offset(field_index), CHECK);
322 current->set_vm_result(res);
323 }
324 JRT_END
325
326 // The protocol to write a nullable flat field is:
327 // If the new field value is null, just write zero to the null marker
328 // Otherwise:
329 // Step 1: write the field value like a regular flat field
330 // Step 2: have a memory barrier to ensure that the whole value content is visible
331 // Step 3: update the null marker to a non zero value
332 JRT_ENTRY(void, InterpreterRuntime::write_nullable_flat_field(JavaThread* current, oopDesc* obj, oopDesc* value, ResolvedFieldEntry* entry))
333 assert(oopDesc::is_oop(obj), "Sanity check");
334 Handle obj_h(THREAD, obj);
335 assert(value == nullptr || oopDesc::is_oop(value), "Sanity check");
336 Handle val_h(THREAD, value);
337
338 InstanceKlass* ik = InstanceKlass::cast(obj_h()->klass());
339 int nm_offset = ik->null_marker_offsets_array()->at(entry->field_index());
340 if (val_h() == nullptr) {
341 obj_h()->byte_field_put(nm_offset, (jbyte)0);
342 return;
343 }
344 InlineKlass* vk = InlineKlass::cast(val_h()->klass());
345 if (entry->has_internal_null_marker()) {
346 // The interpreter copies values with a bulk operation
347 // To avoid accidently setting the null marker to "null" during
348 // the copying, the null marker is set to non zero in the source object
349 if (val_h()->byte_field(vk->get_internal_null_marker_offset()) == 0) {
350 val_h()->byte_field_put(vk->get_internal_null_marker_offset(), (jbyte)1);
351 }
352 vk->write_non_null_flat_field(obj_h(), entry->field_offset(), val_h());
353 } else {
354 vk->write_non_null_flat_field(obj_h(), entry->field_offset(), val_h());
355 OrderAccess::release();
356 obj_h()->byte_field_put(nm_offset, (jbyte)1);
357 }
358 JRT_END
359
360 JRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* current, BasicType type, jint size))
361 oop obj = oopFactory::new_typeArray(type, size, CHECK);
362 current->set_vm_result(obj);
363 JRT_END
364
365
366 JRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* current, ConstantPool* pool, int index, jint size))
367 Klass* klass = pool->klass_at(index, CHECK);
368 arrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
369 current->set_vm_result(obj);
370 JRT_END
371
372 JRT_ENTRY(void, InterpreterRuntime::value_array_load(JavaThread* current, arrayOopDesc* array, int index))
373 flatArrayHandle vah(current, (flatArrayOop)array);
374 oop value_holder = flatArrayOopDesc::value_alloc_copy_from_index(vah, index, CHECK);
375 current->set_vm_result(value_holder);
376 JRT_END
377
378 JRT_ENTRY(void, InterpreterRuntime::value_array_store(JavaThread* current, void* val, arrayOopDesc* array, int index))
379 assert(val != nullptr, "can't store null into flat array");
380 ((flatArrayOop)array)->value_copy_to_index(cast_to_oop(val), index);
381 JRT_END
382
383 JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* current, jint* first_size_address))
384 // We may want to pass in more arguments - could make this slightly faster
385 LastFrameAccessor last_frame(current);
386 ConstantPool* constants = last_frame.method()->constants();
387 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
388 Klass* klass = constants->klass_at(i, CHECK);
389 int nof_dims = last_frame.number_of_dimensions();
390 assert(klass->is_klass(), "not a class");
391 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
392
393 // We must create an array of jints to pass to multi_allocate.
394 ResourceMark rm(current);
395 const int small_dims = 10;
396 jint dim_array[small_dims];
397 jint *dims = &dim_array[0];
398 if (nof_dims > small_dims) {
399 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
400 }
401 for (int index = 0; index < nof_dims; index++) {
402 // offset from first_size_address is addressed as local[index]
403 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
404 dims[index] = first_size_address[n];
405 }
406 oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
407 current->set_vm_result(obj);
408 JRT_END
409
410
411 JRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* current, oopDesc* obj))
412 assert(oopDesc::is_oop(obj), "must be a valid oop");
413 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
414 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
415 JRT_END
416
417 JRT_ENTRY(jboolean, InterpreterRuntime::is_substitutable(JavaThread* current, oopDesc* aobj, oopDesc* bobj))
418 assert(oopDesc::is_oop(aobj) && oopDesc::is_oop(bobj), "must be valid oops");
419
420 Handle ha(THREAD, aobj);
421 Handle hb(THREAD, bobj);
422 JavaValue result(T_BOOLEAN);
423 JavaCallArguments args;
424 args.push_oop(ha);
425 args.push_oop(hb);
426 methodHandle method(current, Universe::is_substitutable_method());
427 method->method_holder()->initialize(CHECK_false); // Ensure class ValueObjectMethods is initialized
428 JavaCalls::call(&result, method, &args, THREAD);
429 if (HAS_PENDING_EXCEPTION) {
430 // Something really bad happened because isSubstitutable() should not throw exceptions
431 // If it is an error, just let it propagate
432 // If it is an exception, wrap it into an InternalError
433 if (!PENDING_EXCEPTION->is_a(vmClasses::Error_klass())) {
434 Handle e(THREAD, PENDING_EXCEPTION);
435 CLEAR_PENDING_EXCEPTION;
436 THROW_MSG_CAUSE_(vmSymbols::java_lang_InternalError(), "Internal error in substitutability test", e, false);
437 }
438 }
439 return result.get_jboolean();
440 JRT_END
441
442 // Quicken instance-of and check-cast bytecodes
443 JRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* current))
444 // Force resolving; quicken the bytecode
445 LastFrameAccessor last_frame(current);
446 int which = last_frame.get_index_u2(Bytecodes::_checkcast);
447 ConstantPool* cpool = last_frame.method()->constants();
448 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded
449 // program we might have seen an unquick'd bytecode in the interpreter but have another
450 // thread quicken the bytecode before we get here.
451 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
452 Klass* klass = cpool->klass_at(which, CHECK);
453 current->set_vm_result_2(klass);
454 JRT_END
455
456
457 //------------------------------------------------------------------------------------------------------------------------
458 // Exceptions
459
460 void InterpreterRuntime::note_trap_inner(JavaThread* current, int reason,
764 // and therefore we don't have the receiver object at our fingertips. (Though,
765 // on some platforms the receiver still resides in a register...). Thus,
766 // we have no choice but print an error message not containing the receiver
767 // type.
768 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* current,
769 Method* missingMethod))
770 ResourceMark rm(current);
771 assert(missingMethod != nullptr, "sanity");
772 methodHandle m(current, missingMethod);
773 LinkResolver::throw_abstract_method_error(m, THREAD);
774 JRT_END
775
776 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* current,
777 Klass* recvKlass,
778 Method* missingMethod))
779 ResourceMark rm(current);
780 methodHandle mh = methodHandle(current, missingMethod);
781 LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
782 JRT_END
783
784 JRT_ENTRY(void, InterpreterRuntime::throw_InstantiationError(JavaThread* current))
785 THROW(vmSymbols::java_lang_InstantiationError());
786 JRT_END
787
788
789 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* current))
790 THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
791 JRT_END
792
793 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* current,
794 Klass* recvKlass,
795 Klass* interfaceKlass))
796 ResourceMark rm(current);
797 char buf[1000];
798 buf[0] = '\0';
799 jio_snprintf(buf, sizeof(buf),
800 "Class %s does not implement the requested interface %s",
801 recvKlass ? recvKlass->external_name() : "nullptr",
802 interfaceKlass ? interfaceKlass->external_name() : "nullptr");
803 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
804 JRT_END
805
806 JRT_ENTRY(void, InterpreterRuntime::throw_NullPointerException(JavaThread* current))
807 THROW(vmSymbols::java_lang_NullPointerException());
852 // initializer method <init>. If resolution were not inhibited, a putfield
853 // in an initializer method could be resolved in the initializer. Subsequent
854 // putfield instructions to the same field would then use cached information.
855 // As a result, those instructions would not pass through the VM. That is,
856 // checks in resolve_field_access() would not be executed for those instructions
857 // and the required IllegalAccessError would not be thrown.
858 //
859 // Also, we need to delay resolving getstatic and putstatic instructions until the
860 // class is initialized. This is required so that access to the static
861 // field will call the initialization function every time until the class
862 // is completely initialized ala. in 2.17.5 in JVM Specification.
863 InstanceKlass* klass = info.field_holder();
864 bool uninitialized_static = is_static && !klass->is_initialized();
865 bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&
866 info.has_initialized_final_update();
867 assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final");
868
869 Bytecodes::Code get_code = (Bytecodes::Code)0;
870 Bytecodes::Code put_code = (Bytecodes::Code)0;
871 if (!uninitialized_static) {
872 if (is_static) {
873 get_code = Bytecodes::_getstatic;
874 } else {
875 get_code = Bytecodes::_getfield;
876 }
877 if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) {
878 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
879 }
880 }
881
882 ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
883 entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile(),
884 info.is_flat(), info.is_null_free_inline_type(),
885 info.has_null_marker(), info.has_internal_null_marker());
886
887 entry->fill_in(info.field_holder(), info.offset(),
888 checked_cast<u2>(info.index()), checked_cast<u1>(state),
889 static_cast<u1>(get_code), static_cast<u1>(put_code));
890 }
891
892
893 //------------------------------------------------------------------------------------------------------------------------
894 // Synchronization
895 //
896 // The interpreter's synchronization code is factored out so that it can
897 // be shared by method invocation and synchronized blocks.
898 //%note synchronization_3
899
900 //%note monitor_1
901 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
902 #ifdef ASSERT
903 current->last_frame().interpreter_frame_verify_monitor(elem);
904 #endif
905 Handle h_obj(current, elem->obj());
906 assert(Universe::heap()->is_in_or_null(h_obj()),
913 #endif
914 JRT_END
915
916 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
917 oop obj = elem->obj();
918 assert(Universe::heap()->is_in(obj), "must be an object");
919 // The object could become unlocked through a JNI call, which we have no other checks for.
920 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
921 if (obj->is_unlocked()) {
922 if (CheckJNICalls) {
923 fatal("Object has been unlocked by JNI");
924 }
925 return;
926 }
927 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
928 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
929 // again at method exit or in the case of an exception.
930 elem->set_obj(nullptr);
931 JRT_END
932
933 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))
934 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
935 JRT_END
936
937 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* current))
938 // Returns an illegal exception to install into the current thread. The
939 // pending_exception flag is cleared so normal exception handling does not
940 // trigger. Any current installed exception will be overwritten. This
941 // method will be called during an exception unwind.
942
943 assert(!HAS_PENDING_EXCEPTION, "no pending exception");
944 Handle exception(current, current->vm_result());
945 assert(exception() != nullptr, "vm result should be set");
946 current->set_vm_result(nullptr); // clear vm result before continuing (may cause memory leaks and assert failures)
947 exception = get_preinitialized_exception(vmClasses::IllegalMonitorStateException_klass(), CATCH);
948 current->set_vm_result(exception());
949 JRT_END
950
951 JRT_ENTRY(void, InterpreterRuntime::throw_identity_exception(JavaThread* current, oopDesc* obj))
952 Klass* klass = cast_to_oop(obj)->klass();
953 ResourceMark rm(THREAD);
954 const char* desc = "Cannot synchronize on an instance of value class ";
955 const char* className = klass->external_name();
956 size_t msglen = strlen(desc) + strlen(className) + 1;
957 char* message = NEW_RESOURCE_ARRAY(char, msglen);
958 if (nullptr == message) {
959 // Out of memory: can't create detailed error message
960 THROW_MSG(vmSymbols::java_lang_IdentityException(), className);
961 } else {
962 jio_snprintf(message, msglen, "%s%s", desc, className);
963 THROW_MSG(vmSymbols::java_lang_IdentityException(), message);
964 }
965 JRT_END
966
967 //------------------------------------------------------------------------------------------------------------------------
968 // Invokes
969
970 JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* current, Method* method, address bcp))
971 return method->orig_bytecode_at(method->bci_from(bcp));
972 JRT_END
973
974 JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code))
975 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
976 JRT_END
977
978 JRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* current, Method* method, address bcp))
979 JvmtiExport::post_raw_breakpoint(current, method, bcp);
980 JRT_END
981
982 void InterpreterRuntime::resolve_invoke(JavaThread* current, Bytecodes::Code bytecode) {
983 LastFrameAccessor last_frame(current);
984 // extract receiver from the outgoing argument list if necessary
985 Handle receiver(current, nullptr);
1338 LastFrameAccessor last_frame(current);
1339 JvmtiExport::at_single_stepping_point(current, last_frame.method(), last_frame.bcp());
1340 }
1341 JRT_END
1342
1343 JRT_LEAF(void, InterpreterRuntime::at_unwind(JavaThread* current))
1344 assert(current == JavaThread::current(), "pre-condition");
1345 // This function is called by the interpreter when the return poll found a reason
1346 // to call the VM. The reason could be that we are returning into a not yet safe
1347 // to access frame. We handle that below.
1348 // Note that this path does not check for single stepping, because we do not want
1349 // to single step when unwinding frames for an exception being thrown. Instead,
1350 // such single stepping code will use the safepoint table, which will use the
1351 // InterpreterRuntime::at_safepoint callback.
1352 StackWatermarkSet::before_unwind(current);
1353 JRT_END
1354
1355 JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDesc* obj,
1356 ResolvedFieldEntry *entry))
1357
1358 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
1359 // check the access_flags for the field in the klass
1360
1361 InstanceKlass* ik = entry->field_holder();
1362 int index = entry->field_index();
1363 if (!ik->field_status(index).is_access_watched()) return;
1364
1365 bool is_static = (obj == nullptr);
1366 bool is_flat = entry->is_flat();
1367 HandleMark hm(current);
1368
1369 Handle h_obj;
1370 if (!is_static) {
1371 // non-static field accessors have an object, but we need a handle
1372 h_obj = Handle(current, obj);
1373 }
1374 InstanceKlass* field_holder = entry->field_holder(); // HERE
1375 jfieldID fid = jfieldIDWorkaround::to_jfieldID(field_holder, entry->field_offset(), is_static, is_flat);
1376 LastFrameAccessor last_frame(current);
1377 JvmtiExport::post_field_access(current, last_frame.method(), last_frame.bcp(), field_holder, h_obj, fid);
1378 JRT_END
1379
1380 JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread* current, oopDesc* obj,
1381 ResolvedFieldEntry *entry, jvalue *value))
1382
1383 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
1384 InstanceKlass* ik = entry->field_holder();
1385
1386 // check the access_flags for the field in the klass
1387 int index = entry->field_index();
1388 // bail out if field modifications are not watched
1389 if (!ik->field_status(index).is_modification_watched()) return;
1390
1391 char sig_type = '\0';
1392
1393 switch((TosState)entry->tos_state()) {
1394 case btos: sig_type = JVM_SIGNATURE_BYTE; break;
1395 case ztos: sig_type = JVM_SIGNATURE_BOOLEAN; break;
1396 case ctos: sig_type = JVM_SIGNATURE_CHAR; break;
1397 case stos: sig_type = JVM_SIGNATURE_SHORT; break;
1398 case itos: sig_type = JVM_SIGNATURE_INT; break;
1399 case ftos: sig_type = JVM_SIGNATURE_FLOAT; break;
1400 case atos: sig_type = JVM_SIGNATURE_CLASS; break;
1401 case ltos: sig_type = JVM_SIGNATURE_LONG; break;
1402 case dtos: sig_type = JVM_SIGNATURE_DOUBLE; break;
1403 default: ShouldNotReachHere(); return;
1404 }
1405
1406 bool is_static = (obj == nullptr);
1407 bool is_flat = entry->is_flat();
1408
1409 HandleMark hm(current);
1410 jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, entry->field_offset(), is_static, is_flat);
1411 jvalue fvalue;
1412 #ifdef _LP64
1413 fvalue = *value;
1414 #else
1415 // Long/double values are stored unaligned and also noncontiguously with
1416 // tagged stacks. We can't just do a simple assignment even in the non-
1417 // J/D cases because a C++ compiler is allowed to assume that a jvalue is
1418 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned.
1419 // We assume that the two halves of longs/doubles are stored in interpreter
1420 // stack slots in platform-endian order.
1421 jlong_accessor u;
1422 jint* newval = (jint*)value;
1423 u.words[0] = newval[0];
1424 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag
1425 fvalue.j = u.long_value;
1426 #endif // _LP64
1427
1428 Handle h_obj;
1429 if (!is_static) {
1430 // non-static field accessors have an object, but we need a handle
|