| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Test calls to stub code which calls into the runtime. | 39 // Test calls to stub code which calls into the runtime. |
| 40 static void GenerateCallToCallRuntimeStub(Assembler* assembler, | 40 static void GenerateCallToCallRuntimeStub(Assembler* assembler, |
| 41 int value1, int value2) { | 41 int value1, int value2) { |
| 42 const int argc = 2; | 42 const int argc = 2; |
| 43 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 43 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
| 44 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 44 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
| 45 const Object& result = Object::ZoneHandle(); | 45 const Object& result = Object::ZoneHandle(); |
| 46 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld)); | 46 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld)); |
| 47 ASSERT(context.isolate() == Isolate::Current()); | 47 ASSERT(context.isolate() == Isolate::Current()); |
| 48 __ EnterStubFrameWithPP(); | 48 __ EnterStubFrame(true); |
| 49 __ LoadObject(CTX, context, PP); | 49 __ LoadObject(CTX, context, PP); |
| 50 __ PushObject(result, PP); // Push Null object for return value. | 50 __ PushObject(result, PP); // Push Null object for return value. |
| 51 __ PushObject(smi1, PP); // Push argument 1 smi1. | 51 __ PushObject(smi1, PP); // Push argument 1 smi1. |
| 52 __ PushObject(smi2, PP); // Push argument 2 smi2. | 52 __ PushObject(smi2, PP); // Push argument 2 smi2. |
| 53 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); | 53 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); |
| 54 __ CallRuntime(kTestSmiSubRuntimeEntry, argc); // Call SmiSub runtime func. | 54 __ CallRuntime(kTestSmiSubRuntimeEntry, argc); // Call SmiSub runtime func. |
| 55 __ AddImmediate(RSP, Immediate(argc * kWordSize), PP); | 55 __ AddImmediate(RSP, Immediate(argc * kWordSize), PP); |
| 56 __ popq(RAX); // Pop return value from return slot. | 56 __ popq(RAX); // Pop return value from return slot. |
| 57 __ LeaveFrameWithPP(); | 57 __ LeaveStubFrame(); |
| 58 __ ret(); | 58 __ ret(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 |
| 62 TEST_CASE(CallRuntimeStubCode) { | 62 TEST_CASE(CallRuntimeStubCode) { |
| 63 extern const Function& RegisterFakeFunction(const char* name, | 63 extern const Function& RegisterFakeFunction(const char* name, |
| 64 const Code& code); | 64 const Code& code); |
| 65 const int value1 = 10; | 65 const int value1 = 10; |
| 66 const int value2 = 20; | 66 const int value2 = 20; |
| 67 const char* kName = "Test_CallRuntimeStubCode"; | 67 const char* kName = "Test_CallRuntimeStubCode"; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 104 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); |
| 105 const Function& function = RegisterFakeFunction(kName, code); | 105 const Function& function = RegisterFakeFunction(kName, code); |
| 106 Smi& result = Smi::Handle(); | 106 Smi& result = Smi::Handle(); |
| 107 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 107 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
| 108 EXPECT_EQ((value1 + value2), result.Value()); | 108 EXPECT_EQ((value1 + value2), result.Value()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace dart | 111 } // namespace dart |
| 112 | 112 |
| 113 #endif // defined TARGET_ARCH_X64 | 113 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |