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

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

Issue 2992483002: [vm] Update runtime/vm/stub_code_<arch>_test to avoid using Bigints (Closed)
Patch Set: Cleanup: _assembler_ locals are renamed to assembler. Created 3 years, 4 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_ia32_test.cc ('k') | no next file » | 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) 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_X64) 6 #if defined(TARGET_ARCH_X64)
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
48 __ popq(RAX); // Pop return value from return slot. 48 __ popq(RAX); // Pop return value from return slot.
49 __ LeaveStubFrame(); 49 __ LeaveStubFrame();
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 __ EnterStubFrame(); 78 __ EnterStubFrame();
77 __ ReserveAlignedFrameSpace(0); 79 __ ReserveAlignedFrameSpace(0);
78 __ LoadObject(CallingConventions::kArg1Reg, bigint1); 80 __ LoadObject(CallingConventions::kArg1Reg, str);
79 __ LoadObject(CallingConventions::kArg2Reg, bigint2); 81 __ LoadObject(CallingConventions::kArg2Reg, lhs_index);
80 __ CallRuntime(kBigintCompareRuntimeEntry, 2); 82 __ LoadObject(CallingConventions::kArg3Reg, rhs_index);
81 __ SmiTag(RAX); 83 __ LoadObject(CallingConventions::kArg4Reg, length);
84 __ CallRuntime(kCaseInsensitiveCompareUC16RuntimeEntry, 4);
82 __ LeaveStubFrame(); 85 __ LeaveStubFrame();
83 __ ret(); // Return value is in RAX. 86 __ ret(); // Return value is in RAX.
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_X64 110 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_ia32_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698