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_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 | 80 |
81 // Test calls to stub code which calls into a leaf runtime entry. | 81 // Test calls to stub code which calls into a leaf runtime entry. |
82 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, | 82 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, |
83 int value1, | 83 int value1, |
84 int value2) { | 84 int value2) { |
85 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 85 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
86 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 86 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
87 __ enter(Immediate(0)); | 87 __ enter(Immediate(0)); |
88 __ ReserveAlignedFrameSpace(0); | 88 __ ReserveAlignedFrameSpace(0); |
89 __ LoadObject(RDI, smi1, PP); // Set up argument 1 smi1. | 89 __ LoadObject(CallingConventions::kArg1Reg, smi1, PP); |
90 __ LoadObject(RSI, smi2, PP); // Set up argument 2 smi2. | 90 __ LoadObject(CallingConventions::kArg2Reg, smi2, PP); |
91 __ CallRuntime(kTestLeafSmiAddRuntimeEntry, 2); // Call SmiAdd runtime func. | 91 __ CallRuntime(kTestLeafSmiAddRuntimeEntry, 2); // Call SmiAdd runtime func. |
92 __ leave(); | 92 __ leave(); |
93 __ ret(); // Return value is in RAX. | 93 __ ret(); // Return value is in RAX. |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 TEST_CASE(CallLeafRuntimeStubCode) { | 97 TEST_CASE(CallLeafRuntimeStubCode) { |
98 extern const Function& RegisterFakeFunction(const char* name, | 98 extern const Function& RegisterFakeFunction(const char* name, |
99 const Code& code); | 99 const Code& code); |
100 const int value1 = 10; | 100 const int value1 = 10; |
101 const int value2 = 20; | 101 const int value2 = 20; |
102 const char* kName = "Test_CallLeafRuntimeStubCode"; | 102 const char* kName = "Test_CallLeafRuntimeStubCode"; |
103 Assembler _assembler_; | 103 Assembler _assembler_; |
104 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); | 104 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); |
105 const Code& code = Code::Handle(Code::FinalizeCode( | 105 const Code& code = Code::Handle(Code::FinalizeCode( |
106 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 106 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); |
107 const Function& function = RegisterFakeFunction(kName, code); | 107 const Function& function = RegisterFakeFunction(kName, code); |
108 Smi& result = Smi::Handle(); | 108 Smi& result = Smi::Handle(); |
109 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 109 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
110 EXPECT_EQ((value1 + value2), result.Value()); | 110 EXPECT_EQ((value1 + value2), result.Value()); |
111 } | 111 } |
112 | 112 |
113 } // namespace dart | 113 } // namespace dart |
114 | 114 |
115 #endif // defined TARGET_ARCH_X64 | 115 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |