OLD | NEW |
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/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 __ Pop(R0); // Pop return value from return slot. | 48 __ Pop(R0); // Pop return value from return slot. |
49 __ LeaveDartFrame(); | 49 __ LeaveDartFrame(); |
50 __ Ret(); | 50 __ Ret(); |
51 } | 51 } |
52 | 52 |
53 TEST_CASE(CallRuntimeStubCode) { | 53 TEST_CASE(CallRuntimeStubCode) { |
54 extern const Function& RegisterFakeFunction(const char* name, | 54 extern const Function& RegisterFakeFunction(const char* name, |
55 const Code& code); | 55 const Code& code); |
56 const int length = 10; | 56 const int length = 10; |
57 const char* kName = "Test_CallRuntimeStubCode"; | 57 const char* kName = "Test_CallRuntimeStubCode"; |
58 Assembler _assembler_; | 58 Assembler assembler; |
59 GenerateCallToCallRuntimeStub(&_assembler_, length); | 59 GenerateCallToCallRuntimeStub(&assembler, length); |
60 const Code& code = Code::Handle(Code::FinalizeCode( | 60 const Code& code = Code::Handle(Code::FinalizeCode( |
61 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); | 61 *CreateFunction("Test_CallRuntimeStubCode"), &assembler)); |
62 const Function& function = RegisterFakeFunction(kName, code); | 62 const Function& function = RegisterFakeFunction(kName, code); |
63 Array& result = Array::Handle(); | 63 Array& result = Array::Handle(); |
64 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 64 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
65 EXPECT_EQ(length, result.Length()); | 65 EXPECT_EQ(length, result.Length()); |
66 } | 66 } |
67 | 67 |
68 // Test calls to stub code which calls into a leaf runtime entry. | 68 // Test calls to stub code which calls into a leaf runtime entry. |
69 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, | 69 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, |
70 const char* value1, | 70 const char* str_value, |
71 const char* value2) { | 71 intptr_t lhs_index_value, |
72 const Bigint& bigint1 = | 72 intptr_t rhs_index_value, |
73 Bigint::ZoneHandle(Bigint::NewFromCString(value1, Heap::kOld)); | 73 intptr_t length_value) { |
74 const Bigint& bigint2 = | 74 const String& str = String::ZoneHandle(String::New(str_value, Heap::kOld)); |
75 Bigint::ZoneHandle(Bigint::NewFromCString(value2, Heap::kOld)); | 75 const Smi& lhs_index = Smi::ZoneHandle(Smi::New(lhs_index_value)); |
| 76 const Smi& rhs_index = Smi::ZoneHandle(Smi::New(rhs_index_value)); |
| 77 const Smi& length = Smi::ZoneHandle(Smi::New(length_value)); |
76 __ EnterDartFrame(0); | 78 __ EnterDartFrame(0); |
77 __ ReserveAlignedFrameSpace(0); | 79 __ ReserveAlignedFrameSpace(0); |
78 __ LoadObject(R0, bigint1); // Set up argument 1 bigint1. | 80 __ LoadObject(R0, str); |
79 __ LoadObject(R1, bigint2); // Set up argument 2 bigint2. | 81 __ LoadObject(R1, lhs_index); |
80 __ CallRuntime(kBigintCompareRuntimeEntry, 2); | 82 __ LoadObject(R2, rhs_index); |
81 __ SmiTag(R0); | 83 __ LoadObject(R3, length); |
| 84 __ CallRuntime(kCaseInsensitiveCompareUC16RuntimeEntry, 4); |
82 __ LeaveDartFrame(); | 85 __ LeaveDartFrame(); |
83 __ Ret(); // Return value is in R0. | 86 __ Ret(); // Return value is in R0. |
84 } | 87 } |
85 | 88 |
86 TEST_CASE(CallLeafRuntimeStubCode) { | 89 TEST_CASE(CallLeafRuntimeStubCode) { |
87 extern const Function& RegisterFakeFunction(const char* name, | 90 extern const Function& RegisterFakeFunction(const char* name, |
88 const Code& code); | 91 const Code& code); |
89 const char* value1 = "0xAAABBCCDDAABBCCDD"; | 92 const char* str_value = "abAB"; |
90 const char* value2 = "0xAABBCCDDAABBCCDD"; | 93 intptr_t lhs_index_value = 0; |
| 94 intptr_t rhs_index_value = 2; |
| 95 intptr_t length_value = 2; |
91 const char* kName = "Test_CallLeafRuntimeStubCode"; | 96 const char* kName = "Test_CallLeafRuntimeStubCode"; |
92 Assembler _assembler_; | 97 Assembler assembler; |
93 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); | 98 GenerateCallToCallLeafRuntimeStub(&assembler, str_value, lhs_index_value, |
| 99 rhs_index_value, length_value); |
94 const Code& code = Code::Handle(Code::FinalizeCode( | 100 const Code& code = Code::Handle(Code::FinalizeCode( |
95 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 101 *CreateFunction("Test_CallLeafRuntimeStubCode"), &assembler)); |
96 const Function& function = RegisterFakeFunction(kName, code); | 102 const Function& function = RegisterFakeFunction(kName, code); |
97 Smi& result = Smi::Handle(); | 103 Instance& result = Instance::Handle(); |
98 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 104 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
99 EXPECT_EQ(1, result.Value()); | 105 EXPECT_EQ(Bool::True().raw(), result.raw()); |
100 } | 106 } |
101 | 107 |
102 } // namespace dart | 108 } // namespace dart |
103 | 109 |
104 #endif // defined TARGET_ARCH_ARM | 110 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |