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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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_arm64_test.cc ('k') | runtime/vm/stub_code_dbc.cc » ('j') | 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) 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_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/dart_entry.h"
8 #include "vm/isolate.h" 9 #include "vm/isolate.h"
9 #include "vm/dart_entry.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
11 #include "vm/native_entry_test.h" 11 #include "vm/native_entry_test.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/runtime_entry.h" 13 #include "vm/runtime_entry.h"
14 #include "vm/stub_code.h" 14 #include "vm/stub_code.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 #include "vm/unit_test.h" 16 #include "vm/unit_test.h"
17 17
18 #define __ assembler-> 18 #define __ assembler->
19 19
20 namespace dart { 20 namespace dart {
21 21
22 static Function* CreateFunction(const char* name) { 22 static Function* CreateFunction(const char* name) {
23 const String& class_name = 23 const String& class_name =
24 String::Handle(Symbols::New(Thread::Current(), "ownerClass")); 24 String::Handle(Symbols::New(Thread::Current(), "ownerClass"));
25 const Script& script = Script::Handle(); 25 const Script& script = Script::Handle();
26 const Library& lib = Library::Handle(Library::New(class_name)); 26 const Library& lib = Library::Handle(Library::New(class_name));
27 const Class& owner_class = Class::Handle( 27 const Class& owner_class = Class::Handle(
28 Class::New(lib, class_name, script, TokenPosition::kNoSource)); 28 Class::New(lib, class_name, script, TokenPosition::kNoSource));
29 const String& function_name = 29 const String& function_name =
30 String::ZoneHandle(Symbols::New(Thread::Current(), name)); 30 String::ZoneHandle(Symbols::New(Thread::Current(), name));
31 Function& function = Function::ZoneHandle(Function::New( 31 Function& function = Function::ZoneHandle(Function::New(
32 function_name, RawFunction::kRegularFunction, true, false, false, false, 32 function_name, RawFunction::kRegularFunction, true, false, false, false,
33 false, owner_class, TokenPosition::kNoSource)); 33 false, owner_class, TokenPosition::kNoSource));
34 return &function; 34 return &function;
35 } 35 }
36 36
37
38 // Test calls to stub code which calls into the runtime. 37 // Test calls to stub code which calls into the runtime.
39 static void GenerateCallToCallRuntimeStub(Assembler* assembler, int length) { 38 static void GenerateCallToCallRuntimeStub(Assembler* assembler, int length) {
40 const int argc = 2; 39 const int argc = 2;
41 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length)); 40 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length));
42 __ EnterDartFrame(0); 41 __ EnterDartFrame(0);
43 __ PushObject(Object::null_object()); // Push Null object for return value. 42 __ PushObject(Object::null_object()); // Push Null object for return value.
44 __ PushObject(smi_length); // Push argument 1: length. 43 __ PushObject(smi_length); // Push argument 1: length.
45 __ PushObject(Object::null_object()); // Push argument 2: type arguments. 44 __ PushObject(Object::null_object()); // Push argument 2: type arguments.
46 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc); 45 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc);
47 __ CallRuntime(kAllocateArrayRuntimeEntry, argc); 46 __ CallRuntime(kAllocateArrayRuntimeEntry, argc);
48 __ AddImmediate(SP, argc * kWordSize); 47 __ AddImmediate(SP, argc * kWordSize);
49 __ Pop(R0); // Pop return value from return slot. 48 __ Pop(R0); // Pop return value from return slot.
50 __ LeaveDartFrame(); 49 __ LeaveDartFrame();
51 __ Ret(); 50 __ Ret();
52 } 51 }
53 52
54
55 TEST_CASE(CallRuntimeStubCode) { 53 TEST_CASE(CallRuntimeStubCode) {
56 extern const Function& RegisterFakeFunction(const char* name, 54 extern const Function& RegisterFakeFunction(const char* name,
57 const Code& code); 55 const Code& code);
58 const int length = 10; 56 const int length = 10;
59 const char* kName = "Test_CallRuntimeStubCode"; 57 const char* kName = "Test_CallRuntimeStubCode";
60 Assembler _assembler_; 58 Assembler _assembler_;
61 GenerateCallToCallRuntimeStub(&_assembler_, length); 59 GenerateCallToCallRuntimeStub(&_assembler_, length);
62 const Code& code = Code::Handle(Code::FinalizeCode( 60 const Code& code = Code::Handle(Code::FinalizeCode(
63 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); 61 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_));
64 const Function& function = RegisterFakeFunction(kName, code); 62 const Function& function = RegisterFakeFunction(kName, code);
65 Array& result = Array::Handle(); 63 Array& result = Array::Handle();
66 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); 64 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
67 EXPECT_EQ(length, result.Length()); 65 EXPECT_EQ(length, result.Length());
68 } 66 }
69 67
70
71 // Test calls to stub code which calls into a leaf runtime entry. 68 // Test calls to stub code which calls into a leaf runtime entry.
72 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, 69 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler,
73 const char* value1, 70 const char* value1,
74 const char* value2) { 71 const char* value2) {
75 const Bigint& bigint1 = 72 const Bigint& bigint1 =
76 Bigint::ZoneHandle(Bigint::NewFromCString(value1, Heap::kOld)); 73 Bigint::ZoneHandle(Bigint::NewFromCString(value1, Heap::kOld));
77 const Bigint& bigint2 = 74 const Bigint& bigint2 =
78 Bigint::ZoneHandle(Bigint::NewFromCString(value2, Heap::kOld)); 75 Bigint::ZoneHandle(Bigint::NewFromCString(value2, Heap::kOld));
79 __ EnterDartFrame(0); 76 __ EnterDartFrame(0);
80 __ ReserveAlignedFrameSpace(0); 77 __ ReserveAlignedFrameSpace(0);
81 __ LoadObject(R0, bigint1); // Set up argument 1 bigint1. 78 __ LoadObject(R0, bigint1); // Set up argument 1 bigint1.
82 __ LoadObject(R1, bigint2); // Set up argument 2 bigint2. 79 __ LoadObject(R1, bigint2); // Set up argument 2 bigint2.
83 __ CallRuntime(kBigintCompareRuntimeEntry, 2); 80 __ CallRuntime(kBigintCompareRuntimeEntry, 2);
84 __ SmiTag(R0); 81 __ SmiTag(R0);
85 __ LeaveDartFrame(); 82 __ LeaveDartFrame();
86 __ Ret(); // Return value is in R0. 83 __ Ret(); // Return value is in R0.
87 } 84 }
88 85
89
90 TEST_CASE(CallLeafRuntimeStubCode) { 86 TEST_CASE(CallLeafRuntimeStubCode) {
91 extern const Function& RegisterFakeFunction(const char* name, 87 extern const Function& RegisterFakeFunction(const char* name,
92 const Code& code); 88 const Code& code);
93 const char* value1 = "0xAAABBCCDDAABBCCDD"; 89 const char* value1 = "0xAAABBCCDDAABBCCDD";
94 const char* value2 = "0xAABBCCDDAABBCCDD"; 90 const char* value2 = "0xAABBCCDDAABBCCDD";
95 const char* kName = "Test_CallLeafRuntimeStubCode"; 91 const char* kName = "Test_CallLeafRuntimeStubCode";
96 Assembler _assembler_; 92 Assembler _assembler_;
97 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); 93 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2);
98 const Code& code = Code::Handle(Code::FinalizeCode( 94 const Code& code = Code::Handle(Code::FinalizeCode(
99 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); 95 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_));
100 const Function& function = RegisterFakeFunction(kName, code); 96 const Function& function = RegisterFakeFunction(kName, code);
101 Smi& result = Smi::Handle(); 97 Smi& result = Smi::Handle();
102 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); 98 result ^= DartEntry::InvokeFunction(function, Object::empty_array());
103 EXPECT_EQ(1, result.Value()); 99 EXPECT_EQ(1, result.Value());
104 } 100 }
105 101
106 } // namespace dart 102 } // namespace dart
107 103
108 #endif // defined TARGET_ARCH_ARM 104 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm64_test.cc ('k') | runtime/vm/stub_code_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698