1 /*
2 * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 "classfile/classFileStream.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/classLoadInfo.hpp"
28 #include "classfile/javaClasses.inline.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "jfr/jfrEvents.hpp"
32 #include "jni.h"
33 #include "jvm.h"
34 #include "memory/allocation.inline.hpp"
35 #include "memory/resourceArea.hpp"
36 #include "oops/access.inline.hpp"
37 #include "oops/fieldStreams.inline.hpp"
38 #include "oops/instanceKlass.inline.hpp"
39 #include "oops/klass.inline.hpp"
40 #include "oops/objArrayOop.inline.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "oops/typeArrayOop.inline.hpp"
43 #include "prims/jvmtiExport.hpp"
44 #include "prims/unsafe.hpp"
45 #include "runtime/globals.hpp"
46 #include "runtime/handles.inline.hpp"
47 #include "runtime/interfaceSupport.inline.hpp"
48 #include "runtime/javaThread.inline.hpp"
49 #include "runtime/jniHandles.inline.hpp"
50 #include "runtime/orderAccess.hpp"
51 #include "runtime/reflection.hpp"
52 #include "runtime/sharedRuntime.hpp"
53 #include "runtime/stubRoutines.hpp"
54 #include "runtime/threadSMR.hpp"
55 #include "runtime/vm_version.hpp"
56 #include "runtime/vmOperations.hpp"
57 #include "sanitizers/ub.hpp"
58 #include "services/threadService.hpp"
59 #include "utilities/align.hpp"
60 #include "utilities/copy.hpp"
61 #include "utilities/dtrace.hpp"
62 #include "utilities/macros.hpp"
63
64 /**
230 jboolean normalize_for_read(jboolean x) {
231 return x != 0;
232 }
233
234 public:
235 MemoryAccess(JavaThread* thread, jobject obj, jlong offset)
236 : _thread(thread), _obj(JNIHandles::resolve(obj)), _offset((ptrdiff_t)offset) {
237 assert_field_offset_sane(_obj, offset);
238 }
239
240 T get() {
241 GuardUnsafeAccess guard(_thread);
242 return normalize_for_read(*addr());
243 }
244
245 // we use this method at some places for writing to 0 e.g. to cause a crash;
246 // ubsan does not know that this is the desired behavior
247 ATTRIBUTE_NO_UBSAN
248 void put(T x) {
249 GuardUnsafeAccess guard(_thread);
250 *addr() = normalize_for_write(x);
251 }
252
253
254 T get_volatile() {
255 GuardUnsafeAccess guard(_thread);
256 volatile T ret = RawAccess<MO_SEQ_CST>::load(addr());
257 return normalize_for_read(ret);
258 }
259
260 void put_volatile(T x) {
261 GuardUnsafeAccess guard(_thread);
262 RawAccess<MO_SEQ_CST>::store(addr(), normalize_for_write(x));
263 }
264 };
265
266 // These functions allow a null base pointer with an arbitrary address.
267 // But if the base pointer is non-null, the offset should make some sense.
268 // That is, it should be in the range [0, MAX_OBJECT_SIZE].
269 UNSAFE_ENTRY(jobject, Unsafe_GetReference(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
270 oop p = JNIHandles::resolve(obj);
271 assert_field_offset_sane(p, offset);
272 oop v = HeapAccess<ON_UNKNOWN_OOP_REF>::oop_load_at(p, offset);
273 return JNIHandles::make_local(THREAD, v);
274 } UNSAFE_END
275
276 UNSAFE_ENTRY(void, Unsafe_PutReference(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
277 oop x = JNIHandles::resolve(x_h);
278 oop p = JNIHandles::resolve(obj);
279 assert_field_offset_sane(p, offset);
280 HeapAccess<ON_UNKNOWN_OOP_REF>::oop_store_at(p, offset, x);
281 } UNSAFE_END
282
283 UNSAFE_ENTRY(jobject, Unsafe_GetReferenceVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
284 oop p = JNIHandles::resolve(obj);
285 assert_field_offset_sane(p, offset);
286 oop v = HeapAccess<MO_SEQ_CST | ON_UNKNOWN_OOP_REF>::oop_load_at(p, offset);
287 return JNIHandles::make_local(THREAD, v);
288 } UNSAFE_END
289
290 UNSAFE_ENTRY(void, Unsafe_PutReferenceVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
291 oop x = JNIHandles::resolve(x_h);
292 oop p = JNIHandles::resolve(obj);
293 assert_field_offset_sane(p, offset);
294 HeapAccess<MO_SEQ_CST | ON_UNKNOWN_OOP_REF>::oop_store_at(p, offset, x);
295 } UNSAFE_END
296
297 UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe, jlong addr)) {
298 oop v = *(oop*) (address) addr;
299 return JNIHandles::make_local(THREAD, v);
300 } UNSAFE_END
301
302 #define DEFINE_GETSETOOP(java_type, Type) \
573 InstanceKlass* k = InstanceKlass::cast(klass);
574 k->initialize(CHECK);
575 }
576 }
577 UNSAFE_END
578
579 UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized0(JNIEnv *env, jobject unsafe, jobject clazz)) {
580 assert(clazz != nullptr, "clazz must not be null");
581
582 oop mirror = JNIHandles::resolve_non_null(clazz);
583 Klass* klass = java_lang_Class::as_Klass(mirror);
584
585 if (klass != nullptr && klass->should_be_initialized()) {
586 return true;
587 }
588
589 return false;
590 }
591 UNSAFE_END
592
593 static void getBaseAndScale(int& base, int& scale, jclass clazz, TRAPS) {
594 assert(clazz != nullptr, "clazz must not be null");
595
596 oop mirror = JNIHandles::resolve_non_null(clazz);
597 Klass* k = java_lang_Class::as_Klass(mirror);
598
599 if (k == nullptr || !k->is_array_klass()) {
600 THROW(vmSymbols::java_lang_InvalidClassException());
601 } else if (k->is_objArray_klass()) {
602 base = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
603 scale = heapOopSize;
604 } else if (k->is_typeArray_klass()) {
605 TypeArrayKlass* tak = TypeArrayKlass::cast(k);
606 base = tak->array_header_in_bytes();
607 assert(base == arrayOopDesc::base_offset_in_bytes(tak->element_type()), "array_header_size semantics ok");
608 scale = (1 << tak->log2_element_size());
609 } else {
610 ShouldNotReachHere();
611 }
612 }
613
614 UNSAFE_ENTRY(jint, Unsafe_ArrayBaseOffset0(JNIEnv *env, jobject unsafe, jclass clazz)) {
615 int base = 0, scale = 0;
616 getBaseAndScale(base, scale, clazz, CHECK_0);
617
618 return field_offset_from_byte_offset(base);
619 } UNSAFE_END
620
621
622 UNSAFE_ENTRY(jint, Unsafe_ArrayIndexScale0(JNIEnv *env, jobject unsafe, jclass clazz)) {
623 int base = 0, scale = 0;
624 getBaseAndScale(base, scale, clazz, CHECK_0);
625
626 // This VM packs both fields and array elements down to the byte.
627 // But watch out: If this changes, so that array references for
628 // a given primitive type (say, T_BOOLEAN) use different memory units
629 // than fields, this method MUST return zero for such arrays.
630 // For example, the VM used to store sub-word sized fields in full
631 // words in the object layout, so that accessors like getByte(Object,int)
632 // did not really do what one might expect for arrays. Therefore,
633 // this function used to report a zero scale factor, so that the user
634 // would know not to attempt to access sub-word array elements.
635 // // Code for unpacked fields:
636 // if (scale < wordSize) return 0;
637
638 // The following allows for a pretty general fieldOffset cookie scheme,
639 // but requires it to be linear in byte offset.
640 return field_offset_from_byte_offset(scale) - field_offset_from_byte_offset(0);
641 } UNSAFE_END
642
643
644 static inline void throw_new(JNIEnv *env, const char *ename) {
645 jclass cls = env->FindClass(ename);
646 if (env->ExceptionCheck()) {
647 env->ExceptionClear();
648 tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", ename);
649 return;
650 }
651
652 env->ThrowNew(cls, nullptr);
653 }
654
655 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) {
656 // Code lifted from JDK 1.3 ClassLoader.c
657
658 jbyte *body;
659 char *utfName = nullptr;
660 jclass result = nullptr;
661 char buf[128];
662
836 case 3: a->double_at_put(2, (jdouble)la[2]); // fall through
837 case 2: a->double_at_put(1, (jdouble)la[1]); // fall through
838 case 1: a->double_at_put(0, (jdouble)la[0]); break;
839 }
840
841 return ret;
842 } UNSAFE_END
843
844
845 /// JVM_RegisterUnsafeMethods
846
847 #define ADR "J"
848
849 #define LANG "Ljava/lang/"
850
851 #define OBJ LANG "Object;"
852 #define CLS LANG "Class;"
853 #define FLD LANG "reflect/Field;"
854 #define THR LANG "Throwable;"
855
856 #define DC_Args LANG "String;[BII" LANG "ClassLoader;" "Ljava/security/ProtectionDomain;"
857 #define DAC_Args CLS "[B[" OBJ
858
859 #define CC (char*) /*cast a literal from (const char*)*/
860 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
861
862 #define DECLARE_GETPUTOOP(Type, Desc) \
863 {CC "get" #Type, CC "(" OBJ "J)" #Desc, FN_PTR(Unsafe_Get##Type)}, \
864 {CC "put" #Type, CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Put##Type)}, \
865 {CC "get" #Type "Volatile", CC "(" OBJ "J)" #Desc, FN_PTR(Unsafe_Get##Type##Volatile)}, \
866 {CC "put" #Type "Volatile", CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Put##Type##Volatile)}
867
868
869 static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = {
870 {CC "getReference", CC "(" OBJ "J)" OBJ "", FN_PTR(Unsafe_GetReference)},
871 {CC "putReference", CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutReference)},
872 {CC "getReferenceVolatile", CC "(" OBJ "J)" OBJ, FN_PTR(Unsafe_GetReferenceVolatile)},
873 {CC "putReferenceVolatile", CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutReferenceVolatile)},
874
875 {CC "getUncompressedObject", CC "(" ADR ")" OBJ, FN_PTR(Unsafe_GetUncompressedObject)},
876
877 DECLARE_GETPUTOOP(Boolean, Z),
878 DECLARE_GETPUTOOP(Byte, B),
879 DECLARE_GETPUTOOP(Short, S),
880 DECLARE_GETPUTOOP(Char, C),
881 DECLARE_GETPUTOOP(Int, I),
882 DECLARE_GETPUTOOP(Long, J),
883 DECLARE_GETPUTOOP(Float, F),
884 DECLARE_GETPUTOOP(Double, D),
885
886 {CC "allocateMemory0", CC "(J)" ADR, FN_PTR(Unsafe_AllocateMemory0)},
887 {CC "reallocateMemory0", CC "(" ADR "J)" ADR, FN_PTR(Unsafe_ReallocateMemory0)},
888 {CC "freeMemory0", CC "(" ADR ")V", FN_PTR(Unsafe_FreeMemory0)},
889
890 {CC "objectFieldOffset0", CC "(" FLD ")J", FN_PTR(Unsafe_ObjectFieldOffset0)},
891 {CC "knownObjectFieldOffset0", CC "(" CLS LANG "String;)J", FN_PTR(Unsafe_KnownObjectFieldOffset0)},
892 {CC "staticFieldOffset0", CC "(" FLD ")J", FN_PTR(Unsafe_StaticFieldOffset0)},
893 {CC "staticFieldBase0", CC "(" FLD ")" OBJ, FN_PTR(Unsafe_StaticFieldBase0)},
894 {CC "ensureClassInitialized0", CC "(" CLS ")V", FN_PTR(Unsafe_EnsureClassInitialized0)},
895 {CC "arrayBaseOffset0", CC "(" CLS ")I", FN_PTR(Unsafe_ArrayBaseOffset0)},
896 {CC "arrayIndexScale0", CC "(" CLS ")I", FN_PTR(Unsafe_ArrayIndexScale0)},
897
898 {CC "defineClass0", CC "(" DC_Args ")" CLS, FN_PTR(Unsafe_DefineClass0)},
899 {CC "allocateInstance", CC "(" CLS ")" OBJ, FN_PTR(Unsafe_AllocateInstance)},
900 {CC "throwException", CC "(" THR ")V", FN_PTR(Unsafe_ThrowException)},
901 {CC "compareAndSetReference",CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSetReference)},
902 {CC "compareAndSetInt", CC "(" OBJ "J""I""I"")Z", FN_PTR(Unsafe_CompareAndSetInt)},
903 {CC "compareAndSetLong", CC "(" OBJ "J""J""J"")Z", FN_PTR(Unsafe_CompareAndSetLong)},
904 {CC "compareAndExchangeReference", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeReference)},
905 {CC "compareAndExchangeInt", CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)},
906 {CC "compareAndExchangeLong", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)},
907
908 {CC "park", CC "(ZJ)V", FN_PTR(Unsafe_Park)},
909 {CC "unpark", CC "(" OBJ ")V", FN_PTR(Unsafe_Unpark)},
910
911 {CC "getLoadAverage0", CC "([DI)I", FN_PTR(Unsafe_GetLoadAverage0)},
912
913 {CC "copyMemory0", CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory0)},
914 {CC "copySwapMemory0", CC "(" OBJ "J" OBJ "JJJ)V", FN_PTR(Unsafe_CopySwapMemory0)},
915 {CC "writeback0", CC "(" "J" ")V", FN_PTR(Unsafe_WriteBack0)},
916 {CC "writebackPreSync0", CC "()V", FN_PTR(Unsafe_WriteBackPreSync0)},
917 {CC "writebackPostSync0", CC "()V", FN_PTR(Unsafe_WriteBackPostSync0)},
918 {CC "setMemory0", CC "(" OBJ "JJB)V", FN_PTR(Unsafe_SetMemory0)},
919
920 {CC "shouldBeInitialized0", CC "(" CLS ")Z", FN_PTR(Unsafe_ShouldBeInitialized0)},
921
922 {CC "fullFence", CC "()V", FN_PTR(Unsafe_FullFence)},
923 };
924
925 #undef CC
926 #undef FN_PTR
927
928 #undef ADR
929 #undef LANG
930 #undef OBJ
931 #undef CLS
932 #undef FLD
933 #undef THR
934 #undef DC_Args
935 #undef DAC_Args
936
937 #undef DECLARE_GETPUTOOP
938
939
940 // This function is exported, used by NativeLookup.
|
1 /*
2 * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 "classfile/classFileStream.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/classLoadInfo.hpp"
28 #include "classfile/javaClasses.inline.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "jfr/jfrEvents.hpp"
32 #include "jni.h"
33 #include "jvm.h"
34 #include "logging/log.hpp"
35 #include "logging/logStream.hpp"
36 #include "memory/allocation.inline.hpp"
37 #include "memory/oopFactory.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "oops/access.inline.hpp"
40 #include "oops/fieldStreams.inline.hpp"
41 #include "oops/flatArrayKlass.hpp"
42 #include "oops/flatArrayOop.inline.hpp"
43 #include "oops/inlineKlass.inline.hpp"
44 #include "oops/instanceKlass.inline.hpp"
45 #include "oops/klass.inline.hpp"
46 #include "oops/objArrayOop.inline.hpp"
47 #include "oops/oop.inline.hpp"
48 #include "oops/oopCast.inline.hpp"
49 #include "oops/typeArrayOop.inline.hpp"
50 #include "oops/valuePayload.hpp"
51 #include "prims/jvmtiExport.hpp"
52 #include "prims/unsafe.hpp"
53 #include "runtime/fieldDescriptor.inline.hpp"
54 #include "runtime/globals.hpp"
55 #include "runtime/handles.inline.hpp"
56 #include "runtime/interfaceSupport.inline.hpp"
57 #include "runtime/javaThread.inline.hpp"
58 #include "runtime/jniHandles.inline.hpp"
59 #include "runtime/orderAccess.hpp"
60 #include "runtime/reflection.hpp"
61 #include "runtime/sharedRuntime.hpp"
62 #include "runtime/stubRoutines.hpp"
63 #include "runtime/threadSMR.hpp"
64 #include "runtime/vm_version.hpp"
65 #include "runtime/vmOperations.hpp"
66 #include "sanitizers/ub.hpp"
67 #include "services/threadService.hpp"
68 #include "utilities/align.hpp"
69 #include "utilities/copy.hpp"
70 #include "utilities/dtrace.hpp"
71 #include "utilities/macros.hpp"
72
73 /**
239 jboolean normalize_for_read(jboolean x) {
240 return x != 0;
241 }
242
243 public:
244 MemoryAccess(JavaThread* thread, jobject obj, jlong offset)
245 : _thread(thread), _obj(JNIHandles::resolve(obj)), _offset((ptrdiff_t)offset) {
246 assert_field_offset_sane(_obj, offset);
247 }
248
249 T get() {
250 GuardUnsafeAccess guard(_thread);
251 return normalize_for_read(*addr());
252 }
253
254 // we use this method at some places for writing to 0 e.g. to cause a crash;
255 // ubsan does not know that this is the desired behavior
256 ATTRIBUTE_NO_UBSAN
257 void put(T x) {
258 GuardUnsafeAccess guard(_thread);
259 assert(_obj == nullptr || !_obj->is_inline_type(), "receiver cannot be an instance of a value class because they are immutable");
260 *addr() = normalize_for_write(x);
261 }
262
263
264 T get_volatile() {
265 GuardUnsafeAccess guard(_thread);
266 volatile T ret = RawAccess<MO_SEQ_CST>::load(addr());
267 return normalize_for_read(ret);
268 }
269
270 void put_volatile(T x) {
271 GuardUnsafeAccess guard(_thread);
272 RawAccess<MO_SEQ_CST>::store(addr(), normalize_for_write(x));
273 }
274 };
275
276 static void log_unsafe_value_access(oop p, jlong offset, InlineKlass* vk) {
277 Klass* k = p->klass();
278 if (log_is_enabled(Trace, valuetypes)) {
279 ResourceMark rm;
280 if (k->is_flatArray_klass()) {
281 FlatArrayKlass* vak = FlatArrayKlass::cast(k);
282 int index = (offset - vak->array_header_in_bytes()) / vak->element_byte_size();
283 flatArrayOop array = oop_cast<flatArrayOop>(p);
284 if (index >= 0 && index < array->length()) {
285 address dest = (address)((flatArrayOop)p)->value_at_addr(index, vak->layout_helper());
286 log_trace(valuetypes)("%s array type %s index %d element size %d offset " UINT64_FORMAT_X " at " INTPTR_FORMAT,
287 p->klass()->external_name(), vak->external_name(),
288 index, vak->element_byte_size(), (uint64_t)offset, p2i(dest));
289 } else {
290 log_trace(valuetypes)("%s array type %s out-of-bounds index %d element size %d offset " UINT64_FORMAT_X,
291 p->klass()->external_name(), vak->external_name(), index, vak->element_byte_size(), (uint64_t)offset);
292 }
293 } else {
294 log_trace(valuetypes)("%s field type %s at offset " UINT64_FORMAT_X,
295 p->klass()->external_name(), vk->external_name(), (uint64_t)offset);
296 }
297 }
298 }
299
300 // These functions allow a null base pointer with an arbitrary address.
301 // But if the base pointer is non-null, the offset should make some sense.
302 // That is, it should be in the range [0, MAX_OBJECT_SIZE].
303 UNSAFE_ENTRY(jobject, Unsafe_GetReference(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
304 oop p = JNIHandles::resolve(obj);
305 assert_field_offset_sane(p, offset);
306 oop v = HeapAccess<ON_UNKNOWN_OOP_REF>::oop_load_at(p, offset);
307 return JNIHandles::make_local(THREAD, v);
308 } UNSAFE_END
309
310 UNSAFE_ENTRY(void, Unsafe_PutReference(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
311 oop x = JNIHandles::resolve(x_h);
312 oop p = JNIHandles::resolve(obj);
313 assert_field_offset_sane(p, offset);
314 assert(!p->is_inline_type(), "receiver cannot be an instance of a value class because they are immutable");
315 HeapAccess<ON_UNKNOWN_OOP_REF>::oop_store_at(p, offset, x);
316 } UNSAFE_END
317
318 UNSAFE_ENTRY(jlong, Unsafe_ValueHeaderSize(JNIEnv *env, jobject unsafe, jclass c)) {
319 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c));
320 InlineKlass* vk = InlineKlass::cast(k);
321 return vk->payload_offset();
322 } UNSAFE_END
323
324 UNSAFE_ENTRY(jboolean, Unsafe_IsFlatField(JNIEnv *env, jobject unsafe, jobject o)) {
325 oop f = JNIHandles::resolve_non_null(o);
326 Klass* k = java_lang_Class::as_Klass(java_lang_reflect_Field::clazz(f));
327 int slot = java_lang_reflect_Field::slot(f);
328 return InstanceKlass::cast(k)->field_is_flat(slot);
329 } UNSAFE_END
330
331 UNSAFE_ENTRY(jboolean, Unsafe_HasNullMarker(JNIEnv *env, jobject unsafe, jobject o)) {
332 oop f = JNIHandles::resolve_non_null(o);
333 Klass* k = java_lang_Class::as_Klass(java_lang_reflect_Field::clazz(f));
334 int slot = java_lang_reflect_Field::slot(f);
335 return InstanceKlass::cast(k)->field_has_null_marker(slot);
336 } UNSAFE_END
337
338 UNSAFE_ENTRY(jint, Unsafe_NullMarkerOffset(JNIEnv *env, jobject unsafe, jobject o)) {
339 oop f = JNIHandles::resolve_non_null(o);
340 Klass* k = java_lang_Class::as_Klass(java_lang_reflect_Field::clazz(f));
341 int slot = java_lang_reflect_Field::slot(f);
342 return InstanceKlass::cast(k)->field_null_marker_offset(slot);
343 } UNSAFE_END
344
345 UNSAFE_ENTRY(jint, Unsafe_ArrayLayout(JNIEnv *env, jobject unsafe, jarray array)) {
346 oop ar = JNIHandles::resolve_non_null(array);
347 ArrayKlass* ak = ArrayKlass::cast(ar->klass());
348 if (ak->is_refArray_klass()) {
349 return (jint)LayoutKind::REFERENCE;
350 } else if (ak->is_flatArray_klass()) {
351 return (jint)FlatArrayKlass::cast(ak)->layout_kind();
352 } else {
353 ShouldNotReachHere();
354 return -1;
355 }
356 } UNSAFE_END
357
358 UNSAFE_ENTRY(jint, Unsafe_FieldLayout(JNIEnv *env, jobject unsafe, jobject field)) {
359 assert(field != nullptr, "field must not be null");
360
361 oop reflected = JNIHandles::resolve_non_null(field);
362 oop mirror = java_lang_reflect_Field::clazz(reflected);
363 Klass* k = java_lang_Class::as_Klass(mirror);
364 int slot = java_lang_reflect_Field::slot(reflected);
365 int modifiers = java_lang_reflect_Field::modifiers(reflected);
366
367 if ((modifiers & JVM_ACC_STATIC) != 0) {
368 return (jint)LayoutKind::REFERENCE; // static fields are never flat
369 } else {
370 InstanceKlass* ik = InstanceKlass::cast(k);
371 if (ik->field_is_flat(slot)) {
372 return (jint)ik->inline_layout_info(slot).kind();
373 } else {
374 return (jint)LayoutKind::REFERENCE;
375 }
376 }
377 } UNSAFE_END
378
379 UNSAFE_ENTRY(jarray, Unsafe_NewSpecialArray(JNIEnv *env, jobject unsafe, jclass elmClass, jint len, jint layoutKind)) {
380 oop mirror = JNIHandles::resolve_non_null(elmClass);
381 Klass* klass = java_lang_Class::as_Klass(mirror);
382 klass->initialize(CHECK_NULL);
383 if (len < 0) {
384 THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "Array length is negative");
385 }
386 if (klass->is_array_klass() || klass->is_identity_class()) {
387 THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "Element class is not a value class");
388 }
389 if (klass->is_abstract()) {
390 THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "Element class is abstract");
391 }
392 LayoutKind lk = static_cast<LayoutKind>(layoutKind);
393 if (lk <= LayoutKind::REFERENCE || lk == LayoutKind::NULLABLE_NON_ATOMIC_FLAT || lk >= LayoutKind::UNKNOWN) {
394 THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "Invalid layout kind");
395 }
396 InlineKlass* vk = InlineKlass::cast(klass);
397 // WARNING: test below will need modifications when flat layouts supported for fields
398 // but not for arrays are introduce (NULLABLE_NON_ATOMIC_FLAT for instance)
399 if (!UseArrayFlattening || !vk->is_layout_supported(lk)) {
400 THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "Layout not supported");
401 }
402 ArrayProperties props = ArrayKlass::array_properties_from_layout(lk);
403 oop array = oopFactory::new_flatArray(vk, len, props, lk, CHECK_NULL);
404 return (jarray) JNIHandles::make_local(THREAD, array);
405 } UNSAFE_END
406
407 UNSAFE_ENTRY(jobject, Unsafe_GetFlatValue(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint layoutKind, jclass vc)) {
408 assert(layoutKind != (int)LayoutKind::UNKNOWN, "Sanity");
409 assert(layoutKind != (int)LayoutKind::REFERENCE, "This method handles only flat layouts");
410 oop base = JNIHandles::resolve(obj);
411 if (base == nullptr) {
412 THROW_NULL(vmSymbols::java_lang_NullPointerException());
413 }
414 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(vc));
415 InlineKlass* vk = InlineKlass::cast(k);
416 log_unsafe_value_access(base, offset, vk);
417 LayoutKind lk = (LayoutKind)layoutKind;
418 FlatValuePayload payload = FlatValuePayload::construct_from_parts(base, offset, vk, lk);
419 oop v = payload.read(CHECK_NULL);
420 return JNIHandles::make_local(THREAD, v);
421 } UNSAFE_END
422
423 UNSAFE_ENTRY(void, Unsafe_PutFlatValue(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint layoutKind, jclass vc, jobject value)) {
424 assert(layoutKind != (int)LayoutKind::UNKNOWN, "Sanity");
425 assert(layoutKind != (int)LayoutKind::REFERENCE, "This method handles only flat layouts");
426 oop base = JNIHandles::resolve(obj);
427 if (base == nullptr) {
428 THROW(vmSymbols::java_lang_NullPointerException());
429 }
430
431 InlineKlass* vk = InlineKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(vc)));
432 log_unsafe_value_access(base, offset, vk);
433 LayoutKind lk = (LayoutKind)layoutKind;
434 FlatValuePayload payload = FlatValuePayload::construct_from_parts(base, offset, vk, lk);
435 payload.write(inlineOop(JNIHandles::resolve(value)), CHECK);
436 } UNSAFE_END
437
438 UNSAFE_ENTRY(jobject, Unsafe_GetReferenceVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
439 oop p = JNIHandles::resolve(obj);
440 assert_field_offset_sane(p, offset);
441 oop v = HeapAccess<MO_SEQ_CST | ON_UNKNOWN_OOP_REF>::oop_load_at(p, offset);
442 return JNIHandles::make_local(THREAD, v);
443 } UNSAFE_END
444
445 UNSAFE_ENTRY(void, Unsafe_PutReferenceVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
446 oop x = JNIHandles::resolve(x_h);
447 oop p = JNIHandles::resolve(obj);
448 assert_field_offset_sane(p, offset);
449 HeapAccess<MO_SEQ_CST | ON_UNKNOWN_OOP_REF>::oop_store_at(p, offset, x);
450 } UNSAFE_END
451
452 UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe, jlong addr)) {
453 oop v = *(oop*) (address) addr;
454 return JNIHandles::make_local(THREAD, v);
455 } UNSAFE_END
456
457 #define DEFINE_GETSETOOP(java_type, Type) \
728 InstanceKlass* k = InstanceKlass::cast(klass);
729 k->initialize(CHECK);
730 }
731 }
732 UNSAFE_END
733
734 UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized0(JNIEnv *env, jobject unsafe, jobject clazz)) {
735 assert(clazz != nullptr, "clazz must not be null");
736
737 oop mirror = JNIHandles::resolve_non_null(clazz);
738 Klass* klass = java_lang_Class::as_Klass(mirror);
739
740 if (klass != nullptr && klass->should_be_initialized()) {
741 return true;
742 }
743
744 return false;
745 }
746 UNSAFE_END
747
748 UNSAFE_ENTRY(void, Unsafe_NotifyStrictStaticAccess0(JNIEnv *env, jobject unsafe, jobject clazz,
749 jlong sfoffset, jboolean writing)) {
750 assert(clazz != nullptr, "clazz must not be null");
751
752 oop mirror = JNIHandles::resolve_non_null(clazz);
753 Klass* klass = java_lang_Class::as_Klass(mirror);
754
755 if (klass != nullptr && klass->is_instance_klass()) {
756 InstanceKlass* ik = InstanceKlass::cast(klass);
757 fieldDescriptor fd;
758 if (ik->find_local_field_from_offset((int)sfoffset, true, &fd)) {
759 // Note: The Unsafe API takes an OFFSET, but the InstanceKlass wants the INDEX.
760 // We could surface field indexes into Unsafe, but that's too much churn.
761 ik->notify_strict_static_access(fd.index(), writing, CHECK);
762 return;
763 }
764 }
765 THROW(vmSymbols::java_lang_InternalError());
766 }
767 UNSAFE_END
768
769 static void getBaseAndScale(int& base, int& scale, jclass clazz, TRAPS) {
770 assert(clazz != nullptr, "clazz must not be null");
771
772 oop mirror = JNIHandles::resolve_non_null(clazz);
773 Klass* k = java_lang_Class::as_Klass(mirror);
774
775 if (k == nullptr || !k->is_array_klass()) {
776 THROW(vmSymbols::java_lang_InvalidClassException());
777 } else if (k->is_typeArray_klass()) {
778 TypeArrayKlass* tak = TypeArrayKlass::cast(k);
779 base = tak->array_header_in_bytes();
780 assert(base == arrayOopDesc::base_offset_in_bytes(tak->element_type()), "array_header_size semantics ok");
781 scale = (1 << tak->log2_element_size());
782 } else if (k->is_objArray_klass()) {
783 Klass* ek = ObjArrayKlass::cast(k)->element_klass();
784 if (!ek->is_identity_class() && !ek->is_abstract()) {
785 // Arrays of a concrete value class type can have multiple layouts
786 // There's no good value to return, so throwing an exception is the way out
787 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Arrays of a concrete value class don't have a single base and offset");
788 }
789 base = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
790 scale = heapOopSize;
791 } else {
792 ShouldNotReachHere();
793 }
794 }
795
796 UNSAFE_ENTRY(jint, Unsafe_ArrayInstanceBaseOffset0(JNIEnv *env, jobject unsafe, jarray array)) {
797 assert(array != nullptr, "array must not be null");
798 oop ar = JNIHandles::resolve_non_null(array);
799 assert(ar->is_array(), "Must be an array");
800 ArrayKlass* ak = ArrayKlass::cast(ar->klass());
801 if (ak->is_refArray_klass()) {
802 return arrayOopDesc::base_offset_in_bytes(T_OBJECT);
803 } else if (ak->is_flatArray_klass()) {
804 FlatArrayKlass* fak = FlatArrayKlass::cast(ak);
805 return fak->array_header_in_bytes();
806 } else {
807 ShouldNotReachHere();
808 }
809 } UNSAFE_END
810
811 UNSAFE_ENTRY(jint, Unsafe_ArrayBaseOffset0(JNIEnv *env, jobject unsafe, jclass clazz)) {
812 int base = 0, scale = 0;
813 getBaseAndScale(base, scale, clazz, CHECK_0);
814
815 return field_offset_from_byte_offset(base);
816 } UNSAFE_END
817
818
819 UNSAFE_ENTRY(jint, Unsafe_ArrayIndexScale0(JNIEnv *env, jobject unsafe, jclass clazz)) {
820 int base = 0, scale = 0;
821 getBaseAndScale(base, scale, clazz, CHECK_0);
822
823 // This VM packs both fields and array elements down to the byte.
824 // But watch out: If this changes, so that array references for
825 // a given primitive type (say, T_BOOLEAN) use different memory units
826 // than fields, this method MUST return zero for such arrays.
827 // For example, the VM used to store sub-word sized fields in full
828 // words in the object layout, so that accessors like getByte(Object,int)
829 // did not really do what one might expect for arrays. Therefore,
830 // this function used to report a zero scale factor, so that the user
831 // would know not to attempt to access sub-word array elements.
832 // // Code for unpacked fields:
833 // if (scale < wordSize) return 0;
834
835 // The following allows for a pretty general fieldOffset cookie scheme,
836 // but requires it to be linear in byte offset.
837 return field_offset_from_byte_offset(scale) - field_offset_from_byte_offset(0);
838 } UNSAFE_END
839
840 UNSAFE_ENTRY(jint, Unsafe_ArrayInstanceIndexScale0(JNIEnv *env, jobject unsafe, jarray array)) {
841 assert(array != nullptr, "array must not be null");
842 oop ar = JNIHandles::resolve_non_null(array);
843 assert(ar->is_array(), "Must be an array");
844 ArrayKlass* ak = ArrayKlass::cast(ar->klass());
845 if (ak->is_refArray_klass()) {
846 return heapOopSize;
847 } else if (ak->is_flatArray_klass()) {
848 FlatArrayKlass* fak = FlatArrayKlass::cast(ak);
849 return fak->element_byte_size();
850 } else {
851 ShouldNotReachHere();
852 }
853 } UNSAFE_END
854
855 UNSAFE_ENTRY(jarray, Unsafe_GetFieldMap0(JNIEnv* env, jobject unsafe, jclass clazz)) {
856 oop mirror = JNIHandles::resolve_non_null(clazz);
857 Klass* k = java_lang_Class::as_Klass(mirror);
858
859 if (!k->is_inline_klass()) {
860 THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "Argument is not a concrete value class");
861 }
862 InlineKlass* vk = InlineKlass::cast(k);
863 oop map = mirror->obj_field(vk->acmp_maps_offset());
864 return (jarray) JNIHandles::make_local(THREAD, map);
865 } UNSAFE_END
866
867 UNSAFE_ENTRY(jlong, Unsafe_GetObjectSize0(JNIEnv* env, jobject o, jobject obj))
868 oop p = JNIHandles::resolve(obj);
869 return p->size() * HeapWordSize;
870 UNSAFE_END
871
872 static inline void throw_new(JNIEnv *env, const char *ename) {
873 jclass cls = env->FindClass(ename);
874 if (env->ExceptionCheck()) {
875 env->ExceptionClear();
876 tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", ename);
877 return;
878 }
879
880 env->ThrowNew(cls, nullptr);
881 }
882
883 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) {
884 // Code lifted from JDK 1.3 ClassLoader.c
885
886 jbyte *body;
887 char *utfName = nullptr;
888 jclass result = nullptr;
889 char buf[128];
890
1064 case 3: a->double_at_put(2, (jdouble)la[2]); // fall through
1065 case 2: a->double_at_put(1, (jdouble)la[1]); // fall through
1066 case 1: a->double_at_put(0, (jdouble)la[0]); break;
1067 }
1068
1069 return ret;
1070 } UNSAFE_END
1071
1072
1073 /// JVM_RegisterUnsafeMethods
1074
1075 #define ADR "J"
1076
1077 #define LANG "Ljava/lang/"
1078
1079 #define OBJ LANG "Object;"
1080 #define CLS LANG "Class;"
1081 #define FLD LANG "reflect/Field;"
1082 #define THR LANG "Throwable;"
1083
1084 #define OBJ_ARR "[" OBJ
1085
1086 #define DC_Args LANG "String;[BII" LANG "ClassLoader;" "Ljava/security/ProtectionDomain;"
1087 #define DAC_Args CLS "[B[" OBJ
1088
1089 #define CC (char*) /*cast a literal from (const char*)*/
1090 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
1091
1092 #define DECLARE_GETPUTOOP(Type, Desc) \
1093 {CC "get" #Type, CC "(" OBJ "J)" #Desc, FN_PTR(Unsafe_Get##Type)}, \
1094 {CC "put" #Type, CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Put##Type)}, \
1095 {CC "get" #Type "Volatile", CC "(" OBJ "J)" #Desc, FN_PTR(Unsafe_Get##Type##Volatile)}, \
1096 {CC "put" #Type "Volatile", CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Put##Type##Volatile)}
1097
1098
1099 static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = {
1100 {CC "getReference", CC "(" OBJ "J)" OBJ "", FN_PTR(Unsafe_GetReference)},
1101 {CC "putReference", CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutReference)},
1102 {CC "getReferenceVolatile", CC "(" OBJ "J)" OBJ, FN_PTR(Unsafe_GetReferenceVolatile)},
1103 {CC "putReferenceVolatile", CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutReferenceVolatile)},
1104
1105 {CC "isFlatField0", CC "(" OBJ ")Z", FN_PTR(Unsafe_IsFlatField)},
1106 {CC "hasNullMarker0", CC "(" OBJ ")Z", FN_PTR(Unsafe_HasNullMarker)},
1107 {CC "nullMarkerOffset0", CC "(" OBJ ")I", FN_PTR(Unsafe_NullMarkerOffset)},
1108 {CC "arrayLayout0", CC "(" OBJ_ARR ")I", FN_PTR(Unsafe_ArrayLayout)},
1109 {CC "fieldLayout0", CC "(" OBJ ")I", FN_PTR(Unsafe_FieldLayout)},
1110 {CC "newSpecialArray", CC "(" CLS "II)[" OBJ, FN_PTR(Unsafe_NewSpecialArray)},
1111 {CC "getFlatValue", CC "(" OBJ "JI" CLS ")" OBJ, FN_PTR(Unsafe_GetFlatValue)},
1112 {CC "putFlatValue", CC "(" OBJ "JI" CLS OBJ ")V", FN_PTR(Unsafe_PutFlatValue)},
1113 {CC "valueHeaderSize", CC "(" CLS ")J", FN_PTR(Unsafe_ValueHeaderSize)},
1114 {CC "getUncompressedObject", CC "(" ADR ")" OBJ, FN_PTR(Unsafe_GetUncompressedObject)},
1115
1116 DECLARE_GETPUTOOP(Boolean, Z),
1117 DECLARE_GETPUTOOP(Byte, B),
1118 DECLARE_GETPUTOOP(Short, S),
1119 DECLARE_GETPUTOOP(Char, C),
1120 DECLARE_GETPUTOOP(Int, I),
1121 DECLARE_GETPUTOOP(Long, J),
1122 DECLARE_GETPUTOOP(Float, F),
1123 DECLARE_GETPUTOOP(Double, D),
1124
1125 {CC "allocateMemory0", CC "(J)" ADR, FN_PTR(Unsafe_AllocateMemory0)},
1126 {CC "reallocateMemory0", CC "(" ADR "J)" ADR, FN_PTR(Unsafe_ReallocateMemory0)},
1127 {CC "freeMemory0", CC "(" ADR ")V", FN_PTR(Unsafe_FreeMemory0)},
1128
1129 {CC "objectFieldOffset0", CC "(" FLD ")J", FN_PTR(Unsafe_ObjectFieldOffset0)},
1130 {CC "knownObjectFieldOffset0", CC "(" CLS LANG "String;)J", FN_PTR(Unsafe_KnownObjectFieldOffset0)},
1131 {CC "staticFieldOffset0", CC "(" FLD ")J", FN_PTR(Unsafe_StaticFieldOffset0)},
1132 {CC "staticFieldBase0", CC "(" FLD ")" OBJ, FN_PTR(Unsafe_StaticFieldBase0)},
1133 {CC "ensureClassInitialized0", CC "(" CLS ")V", FN_PTR(Unsafe_EnsureClassInitialized0)},
1134 {CC "arrayBaseOffset0", CC "(" CLS ")I", FN_PTR(Unsafe_ArrayBaseOffset0)},
1135 {CC "arrayInstanceBaseOffset0", CC "(" OBJ_ARR ")I", FN_PTR(Unsafe_ArrayInstanceBaseOffset0)},
1136 {CC "arrayIndexScale0", CC "(" CLS ")I", FN_PTR(Unsafe_ArrayIndexScale0)},
1137 {CC "arrayInstanceIndexScale0", CC "(" OBJ_ARR ")I", FN_PTR(Unsafe_ArrayInstanceIndexScale0)},
1138 {CC "getFieldMap0", CC "(Ljava/lang/Class;)[I", FN_PTR(Unsafe_GetFieldMap0)},
1139 {CC "getObjectSize0", CC "(Ljava/lang/Object;)J", FN_PTR(Unsafe_GetObjectSize0)},
1140
1141 {CC "defineClass0", CC "(" DC_Args ")" CLS, FN_PTR(Unsafe_DefineClass0)},
1142 {CC "allocateInstance", CC "(" CLS ")" OBJ, FN_PTR(Unsafe_AllocateInstance)},
1143 {CC "throwException", CC "(" THR ")V", FN_PTR(Unsafe_ThrowException)},
1144 {CC "compareAndSetReference",CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSetReference)},
1145 {CC "compareAndSetInt", CC "(" OBJ "J""I""I"")Z", FN_PTR(Unsafe_CompareAndSetInt)},
1146 {CC "compareAndSetLong", CC "(" OBJ "J""J""J"")Z", FN_PTR(Unsafe_CompareAndSetLong)},
1147 {CC "compareAndExchangeReference", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeReference)},
1148 {CC "compareAndExchangeInt", CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)},
1149 {CC "compareAndExchangeLong", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)},
1150
1151 {CC "park", CC "(ZJ)V", FN_PTR(Unsafe_Park)},
1152 {CC "unpark", CC "(" OBJ ")V", FN_PTR(Unsafe_Unpark)},
1153
1154 {CC "getLoadAverage0", CC "([DI)I", FN_PTR(Unsafe_GetLoadAverage0)},
1155
1156 {CC "copyMemory0", CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory0)},
1157 {CC "copySwapMemory0", CC "(" OBJ "J" OBJ "JJJ)V", FN_PTR(Unsafe_CopySwapMemory0)},
1158 {CC "writeback0", CC "(" "J" ")V", FN_PTR(Unsafe_WriteBack0)},
1159 {CC "writebackPreSync0", CC "()V", FN_PTR(Unsafe_WriteBackPreSync0)},
1160 {CC "writebackPostSync0", CC "()V", FN_PTR(Unsafe_WriteBackPostSync0)},
1161 {CC "setMemory0", CC "(" OBJ "JJB)V", FN_PTR(Unsafe_SetMemory0)},
1162
1163 {CC "shouldBeInitialized0", CC "(" CLS ")Z", FN_PTR(Unsafe_ShouldBeInitialized0)},
1164 {CC "notifyStrictStaticAccess0", CC "(" CLS "JZ)V", FN_PTR(Unsafe_NotifyStrictStaticAccess0)},
1165
1166 {CC "fullFence", CC "()V", FN_PTR(Unsafe_FullFence)},
1167 };
1168
1169 #undef CC
1170 #undef FN_PTR
1171
1172 #undef ADR
1173 #undef LANG
1174 #undef OBJ
1175 #undef CLS
1176 #undef FLD
1177 #undef THR
1178 #undef DC_Args
1179 #undef DAC_Args
1180
1181 #undef DECLARE_GETPUTOOP
1182
1183
1184 // This function is exported, used by NativeLookup.
|