jni_internal_test.cc revision 9b9ba28b1277b4ddb967c5a968c6d550febce6af
10c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes// Copyright 2011 Google Inc. All Rights Reserved. 20c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 39b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro#include "jni_internal.h" 49b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 59b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro#include <cmath> 69b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro#include <sys/mman.h> 70c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 89b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro#include "common_test.h" 90c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes#include "gtest/gtest.h" 100c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 110c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughesnamespace art { 120c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 130c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughesclass JniInternalTest : public RuntimeTest { 14c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes protected: 15c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes virtual void SetUp() { 16c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes RuntimeTest::SetUp(); 17c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes env_ = Thread::Current()->GetJniEnv(); 18c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes } 19c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes JNIEnv* env_; 200c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes}; 210c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 22c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott HughesTEST_F(JniInternalTest, GetVersion) { 23c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes ASSERT_EQ(JNI_VERSION_1_6, env_->GetVersion()); 24c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes} 25c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes 260c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes#define EXPECT_CLASS_FOUND(NAME) \ 27c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes EXPECT_TRUE(env_->FindClass(NAME) != NULL) 280c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 290c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes#define EXPECT_CLASS_NOT_FOUND(NAME) \ 30c7ac37f0b8b64cfb53d8b9cc8dddbb34be3dd5eeElliott Hughes EXPECT_TRUE(env_->FindClass(NAME) == NULL) 310c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 320c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott HughesTEST_F(JniInternalTest, FindClass) { 330c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // TODO: when these tests start failing because you're calling FindClass 340c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // with a pending exception, fix EXPECT_CLASS_NOT_FOUND to assert that an 350c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // exception was thrown and clear the exception. 360c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 370c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // TODO: . is only allowed as an alternative to / if CheckJNI is off. 380c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 390c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // Reference types... 400c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // You can't include the "L;" in a JNI class descriptor. 410c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_FOUND("java/lang/String"); 420c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("Ljava/lang/String;"); 430c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // We support . as well as / for compatibility. 440c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_FOUND("java.lang.String"); 450c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("Ljava.lang.String;"); 460c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // ...for arrays too, where you must include "L;". 470c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_FOUND("[Ljava/lang/String;"); 480c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("[java/lang/String"); 490c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_FOUND("[Ljava.lang.String;"); 500c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("[java.lang.String"); 510c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 520c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // Primitive arrays are okay (if the primitive type is valid)... 530c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_FOUND("[C"); 540c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("[K"); 550c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes // But primitive types aren't allowed... 560c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("C"); 570c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes EXPECT_CLASS_NOT_FOUND("K"); 580c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes} 590c9cd5692fbbc5d92fcdc1ef41ef881a492b00ceElliott Hughes 609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapirobool EnsureInvokeStub(Method* method); 619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapirobyte* AllocateCode(void* code, size_t length) { 639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int prot = PROT_READ | PROT_WRITE | PROT_EXEC; 649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro void* addr = mmap(NULL, length, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro CHECK(addr != MAP_FAILED); 669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro memcpy(addr, code, length); 679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro __builtin___clear_cache(addr, (byte*)addr + length); 689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro // Set the low-order bit so a BLX will switch to Thumb mode. 699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro return reinterpret_cast<byte*>(reinterpret_cast<uintptr_t>(addr) | 1); 709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroMethod::InvokeStub* AllocateStub(Method* method, 739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte* code, 749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro size_t length) { 759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro CHECK(method->GetInvokeStub() == NULL); 769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EnsureInvokeStub(method); 779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = method->GetInvokeStub(); 789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro CHECK(stub != NULL); 799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro method->SetCode(AllocateCode(code, length)); 809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro CHECK(method->GetCode() != NULL); 819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro return stub; 829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapirovoid FreeStub(Method* method, size_t length) { 859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro void* addr = const_cast<void*>(method->GetCode()); 869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro munmap(addr, length); 879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro method->SetCode(NULL); 889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro#if defined(__arm__) 919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticMainMethod) { 929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kMainDex)); 939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LMain;", class_loader); 989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); 1019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 1029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte main_LV_code[] = { 1049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 0x00, 0x00, 1059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0xcd, 0xf8, 0x14, 0x10, 0x03, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 1069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 1079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 1099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro main_LV_code, 1109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(main_LV_code)); 1119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Object* arg = NULL; 1139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), NULL); 1159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(main_LV_code)); 1179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 1189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticNopMethod) { 1209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 1219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 1239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 1249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 1269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 1279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("nop", "()V"); 1299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 1309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte nop_V_code[] = { 1329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 1339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0x03, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 1349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 1359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 1379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro nop_V_code, 1389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(nop_V_code)); 1399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(stub); 1409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, NULL, NULL); 1429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(nop_V_code)); 1449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 1459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticIdentityByteMethod) { 1479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 1489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 1509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 1519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 1539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 1549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("identity", "(B)B"); 1569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 1579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte identity_BB_code[] = { 1599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 1609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0x05, 0x98, 1619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x03, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 0x00, 0x00, 1629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 1639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 1659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro identity_BB_code, 1669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(identity_BB_code)); 1679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int arg; 1699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 1709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = 0; 1729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.b = -1; 1739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 1749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0, result.b); 1759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = -1; 1779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.b = 0; 1789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 1799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-1, result.b); 1809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = SCHAR_MAX; 1829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.b = 0; 1839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 1849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(SCHAR_MAX, result.b); 1859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = SCHAR_MIN; 1879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.b = 0; 1889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 1899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(SCHAR_MIN, result.b); 1909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(identity_BB_code)); 1929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 1939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticIdentityIntMethod) { 1959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 1969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 1979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 1989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 1999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 2019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 2029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("identity", "(I)I"); 2049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 2059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte identity_II_code[] = { 2079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 2089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0x05, 0x98, 2099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x03, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 0x00, 0x00, 2109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 2119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 2139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro identity_II_code, 2149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(identity_II_code)); 2159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int arg; 2179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 2189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = 0; 2209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = -1; 2219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0, result.i); 2239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = -1; 2259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 2269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-1, result.i); 2289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = INT_MAX; 2309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 2319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(INT_MAX, result.i); 2339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = INT_MIN; 2359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 2369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(INT_MIN, result.i); 2389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(identity_II_code)); 2409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 2419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticIdentityDoubleMethod) { 2439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 2449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 2469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 2479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 2499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 2509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("identity", "(D)D"); 2529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 2539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte identity_DD_code[] = { 2559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 2569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0xcd, 0xf8, 2579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x18, 0x20, 0x05, 0x98, 0x06, 0x99, 0x03, 0xb0, 2589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0xbd, 0xe8, 0x00, 0x80, 2599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 2609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 2629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro identity_DD_code, 2639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(identity_DD_code)); 2649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro double arg; 2669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 2679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = 0.0; 2699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = -1.0; 2709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0.0, result.d); 2729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = -1.0; 2749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 2759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-1.0, result.d); 2779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = DBL_MAX; 2799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 2809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(DBL_MAX, result.d); 2829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro arg = DBL_MIN; 2849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 2859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(&arg), &result); 2869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(DBL_MIN, result.d); 2879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(identity_DD_code)); 2899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 2909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumIntIntMethod) { 2929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 2939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 2959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 2969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 2979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 2989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 2999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(II)I"); 3019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 3029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_III_code[] = { 3049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 3059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0xcd, 0xf8, 3069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x18, 0x20, 0x05, 0x98, 0x06, 0x99, 0x42, 0x18, 3079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0xcd, 0xf8, 0x04, 0x20, 0x01, 0x98, 0x03, 0xb0, 3089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0xbd, 0xe8, 0x00, 0x80, 3099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 3109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 3129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_III_code, 3139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_III_code)); 3149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int args[2]; 3169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 3179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0; 3199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0; 3209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = -1; 3219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0, result.i); 3239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1; 3259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 3269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 3279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(3, result.i); 3299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = -2; 3319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 5; 3329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 3339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(3, result.i); 3359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 3379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MIN; 3389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 1234; 3399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-1, result.i); 3419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 3439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MAX; 3449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = INT_MIN; 3459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-2, result.i); 3479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_III_code)); 3499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 3509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumIntIntIntMethod) { 3529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 3539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 3559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 3569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 3589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 3599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(III)I"); 3619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 3629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_IIII_code[] = { 3649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 3659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0xcd, 0xf8, 3669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x18, 0x20, 0xcd, 0xf8, 0x1c, 0x30, 0x05, 0x98, 3679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x06, 0x99, 0x42, 0x18, 0xcd, 0xf8, 0x04, 0x20, 3689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x9b, 0xdd, 0xf8, 0x1c, 0xc0, 0x13, 0xeb, 3699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x0c, 0x03, 0xcd, 0xf8, 0x04, 0x30, 0x01, 0x98, 3709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x03, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 0x00, 0x00, 3719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 3729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 3749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_IIII_code, 3759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_IIII_code)); 3769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int args[3]; 3789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 3799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0; 3819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0; 3829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 0; 3839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = -1; 3849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0, result.i); 3869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1; 3889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 3899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3; 3909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 3919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(6, result.i); 3939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 3949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = -1; 3959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 3969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = -3; 3979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 3989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 3999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-2, result.i); 4009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 4029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MIN; 4039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = INT_MAX; 4049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 1234; 4059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(2147483646, result.i); 4079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 4099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MAX; 4109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = INT_MAX; 4119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = INT_MIN; 4129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(2147483645, result.i); 4149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_IIII_code)); 4169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 4179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumIntIntIntIntMethod) { 4199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 4209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 4229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 4239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 4259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 4269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(IIII)I"); 4289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 4299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_IIIII_code[] = { 4319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 4329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0xcd, 0xf8, 4339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x18, 0x20, 0xcd, 0xf8, 0x1c, 0x30, 0x05, 0x98, 4349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x06, 0x99, 0x42, 0x18, 0xcd, 0xf8, 0x04, 0x20, 4359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x9b, 0xdd, 0xf8, 0x1c, 0xc0, 0x13, 0xeb, 4369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x0c, 0x03, 0xcd, 0xf8, 0x04, 0x30, 0x01, 0x98, 4379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x08, 0x99, 0x40, 0x18, 0xcd, 0xf8, 0x04, 0x00, 4389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x98, 0x03, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 4399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 4409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 4429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_IIIII_code, 4439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_IIIII_code)); 4449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int args[4]; 4469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 4479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0; 4499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0; 4509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 0; 4519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 0; 4529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = -1; 4539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0, result.i); 4559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1; 4579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 4589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3; 4599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 4; 4609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 4619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(10, result.i); 4639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = -1; 4659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 4669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = -3; 4679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 4; 4689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 4699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(2, result.i); 4719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 4739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MIN; 4749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = INT_MAX; 4759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = INT_MIN; 4769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 1234; 4779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-2, result.i); 4799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 4819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MAX; 4829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = INT_MAX; 4839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = INT_MAX; 4849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = INT_MIN; 4859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 4869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-4, result.i); 4879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_IIIII_code)); 4899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 4909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumIntIntIntIntIntMethod) { 4929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 4939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 4959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 4969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 4979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 4989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 4999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(IIIII)I"); 5019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 5029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_IIIIII_code[] = { 5049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x83, 0xb0, 0xcd, 0xf8, 5059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x14, 0x10, 0xcd, 0xf8, 5069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x18, 0x20, 0xcd, 0xf8, 0x1c, 0x30, 0x05, 0x98, 5079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x06, 0x99, 0x42, 0x18, 0xcd, 0xf8, 0x04, 0x20, 5089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x9b, 0xdd, 0xf8, 0x1c, 0xc0, 0x13, 0xeb, 5099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x0c, 0x03, 0xcd, 0xf8, 0x04, 0x30, 0x01, 0x98, 5109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x08, 0x99, 0x40, 0x18, 0xcd, 0xf8, 0x04, 0x00, 5119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x9a, 0x09, 0x9b, 0xd2, 0x18, 0xcd, 0xf8, 5129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x20, 0x01, 0x98, 0x03, 0xb0, 0xbd, 0xe8, 5139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x80, 0x00, 0x00, 5149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 5159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 5179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_IIIIII_code, 5189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_IIIIII_code)); 5199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro int args[5]; 5219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 5229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0; 5249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0; 5259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 0; 5269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 0; 5279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = 0; 5289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = -1.0; 5299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 5309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0, result.i); 5319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1; 5339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 5349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3; 5359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 4; 5369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = 5; 5379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 5389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 5399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(15, result.i); 5409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = -1; 5429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2; 5439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = -3; 5449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 4; 5459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = -5; 5469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 0; 5479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 5489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-3, result.i); 5499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 5519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MIN; 5529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = INT_MAX; 5539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = INT_MIN; 5549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = INT_MAX; 5559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = 1234; 5569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 5579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(2147483645, result.i); 5589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = INT_MAX; 5609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = INT_MAX; 5619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = INT_MAX; 5629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = INT_MAX; 5639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = INT_MAX; 5649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.i = INT_MIN; 5659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 5669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(2147483643, result.i); 5679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_IIIIII_code)); 5699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 5709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumDoubleDoubleMethod) { 5729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 5739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 5759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 5769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 5789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 5799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(DD)D"); 5819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 5829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_DDD_code[] = { 5849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x87, 0xb0, 0xcd, 0xf8, 5859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x24, 0x10, 0xcd, 0xf8, 5869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x28, 0x20, 0xcd, 0xf8, 0x2c, 0x30, 0x9d, 0xed, 5879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x09, 0x0b, 0x9d, 0xed, 0x0b, 0x1b, 0x30, 0xee, 5889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x2b, 0x8d, 0xed, 0x04, 0x2b, 0x04, 0x98, 5899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x05, 0x99, 0x07, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 5909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 5919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 5939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_DDD_code, 5949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_DDD_code)); 5959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro double args[2]; 5979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 5989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 5999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0.0; 6009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0.0; 6019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = -1.0; 6029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0.0, result.d); 6049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 6069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2.0; 6079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 6089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(3.0, result.d); 6109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 6129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = -2.0; 6139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 6149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-1.0, result.d); 6169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = DBL_MAX; 6189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = DBL_MIN; 6199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 6209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(1.7976931348623157e308, result.d); 6229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = DBL_MAX; 6249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = DBL_MAX; 6259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 6269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(INFINITY, result.d); 6289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_DDD_code)); 6309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 6319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumDoubleDoubleDoubleMethod) { 6339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 6349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 6369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 6379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 6399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 6409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(DDD)D"); 6429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 6439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_DDDD_code[] = { 6459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x87, 0xb0, 0xcd, 0xf8, 6469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x24, 0x10, 0xcd, 0xf8, 6479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x28, 0x20, 0xcd, 0xf8, 0x2c, 0x30, 0x9d, 0xed, 6489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x09, 0x0b, 0x9d, 0xed, 0x0b, 0x1b, 0x30, 0xee, 6499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x2b, 0x8d, 0xed, 0x04, 0x2b, 0x9d, 0xed, 6509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x3b, 0x9d, 0xed, 0x0d, 0x4b, 0x33, 0xee, 6519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x3b, 0x8d, 0xed, 0x04, 0x3b, 0x04, 0x98, 6529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x05, 0x99, 0x07, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 6539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 6549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 6569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_DDDD_code, 6579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_DDDD_code)); 6589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro double args[3]; 6609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 6619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0.0; 6639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0.0; 6649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 0.0; 6659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = -1.0; 6669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0.0, result.d); 6689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 6709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2.0; 6719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3.0; 6729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 6739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(6.0, result.d); 6759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 6779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = -2.0; 6789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3.0; 6799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 6809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 6819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(2.0, result.d); 6829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_DDDD_code)); 6849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 6859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumDoubleDoubleDoubleDoubleMethod) { 6879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 6889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 6909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 6919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 6939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 6949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(DDDD)D"); 6969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 6979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 6989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_DDDDD_code[] = { 6999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x87, 0xb0, 0xcd, 0xf8, 7009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x24, 0x10, 0xcd, 0xf8, 7019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x28, 0x20, 0xcd, 0xf8, 0x2c, 0x30, 0x9d, 0xed, 7029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x09, 0x0b, 0x9d, 0xed, 0x0b, 0x1b, 0x30, 0xee, 7039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x2b, 0x8d, 0xed, 0x04, 0x2b, 0x9d, 0xed, 7049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x3b, 0x9d, 0xed, 0x0d, 0x4b, 0x33, 0xee, 7059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x3b, 0x8d, 0xed, 0x04, 0x3b, 0x9d, 0xed, 7069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x5b, 0x9d, 0xed, 0x0f, 0x6b, 0x35, 0xee, 7079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x06, 0x5b, 0x8d, 0xed, 0x04, 0x5b, 0x04, 0x98, 7089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x05, 0x99, 0x07, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 7099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 7109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7119b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 7129b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_DDDDD_code, 7139b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_DDDDD_code)); 7149b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7159b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro double args[4]; 7169b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 7179b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7189b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0.0; 7199b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0.0; 7209b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 0.0; 7219b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 0.0; 7229b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = -1.0; 7239b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 7249b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0.0, result.d); 7259b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7269b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 7279b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2.0; 7289b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3.0; 7299b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 4.0; 7309b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 7319b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 7329b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(10.0, result.d); 7339b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7349b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 7359b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = -2.0; 7369b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3.0; 7379b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = -4.0; 7389b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 7399b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 7409b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(-2.0, result.d); 7419b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7429b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_DDDDD_code)); 7439b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 7449b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7459b9ba28b1277b4ddb967c5a968c6d550febce6afCarl ShapiroTEST_F(JniInternalTest, StaticSumDoubleDoubleDoubleDoubleDoubleMethod) { 7469b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro scoped_ptr<DexFile> dex(OpenDexFileBase64(kStaticLeafMethodsDex)); 7479b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7489b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro PathClassLoader* class_loader = AllocPathClassLoader(dex.get()); 7499b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(class_loader != NULL); 7509b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7519b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Class* klass = class_linker_->FindClass("LStaticLeafMethods;", class_loader); 7529b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(klass != NULL); 7539b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7549b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method* method = klass->FindDirectMethod("sum", "(DDDDD)D"); 7559b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro ASSERT_TRUE(method != NULL); 7569b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7579b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro byte sum_DDDDDD_code[] = { 7589b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x2d, 0xe9, 0x00, 0x40, 0x87, 0xb0, 0xcd, 0xf8, 7599b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x00, 0xcd, 0xf8, 0x24, 0x10, 0xcd, 0xf8, 7609b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x28, 0x20, 0xcd, 0xf8, 0x2c, 0x30, 0x9d, 0xed, 7619b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x09, 0x0b, 0x9d, 0xed, 0x0b, 0x1b, 0x30, 0xee, 7629b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x01, 0x2b, 0x8d, 0xed, 0x04, 0x2b, 0x9d, 0xed, 7639b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x3b, 0x9d, 0xed, 0x0d, 0x4b, 0x33, 0xee, 7649b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x3b, 0x8d, 0xed, 0x04, 0x3b, 0x9d, 0xed, 7659b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x5b, 0x9d, 0xed, 0x0f, 0x6b, 0x35, 0xee, 7669b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x06, 0x5b, 0x8d, 0xed, 0x04, 0x5b, 0x9d, 0xed, 7679b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x04, 0x7b, 0x9d, 0xed, 0x11, 0x0b, 0x37, 0xee, 7689b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x00, 0x7b, 0x8d, 0xed, 0x04, 0x7b, 0x04, 0x98, 7699b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 0x05, 0x99, 0x07, 0xb0, 0xbd, 0xe8, 0x00, 0x80, 7709b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro }; 7719b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7729b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro Method::InvokeStub* stub = AllocateStub(method, 7739b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sum_DDDDDD_code, 7749b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro sizeof(sum_DDDDDD_code)); 7759b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7769b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro double args[5]; 7779b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro JValue result; 7789b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7799b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 0.0; 7809b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 0.0; 7819b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 0.0; 7829b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 0.0; 7839b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = 0.0; 7849b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = -1.0; 7859b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 7869b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(0.0, result.d); 7879b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7889b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 7899b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = 2.0; 7909b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3.0; 7919b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = 4.0; 7929b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = 5.0; 7939b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 7949b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 7959b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(15.0, result.d); 7969b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 7979b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[0] = 1.0; 7989b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[1] = -2.0; 7999b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[2] = 3.0; 8009b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[3] = -4.0; 8019b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro args[4] = 5.0; 8029b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro result.d = 0.0; 8039b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro (*stub)(method, NULL, NULL, reinterpret_cast<byte*>(args), &result); 8049b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro EXPECT_EQ(3.0, result.d); 8059b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 8069b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro FreeStub(method, sizeof(sum_DDDDDD_code)); 8079b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 8089b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro#endif // __arm__ 8099b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro 8109b9ba28b1277b4ddb967c5a968c6d550febce6afCarl Shapiro} 811