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

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

Issue 243773002: Adds Runtime call stub and Dart entry stub to ARM64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 // TODO(zra): Port these tests. 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 DECLARE_RUNTIME_ENTRY(TestSmiSub);
23 DECLARE_LEAF_RUNTIME_ENTRY(RawObject*, TestLeafSmiAdd, RawObject*, RawObject*);
24
25
26 static Function* CreateFunction(const char* name) {
27 const String& class_name = String::Handle(Symbols::New("ownerClass"));
28 const Script& script = Script::Handle();
29 const Class& owner_class =
30 Class::Handle(Class::New(class_name, script, Scanner::kNoSourcePos));
31 const Library& lib = Library::Handle(Library::New(class_name));
32 owner_class.set_library(lib);
33 const String& function_name = String::ZoneHandle(Symbols::New(name));
34 Function& function = Function::ZoneHandle(
35 Function::New(function_name, RawFunction::kRegularFunction,
36 true, false, false, false, false, owner_class, 0));
37 return &function;
38 }
39
40
41 // Test calls to stub code which calls into the runtime.
42 static void GenerateCallToCallRuntimeStub(Assembler* assembler,
43 int value1, int value2) {
44 const int argc = 2;
45 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1));
46 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2));
47 const Object& result = Object::ZoneHandle();
48 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld));
49 ASSERT(context.isolate() == Isolate::Current());
50 __ EnterDartFrame(0);
51 __ LoadObject(CTX, context, PP);
52 __ PushObject(result, PP); // Push Null object for return value.
53 __ PushObject(smi1, PP); // Push argument 1 smi1.
54 __ PushObject(smi2, PP); // Push argument 2 smi2.
55 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc);
56 __ CallRuntime(kTestSmiSubRuntimeEntry, argc); // Call SmiSub runtime func.
57 __ add(SP, SP, Operand(argc * kWordSize));
58 __ Pop(R0); // Pop return value from return slot.
59 __ LeaveDartFrame();
60 __ ret();
61 }
62
63
64 TEST_CASE(CallRuntimeStubCode) {
65 extern const Function& RegisterFakeFunction(const char* name,
66 const Code& code);
67 const int value1 = 10;
68 const int value2 = 20;
69 const char* kName = "Test_CallRuntimeStubCode";
70 Assembler _assembler_;
71 GenerateCallToCallRuntimeStub(&_assembler_, value1, value2);
72 const Code& code = Code::Handle(Code::FinalizeCode(
73 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_));
74 const Function& function = RegisterFakeFunction(kName, code);
75 Smi& result = Smi::Handle();
76 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
77 EXPECT_EQ((value1 - value2), result.Value());
78 }
79
80
81 // Test calls to stub code which calls into a leaf runtime entry.
82 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler,
83 int value1,
84 int value2) {
85 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1));
86 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2));
87 __ EnterDartFrame(0);
88 __ ReserveAlignedFrameSpace(0);
89 __ LoadObject(R0, smi1, PP); // Set up argument 1 smi1.
90 __ LoadObject(R1, smi2, PP); // Set up argument 2 smi2.
91 __ CallRuntime(kTestLeafSmiAddRuntimeEntry, 2); // Call SmiAdd runtime func.
92 __ LeaveDartFrame();
93 __ ret(); // Return value is in R0.
94 }
95
96
97 TEST_CASE(CallLeafRuntimeStubCode) {
98 extern const Function& RegisterFakeFunction(const char* name,
99 const Code& code);
100 const int value1 = 10;
101 const int value2 = 20;
102 const char* kName = "Test_CallLeafRuntimeStubCode";
103 Assembler _assembler_;
104 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2);
105 const Code& code = Code::Handle(Code::FinalizeCode(
106 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_));
107 const Function& function = RegisterFakeFunction(kName, code);
108 Smi& result = Smi::Handle();
109 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
110 EXPECT_EQ((value1 + value2), result.Value());
111 }
112
113 } // namespace dart
9 114
10 #endif // defined TARGET_ARCH_ARM64 115 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698