Implement getByte/putByte intrinsics
Note that in Android we don't use the volatile, release, or
acquire versions for get/putByte.
Bug: 313284159
Test: art/test/testrunner/testrunner.py --target --64 --optimizing
Change-Id: Ic0953db52e2721f90e81bb600eaa95395941f578
diff --git a/compiler/optimizing/code_generator_riscv64.h b/compiler/optimizing/code_generator_riscv64.h
index 522adfd..c44a560 100644
--- a/compiler/optimizing/code_generator_riscv64.h
+++ b/compiler/optimizing/code_generator_riscv64.h
@@ -106,6 +106,7 @@
V(UnsafeGetObjectVolatile) \
V(UnsafeGetLong) \
V(UnsafeGetLongVolatile) \
+ V(UnsafeGetByte) \
V(UnsafePut) \
V(UnsafePutOrdered) \
V(UnsafePutVolatile) \
@@ -115,6 +116,7 @@
V(UnsafePutLong) \
V(UnsafePutLongOrdered) \
V(UnsafePutLongVolatile) \
+ V(UnsafePutByte) \
V(UnsafeGetAndAddInt) \
V(UnsafeGetAndAddLong) \
V(UnsafeGetAndSetInt) \
@@ -135,6 +137,7 @@
V(JdkUnsafeGetLong) \
V(JdkUnsafeGetLongVolatile) \
V(JdkUnsafeGetLongAcquire) \
+ V(JdkUnsafeGetByte) \
V(JdkUnsafePut) \
V(JdkUnsafePutOrdered) \
V(JdkUnsafePutRelease) \
@@ -144,6 +147,7 @@
V(JdkUnsafePutReferenceVolatile) \
V(JdkUnsafePutReferenceRelease) \
V(JdkUnsafePutLong) \
+ V(JdkUnsafePutByte) \
V(JdkUnsafePutLongOrdered) \
V(JdkUnsafePutLongVolatile) \
V(JdkUnsafePutLongRelease) \
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index 5963b7f..9add804 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -701,7 +701,8 @@
bool is_volatile,
CodeGeneratorARM64* codegen) {
LocationSummary* locations = invoke->GetLocations();
- DCHECK((type == DataType::Type::kInt32) ||
+ DCHECK((type == DataType::Type::kInt8) ||
+ (type == DataType::Type::kInt32) ||
(type == DataType::Type::kInt64) ||
(type == DataType::Type::kReference));
Location base_loc = locations->InAt(1);
@@ -780,6 +781,9 @@
void IntrinsicLocationsBuilderARM64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
+void IntrinsicLocationsBuilderARM64::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
void IntrinsicLocationsBuilderARM64::VisitJdkUnsafeGet(HInvoke* invoke) {
CreateUnsafeGetLocations(allocator_, invoke, codegen_);
@@ -808,6 +812,9 @@
void IntrinsicLocationsBuilderARM64::VisitJdkUnsafeGetReferenceAcquire(HInvoke* invoke) {
CreateUnsafeGetLocations(allocator_, invoke, codegen_);
}
+void IntrinsicLocationsBuilderARM64::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ CreateUnsafeGetLocations(allocator_, invoke, codegen_);
+}
void IntrinsicCodeGeneratorARM64::VisitUnsafeGet(HInvoke* invoke) {
VisitJdkUnsafeGet(invoke);
@@ -827,6 +834,9 @@
void IntrinsicCodeGeneratorARM64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
+void IntrinsicCodeGeneratorARM64::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
void IntrinsicCodeGeneratorARM64::VisitJdkUnsafeGet(HInvoke* invoke) {
GenUnsafeGet(invoke, DataType::Type::kInt32, /*is_volatile=*/ false, codegen_);
@@ -855,6 +865,9 @@
void IntrinsicCodeGeneratorARM64::VisitJdkUnsafeGetReferenceAcquire(HInvoke* invoke) {
GenUnsafeGet(invoke, DataType::Type::kReference, /*is_volatile=*/ true, codegen_);
}
+void IntrinsicCodeGeneratorARM64::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ GenUnsafeGet(invoke, DataType::Type::kInt8, /*is_volatile=*/ false, codegen_);
+}
static void CreateUnsafePutLocations(ArenaAllocator* allocator, HInvoke* invoke) {
LocationSummary* locations =
@@ -892,6 +905,9 @@
void IntrinsicLocationsBuilderARM64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicLocationsBuilderARM64::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
void IntrinsicLocationsBuilderARM64::VisitJdkUnsafePut(HInvoke* invoke) {
CreateUnsafePutLocations(allocator_, invoke);
@@ -929,6 +945,9 @@
void IntrinsicLocationsBuilderARM64::VisitJdkUnsafePutLongRelease(HInvoke* invoke) {
CreateUnsafePutLocations(allocator_, invoke);
}
+void IntrinsicLocationsBuilderARM64::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ CreateUnsafePutLocations(allocator_, invoke);
+}
static void GenUnsafePut(HInvoke* invoke,
DataType::Type type,
@@ -997,6 +1016,9 @@
void IntrinsicCodeGeneratorARM64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicCodeGeneratorARM64::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
void IntrinsicCodeGeneratorARM64::VisitJdkUnsafePut(HInvoke* invoke) {
GenUnsafePut(invoke,
@@ -1082,6 +1104,13 @@
/*is_ordered=*/ false,
codegen_);
}
+void IntrinsicCodeGeneratorARM64::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ GenUnsafePut(invoke,
+ DataType::Type::kInt8,
+ /*is_volatile=*/ false,
+ /*is_ordered=*/ false,
+ codegen_);
+}
static void CreateUnsafeCASLocations(ArenaAllocator* allocator,
HInvoke* invoke,
diff --git a/compiler/optimizing/intrinsics_arm_vixl.cc b/compiler/optimizing/intrinsics_arm_vixl.cc
index 5c231ec..5eea026 100644
--- a/compiler/optimizing/intrinsics_arm_vixl.cc
+++ b/compiler/optimizing/intrinsics_arm_vixl.cc
@@ -2906,6 +2906,14 @@
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
+void IntrinsicLocationsBuilderARMVIXL::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
+
+void IntrinsicCodeGeneratorARMVIXL::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
+
void IntrinsicLocationsBuilderARMVIXL::VisitJdkUnsafeGet(HInvoke* invoke) {
CreateUnsafeGetLocations(invoke, codegen_, DataType::Type::kInt32, /*atomic=*/ false);
}
@@ -2987,6 +2995,15 @@
invoke, codegen_, DataType::Type::kReference, std::memory_order_acquire, /*atomic=*/ true);
}
+void IntrinsicLocationsBuilderARMVIXL::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ CreateUnsafeGetLocations(invoke, codegen_, DataType::Type::kInt8, /*atomic=*/ false);
+}
+
+void IntrinsicCodeGeneratorARMVIXL::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ GenUnsafeGet(
+ invoke, codegen_, DataType::Type::kInt8, std::memory_order_relaxed, /*atomic=*/ false);
+}
+
static void GenerateIntrinsicSet(CodeGeneratorARMVIXL* codegen,
DataType::Type type,
std::memory_order order,
@@ -3207,6 +3224,14 @@
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicLocationsBuilderARMVIXL::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
+
+void IntrinsicCodeGeneratorARMVIXL::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
+
void IntrinsicLocationsBuilderARMVIXL::VisitJdkUnsafePut(HInvoke* invoke) {
CreateUnsafePutLocations(invoke, codegen_, DataType::Type::kInt32, /*atomic=*/ false);
}
@@ -3219,6 +3244,18 @@
codegen_);
}
+void IntrinsicLocationsBuilderARMVIXL::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ CreateUnsafePutLocations(invoke, codegen_, DataType::Type::kInt8, /*atomic=*/ false);
+}
+
+void IntrinsicCodeGeneratorARMVIXL::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ GenUnsafePut(invoke,
+ DataType::Type::kInt8,
+ std::memory_order_relaxed,
+ /*atomic=*/ false,
+ codegen_);
+}
+
void IntrinsicLocationsBuilderARMVIXL::VisitJdkUnsafePutOrdered(HInvoke* invoke) {
CreateUnsafePutLocations(invoke, codegen_, DataType::Type::kInt32, /*atomic=*/ true);
}
diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc
index 3589f4a..b1f6255 100644
--- a/compiler/optimizing/intrinsics_x86.cc
+++ b/compiler/optimizing/intrinsics_x86.cc
@@ -1691,6 +1691,12 @@
Location output_loc = locations->Out();
switch (type) {
+ case DataType::Type::kInt8: {
+ Register output = output_loc.AsRegister<Register>();
+ __ movsxb(output, Address(base, offset, ScaleFactor::TIMES_1, 0));
+ break;
+ }
+
case DataType::Type::kInt32: {
Register output = output_loc.AsRegister<Register>();
__ movl(output, Address(base, offset, ScaleFactor::TIMES_1, 0));
@@ -1789,7 +1795,9 @@
void IntrinsicLocationsBuilderX86::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
-
+void IntrinsicLocationsBuilderX86::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
void IntrinsicCodeGeneratorX86::VisitUnsafeGet(HInvoke* invoke) {
VisitJdkUnsafeGet(invoke);
@@ -1809,7 +1817,9 @@
void IntrinsicCodeGeneratorX86::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
-
+void IntrinsicCodeGeneratorX86::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
void IntrinsicLocationsBuilderX86::VisitJdkUnsafeGet(HInvoke* invoke) {
CreateIntIntIntToIntLocations(
@@ -1847,6 +1857,10 @@
CreateIntIntIntToIntLocations(
allocator_, invoke, codegen_, DataType::Type::kReference, /*is_volatile=*/ true);
}
+void IntrinsicLocationsBuilderX86::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ CreateIntIntIntToIntLocations(
+ allocator_, invoke, codegen_, DataType::Type::kInt8, /*is_volatile=*/ false);
+}
void IntrinsicCodeGeneratorX86::VisitJdkUnsafeGet(HInvoke* invoke) {
GenUnsafeGet(invoke, DataType::Type::kInt32, /*is_volatile=*/ false, codegen_);
@@ -1875,6 +1889,9 @@
void IntrinsicCodeGeneratorX86::VisitJdkUnsafeGetReferenceAcquire(HInvoke* invoke) {
GenUnsafeGet(invoke, DataType::Type::kReference, /*is_volatile=*/ true, codegen_);
}
+void IntrinsicCodeGeneratorX86::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ GenUnsafeGet(invoke, DataType::Type::kInt8, /*is_volatile=*/ false, codegen_);
+}
static void CreateIntIntIntIntToVoidPlusTempsLocations(ArenaAllocator* allocator,
DataType::Type type,
@@ -1924,6 +1941,9 @@
void IntrinsicLocationsBuilderX86::VisitUnsafePutLongVolatile(HInvoke* invoke) {
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicLocationsBuilderX86::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
void IntrinsicLocationsBuilderX86::VisitJdkUnsafePut(HInvoke* invoke) {
CreateIntIntIntIntToVoidPlusTempsLocations(
@@ -1973,6 +1993,10 @@
CreateIntIntIntIntToVoidPlusTempsLocations(
allocator_, DataType::Type::kInt64, invoke, /*is_volatile=*/ true);
}
+void IntrinsicLocationsBuilderX86::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ CreateIntIntIntIntToVoidPlusTempsLocations(
+ allocator_, DataType::Type::kInt8, invoke, /*is_volatile=*/ false);
+}
// We don't care for ordered: it requires an AnyStore barrier, which is already given by the x86
// memory model.
@@ -2049,6 +2073,9 @@
void IntrinsicCodeGeneratorX86::VisitUnsafePutLongVolatile(HInvoke* invoke) {
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicCodeGeneratorX86::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
void IntrinsicCodeGeneratorX86::VisitJdkUnsafePut(HInvoke* invoke) {
GenUnsafePut(invoke->GetLocations(), DataType::Type::kInt32, /*is_volatile=*/ false, codegen_);
@@ -2090,6 +2117,9 @@
void IntrinsicCodeGeneratorX86::VisitJdkUnsafePutLongRelease(HInvoke* invoke) {
GenUnsafePut(invoke->GetLocations(), DataType::Type::kInt64, /*is_volatile=*/ true, codegen_);
}
+void IntrinsicCodeGeneratorX86::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ GenUnsafePut(invoke->GetLocations(), DataType::Type::kInt8, /*is_volatile=*/ false, codegen_);
+}
static void CreateIntIntIntIntIntToInt(ArenaAllocator* allocator,
CodeGeneratorX86* codegen,
diff --git a/compiler/optimizing/intrinsics_x86_64.cc b/compiler/optimizing/intrinsics_x86_64.cc
index cf04954..d38509f 100644
--- a/compiler/optimizing/intrinsics_x86_64.cc
+++ b/compiler/optimizing/intrinsics_x86_64.cc
@@ -1884,6 +1884,10 @@
CpuRegister output = output_loc.AsRegister<CpuRegister>();
switch (type) {
+ case DataType::Type::kInt8:
+ __ movsxb(output, Address(base, offset, ScaleFactor::TIMES_1, 0));
+ break;
+
case DataType::Type::kInt32:
__ movl(output, Address(base, offset, ScaleFactor::TIMES_1, 0));
break;
@@ -1954,6 +1958,9 @@
void IntrinsicLocationsBuilderX86_64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
+void IntrinsicLocationsBuilderX86_64::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
void IntrinsicLocationsBuilderX86_64::VisitJdkUnsafeGet(HInvoke* invoke) {
CreateIntIntIntToIntLocations(allocator_, invoke, codegen_);
@@ -1982,7 +1989,9 @@
void IntrinsicLocationsBuilderX86_64::VisitJdkUnsafeGetReferenceAcquire(HInvoke* invoke) {
CreateIntIntIntToIntLocations(allocator_, invoke, codegen_);
}
-
+void IntrinsicLocationsBuilderX86_64::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ CreateIntIntIntToIntLocations(allocator_, invoke, codegen_);
+}
void IntrinsicCodeGeneratorX86_64::VisitUnsafeGet(HInvoke* invoke) {
VisitJdkUnsafeGet(invoke);
@@ -2002,6 +2011,9 @@
void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetObjectVolatile(HInvoke* invoke) {
VisitJdkUnsafeGetReferenceVolatile(invoke);
}
+void IntrinsicCodeGeneratorX86_64::VisitUnsafeGetByte(HInvoke* invoke) {
+ VisitJdkUnsafeGetByte(invoke);
+}
void IntrinsicCodeGeneratorX86_64::VisitJdkUnsafeGet(HInvoke* invoke) {
GenUnsafeGet(invoke, DataType::Type::kInt32, /*is_volatile=*/ false, codegen_);
@@ -2030,7 +2042,9 @@
void IntrinsicCodeGeneratorX86_64::VisitJdkUnsafeGetReferenceAcquire(HInvoke* invoke) {
GenUnsafeGet(invoke, DataType::Type::kReference, /*is_volatile=*/ true, codegen_);
}
-
+void IntrinsicCodeGeneratorX86_64::VisitJdkUnsafeGetByte(HInvoke* invoke) {
+ GenUnsafeGet(invoke, DataType::Type::kInt8, /*is_volatile=*/false, codegen_);
+}
static void CreateIntIntIntIntToVoidPlusTempsLocations(ArenaAllocator* allocator,
DataType::Type type,
@@ -2075,6 +2089,9 @@
void IntrinsicLocationsBuilderX86_64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicLocationsBuilderX86_64::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePut(invoke);
+}
void IntrinsicLocationsBuilderX86_64::VisitJdkUnsafePut(HInvoke* invoke) {
CreateIntIntIntIntToVoidPlusTempsLocations(allocator_, DataType::Type::kInt32, invoke);
@@ -2112,6 +2129,9 @@
void IntrinsicLocationsBuilderX86_64::VisitJdkUnsafePutLongRelease(HInvoke* invoke) {
CreateIntIntIntIntToVoidPlusTempsLocations(allocator_, DataType::Type::kInt64, invoke);
}
+void IntrinsicLocationsBuilderX86_64::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ CreateIntIntIntIntToVoidPlusTempsLocations(allocator_, DataType::Type::kUint8, invoke);
+}
// We don't care for ordered: it requires an AnyStore barrier, which is already given by the x86
// memory model.
@@ -2174,6 +2194,9 @@
void IntrinsicCodeGeneratorX86_64::VisitUnsafePutLongVolatile(HInvoke* invoke) {
VisitJdkUnsafePutLongVolatile(invoke);
}
+void IntrinsicCodeGeneratorX86_64::VisitUnsafePutByte(HInvoke* invoke) {
+ VisitJdkUnsafePutByte(invoke);
+}
void IntrinsicCodeGeneratorX86_64::VisitJdkUnsafePut(HInvoke* invoke) {
GenUnsafePut(invoke->GetLocations(), DataType::Type::kInt32, /*is_volatile=*/ false, codegen_);
@@ -2215,6 +2238,9 @@
void IntrinsicCodeGeneratorX86_64::VisitJdkUnsafePutLongRelease(HInvoke* invoke) {
GenUnsafePut(invoke->GetLocations(), DataType::Type::kInt64, /*is_volatile=*/ true, codegen_);
}
+void IntrinsicCodeGeneratorX86_64::VisitJdkUnsafePutByte(HInvoke* invoke) {
+ GenUnsafePut(invoke->GetLocations(), DataType::Type::kInt8, /*is_volatile=*/false, codegen_);
+}
static void CreateUnsafeCASLocations(ArenaAllocator* allocator,
HInvoke* invoke,
diff --git a/runtime/hidden_api.h b/runtime/hidden_api.h
index 37b6762..1f6abf7 100644
--- a/runtime/hidden_api.h
+++ b/runtime/hidden_api.h
@@ -357,10 +357,12 @@
case Intrinsics::kJdkUnsafeFullFence:
case Intrinsics::kJdkUnsafeGet:
case Intrinsics::kJdkUnsafeGetLong:
+ case Intrinsics::kJdkUnsafeGetByte:
case Intrinsics::kJdkUnsafeGetReference:
case Intrinsics::kJdkUnsafePutLong:
case Intrinsics::kJdkUnsafePut:
case Intrinsics::kJdkUnsafePutReference:
+ case Intrinsics::kJdkUnsafePutByte:
return 0u;
case Intrinsics::kFP16Ceil:
case Intrinsics::kFP16Compare:
@@ -376,10 +378,12 @@
case Intrinsics::kFP16Rint:
case Intrinsics::kUnsafeGet:
case Intrinsics::kUnsafeGetLong:
+ case Intrinsics::kUnsafeGetByte:
case Intrinsics::kUnsafeGetObject:
case Intrinsics::kUnsafePutLong:
case Intrinsics::kUnsafePut:
case Intrinsics::kUnsafePutObject:
+ case Intrinsics::kUnsafePutByte:
return kAccCorePlatformApi;
default:
// Remaining intrinsics are public API. We DCHECK that in SetIntrinsic().
diff --git a/runtime/intrinsics_list.h b/runtime/intrinsics_list.h
index 12270a0..d931c26 100644
--- a/runtime/intrinsics_list.h
+++ b/runtime/intrinsics_list.h
@@ -221,6 +221,7 @@
V(UnsafeGetObjectVolatile, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getObjectVolatile", "(Ljava/lang/Object;J)Ljava/lang/Object;") \
V(UnsafeGetLong, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getLong", "(Ljava/lang/Object;J)J") \
V(UnsafeGetLongVolatile, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getLongVolatile", "(Ljava/lang/Object;J)J") \
+ V(UnsafeGetByte, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getByte", "(Ljava/lang/Object;J)B") \
V(UnsafePut, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putInt", "(Ljava/lang/Object;JI)V") \
V(UnsafePutOrdered, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putOrderedInt", "(Ljava/lang/Object;JI)V") \
V(UnsafePutVolatile, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putIntVolatile", "(Ljava/lang/Object;JI)V") \
@@ -230,6 +231,7 @@
V(UnsafePutLong, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putLong", "(Ljava/lang/Object;JJ)V") \
V(UnsafePutLongOrdered, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putOrderedLong", "(Ljava/lang/Object;JJ)V") \
V(UnsafePutLongVolatile, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putLongVolatile", "(Ljava/lang/Object;JJ)V") \
+ V(UnsafePutByte, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putByte", "(Ljava/lang/Object;JB)V") \
V(UnsafeGetAndAddInt, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndAddInt", "(Ljava/lang/Object;JI)I") \
V(UnsafeGetAndAddLong, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndAddLong", "(Ljava/lang/Object;JJ)J") \
V(UnsafeGetAndSetInt, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndSetInt", "(Ljava/lang/Object;JI)I") \
@@ -253,6 +255,7 @@
V(JdkUnsafeGetLong, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getLong", "(Ljava/lang/Object;J)J") \
V(JdkUnsafeGetLongVolatile, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getLongVolatile", "(Ljava/lang/Object;J)J") \
V(JdkUnsafeGetLongAcquire, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getLongAcquire", "(Ljava/lang/Object;J)J") \
+ V(JdkUnsafeGetByte, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getByte", "(Ljava/lang/Object;J)B") \
V(JdkUnsafePut, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putInt", "(Ljava/lang/Object;JI)V") \
V(JdkUnsafePutOrdered, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putOrderedInt", "(Ljava/lang/Object;JI)V") \
V(JdkUnsafePutRelease, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putIntRelease", "(Ljava/lang/Object;JI)V") \
@@ -265,6 +268,7 @@
V(JdkUnsafePutLongOrdered, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putOrderedLong", "(Ljava/lang/Object;JJ)V") \
V(JdkUnsafePutLongVolatile, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putLongVolatile", "(Ljava/lang/Object;JJ)V") \
V(JdkUnsafePutLongRelease, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putLongRelease", "(Ljava/lang/Object;JJ)V") \
+ V(JdkUnsafePutByte, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "putByte", "(Ljava/lang/Object;JB)V") \
V(JdkUnsafeGetAndAddInt, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getAndAddInt", "(Ljava/lang/Object;JI)I") \
V(JdkUnsafeGetAndAddLong, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getAndAddLong", "(Ljava/lang/Object;JJ)J") \
V(JdkUnsafeGetAndSetInt, kVirtual, kNeedsEnvironment, kAllSideEffects, kCanThrow, "Ljdk/internal/misc/Unsafe;", "getAndSetInt", "(Ljava/lang/Object;JI)I") \
diff --git a/test/004-UnsafeTest/src/Main.java b/test/004-UnsafeTest/src/Main.java
index 9176e89..cfa3691 100644
--- a/test/004-UnsafeTest/src/Main.java
+++ b/test/004-UnsafeTest/src/Main.java
@@ -136,6 +136,14 @@
check(t.objectVar, objectValue, "Unsafe.putObject(Object, long, Object)");
check(unsafe.getObject(t, objectOffset), objectValue, "Unsafe.getObject(Object, long)");
+ byte byteValue = 123;
+ Field byteField = TestClass.class.getDeclaredField("byteVar");
+ long byteOffset = unsafe.objectFieldOffset(byteField);
+ check(unsafe.getByte(t, byteOffset), 0, "Unsafe.getByte(Object, long) - initial");
+ unsafe.putByte(t, byteOffset, byteValue);
+ check(t.byteVar, byteValue, "Unsafe.putByte(Object, long, byte)");
+ check(unsafe.getByte(t, byteOffset), byteValue, "Unsafe.getByte(Object, long)");
+
if (unsafe.compareAndSwapInt(t, intOffset, 0, 1)) {
System.out.println("Unexpectedly succeeding compareAndSwapInt(t, intOffset, 0, 1)");
}
@@ -288,6 +296,7 @@
public int intVar = 0;
public long longVar = 0;
public Object objectVar = null;
+ public byte byteVar = 0;
}
private static class TestVolatileClass {