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