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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
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" |
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 = String::Handle(Symbols::New(Thread::Current(), | 23 const String& class_name = |
24 "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 = String::ZoneHandle( | 29 const String& function_name = |
30 Symbols::New(Thread::Current(), name)); | 30 String::ZoneHandle(Symbols::New(Thread::Current(), name)); |
31 Function& function = Function::ZoneHandle( | 31 Function& function = Function::ZoneHandle(Function::New( |
32 Function::New(function_name, RawFunction::kRegularFunction, | 32 function_name, RawFunction::kRegularFunction, true, false, false, false, |
33 true, false, false, false, false, owner_class, | 33 false, owner_class, TokenPosition::kNoSource)); |
34 TokenPosition::kNoSource)); | |
35 return &function; | 34 return &function; |
36 } | 35 } |
37 | 36 |
38 | 37 |
39 // Test calls to stub code which calls into the runtime. | 38 // Test calls to stub code which calls into the runtime. |
40 static void GenerateCallToCallRuntimeStub(Assembler* assembler, | 39 static void GenerateCallToCallRuntimeStub(Assembler* assembler, int length) { |
41 int length) { | |
42 const int argc = 2; | 40 const int argc = 2; |
43 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length)); | 41 const Smi& smi_length = Smi::ZoneHandle(Smi::New(length)); |
44 __ EnterDartFrame(0); | 42 __ EnterDartFrame(0); |
45 __ PushObject(Object::null_object()); // Push Null object for return value. | 43 __ PushObject(Object::null_object()); // Push Null object for return value. |
46 __ PushObject(smi_length); // Push argument 1: length. | 44 __ PushObject(smi_length); // Push argument 1: length. |
47 __ PushObject(Object::null_object()); // Push argument 2: type arguments. | 45 __ PushObject(Object::null_object()); // Push argument 2: type arguments. |
48 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc); | 46 ASSERT(kAllocateArrayRuntimeEntry.argument_count() == argc); |
49 __ CallRuntime(kAllocateArrayRuntimeEntry, argc); | 47 __ CallRuntime(kAllocateArrayRuntimeEntry, argc); |
50 __ AddImmediate(SP, argc * kWordSize); | 48 __ AddImmediate(SP, argc * kWordSize); |
51 __ Pop(R0); // Pop return value from return slot. | 49 __ Pop(R0); // Pop return value from return slot. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 99 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); |
102 const Function& function = RegisterFakeFunction(kName, code); | 100 const Function& function = RegisterFakeFunction(kName, code); |
103 Smi& result = Smi::Handle(); | 101 Smi& result = Smi::Handle(); |
104 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); | 102 result ^= DartEntry::InvokeFunction(function, Object::empty_array()); |
105 EXPECT_EQ(1, result.Value()); | 103 EXPECT_EQ(1, result.Value()); |
106 } | 104 } |
107 | 105 |
108 } // namespace dart | 106 } // namespace dart |
109 | 107 |
110 #endif // defined TARGET_ARCH_ARM | 108 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |