summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter.cc
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-02-10 16:19:09 -0800
committerHiroshi Yamauchi <yamauchi@google.com>2014-02-11 13:16:20 -0800
commit4d2efce8bf1947880b90efc44448b4940c8016fb (patch)
tree61adad3b981719a12d00aa9be44f76c004dd44c4 /runtime/interpreter/interpreter.cc
parent6b3697fec487b355d107b693c965919bf5fff906 (diff)
downloadart-4d2efce8bf1947880b90efc44448b4940c8016fb.zip
art-4d2efce8bf1947880b90efc44448b4940c8016fb.tar.gz
art-4d2efce8bf1947880b90efc44448b4940c8016fb.tar.bz2
Don't hardcode object layout in Unsafe and space_test.
Add a test for Unsafe.arrayBaseOffset() and Unsafe.arrayIndexScale(). Change-Id: I9cbdb79a4a7ee055129f41811a117910c8b2febd
Diffstat (limited to 'runtime/interpreter/interpreter.cc')
-rw-r--r--runtime/interpreter/interpreter.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index 922e642..c6faf44 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -80,6 +80,14 @@ static void UnstartedRuntimeJni(Thread* self, ArtMethod* method,
Object* obj = reinterpret_cast<Object*>(args[0]);
Object* newValue = reinterpret_cast<Object*>(args[3]);
obj->SetFieldObject(MemberOffset((static_cast<uint64_t>(args[2]) << 32) | args[1]), newValue, false);
+ } else if (name == "int sun.misc.Unsafe.getArrayBaseOffsetForComponentType(java.lang.Class)") {
+ mirror::Class* component = reinterpret_cast<Object*>(args[0])->AsClass();
+ Primitive::Type primitive_type = component->GetPrimitiveType();
+ result->SetI(mirror::Array::DataOffset(Primitive::ComponentSize(primitive_type)).Int32Value());
+ } else if (name == "int sun.misc.Unsafe.getArrayIndexScaleForComponentType(java.lang.Class)") {
+ mirror::Class* component = reinterpret_cast<Object*>(args[0])->AsClass();
+ Primitive::Type primitive_type = component->GetPrimitiveType();
+ result->SetI(Primitive::ComponentSize(primitive_type));
} else {
LOG(FATAL) << "Attempt to invoke native method in non-started runtime: " << name;
}