OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 // Test calls to stub code which calls into the runtime. | 33 // Test calls to stub code which calls into the runtime. |
34 static void GenerateCallToCallRuntimeStub(Assembler* assembler, | 34 static void GenerateCallToCallRuntimeStub(Assembler* assembler, |
35 int value1, int value2) { | 35 int value1, int value2) { |
36 const int argc = 2; | 36 const int argc = 2; |
37 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 37 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
38 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 38 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
39 const Object& result = Object::ZoneHandle(); | 39 const Object& result = Object::ZoneHandle(); |
40 const Context& context = Context::ZoneHandle(Context::New(0)); | 40 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld)); |
41 ASSERT(context.isolate() == Isolate::Current()); | 41 ASSERT(context.isolate() == Isolate::Current()); |
42 __ enter(Immediate(0)); | 42 __ enter(Immediate(0)); |
43 __ LoadObject(CTX, context); | 43 __ LoadObject(CTX, context); |
44 __ PushObject(result); // Push Null object for return value. | 44 __ PushObject(result); // Push Null object for return value. |
45 __ PushObject(smi1); // Push argument 1 smi1. | 45 __ PushObject(smi1); // Push argument 1 smi1. |
46 __ PushObject(smi2); // Push argument 2 smi2. | 46 __ PushObject(smi2); // Push argument 2 smi2. |
47 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); | 47 ASSERT(kTestSmiSubRuntimeEntry.argument_count() == argc); |
48 __ CallRuntime(kTestSmiSubRuntimeEntry); // Call SmiSub runtime func. | 48 __ CallRuntime(kTestSmiSubRuntimeEntry); // Call SmiSub runtime func. |
49 __ AddImmediate(RSP, Immediate(argc * kWordSize)); | 49 __ AddImmediate(RSP, Immediate(argc * kWordSize)); |
50 __ popq(RAX); // Pop return value from return slot. | 50 __ popq(RAX); // Pop return value from return slot. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler, | 111 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler, |
112 int value1, int value2) { | 112 int value1, int value2) { |
113 const int argc = 2; | 113 const int argc = 2; |
114 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 114 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
115 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 115 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
116 const Object& result = Object::ZoneHandle(); | 116 const Object& result = Object::ZoneHandle(); |
117 const String& native_name = String::ZoneHandle(String::New("TestSmiSub")); | 117 const String& native_name = String::ZoneHandle(String::New("TestSmiSub")); |
118 Dart_NativeFunction native_function = | 118 Dart_NativeFunction native_function = |
119 NativeTestEntry_Lookup(native_name, argc); | 119 NativeTestEntry_Lookup(native_name, argc); |
120 ASSERT(native_function != NULL); | 120 ASSERT(native_function != NULL); |
121 const Context& context = Context::ZoneHandle(Context::New(0)); | 121 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld)); |
122 ASSERT(context.isolate() == Isolate::Current()); | 122 ASSERT(context.isolate() == Isolate::Current()); |
123 __ enter(Immediate(0)); | 123 __ enter(Immediate(0)); |
124 __ LoadObject(CTX, context); | 124 __ LoadObject(CTX, context); |
125 __ PushObject(smi1); // Push argument 1 smi1. | 125 __ PushObject(smi1); // Push argument 1 smi1. |
126 __ PushObject(smi2); // Push argument 2 smi2. | 126 __ PushObject(smi2); // Push argument 2 smi2. |
127 __ PushObject(result); // Push Null object for return value. | 127 __ PushObject(result); // Push Null object for return value. |
128 // Pass a pointer to the first argument in RAX. | 128 // Pass a pointer to the first argument in RAX. |
129 __ leaq(RAX, Address(RSP, 2 * kWordSize)); | 129 __ leaq(RAX, Address(RSP, 2 * kWordSize)); |
130 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_function))); | 130 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_function))); |
131 __ movq(R10, Immediate(argc)); | 131 __ movq(R10, Immediate(argc)); |
(...skipping 19 matching lines...) Expand all Loading... |
151 GrowableArray<const Object*> arguments; | 151 GrowableArray<const Object*> arguments; |
152 const Array& kNoArgumentNames = Array::Handle(); | 152 const Array& kNoArgumentNames = Array::Handle(); |
153 Smi& result = Smi::Handle(); | 153 Smi& result = Smi::Handle(); |
154 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 154 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
155 EXPECT_EQ((value1 - value2), result.Value()); | 155 EXPECT_EQ((value1 - value2), result.Value()); |
156 } | 156 } |
157 | 157 |
158 } // namespace dart | 158 } // namespace dart |
159 | 159 |
160 #endif // defined TARGET_ARCH_X64 | 160 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |