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 if (!field_k->is_inline_klass()) {
263 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
264 err_msg("class %s expects class %s to be a concrete value class but it is not",
265 klass->name()->as_C_string(), field_k->external_name()));
266 }
267 InlineLayoutInfo* li = klass->inline_layout_info_adr(index);
268 li->set_klass(InlineKlass::cast(field_k));
269 li->set_kind(LayoutKind::REFERENCE);
270 }
271 field_k->initialize(CHECK);
272 oop defaultvalue = InlineKlass::cast(field_k)->default_value();
273 // It is safe to initialize the static field because 1) the current thread is the initializing thread
274 // and is the only one that can access it, and 2) the field is actually not initialized (i.e. null)
275 // otherwise the JVM should not be executing this code.
276 mirror_h()->obj_field_put(offset, defaultvalue);
277 current->set_vm_result(defaultvalue);
278 } else {
279 assert(klass->is_in_error_state(), "If not initializing, initialization must have failed to get there");
280 ResourceMark rm(THREAD);
281 const char* desc = "Could not initialize class ";
282 const char* className = klass->external_name();
283 size_t msglen = strlen(desc) + strlen(className) + 1;
284 char* message = NEW_RESOURCE_ARRAY(char, msglen);
285 if (nullptr == message) {
286 // Out of memory: can't create detailed error message
287 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), className);
288 } else {
289 jio_snprintf(message, msglen, "%s%s", desc, className);
290 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), message);
291 }
292 }
293 JRT_END
294
295 JRT_ENTRY(void, InterpreterRuntime::read_flat_field(JavaThread* current, oopDesc* obj, ResolvedFieldEntry* entry))
296 assert(oopDesc::is_oop(obj), "Sanity check");
297 Handle obj_h(THREAD, obj);
298
299 InstanceKlass* holder = InstanceKlass::cast(entry->field_holder());
300 assert(entry->field_holder()->field_is_flat(entry->field_index()), "Sanity check");
301
302 InlineLayoutInfo* layout_info = holder->inline_layout_info_adr(entry->field_index());
303 InlineKlass* field_vklass = layout_info->klass();
304
305 oop res = field_vklass->read_flat_field(obj_h(), entry->field_offset(), layout_info->kind(), CHECK);
306 current->set_vm_result(res);
307 JRT_END
308
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* holder = entry->field_holder();
315 int field_index = entry->field_index();
316 InlineLayoutInfo* li= holder->inline_layout_info_adr(field_index);
317
318 int nm_offset = li->null_marker_offset();
319 if (obj_h()->byte_field_acquire(nm_offset) == 0) {
320 current->set_vm_result(nullptr);
321 } else {
322 InlineKlass* field_vklass = InlineKlass::cast(li->klass());
323 oop res = field_vklass->read_flat_field(obj_h(), entry->field_offset(), LayoutKind::NULLABLE_ATOMIC_FLAT, CHECK);
324 current->set_vm_result(res);
325 }
326 JRT_END
327
328 JRT_ENTRY(void, InterpreterRuntime::write_nullable_flat_field(JavaThread* current, oopDesc* obj, oopDesc* value, ResolvedFieldEntry* entry))
329 assert(oopDesc::is_oop(obj), "Sanity check");
330 Handle obj_h(THREAD, obj);
331 assert(value == nullptr || oopDesc::is_oop(value), "Sanity check");
332 Handle val_h(THREAD, value);
333
334 InstanceKlass* holder = entry->field_holder();
335 InlineLayoutInfo* li = holder->inline_layout_info_adr(entry->field_index());
336 InlineKlass* vk = li->klass();
337 assert(li->kind() == LayoutKind::NULLABLE_ATOMIC_FLAT, "Must be");
338 int nm_offset = li->null_marker_offset();
339
340 if (val_h() == nullptr) {
341 if(li->klass()->nonstatic_oop_count() == 0) {
342 // No embedded oops, just reset the null marker
343 obj_h()->byte_field_put(nm_offset, (jbyte)0);
344 } else {
345 // Has embedded oops, using the reset value to rewrite all fields to null/zeros
346 assert(li->klass()->null_reset_value()->byte_field(vk->null_marker_offset()) == 0, "reset value must always have a null marker set to 0");
347 vk->inline_copy_oop_to_payload(vk->null_reset_value(), ((char*)(oopDesc*)obj_h()) + entry->field_offset(), li->kind());
348 }
349 return;
350 }
351
352 assert(val_h()->klass() == vk, "Must match because flat fields are monomorphic");
353 // The interpreter copies values with a bulk operation
354 // To avoid accidentally setting the null marker to "null" during
355 // the copying, the null marker is set to non zero in the source object
356 if (val_h()->byte_field(vk->null_marker_offset()) == 0) {
357 val_h()->byte_field_put(vk->null_marker_offset(), (jbyte)1);
358 }
359 vk->inline_copy_oop_to_payload(val_h(), ((char*)(oopDesc*)obj_h()) + entry->field_offset(), li->kind());
360 JRT_END
361
362 JRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* current, BasicType type, jint size))
363 oop obj = oopFactory::new_typeArray(type, size, CHECK);
364 current->set_vm_result(obj);
365 JRT_END
366
367
368 JRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* current, ConstantPool* pool, int index, jint size))
369 Klass* klass = pool->klass_at(index, CHECK);
370 arrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
371 current->set_vm_result(obj);
372 JRT_END
373
374 JRT_ENTRY(void, InterpreterRuntime::value_array_load(JavaThread* current, arrayOopDesc* array, int index))
375 flatArrayHandle vah(current, (flatArrayOop)array);
376 oop value_holder = flatArrayOopDesc::value_alloc_copy_from_index(vah, index, CHECK);
377 current->set_vm_result(value_holder);
378 JRT_END
379
380 JRT_ENTRY(void, InterpreterRuntime::value_array_store(JavaThread* current, void* val, arrayOopDesc* array, int index))
381 assert(val != nullptr, "can't store null into flat array");
382 ((flatArrayOop)array)->value_copy_to_index(cast_to_oop(val), index, LayoutKind::PAYLOAD); // Non atomic is the only layout currently supported by flat arrays
383 JRT_END
384
385 JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* current, jint* first_size_address))
386 // We may want to pass in more arguments - could make this slightly faster
387 LastFrameAccessor last_frame(current);
388 ConstantPool* constants = last_frame.method()->constants();
389 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
390 Klass* klass = constants->klass_at(i, CHECK);
391 int nof_dims = last_frame.number_of_dimensions();
392 assert(klass->is_klass(), "not a class");
393 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
394
395 // We must create an array of jints to pass to multi_allocate.
396 ResourceMark rm(current);
397 const int small_dims = 10;
398 jint dim_array[small_dims];
399 jint *dims = &dim_array[0];
400 if (nof_dims > small_dims) {
401 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
402 }
403 for (int index = 0; index < nof_dims; index++) {
404 // offset from first_size_address is addressed as local[index]
405 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
406 dims[index] = first_size_address[n];
407 }
408 oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
409 current->set_vm_result(obj);
410 JRT_END
411
412
413 JRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* current, oopDesc* obj))
414 assert(oopDesc::is_oop(obj), "must be a valid oop");
415 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
416 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
417 JRT_END
418
419 JRT_ENTRY(jboolean, InterpreterRuntime::is_substitutable(JavaThread* current, oopDesc* aobj, oopDesc* bobj))
420 assert(oopDesc::is_oop(aobj) && oopDesc::is_oop(bobj), "must be valid oops");
421
422 Handle ha(THREAD, aobj);
423 Handle hb(THREAD, bobj);
424 JavaValue result(T_BOOLEAN);
425 JavaCallArguments args;
426 args.push_oop(ha);
427 args.push_oop(hb);
428 methodHandle method(current, Universe::is_substitutable_method());
429 method->method_holder()->initialize(CHECK_false); // Ensure class ValueObjectMethods is initialized
430 JavaCalls::call(&result, method, &args, THREAD);
431 if (HAS_PENDING_EXCEPTION) {
432 // Something really bad happened because isSubstitutable() should not throw exceptions
433 // If it is an error, just let it propagate
434 // If it is an exception, wrap it into an InternalError
435 if (!PENDING_EXCEPTION->is_a(vmClasses::Error_klass())) {
436 Handle e(THREAD, PENDING_EXCEPTION);
437 CLEAR_PENDING_EXCEPTION;
438 THROW_MSG_CAUSE_(vmSymbols::java_lang_InternalError(), "Internal error in substitutability test", e, false);
439 }
440 }
441 return result.get_jboolean();
442 JRT_END
443
444 // Quicken instance-of and check-cast bytecodes
445 JRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* current))
446 // Force resolving; quicken the bytecode
447 LastFrameAccessor last_frame(current);
448 int which = last_frame.get_index_u2(Bytecodes::_checkcast);
449 ConstantPool* cpool = last_frame.method()->constants();
450 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded
451 // program we might have seen an unquick'd bytecode in the interpreter but have another
452 // thread quicken the bytecode before we get here.
453 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
454 Klass* klass = cpool->klass_at(which, CHECK);
455 current->set_vm_result_2(klass);
456 JRT_END
457
458
459 //------------------------------------------------------------------------------------------------------------------------
460 // Exceptions
461
462 void InterpreterRuntime::note_trap_inner(JavaThread* current, int reason,
766 // and therefore we don't have the receiver object at our fingertips. (Though,
767 // on some platforms the receiver still resides in a register...). Thus,
768 // we have no choice but print an error message not containing the receiver
769 // type.
770 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* current,
771 Method* missingMethod))
772 ResourceMark rm(current);
773 assert(missingMethod != nullptr, "sanity");
774 methodHandle m(current, missingMethod);
775 LinkResolver::throw_abstract_method_error(m, THREAD);
776 JRT_END
777
778 JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* current,
779 Klass* recvKlass,
780 Method* missingMethod))
781 ResourceMark rm(current);
782 methodHandle mh = methodHandle(current, missingMethod);
783 LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
784 JRT_END
785
786 JRT_ENTRY(void, InterpreterRuntime::throw_InstantiationError(JavaThread* current))
787 THROW(vmSymbols::java_lang_InstantiationError());
788 JRT_END
789
790
791 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* current))
792 THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
793 JRT_END
794
795 JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* current,
796 Klass* recvKlass,
797 Klass* interfaceKlass))
798 ResourceMark rm(current);
799 char buf[1000];
800 buf[0] = '\0';
801 jio_snprintf(buf, sizeof(buf),
802 "Class %s does not implement the requested interface %s",
803 recvKlass ? recvKlass->external_name() : "nullptr",
804 interfaceKlass ? interfaceKlass->external_name() : "nullptr");
805 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
806 JRT_END
807
808 JRT_ENTRY(void, InterpreterRuntime::throw_NullPointerException(JavaThread* current))
809 THROW(vmSymbols::java_lang_NullPointerException());
854 // initializer method <init>. If resolution were not inhibited, a putfield
855 // in an initializer method could be resolved in the initializer. Subsequent
856 // putfield instructions to the same field would then use cached information.
857 // As a result, those instructions would not pass through the VM. That is,
858 // checks in resolve_field_access() would not be executed for those instructions
859 // and the required IllegalAccessError would not be thrown.
860 //
861 // Also, we need to delay resolving getstatic and putstatic instructions until the
862 // class is initialized. This is required so that access to the static
863 // field will call the initialization function every time until the class
864 // is completely initialized ala. in 2.17.5 in JVM Specification.
865 InstanceKlass* klass = info.field_holder();
866 bool uninitialized_static = is_static && !klass->is_initialized();
867 bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&
868 info.has_initialized_final_update();
869 assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final");
870
871 Bytecodes::Code get_code = (Bytecodes::Code)0;
872 Bytecodes::Code put_code = (Bytecodes::Code)0;
873 if (!uninitialized_static) {
874 if (is_static) {
875 get_code = Bytecodes::_getstatic;
876 } else {
877 get_code = Bytecodes::_getfield;
878 }
879 if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) {
880 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
881 }
882 }
883
884 ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
885 entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile(),
886 info.is_flat(), info.is_null_free_inline_type(),
887 info.has_null_marker());
888
889 entry->fill_in(info.field_holder(), info.offset(),
890 checked_cast<u2>(info.index()), checked_cast<u1>(state),
891 static_cast<u1>(get_code), static_cast<u1>(put_code));
892 }
893
894
895 //------------------------------------------------------------------------------------------------------------------------
896 // Synchronization
897 //
898 // The interpreter's synchronization code is factored out so that it can
899 // be shared by method invocation and synchronized blocks.
900 //%note synchronization_3
901
902 //%note monitor_1
903 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
904 #ifdef ASSERT
905 current->last_frame().interpreter_frame_verify_monitor(elem);
906 #endif
907 Handle h_obj(current, elem->obj());
908 assert(Universe::heap()->is_in_or_null(h_obj()),
915 #endif
916 JRT_END
917
918 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
919 oop obj = elem->obj();
920 assert(Universe::heap()->is_in(obj), "must be an object");
921 // The object could become unlocked through a JNI call, which we have no other checks for.
922 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
923 if (obj->is_unlocked()) {
924 if (CheckJNICalls) {
925 fatal("Object has been unlocked by JNI");
926 }
927 return;
928 }
929 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
930 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
931 // again at method exit or in the case of an exception.
932 elem->set_obj(nullptr);
933 JRT_END
934
935 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* current))
936 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
937 JRT_END
938
939 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* current))
940 // Returns an illegal exception to install into the current thread. The
941 // pending_exception flag is cleared so normal exception handling does not
942 // trigger. Any current installed exception will be overwritten. This
943 // method will be called during an exception unwind.
944
945 assert(!HAS_PENDING_EXCEPTION, "no pending exception");
946 Handle exception(current, current->vm_result());
947 assert(exception() != nullptr, "vm result should be set");
948 current->set_vm_result(nullptr); // clear vm result before continuing (may cause memory leaks and assert failures)
949 exception = get_preinitialized_exception(vmClasses::IllegalMonitorStateException_klass(), CATCH);
950 current->set_vm_result(exception());
951 JRT_END
952
953 JRT_ENTRY(void, InterpreterRuntime::throw_identity_exception(JavaThread* current, oopDesc* obj))
954 Klass* klass = cast_to_oop(obj)->klass();
955 ResourceMark rm(THREAD);
956 const char* desc = "Cannot synchronize on an instance of value class ";
957 const char* className = klass->external_name();
958 size_t msglen = strlen(desc) + strlen(className) + 1;
959 char* message = NEW_RESOURCE_ARRAY(char, msglen);
960 if (nullptr == message) {
961 // Out of memory: can't create detailed error message
962 THROW_MSG(vmSymbols::java_lang_IdentityException(), className);
963 } else {
964 jio_snprintf(message, msglen, "%s%s", desc, className);
965 THROW_MSG(vmSymbols::java_lang_IdentityException(), message);
966 }
967 JRT_END
968
969 //------------------------------------------------------------------------------------------------------------------------
970 // Invokes
971
972 JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* current, Method* method, address bcp))
973 return method->orig_bytecode_at(method->bci_from(bcp));
974 JRT_END
975
976 JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code))
977 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
978 JRT_END
979
980 JRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* current, Method* method, address bcp))
981 JvmtiExport::post_raw_breakpoint(current, method, bcp);
982 JRT_END
983
984 void InterpreterRuntime::resolve_invoke(JavaThread* current, Bytecodes::Code bytecode) {
985 LastFrameAccessor last_frame(current);
986 // extract receiver from the outgoing argument list if necessary
987 Handle receiver(current, nullptr);
1340 LastFrameAccessor last_frame(current);
1341 JvmtiExport::at_single_stepping_point(current, last_frame.method(), last_frame.bcp());
1342 }
1343 JRT_END
1344
1345 JRT_LEAF(void, InterpreterRuntime::at_unwind(JavaThread* current))
1346 assert(current == JavaThread::current(), "pre-condition");
1347 // This function is called by the interpreter when the return poll found a reason
1348 // to call the VM. The reason could be that we are returning into a not yet safe
1349 // to access frame. We handle that below.
1350 // Note that this path does not check for single stepping, because we do not want
1351 // to single step when unwinding frames for an exception being thrown. Instead,
1352 // such single stepping code will use the safepoint table, which will use the
1353 // InterpreterRuntime::at_safepoint callback.
1354 StackWatermarkSet::before_unwind(current);
1355 JRT_END
1356
1357 JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread* current, oopDesc* obj,
1358 ResolvedFieldEntry *entry))
1359
1360 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
1361 // check the access_flags for the field in the klass
1362
1363 InstanceKlass* ik = entry->field_holder();
1364 int index = entry->field_index();
1365 if (!ik->field_status(index).is_access_watched()) return;
1366
1367 bool is_static = (obj == nullptr);
1368 bool is_flat = entry->is_flat();
1369 HandleMark hm(current);
1370
1371 Handle h_obj;
1372 if (!is_static) {
1373 // non-static field accessors have an object, but we need a handle
1374 h_obj = Handle(current, obj);
1375 }
1376 InstanceKlass* field_holder = entry->field_holder(); // HERE
1377 jfieldID fid = jfieldIDWorkaround::to_jfieldID(field_holder, entry->field_offset(), is_static, is_flat);
1378 LastFrameAccessor last_frame(current);
1379 JvmtiExport::post_field_access(current, last_frame.method(), last_frame.bcp(), field_holder, h_obj, fid);
1380 JRT_END
1381
1382 JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread* current, oopDesc* obj,
1383 ResolvedFieldEntry *entry, jvalue *value))
1384
1385 assert(entry->is_valid(), "Invalid ResolvedFieldEntry");
1386 InstanceKlass* ik = entry->field_holder();
1387
1388 // check the access_flags for the field in the klass
1389 int index = entry->field_index();
1390 // bail out if field modifications are not watched
1391 if (!ik->field_status(index).is_modification_watched()) return;
1392
1393 char sig_type = '\0';
1394
1395 switch((TosState)entry->tos_state()) {
1396 case btos: sig_type = JVM_SIGNATURE_BYTE; break;
1397 case ztos: sig_type = JVM_SIGNATURE_BOOLEAN; break;
1398 case ctos: sig_type = JVM_SIGNATURE_CHAR; break;
1399 case stos: sig_type = JVM_SIGNATURE_SHORT; break;
1400 case itos: sig_type = JVM_SIGNATURE_INT; break;
1401 case ftos: sig_type = JVM_SIGNATURE_FLOAT; break;
1402 case atos: sig_type = JVM_SIGNATURE_CLASS; break;
1403 case ltos: sig_type = JVM_SIGNATURE_LONG; break;
1404 case dtos: sig_type = JVM_SIGNATURE_DOUBLE; break;
1405 default: ShouldNotReachHere(); return;
1406 }
1407
1408 bool is_static = (obj == nullptr);
1409 bool is_flat = entry->is_flat();
1410
1411 HandleMark hm(current);
1412 jfieldID fid = jfieldIDWorkaround::to_jfieldID(ik, entry->field_offset(), is_static, is_flat);
1413 jvalue fvalue;
1414 #ifdef _LP64
1415 fvalue = *value;
1416 #else
1417 // Long/double values are stored unaligned and also noncontiguously with
1418 // tagged stacks. We can't just do a simple assignment even in the non-
1419 // J/D cases because a C++ compiler is allowed to assume that a jvalue is
1420 // 8-byte aligned, and interpreter stack slots are only 4-byte aligned.
1421 // We assume that the two halves of longs/doubles are stored in interpreter
1422 // stack slots in platform-endian order.
1423 jlong_accessor u;
1424 jint* newval = (jint*)value;
1425 u.words[0] = newval[0];
1426 u.words[1] = newval[Interpreter::stackElementWords]; // skip if tag
1427 fvalue.j = u.long_value;
1428 #endif // _LP64
1429
1430 Handle h_obj;
1431 if (!is_static) {
1432 // non-static field accessors have an object, but we need a handle
|