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.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); }
224 klass->initialize(CHECK);
225
226 // At this point the class may not be fully initialized
227 // because of recursive initialization. If it is fully
228 // initialized & has_finalized is not set, we rewrite
229 // it into its fast version (Note: no locking is needed
230 // here since this is an atomic byte write and can be
231 // done more than once).
232 //
233 // Note: In case of classes with has_finalized we don't
234 // rewrite since that saves us an extra check in
235 // the fast version which then would call the
236 // slow version anyway (and do a call back into
237 // Java).
238 // If we have a breakpoint, then we don't rewrite
239 // because the _breakpoint bytecode would be lost.
240 oop obj = klass->allocate_instance(CHECK);
241 current->set_vm_result(obj);
242 JRT_END
243
244
245 JRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* current, BasicType type, jint size))
246 oop obj = oopFactory::new_typeArray(type, size, CHECK);
247 current->set_vm_result(obj);
248 JRT_END
249
250
251 JRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* current, ConstantPool* pool, int index, jint size))
252 Klass* klass = pool->klass_at(index, CHECK);
253 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
254 current->set_vm_result(obj);
255 JRT_END
256
257
258 JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* current, jint* first_size_address))
259 // We may want to pass in more arguments - could make this slightly faster
260 LastFrameAccessor last_frame(current);
261 ConstantPool* constants = last_frame.method()->constants();
262 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
263 Klass* klass = constants->klass_at(i, CHECK);
264 int nof_dims = last_frame.number_of_dimensions();
265 assert(klass->is_klass(), "not a class");
266 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
267
268 // We must create an array of jints to pass to multi_allocate.
269 ResourceMark rm(current);
270 const int small_dims = 10;
271 jint dim_array[small_dims];
272 jint *dims = &dim_array[0];
273 if (nof_dims > small_dims) {
274 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
275 }
276 for (int index = 0; index < nof_dims; index++) {
277 // offset from first_size_address is addressed as local[index]
278 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
279 dims[index] = first_size_address[n];
280 }
281 oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
282 current->set_vm_result(obj);
283 JRT_END
284
285
286 JRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* current, oopDesc* obj))
287 assert(oopDesc::is_oop(obj), "must be a valid oop");
288 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
289 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
290 JRT_END
291
292
293 // Quicken instance-of and check-cast bytecodes
294 JRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* current))
295 // Force resolving; quicken the bytecode
296 LastFrameAccessor last_frame(current);
297 int which = last_frame.get_index_u2(Bytecodes::_checkcast);
298 ConstantPool* cpool = last_frame.method()->constants();
299 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded
300 // program we might have seen an unquick'd bytecode in the interpreter but have another
301 // thread quicken the bytecode before we get here.
302 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
303 Klass* klass = cpool->klass_at(which, CHECK);
304 current->set_vm_result_2(klass);
305 JRT_END
306
307
308 //------------------------------------------------------------------------------------------------------------------------
309 // Exceptions
310
311 void InterpreterRuntime::note_trap_inner(JavaThread* current, int reason,
615 // and therefore we don't have the receiver object at our fingertips. (Though,
616 // on some platforms the receiver still resides in a register...). Thus,
617 // we have no choice but print an error message not containing the receiver
618 // type.
619 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* current,
620 Method* missingMethod))
621 ResourceMark rm(current);
622 assert(missingMethod != nullptr, "sanity");
623 methodHandle m(current, missingMethod);
624 LinkResolver::throw_abstract_method_error(m, THREAD);
625 JRT_END
626
627 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* current,
628 Klass* recvKlass,
629 Method* missingMethod))
630 ResourceMark rm(current);
631 methodHandle mh = methodHandle(current, missingMethod);
632 LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
633 JRT_END
634
635
636 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* current))
637 THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
638 JRT_END
639
640 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* current,
641 Klass* recvKlass,
642 Klass* interfaceKlass))
643 ResourceMark rm(current);
644 char buf[1000];
645 buf[0] = '\0';
646 jio_snprintf(buf, sizeof(buf),
647 "Class %s does not implement the requested interface %s",
648 recvKlass ? recvKlass->external_name() : "nullptr",
649 interfaceKlass ? interfaceKlass->external_name() : "nullptr");
650 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
651 JRT_END
652
653 JRT_ENTRY(void, InterpreterRuntime::throw_NullPointerException(JavaThread* current))
654 THROW(vmSymbols::java_lang_NullPointerException());
695 // initializer method <init>. If resolution were not inhibited, a putfield
696 // in an initializer method could be resolved in the initializer. Subsequent
697 // putfield instructions to the same field would then use cached information.
698 // As a result, those instructions would not pass through the VM. That is,
699 // checks in resolve_field_access() would not be executed for those instructions
700 // and the required IllegalAccessError would not be thrown.
701 //
702 // Also, we need to delay resolving getstatic and putstatic instructions until the
703 // class is initialized. This is required so that access to the static
704 // field will call the initialization function every time until the class
705 // is completely initialized ala. in 2.17.5 in JVM Specification.
706 InstanceKlass* klass = info.field_holder();
707 bool uninitialized_static = is_static && !klass->is_initialized();
708 bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&
709 info.has_initialized_final_update();
710 assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final");
711
712 Bytecodes::Code get_code = (Bytecodes::Code)0;
713 Bytecodes::Code put_code = (Bytecodes::Code)0;
714 if (!uninitialized_static) {
715 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
716 if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) {
717 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
718 }
719 }
720
721 ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
722 entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile());
723 entry->fill_in(info.field_holder(), info.offset(),
724 checked_cast<u2>(info.index()), checked_cast<u1>(state),
725 static_cast<u1>(get_code), static_cast<u1>(put_code));
726 }
727
728
729 //------------------------------------------------------------------------------------------------------------------------
730 // Synchronization
731 //
732 // The interpreter's synchronization code is factored out so that it can
733 // be shared by method invocation and synchronized blocks.
734 //%note synchronization_3
735
736 //%note monitor_1
737 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
738 assert(LockingMode != LM_LIGHTWEIGHT, "Should call monitorenter_obj() when using the new lightweight locking");
739 #ifdef ASSERT
740 current->last_frame().interpreter_frame_verify_monitor(elem);
741 #endif
742 Handle h_obj(current, elem->obj());
767 return;
768 JRT_END
769
770 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
771 oop obj = elem->obj();
772 assert(Universe::heap()->is_in(obj), "must be an object");
773 // The object could become unlocked through a JNI call, which we have no other checks for.
774 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
775 if (obj->is_unlocked()) {
776 if (CheckJNICalls) {
777 fatal("Object has been unlocked by JNI");
778 }
779 return;
780 }
781 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
782 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
783 // again at method exit or in the case of an exception.
784 elem->set_obj(nullptr);
785 JRT_END
786
787
788 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))
789 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
790 JRT_END
791
792
793 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* current))
794 // Returns an illegal exception to install into the current thread. The
795 // pending_exception flag is cleared so normal exception handling does not
796 // trigger. Any current installed exception will be overwritten. This
797 // method will be called during an exception unwind.
798
799 assert(!HAS_PENDING_EXCEPTION, "no pending exception");
800 Handle exception(current, current->vm_result());
801 assert(exception() != nullptr, "vm result should be set");
802 current->set_vm_result(nullptr); // clear vm result before continuing (may cause memory leaks and assert failures)
803 exception = get_preinitialized_exception(vmClasses::IllegalMonitorStateException_klass(), CATCH);
804 current->set_vm_result(exception());
805 JRT_END
806
807
808 //------------------------------------------------------------------------------------------------------------------------
809 // Invokes
810
811 JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* current, Method* method, address bcp))
812 return method->orig_bytecode_at(method->bci_from(bcp));
813 JRT_END
814
815 JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code))
816 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
817 JRT_END
818
819 JRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* current, Method* method, address bcp))
820 JvmtiExport::post_raw_breakpoint(current, method, bcp);
821 JRT_END
822
823 void InterpreterRuntime::resolve_invoke(JavaThread* current, Bytecodes::Code bytecode) {
824 LastFrameAccessor last_frame(current);
825 // extract receiver from the outgoing argument list if necessary
826 Handle receiver(current, nullptr);
1146 LastFrameAccessor last_frame(current);
1147 JvmtiExport::at_single_stepping_point(current, last_frame.method(), last_frame.bcp());
1148 }
1149 JRT_END
1150
1151 JRT_LEAF(void, InterpreterRuntime::at_unwind(JavaThread* current))
1152 assert(current == JavaThread::current(), "pre-condition");
1153 // This function is called by the interpreter when the return poll found a reason
1154 // to call the VM. The reason could be that we are returning into a not yet safe
1155 // to access frame. We handle that below.
1156 // Note that this path does not check for single stepping, because we do not want
1157 // to single step when unwinding frames for an exception being thrown. Instead,
1158 // such single stepping code will use the safepoint table, which will use the
1159 // InterpreterRuntime::at_safepoint callback.
1160 StackWatermarkSet::before_unwind(current);
1161 JRT_END
1162
1163 JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDesc* obj,
1164 ResolvedFieldEntry *entry))
1165
1166 // check the access_flags for the field in the klass
1167
1168 InstanceKlass* ik = entry->field_holder();
1169 int index = entry->field_index();
1170 if (!ik->field_status(index).is_access_watched()) return;
1171
1172 bool is_static = (obj == nullptr);
1173 HandleMark hm(current);
1174
1175 Handle h_obj;
1176 if (!is_static) {
1177 // non-static field accessors have an object, but we need a handle
1178 h_obj = Handle(current, obj);
1179 }
1180 InstanceKlass* field_holder = entry->field_holder(); // HERE
1181 jfieldID fid = jfieldIDWorkaround::to_jfieldID(field_holder, entry->field_offset(), is_static);
1182 LastFrameAccessor last_frame(current);
1183 JvmtiExport::post_field_access(current, last_frame.method(), last_frame.bcp(), field_holder, h_obj, fid);
1184 JRT_END
1185
1186 JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread* current, oopDesc* obj,
1187 ResolvedFieldEntry *entry, jvalue *value))
1188
1189 InstanceKlass* ik = entry->field_holder();
1190
1191 // check the access_flags for the field in the klass
1192 int index = entry->field_index();
1193 // bail out if field modifications are not watched
1194 if (!ik->field_status(index).is_modification_watched()) return;
1195
1196 char sig_type = '\0';
1197
1198 switch((TosState)entry->tos_state()) {
1199 case btos: sig_type = JVM_SIGNATURE_BYTE; break;
1200 case ztos: sig_type = JVM_SIGNATURE_BOOLEAN; break;
1201 case ctos: sig_type = JVM_SIGNATURE_CHAR; break;
1202 case stos: sig_type = JVM_SIGNATURE_SHORT; break;
1203 case itos: sig_type = JVM_SIGNATURE_INT; break;
1204 case ftos: sig_type = JVM_SIGNATURE_FLOAT; break;
1205 case atos: sig_type = JVM_SIGNATURE_CLASS; break;
1206 case ltos: sig_type = JVM_SIGNATURE_LONG; break;
1207 case dtos: sig_type = JVM_SIGNATURE_DOUBLE; break;
1208 default: ShouldNotReachHere(); return;
1209 }
1210 bool is_static = (obj == nullptr);
1211
1212 HandleMark hm(current);
1213 jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, entry->field_offset(), is_static);
1214 jvalue fvalue;
1215 #ifdef _LP64
1216 fvalue = *value;
1217 #else
1218 // Long/double values are stored unaligned and also noncontiguously with
1219 // tagged stacks. We can't just do a simple assignment even in the non-
1220 // J/D cases because a C++ compiler is allowed to assume that a jvalue is
1221 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned.
1222 // We assume that the two halves of longs/doubles are stored in interpreter
1223 // stack slots in platform-endian order.
1224 jlong_accessor u;
1225 jint* newval = (jint*)value;
1226 u.words[0] = newval[0];
1227 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag
1228 fvalue.j = u.long_value;
1229 #endif // _LP64
1230
1231 Handle h_obj;
1232 if (!is_static) {
1233 // 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.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); }
229 klass->initialize(CHECK);
230
231 // At this point the class may not be fully initialized
232 // because of recursive initialization. If it is fully
233 // initialized & has_finalized is not set, we rewrite
234 // it into its fast version (Note: no locking is needed
235 // here since this is an atomic byte write and can be
236 // done more than once).
237 //
238 // Note: In case of classes with has_finalized we don't
239 // rewrite since that saves us an extra check in
240 // the fast version which then would call the
241 // slow version anyway (and do a call back into
242 // Java).
243 // If we have a breakpoint, then we don't rewrite
244 // because the _breakpoint bytecode would be lost.
245 oop obj = klass->allocate_instance(CHECK);
246 current->set_vm_result(obj);
247 JRT_END
248
249 JRT_ENTRY(void, InterpreterRuntime::uninitialized_static_inline_type_field(JavaThread* current, oopDesc* mirror, ResolvedFieldEntry* entry))
250 // The interpreter tries to access an inline static field that has not been initialized.
251 // This situation can happen in different scenarios:
252 // 1 - if the load or initialization of the field failed during step 8 of
253 // the initialization of the holder of the field, in this case the access to the field
254 // must fail
255 // 2 - it can also happen when the initialization of the holder class triggered the initialization of
256 // another class which accesses this field in its static initializer, in this case the
257 // access must succeed to allow circularity
258 // The code below tries to load and initialize the field's class again before returning the default value.
259 // If the field was not initialized because of an error, an exception should be thrown.
260 // If the class is being initialized, the default value is returned.
261 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
262 instanceHandle mirror_h(THREAD, (instanceOop)mirror);
263 InstanceKlass* klass = entry->field_holder();
264 u2 index = entry->field_index();
265 assert(klass == java_lang_Class::as_Klass(mirror), "Not the field holder klass");
266 assert(klass->field_is_null_free_inline_type(index), "Sanity check");
267 if (klass->is_being_initialized() && klass->is_init_thread(THREAD)) {
268 int offset = klass->field_offset(index);
269 Klass* field_k = klass->get_inline_type_field_klass_or_null(index);
270 if (field_k == nullptr) {
271 field_k = SystemDictionary::resolve_or_fail(klass->field_signature(index)->fundamental_name(THREAD),
272 Handle(THREAD, klass->class_loader()),
273 Handle(THREAD, klass->protection_domain()),
274 true, CHECK);
275 assert(field_k != nullptr, "Should have been loaded or an exception thrown above");
276 klass->set_inline_type_field_klass(index, InlineKlass::cast(field_k));
277 }
278 field_k->initialize(CHECK);
279 oop defaultvalue = InlineKlass::cast(field_k)->default_value();
280 // It is safe to initialize the static field because 1) the current thread is the initializing thread
281 // and is the only one that can access it, and 2) the field is actually not initialized (i.e. null)
282 // otherwise the JVM should not be executing this code.
283 mirror_h()->obj_field_put(offset, defaultvalue);
284 current->set_vm_result(defaultvalue);
285 } else {
286 assert(klass->is_in_error_state(), "If not initializing, initialization must have failed to get there");
287 ResourceMark rm(THREAD);
288 const char* desc = "Could not initialize class ";
289 const char* className = klass->external_name();
290 size_t msglen = strlen(desc) + strlen(className) + 1;
291 char* message = NEW_RESOURCE_ARRAY(char, msglen);
292 if (nullptr == message) {
293 // Out of memory: can't create detailed error message
294 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), className);
295 } else {
296 jio_snprintf(message, msglen, "%s%s", desc, className);
297 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), message);
298 }
299 }
300 JRT_END
301
302 JRT_ENTRY(void, InterpreterRuntime::read_flat_field(JavaThread* current, oopDesc* obj, int index, Klass* field_holder))
303 Handle obj_h(THREAD, obj);
304
305 assert(oopDesc::is_oop(obj), "Sanity check");
306
307 assert(field_holder->is_instance_klass(), "Sanity check");
308 InstanceKlass* klass = InstanceKlass::cast(field_holder);
309
310 assert(klass->field_is_flat(index), "Sanity check");
311
312 InlineKlass* field_vklass = InlineKlass::cast(klass->get_inline_type_field_klass(index));
313
314 oop res = field_vklass->read_flat_field(obj_h(), klass->field_offset(index), CHECK);
315 current->set_vm_result(res);
316 JRT_END
317
318 // The protocol to read a nullable flat field is:
319 // Step 1: read the null marker with an load_acquire barrier to ensure that
320 // reordered loads won't try to load the value before the null marker is read
321 // Step 2: if the null marker value is zero, the field's value is null
322 // otherwise the flat field value can be read like a regular flat field
323 JRT_ENTRY(void, InterpreterRuntime::read_nullable_flat_field(JavaThread* current, oopDesc* obj, ResolvedFieldEntry* entry))
324 assert(oopDesc::is_oop(obj), "Sanity check");
325 assert(entry->has_null_marker(), "Otherwise should not get there");
326 Handle obj_h(THREAD, obj);
327
328 InstanceKlass* ik = InstanceKlass::cast(obj_h()->klass());
329 int field_index = entry->field_index();
330 int nm_offset = ik->null_marker_offsets_array()->at(field_index);
331 if (obj_h()->byte_field_acquire(nm_offset) == 0) {
332 current->set_vm_result(nullptr);
333 } else {
334 InlineKlass* field_vklass = InlineKlass::cast(ik->get_inline_type_field_klass(field_index));
335 oop res = field_vklass->read_flat_field(obj_h(), ik->field_offset(field_index), CHECK);
336 current->set_vm_result(res);
337 }
338 JRT_END
339
340 // The protocol to write a nullable flat field is:
341 // If the new field value is null, just write zero to the null marker
342 // Otherwise:
343 // Step 1: write the field value like a regular flat field
344 // Step 2: have a memory barrier to ensure that the whole value content is visible
345 // Step 3: update the null marker to a non zero value
346 JRT_ENTRY(void, InterpreterRuntime::write_nullable_flat_field(JavaThread* current, oopDesc* obj, oopDesc* value, ResolvedFieldEntry* entry))
347 assert(oopDesc::is_oop(obj), "Sanity check");
348 Handle obj_h(THREAD, obj);
349 assert(value == nullptr || oopDesc::is_oop(value), "Sanity check");
350 Handle val_h(THREAD, value);
351
352 InstanceKlass* ik = InstanceKlass::cast(obj_h()->klass());
353 int nm_offset = ik->null_marker_offsets_array()->at(entry->field_index());
354 if (val_h() == nullptr) {
355 obj_h()->byte_field_put(nm_offset, (jbyte)0);
356 return;
357 }
358 InlineKlass* vk = InlineKlass::cast(val_h()->klass());
359 if (entry->has_internal_null_marker()) {
360 // The interpreter copies values with a bulk operation
361 // To avoid accidently setting the null marker to "null" during
362 // the copying, the null marker is set to non zero in the source object
363 if (val_h()->byte_field(vk->get_internal_null_marker_offset()) == 0) {
364 val_h()->byte_field_put(vk->get_internal_null_marker_offset(), (jbyte)1);
365 }
366 vk->write_non_null_flat_field(obj_h(), entry->field_offset(), val_h());
367 } else {
368 vk->write_non_null_flat_field(obj_h(), entry->field_offset(), val_h());
369 OrderAccess::release();
370 obj_h()->byte_field_put(nm_offset, (jbyte)1);
371 }
372 JRT_END
373
374 JRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* current, BasicType type, jint size))
375 oop obj = oopFactory::new_typeArray(type, size, CHECK);
376 current->set_vm_result(obj);
377 JRT_END
378
379
380 JRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* current, ConstantPool* pool, int index, jint size))
381 Klass* klass = pool->klass_at(index, CHECK);
382 arrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
383 current->set_vm_result(obj);
384 JRT_END
385
386 JRT_ENTRY(void, InterpreterRuntime::value_array_load(JavaThread* current, arrayOopDesc* array, int index))
387 flatArrayHandle vah(current, (flatArrayOop)array);
388 oop value_holder = flatArrayOopDesc::value_alloc_copy_from_index(vah, index, CHECK);
389 current->set_vm_result(value_holder);
390 JRT_END
391
392 JRT_ENTRY(void, InterpreterRuntime::value_array_store(JavaThread* current, void* val, arrayOopDesc* array, int index))
393 assert(val != nullptr, "can't store null into flat array");
394 ((flatArrayOop)array)->value_copy_to_index(cast_to_oop(val), index);
395 JRT_END
396
397 JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* current, jint* first_size_address))
398 // We may want to pass in more arguments - could make this slightly faster
399 LastFrameAccessor last_frame(current);
400 ConstantPool* constants = last_frame.method()->constants();
401 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
402 Klass* klass = constants->klass_at(i, CHECK);
403 int nof_dims = last_frame.number_of_dimensions();
404 assert(klass->is_klass(), "not a class");
405 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
406
407 // We must create an array of jints to pass to multi_allocate.
408 ResourceMark rm(current);
409 const int small_dims = 10;
410 jint dim_array[small_dims];
411 jint *dims = &dim_array[0];
412 if (nof_dims > small_dims) {
413 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
414 }
415 for (int index = 0; index < nof_dims; index++) {
416 // offset from first_size_address is addressed as local[index]
417 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
418 dims[index] = first_size_address[n];
419 }
420 oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
421 current->set_vm_result(obj);
422 JRT_END
423
424
425 JRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* current, oopDesc* obj))
426 assert(oopDesc::is_oop(obj), "must be a valid oop");
427 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
428 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
429 JRT_END
430
431 JRT_ENTRY(jboolean, InterpreterRuntime::is_substitutable(JavaThread* current, oopDesc* aobj, oopDesc* bobj))
432 assert(oopDesc::is_oop(aobj) && oopDesc::is_oop(bobj), "must be valid oops");
433
434 Handle ha(THREAD, aobj);
435 Handle hb(THREAD, bobj);
436 JavaValue result(T_BOOLEAN);
437 JavaCallArguments args;
438 args.push_oop(ha);
439 args.push_oop(hb);
440 methodHandle method(current, Universe::is_substitutable_method());
441 method->method_holder()->initialize(CHECK_false); // Ensure class ValueObjectMethods is initialized
442 JavaCalls::call(&result, method, &args, THREAD);
443 if (HAS_PENDING_EXCEPTION) {
444 // Something really bad happened because isSubstitutable() should not throw exceptions
445 // If it is an error, just let it propagate
446 // If it is an exception, wrap it into an InternalError
447 if (!PENDING_EXCEPTION->is_a(vmClasses::Error_klass())) {
448 Handle e(THREAD, PENDING_EXCEPTION);
449 CLEAR_PENDING_EXCEPTION;
450 THROW_MSG_CAUSE_(vmSymbols::java_lang_InternalError(), "Internal error in substitutability test", e, false);
451 }
452 }
453 return result.get_jboolean();
454 JRT_END
455
456 // Quicken instance-of and check-cast bytecodes
457 JRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* current))
458 // Force resolving; quicken the bytecode
459 LastFrameAccessor last_frame(current);
460 int which = last_frame.get_index_u2(Bytecodes::_checkcast);
461 ConstantPool* cpool = last_frame.method()->constants();
462 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded
463 // program we might have seen an unquick'd bytecode in the interpreter but have another
464 // thread quicken the bytecode before we get here.
465 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
466 Klass* klass = cpool->klass_at(which, CHECK);
467 current->set_vm_result_2(klass);
468 JRT_END
469
470
471 //------------------------------------------------------------------------------------------------------------------------
472 // Exceptions
473
474 void InterpreterRuntime::note_trap_inner(JavaThread* current, int reason,
778 // and therefore we don't have the receiver object at our fingertips. (Though,
779 // on some platforms the receiver still resides in a register...). Thus,
780 // we have no choice but print an error message not containing the receiver
781 // type.
782 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* current,
783 Method* missingMethod))
784 ResourceMark rm(current);
785 assert(missingMethod != nullptr, "sanity");
786 methodHandle m(current, missingMethod);
787 LinkResolver::throw_abstract_method_error(m, THREAD);
788 JRT_END
789
790 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* current,
791 Klass* recvKlass,
792 Method* missingMethod))
793 ResourceMark rm(current);
794 methodHandle mh = methodHandle(current, missingMethod);
795 LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
796 JRT_END
797
798 JRT_ENTRY(void, InterpreterRuntime::throw_InstantiationError(JavaThread* current))
799 THROW(vmSymbols::java_lang_InstantiationError());
800 JRT_END
801
802
803 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* current))
804 THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
805 JRT_END
806
807 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* current,
808 Klass* recvKlass,
809 Klass* interfaceKlass))
810 ResourceMark rm(current);
811 char buf[1000];
812 buf[0] = '\0';
813 jio_snprintf(buf, sizeof(buf),
814 "Class %s does not implement the requested interface %s",
815 recvKlass ? recvKlass->external_name() : "nullptr",
816 interfaceKlass ? interfaceKlass->external_name() : "nullptr");
817 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
818 JRT_END
819
820 JRT_ENTRY(void, InterpreterRuntime::throw_NullPointerException(JavaThread* current))
821 THROW(vmSymbols::java_lang_NullPointerException());
862 // initializer method <init>. If resolution were not inhibited, a putfield
863 // in an initializer method could be resolved in the initializer. Subsequent
864 // putfield instructions to the same field would then use cached information.
865 // As a result, those instructions would not pass through the VM. That is,
866 // checks in resolve_field_access() would not be executed for those instructions
867 // and the required IllegalAccessError would not be thrown.
868 //
869 // Also, we need to delay resolving getstatic and putstatic instructions until the
870 // class is initialized. This is required so that access to the static
871 // field will call the initialization function every time until the class
872 // is completely initialized ala. in 2.17.5 in JVM Specification.
873 InstanceKlass* klass = info.field_holder();
874 bool uninitialized_static = is_static && !klass->is_initialized();
875 bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&
876 info.has_initialized_final_update();
877 assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final");
878
879 Bytecodes::Code get_code = (Bytecodes::Code)0;
880 Bytecodes::Code put_code = (Bytecodes::Code)0;
881 if (!uninitialized_static) {
882 if (is_static) {
883 get_code = Bytecodes::_getstatic;
884 } else {
885 get_code = Bytecodes::_getfield;
886 }
887 if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) {
888 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
889 }
890 }
891
892 ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
893 entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile(),
894 info.is_flat(), info.is_null_free_inline_type(),
895 info.has_null_marker(), info.has_internal_null_marker());
896
897 entry->fill_in(info.field_holder(), info.offset(),
898 checked_cast<u2>(info.index()), checked_cast<u1>(state),
899 static_cast<u1>(get_code), static_cast<u1>(put_code));
900 }
901
902
903 //------------------------------------------------------------------------------------------------------------------------
904 // Synchronization
905 //
906 // The interpreter's synchronization code is factored out so that it can
907 // be shared by method invocation and synchronized blocks.
908 //%note synchronization_3
909
910 //%note monitor_1
911 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
912 assert(LockingMode != LM_LIGHTWEIGHT, "Should call monitorenter_obj() when using the new lightweight locking");
913 #ifdef ASSERT
914 current->last_frame().interpreter_frame_verify_monitor(elem);
915 #endif
916 Handle h_obj(current, elem->obj());
941 return;
942 JRT_END
943
944 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
945 oop obj = elem->obj();
946 assert(Universe::heap()->is_in(obj), "must be an object");
947 // The object could become unlocked through a JNI call, which we have no other checks for.
948 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
949 if (obj->is_unlocked()) {
950 if (CheckJNICalls) {
951 fatal("Object has been unlocked by JNI");
952 }
953 return;
954 }
955 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
956 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
957 // again at method exit or in the case of an exception.
958 elem->set_obj(nullptr);
959 JRT_END
960
961 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))
962 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
963 JRT_END
964
965 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* current))
966 // Returns an illegal exception to install into the current thread. The
967 // pending_exception flag is cleared so normal exception handling does not
968 // trigger. Any current installed exception will be overwritten. This
969 // method will be called during an exception unwind.
970
971 assert(!HAS_PENDING_EXCEPTION, "no pending exception");
972 Handle exception(current, current->vm_result());
973 assert(exception() != nullptr, "vm result should be set");
974 current->set_vm_result(nullptr); // clear vm result before continuing (may cause memory leaks and assert failures)
975 exception = get_preinitialized_exception(vmClasses::IllegalMonitorStateException_klass(), CATCH);
976 current->set_vm_result(exception());
977 JRT_END
978
979 JRT_ENTRY(void, InterpreterRuntime::throw_identity_exception(JavaThread* current, oopDesc* obj))
980 Klass* klass = cast_to_oop(obj)->klass();
981 ResourceMark rm(THREAD);
982 const char* desc = "Cannot synchronize on an instance of value class ";
983 const char* className = klass->external_name();
984 size_t msglen = strlen(desc) + strlen(className) + 1;
985 char* message = NEW_RESOURCE_ARRAY(char, msglen);
986 if (nullptr == message) {
987 // Out of memory: can't create detailed error message
988 THROW_MSG(vmSymbols::java_lang_IdentityException(), className);
989 } else {
990 jio_snprintf(message, msglen, "%s%s", desc, className);
991 THROW_MSG(vmSymbols::java_lang_IdentityException(), message);
992 }
993 JRT_END
994
995 //------------------------------------------------------------------------------------------------------------------------
996 // Invokes
997
998 JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* current, Method* method, address bcp))
999 return method->orig_bytecode_at(method->bci_from(bcp));
1000 JRT_END
1001
1002 JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code))
1003 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
1004 JRT_END
1005
1006 JRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* current, Method* method, address bcp))
1007 JvmtiExport::post_raw_breakpoint(current, method, bcp);
1008 JRT_END
1009
1010 void InterpreterRuntime::resolve_invoke(JavaThread* current, Bytecodes::Code bytecode) {
1011 LastFrameAccessor last_frame(current);
1012 // extract receiver from the outgoing argument list if necessary
1013 Handle receiver(current, nullptr);
1333 LastFrameAccessor last_frame(current);
1334 JvmtiExport::at_single_stepping_point(current, last_frame.method(), last_frame.bcp());
1335 }
1336 JRT_END
1337
1338 JRT_LEAF(void, InterpreterRuntime::at_unwind(JavaThread* current))
1339 assert(current == JavaThread::current(), "pre-condition");
1340 // This function is called by the interpreter when the return poll found a reason
1341 // to call the VM. The reason could be that we are returning into a not yet safe
1342 // to access frame. We handle that below.
1343 // Note that this path does not check for single stepping, because we do not want
1344 // to single step when unwinding frames for an exception being thrown. Instead,
1345 // such single stepping code will use the safepoint table, which will use the
1346 // InterpreterRuntime::at_safepoint callback.
1347 StackWatermarkSet::before_unwind(current);
1348 JRT_END
1349
1350 JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDesc* obj,
1351 ResolvedFieldEntry *entry))
1352
1353 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
1354 // check the access_flags for the field in the klass
1355
1356 InstanceKlass* ik = entry->field_holder();
1357 int index = entry->field_index();
1358 if (!ik->field_status(index).is_access_watched()) return;
1359
1360 bool is_static = (obj == nullptr);
1361 bool is_flat = entry->is_flat();
1362 HandleMark hm(current);
1363
1364 Handle h_obj;
1365 if (!is_static) {
1366 // non-static field accessors have an object, but we need a handle
1367 h_obj = Handle(current, obj);
1368 }
1369 InstanceKlass* field_holder = entry->field_holder(); // HERE
1370 jfieldID fid = jfieldIDWorkaround::to_jfieldID(field_holder, entry->field_offset(), is_static, is_flat);
1371 LastFrameAccessor last_frame(current);
1372 JvmtiExport::post_field_access(current, last_frame.method(), last_frame.bcp(), field_holder, h_obj, fid);
1373 JRT_END
1374
1375 JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread* current, oopDesc* obj,
1376 ResolvedFieldEntry *entry, jvalue *value))
1377
1378 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
1379 InstanceKlass* ik = entry->field_holder();
1380
1381 // check the access_flags for the field in the klass
1382 int index = entry->field_index();
1383 // bail out if field modifications are not watched
1384 if (!ik->field_status(index).is_modification_watched()) return;
1385
1386 char sig_type = '\0';
1387
1388 switch((TosState)entry->tos_state()) {
1389 case btos: sig_type = JVM_SIGNATURE_BYTE; break;
1390 case ztos: sig_type = JVM_SIGNATURE_BOOLEAN; break;
1391 case ctos: sig_type = JVM_SIGNATURE_CHAR; break;
1392 case stos: sig_type = JVM_SIGNATURE_SHORT; break;
1393 case itos: sig_type = JVM_SIGNATURE_INT; break;
1394 case ftos: sig_type = JVM_SIGNATURE_FLOAT; break;
1395 case atos: sig_type = JVM_SIGNATURE_CLASS; break;
1396 case ltos: sig_type = JVM_SIGNATURE_LONG; break;
1397 case dtos: sig_type = JVM_SIGNATURE_DOUBLE; break;
1398 default: ShouldNotReachHere(); return;
1399 }
1400
1401 bool is_static = (obj == nullptr);
1402 bool is_flat = entry->is_flat();
1403
1404 HandleMark hm(current);
1405 jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, entry->field_offset(), is_static, is_flat);
1406 jvalue fvalue;
1407 #ifdef _LP64
1408 fvalue = *value;
1409 #else
1410 // Long/double values are stored unaligned and also noncontiguously with
1411 // tagged stacks. We can't just do a simple assignment even in the non-
1412 // J/D cases because a C++ compiler is allowed to assume that a jvalue is
1413 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned.
1414 // We assume that the two halves of longs/doubles are stored in interpreter
1415 // stack slots in platform-endian order.
1416 jlong_accessor u;
1417 jint* newval = (jint*)value;
1418 u.words[0] = newval[0];
1419 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag
1420 fvalue.j = u.long_value;
1421 #endif // _LP64
1422
1423 Handle h_obj;
1424 if (!is_static) {
1425 // non-static field accessors have an object, but we need a handle
|