| 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 18 matching lines...) Expand all Loading... |
| 29 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 29 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
| 30 Function& function = Function::ZoneHandle( | 30 Function& function = Function::ZoneHandle( |
| 31 Function::New(function_name, RawFunction::kRegularFunction, | 31 Function::New(function_name, RawFunction::kRegularFunction, |
| 32 true, false, false, false, false, owner_class, 0)); | 32 true, false, false, false, false, owner_class, 0)); |
| 33 return &function; | 33 return &function; |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 // Test calls to stub code which calls into the runtime. | 37 // Test calls to stub code which calls into the runtime. |
| 38 static void GenerateCallToCallRuntimeStub(Assembler* assembler, | 38 static void GenerateCallToCallRuntimeStub(Assembler* assembler, |
| 39 int value1, int value2) { | 39 int length) { |
| 40 const int argc = 2; | 40 const int argc = 2; |
| 41 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 41 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length)); |
| 42 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | |
| 43 __ EnterDartFrame(0); | 42 __ EnterDartFrame(0); |
| 44 __ PushObject(Object::null_object()); // Push Null object for return value. | 43 __ PushObject(Object::null_object()); // Push Null object for return value. |
| 45 __ PushObject(smi1); // Push argument 1 smi1. | 44 __ PushObject(smi_length); // Push argument 1: length. |
| 46 __ PushObject(smi2); // Push argument 2 smi2. | 45 __ PushObject(Object::null_object()); // Push argument 2: type arguments. |
| 47 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); | 46 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc); |
| 48 __ CallRuntime(kTestSmiSubRuntimeEntry, argc); // Call SmiSub runtime func. | 47 __ CallRuntime(kAllocateArrayRuntimeEntry, argc); |
| 49 __ addiu(SP, SP, Immediate(argc * kWordSize)); | 48 __ addiu(SP, SP, Immediate(argc * kWordSize)); |
| 50 __ Pop(V0); // Pop return value from return slot. | 49 __ Pop(V0); // Pop return value from return slot. |
| 51 __ LeaveDartFrameAndReturn(); | 50 __ LeaveDartFrameAndReturn(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 | 53 |
| 55 TEST_CASE(CallRuntimeStubCode) { | 54 TEST_CASE(CallRuntimeStubCode) { |
| 56 extern const Function& RegisterFakeFunction(const char* name, | 55 extern const Function& RegisterFakeFunction(const char* name, |
| 57 const Code& code); | 56 const Code& code); |
| 58 const int value1 = 10; | 57 const int length = 10; |
| 59 const int value2 = 20; | |
| 60 const char* kName = "Test_CallRuntimeStubCode"; | 58 const char* kName = "Test_CallRuntimeStubCode"; |
| 61 Assembler _assembler_; | 59 Assembler _assembler_; |
| 62 GenerateCallToCallRuntimeStub(&_assembler_, value1, value2); | 60 GenerateCallToCallRuntimeStub(&_assembler_, length); |
| 63 const Code& code = Code::Handle(Code::FinalizeCode( | 61 const Code& code = Code::Handle(Code::FinalizeCode( |
| 64 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); | 62 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); |
| 65 const Function& function = RegisterFakeFunction(kName, code); | 63 const Function& function = RegisterFakeFunction(kName, code); |
| 66 Smi& result = Smi::Handle(); | 64 Array& result = Array::Handle(); |
| 67 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 65 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
| 68 EXPECT_EQ((value1 - value2), result.Value()); | 66 EXPECT_EQ(length, result.Length()); |
| 69 } | 67 } |
| 70 | 68 |
| 71 | 69 |
| 72 // Test calls to stub code which calls into a leaf runtime entry. | 70 // Test calls to stub code which calls into a leaf runtime entry. |
| 73 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, | 71 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, |
| 74 int value1, | 72 const char* value1, |
| 75 int value2) { | 73 const char* value2) { |
| 76 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 74 const Bigint& bigint1 = |
| 77 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 75 Bigint::ZoneHandle(Bigint::NewFromCString(value1, Heap::kOld)); |
| 76 const Bigint& bigint2 = |
| 77 Bigint::ZoneHandle(Bigint::NewFromCString(value2, Heap::kOld)); |
| 78 __ EnterDartFrame(0); | 78 __ EnterDartFrame(0); |
| 79 __ ReserveAlignedFrameSpace(0); | 79 __ ReserveAlignedFrameSpace(0); |
| 80 __ LoadObject(A0, smi1); // Set up argument 1 smi1. | 80 __ LoadObject(A0, bigint1); // Set up argument 1 bigint1. |
| 81 __ LoadObject(A1, smi2); // Set up argument 2 smi2. | 81 __ LoadObject(A1, bigint2); // Set up argument 2 bigint2. |
| 82 __ CallRuntime(kTestLeafSmiAddRuntimeEntry, 2); // Call SmiAdd runtime func. | 82 __ CallRuntime(kBigintCompareRuntimeEntry, 2); |
| 83 __ SmiTag(V0); |
| 83 __ LeaveDartFrameAndReturn(); // Return value is in V0. | 84 __ LeaveDartFrameAndReturn(); // Return value is in V0. |
| 84 } | 85 } |
| 85 | 86 |
| 86 | 87 |
| 87 TEST_CASE(CallLeafRuntimeStubCode) { | 88 TEST_CASE(CallLeafRuntimeStubCode) { |
| 88 extern const Function& RegisterFakeFunction(const char* name, | 89 extern const Function& RegisterFakeFunction(const char* name, |
| 89 const Code& code); | 90 const Code& code); |
| 90 const int value1 = 10; | 91 const char* value1 = "0xAAABBCCDDAABBCCDD"; |
| 91 const int value2 = 20; | 92 const char* value2 = "0xAABBCCDDAABBCCDD"; |
| 92 const char* kName = "Test_CallLeafRuntimeStubCode"; | 93 const char* kName = "Test_CallLeafRuntimeStubCode"; |
| 93 Assembler _assembler_; | 94 Assembler _assembler_; |
| 94 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); | 95 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); |
| 95 const Code& code = Code::Handle(Code::FinalizeCode( | 96 const Code& code = Code::Handle(Code::FinalizeCode( |
| 96 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 97 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); |
| 97 const Function& function = RegisterFakeFunction(kName, code); | 98 const Function& function = RegisterFakeFunction(kName, code); |
| 98 Smi& result = Smi::Handle(); | 99 Smi& result = Smi::Handle(); |
| 99 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 100 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
| 100 EXPECT_EQ((value1 + value2), result.Value()); | 101 EXPECT_EQ(1, result.Value()); |
| 101 } | 102 } |
| 102 | 103 |
| 103 } // namespace dart | 104 } // namespace dart |
| 104 | 105 |
| 105 #endif // defined TARGET_ARCH_MIPS | 106 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |