Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: runtime/vm/stub_code_arm_test.cc

Issue 1315893004: Load runtime entries from the Thread instead of the ObjectPool. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/stub_code_arm64_test.cc ('k') | runtime/vm/stub_code_ia32_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 18 matching lines...) Expand all
29 const String& function_name = String::ZoneHandle(Symbols::New(name)); 29 const String& function_name = String::ZoneHandle(Symbols::New(name));
30 Function& function = Function::ZoneHandle( 30 Function& function = Function::ZoneHandle(
31 Function::New(function_name, RawFunction::kRegularFunction, 31 Function::New(function_name, RawFunction::kRegularFunction,
32 true, false, false, false, false, owner_class, 0)); 32 true, false, false, false, false, owner_class, 0));
33 return &function; 33 return &function;
34 } 34 }
35 35
36 36
37 // Test calls to stub code which calls into the runtime. 37 // Test calls to stub code which calls into the runtime.
38 static void GenerateCallToCallRuntimeStub(Assembler* assembler, 38 static void GenerateCallToCallRuntimeStub(Assembler* assembler,
39 int value1, int value2) { 39 int length) {
40 const int argc = 2; 40 const int argc = 2;
41 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); 41 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length));
42 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2));
43 __ EnterDartFrame(0); 42 __ EnterDartFrame(0);
44 __ PushObject(Object::null_object()); // Push Null object for return value. 43 __ PushObject(Object::null_object()); // Push Null object for return value.
45 __ PushObject(smi1); // Push argument 1 smi1. 44 __ PushObject(smi_length); // Push argument 1: length.
46 __ PushObject(smi2); // Push argument 2 smi2. 45 __ PushObject(Object::null_object()); // Push argument 2: type arguments.
47 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); 46 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc);
48 __ CallRuntime(kTestSmiSubRuntimeEntry, argc); // Call SmiSub runtime func. 47 __ CallRuntime(kAllocateArrayRuntimeEntry, argc);
49 __ AddImmediate(SP, argc * kWordSize); 48 __ AddImmediate(SP, argc * kWordSize);
50 __ Pop(R0); // Pop return value from return slot. 49 __ Pop(R0); // Pop return value from return slot.
51 __ LeaveDartFrame(); 50 __ LeaveDartFrame();
52 __ Ret(); 51 __ Ret();
53 } 52 }
54 53
55 54
56 TEST_CASE(CallRuntimeStubCode) { 55 TEST_CASE(CallRuntimeStubCode) {
57 extern const Function& RegisterFakeFunction(const char* name, 56 extern const Function& RegisterFakeFunction(const char* name,
58 const Code& code); 57 const Code& code);
59 const int value1 = 10; 58 const int length = 10;
60 const int value2 = 20;
61 const char* kName = "Test_CallRuntimeStubCode"; 59 const char* kName = "Test_CallRuntimeStubCode";
62 Assembler _assembler_; 60 Assembler _assembler_;
63 GenerateCallToCallRuntimeStub(&_assembler_, value1, value2); 61 GenerateCallToCallRuntimeStub(&_assembler_, length);
64 const Code& code = Code::Handle(Code::FinalizeCode( 62 const Code& code = Code::Handle(Code::FinalizeCode(
65 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); 63 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_));
66 const Function& function = RegisterFakeFunction(kName, code); 64 const Function& function = RegisterFakeFunction(kName, code);
67 Smi& result = Smi::Handle(); 65 Array& result = Array::Handle();
68 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); 66 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
69 EXPECT_EQ((value1 - value2), result.Value()); 67 EXPECT_EQ(length, result.Length());
70 } 68 }
71 69
72 70
73 // Test calls to stub code which calls into a leaf runtime entry. 71 // Test calls to stub code which calls into a leaf runtime entry.
74 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, 72 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler,
75 int value1, 73 const char* value1,
76 int value2) { 74 const char* value2) {
77 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); 75 const Bigint& bigint1 =
78 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); 76 Bigint::ZoneHandle(Bigint::NewFromCString(value1, Heap::kOld));
77 const Bigint& bigint2 =
78 Bigint::ZoneHandle(Bigint::NewFromCString(value2, Heap::kOld));
79 __ EnterDartFrame(0); 79 __ EnterDartFrame(0);
80 __ ReserveAlignedFrameSpace(0); 80 __ ReserveAlignedFrameSpace(0);
81 __ LoadObject(R0, smi1); // Set up argument 1 smi1. 81 __ LoadObject(R0, bigint1); // Set up argument 1 bigint1.
82 __ LoadObject(R1, smi2); // Set up argument 2 smi2. 82 __ LoadObject(R1, bigint2); // Set up argument 2 bigint2.
83 __ CallRuntime(kTestLeafSmiAddRuntimeEntry, 2); // Call SmiAdd runtime func. 83 __ CallRuntime(kBigintCompareRuntimeEntry, 2);
84 __ SmiTag(R0);
84 __ LeaveDartFrame(); 85 __ LeaveDartFrame();
85 __ Ret(); // Return value is in R0. 86 __ Ret(); // Return value is in R0.
86 } 87 }
87 88
88 89
89 TEST_CASE(CallLeafRuntimeStubCode) { 90 TEST_CASE(CallLeafRuntimeStubCode) {
90 extern const Function& RegisterFakeFunction(const char* name, 91 extern const Function& RegisterFakeFunction(const char* name,
91 const Code& code); 92 const Code& code);
92 const int value1 = 10; 93 const char* value1 = "0xAAABBCCDDAABBCCDD";
93 const int value2 = 20; 94 const char* value2 = "0xAABBCCDDAABBCCDD";
94 const char* kName = "Test_CallLeafRuntimeStubCode"; 95 const char* kName = "Test_CallLeafRuntimeStubCode";
95 Assembler _assembler_; 96 Assembler _assembler_;
96 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); 97 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2);
97 const Code& code = Code::Handle(Code::FinalizeCode( 98 const Code& code = Code::Handle(Code::FinalizeCode(
98 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); 99 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_));
99 const Function& function = RegisterFakeFunction(kName, code); 100 const Function& function = RegisterFakeFunction(kName, code);
100 Smi& result = Smi::Handle(); 101 Smi& result = Smi::Handle();
101 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); 102 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
102 EXPECT_EQ((value1 + value2), result.Value()); 103 EXPECT_EQ(1, result.Value());
103 } 104 }
104 105
105 } // namespace dart 106 } // namespace dart
106 107
107 #endif // defined TARGET_ARCH_ARM 108 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm64_test.cc ('k') | runtime/vm/stub_code_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698