Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: runtime/vm/stub_code_mips_test.cc

Issue 2858623002: Remove MIPS support (Closed)
Patch Set: Merge and cleanup Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS)
7
8 #include "vm/isolate.h"
9 #include "vm/dart_entry.h"
10 #include "vm/native_entry.h"
11 #include "vm/native_entry_test.h"
12 #include "vm/object.h"
13 #include "vm/runtime_entry.h"
14 #include "vm/stub_code.h"
15 #include "vm/symbols.h"
16 #include "vm/unit_test.h"
17
18 #define __ assembler->
19
20 namespace dart {
21
22 static Function* CreateFunction(const char* name) {
23 const String& class_name =
24 String::Handle(Symbols::New(Thread::Current(), "ownerClass"));
25 const Script& script = Script::Handle();
26 const Library& lib = Library::Handle(Library::New(class_name));
27 const Class& owner_class = Class::Handle(
28 Class::New(lib, class_name, script, TokenPosition::kNoSource));
29 const String& function_name =
30 String::ZoneHandle(Symbols::New(Thread::Current(), name));
31 Function& function = Function::ZoneHandle(Function::New(
32 function_name, RawFunction::kRegularFunction, true, false, false, false,
33 false, owner_class, TokenPosition::kNoSource));
34 return &function;
35 }
36
37
38 // Test calls to stub code which calls into the runtime.
39 static void GenerateCallToCallRuntimeStub(Assembler* assembler, int length) {
40 const int argc = 2;
41 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length));
42 __ EnterDartFrame(0);
43 __ PushObject(Object::null_object()); // Push Null object for return value.
44 __ PushObject(smi_length); // Push argument 1: length.
45 __ PushObject(Object::null_object()); // Push argument 2: type arguments.
46 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc);
47 __ CallRuntime(kAllocateArrayRuntimeEntry, argc);
48 __ addiu(SP, SP, Immediate(argc * kWordSize));
49 __ Pop(V0); // Pop return value from return slot.
50 __ LeaveDartFrameAndReturn();
51 }
52
53
54 TEST_CASE(CallRuntimeStubCode) {
55 extern const Function& RegisterFakeFunction(const char* name,
56 const Code& code);
57 const int length = 10;
58 const char* kName = "Test_CallRuntimeStubCode";
59 Assembler _assembler_;
60 GenerateCallToCallRuntimeStub(&_assembler_, length);
61 const Code& code = Code::Handle(Code::FinalizeCode(
62 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_));
63 const Function& function = RegisterFakeFunction(kName, code);
64 Array& result = Array::Handle();
65 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
66 EXPECT_EQ(length, result.Length());
67 }
68
69
70 // Test calls to stub code which calls into a leaf runtime entry.
71 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler,
72 const char* value1,
73 const char* value2) {
74 const Bigint& bigint1 =
75 Bigint::ZoneHandle(Bigint::NewFromCString(value1, Heap::kOld));
76 const Bigint& bigint2 =
77 Bigint::ZoneHandle(Bigint::NewFromCString(value2, Heap::kOld));
78 __ EnterDartFrame(0);
79 __ ReserveAlignedFrameSpace(0);
80 __ LoadObject(A0, bigint1); // Set up argument 1 bigint1.
81 __ LoadObject(A1, bigint2); // Set up argument 2 bigint2.
82 __ CallRuntime(kBigintCompareRuntimeEntry, 2);
83 __ SmiTag(V0);
84 __ LeaveDartFrameAndReturn(); // Return value is in V0.
85 }
86
87
88 TEST_CASE(CallLeafRuntimeStubCode) {
89 extern const Function& RegisterFakeFunction(const char* name,
90 const Code& code);
91 const char* value1 = "0xAAABBCCDDAABBCCDD";
92 const char* value2 = "0xAABBCCDDAABBCCDD";
93 const char* kName = "Test_CallLeafRuntimeStubCode";
94 Assembler _assembler_;
95 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2);
96 const Code& code = Code::Handle(Code::FinalizeCode(
97 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_));
98 const Function& function = RegisterFakeFunction(kName, code);
99 Smi& result = Smi::Handle();
100 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
101 EXPECT_EQ(1, result.Value());
102 }
103
104 } // namespace dart
105
106 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698