OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 __ popl(EAX); // Pop return value from return slot. | 48 __ popl(EAX); // Pop return value from return slot. |
49 __ leave(); | 49 __ leave(); |
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 __ enter(Immediate(0)); | 78 __ enter(Immediate(0)); |
77 __ ReserveAlignedFrameSpace(2 * kWordSize); | 79 __ ReserveAlignedFrameSpace(4 * kWordSize); |
78 __ LoadObject(EAX, bigint1); | 80 __ LoadObject(EAX, str); |
79 __ movl(Address(ESP, 0), EAX); // Push argument 1 bigint1. | 81 __ movl(Address(ESP, 0), EAX); // Push argument 1. |
80 __ LoadObject(EAX, bigint2); | 82 __ LoadObject(EAX, lhs_index); |
81 __ movl(Address(ESP, kWordSize), EAX); // Push argument 2 bigint2. | 83 __ movl(Address(ESP, kWordSize), EAX); // Push argument 2. |
82 __ CallRuntime(kBigintCompareRuntimeEntry, 2); | 84 __ LoadObject(EAX, rhs_index); |
83 __ SmiTag(EAX); | 85 __ movl(Address(ESP, 2 * kWordSize), EAX); // Push argument 3. |
| 86 __ LoadObject(EAX, length); |
| 87 __ movl(Address(ESP, 3 * kWordSize), EAX); // Push argument 4. |
| 88 __ CallRuntime(kCaseInsensitiveCompareUC16RuntimeEntry, 4); |
84 __ leave(); | 89 __ leave(); |
85 __ ret(); // Return value is in EAX. | 90 __ ret(); // Return value is in EAX. |
86 } | 91 } |
87 | 92 |
88 TEST_CASE(CallLeafRuntimeStubCode) { | 93 TEST_CASE(CallLeafRuntimeStubCode) { |
89 extern const Function& RegisterFakeFunction(const char* name, | 94 extern const Function& RegisterFakeFunction(const char* name, |
90 const Code& code); | 95 const Code& code); |
91 const char* value1 = "0xAAABBCCDDAABBCCDD"; | 96 const char* str_value = "abAB"; |
92 const char* value2 = "0xAABBCCDDAABBCCDD"; | 97 intptr_t lhs_index_value = 0; |
| 98 intptr_t rhs_index_value = 2; |
| 99 intptr_t length_value = 2; |
93 const char* kName = "Test_CallLeafRuntimeStubCode"; | 100 const char* kName = "Test_CallLeafRuntimeStubCode"; |
94 Assembler _assembler_; | 101 Assembler assembler; |
95 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); | 102 GenerateCallToCallLeafRuntimeStub(&assembler, str_value, lhs_index_value, |
| 103 rhs_index_value, length_value); |
96 const Code& code = Code::Handle(Code::FinalizeCode( | 104 const Code& code = Code::Handle(Code::FinalizeCode( |
97 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 105 *CreateFunction("Test_CallLeafRuntimeStubCode"), &assembler)); |
98 const Function& function = RegisterFakeFunction(kName, code); | 106 const Function& function = RegisterFakeFunction(kName, code); |
99 Smi& result = Smi::Handle(); | 107 Instance& result = Instance::Handle(); |
100 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 108 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
101 EXPECT_EQ(1, result.Value()); | 109 EXPECT_EQ(Bool::True().raw(), result.raw()); |
102 } | 110 } |
103 | 111 |
104 } // namespace dart | 112 } // namespace dart |
105 | 113 |
106 #endif // defined TARGET_ARCH_IA32 | 114 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |