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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 // Test calls to stub code which calls a native C function. | 116 // Test calls to stub code which calls a native C function. |
117 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler, | 117 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler, |
118 int value1, int value2) { | 118 int value1, int value2) { |
119 const int argc = 2; | 119 const int argc = 2; |
120 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 120 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
121 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 121 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
122 const Object& result = Object::ZoneHandle(); | 122 const Object& result = Object::ZoneHandle(); |
123 const String& native_name = String::ZoneHandle(String::New("TestSmiSub")); | 123 Dart_NativeFunction native_function = TestSmiSub; |
124 Dart_NativeFunction native_function = | |
125 NativeTestEntry_Lookup(native_name, argc); | |
126 ASSERT(native_function != NULL); | 124 ASSERT(native_function != NULL); |
127 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld)); | 125 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld)); |
128 ASSERT(context.isolate() == Isolate::Current()); | 126 ASSERT(context.isolate() == Isolate::Current()); |
129 __ enter(Immediate(0)); | 127 __ enter(Immediate(0)); |
130 __ LoadObject(CTX, context); | 128 __ LoadObject(CTX, context); |
131 __ PushObject(smi1); // Push argument 1 smi1. | 129 __ PushObject(smi1); // Push argument 1 smi1. |
132 __ PushObject(smi2); // Push argument 2 smi2. | 130 __ PushObject(smi2); // Push argument 2 smi2. |
133 __ PushObject(result); // Push Null object for return value. | 131 __ PushObject(result); // Push Null object for return value. |
134 // Pass a pointer to the first argument in RAX. | 132 // Pass a pointer to the first argument in RAX. |
135 __ leaq(RAX, Address(RSP, 2 * kWordSize)); | 133 __ leaq(RAX, Address(RSP, 2 * kWordSize)); |
(...skipping 21 matching lines...) Expand all Loading... |
157 GrowableArray<const Object*> arguments; | 155 GrowableArray<const Object*> arguments; |
158 const Array& kNoArgumentNames = Array::Handle(); | 156 const Array& kNoArgumentNames = Array::Handle(); |
159 Smi& result = Smi::Handle(); | 157 Smi& result = Smi::Handle(); |
160 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 158 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
161 EXPECT_EQ((value1 - value2), result.Value()); | 159 EXPECT_EQ((value1 - value2), result.Value()); |
162 } | 160 } |
163 | 161 |
164 } // namespace dart | 162 } // namespace dart |
165 | 163 |
166 #endif // defined TARGET_ARCH_X64 | 164 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |