OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 __ EnterDartFrame(0); | 48 __ EnterDartFrame(0); |
49 __ LoadObject(CTX, context); | 49 __ LoadObject(CTX, context); |
50 __ PushObject(result); // Push Null object for return value. | 50 __ PushObject(result); // Push Null object for return value. |
51 __ PushObject(smi1); // Push argument 1 smi1. | 51 __ PushObject(smi1); // Push argument 1 smi1. |
52 __ PushObject(smi2); // Push argument 2 smi2. | 52 __ PushObject(smi2); // Push argument 2 smi2. |
53 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); | 53 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); |
54 __ CallRuntime(kTestSmiSubRuntimeEntry); // Call SmiSub runtime func. | 54 __ CallRuntime(kTestSmiSubRuntimeEntry, argc); // Call SmiSub runtime func. |
55 __ addiu(SP, SP, Immediate(argc * kWordSize)); | 55 __ addiu(SP, SP, Immediate(argc * kWordSize)); |
56 __ Pop(V0); // Pop return value from return slot. | 56 __ Pop(V0); // Pop return value from return slot. |
57 __ LeaveDartFrameAndReturn(); | 57 __ LeaveDartFrameAndReturn(); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 TEST_CASE(CallRuntimeStubCode) { | 61 TEST_CASE(CallRuntimeStubCode) { |
62 extern const Function& RegisterFakeFunction(const char* name, | 62 extern const Function& RegisterFakeFunction(const char* name, |
63 const Code& code); | 63 const Code& code); |
64 const int value1 = 10; | 64 const int value1 = 10; |
(...skipping 13 matching lines...) Expand all Loading... |
78 // Test calls to stub code which calls into a leaf runtime entry. | 78 // Test calls to stub code which calls into a leaf runtime entry. |
79 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, | 79 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, |
80 int value1, | 80 int value1, |
81 int value2) { | 81 int value2) { |
82 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 82 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
83 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 83 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
84 __ EnterDartFrame(0); | 84 __ EnterDartFrame(0); |
85 __ ReserveAlignedFrameSpace(0); | 85 __ ReserveAlignedFrameSpace(0); |
86 __ LoadObject(A0, smi1); // Set up argument 1 smi1. | 86 __ LoadObject(A0, smi1); // Set up argument 1 smi1. |
87 __ LoadObject(A1, smi2); // Set up argument 2 smi2. | 87 __ LoadObject(A1, smi2); // Set up argument 2 smi2. |
88 __ CallRuntime(kTestLeafSmiAddRuntimeEntry); // Call SmiAdd runtime func. | 88 __ CallRuntime(kTestLeafSmiAddRuntimeEntry, 2); // Call SmiAdd runtime func. |
89 __ LeaveDartFrameAndReturn(); // Return value is in V0. | 89 __ LeaveDartFrameAndReturn(); // Return value is in V0. |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 TEST_CASE(CallLeafRuntimeStubCode) { | 93 TEST_CASE(CallLeafRuntimeStubCode) { |
94 extern const Function& RegisterFakeFunction(const char* name, | 94 extern const Function& RegisterFakeFunction(const char* name, |
95 const Code& code); | 95 const Code& code); |
96 const int value1 = 10; | 96 const int value1 = 10; |
97 const int value2 = 20; | 97 const int value2 = 20; |
98 const char* kName = "Test_CallLeafRuntimeStubCode"; | 98 const char* kName = "Test_CallLeafRuntimeStubCode"; |
99 Assembler _assembler_; | 99 Assembler _assembler_; |
100 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); | 100 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); |
101 const Code& code = Code::Handle(Code::FinalizeCode( | 101 const Code& code = Code::Handle(Code::FinalizeCode( |
102 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 102 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); |
103 const Function& function = RegisterFakeFunction(kName, code); | 103 const Function& function = RegisterFakeFunction(kName, code); |
104 Smi& result = Smi::Handle(); | 104 Smi& result = Smi::Handle(); |
105 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 105 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
106 EXPECT_EQ((value1 + value2), result.Value()); | 106 EXPECT_EQ((value1 + value2), result.Value()); |
107 } | 107 } |
108 | 108 |
109 } // namespace dart | 109 } // namespace dart |
110 | 110 |
111 #endif // defined TARGET_ARCH_MIPS | 111 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |