| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // Test calls to stub code which calls a native C function. | 110 // Test calls to stub code which calls a native C function. |
| 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 const Context& context = Context::ZoneHandle(Context::New(0)); | 121 const Context& context = Context::ZoneHandle(Context::New(0)); |
| 121 ASSERT(context.isolate() == Isolate::Current()); | 122 ASSERT(context.isolate() == Isolate::Current()); |
| 122 __ enter(Immediate(0)); | 123 __ enter(Immediate(0)); |
| 123 __ LoadObject(CTX, context); | 124 __ LoadObject(CTX, context); |
| 124 __ PushObject(smi1); // Push argument 1 smi1. | 125 __ PushObject(smi1); // Push argument 1 smi1. |
| 125 __ PushObject(smi2); // Push argument 2 smi2. | 126 __ PushObject(smi2); // Push argument 2 smi2. |
| 126 __ PushObject(result); // Push Null object for return value. | 127 __ PushObject(result); // Push Null object for return value. |
| 127 // Pass a pointer to the first argument in RAX. | 128 // Pass a pointer to the first argument in RAX. |
| 128 __ leaq(RAX, Address(RSP, 2 * kWordSize)); | 129 __ leaq(RAX, Address(RSP, 2 * kWordSize)); |
| 129 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_function))); | 130 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_function))); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 150 GrowableArray<const Object*> arguments; | 151 GrowableArray<const Object*> arguments; |
| 151 const Array& kNoArgumentNames = Array::Handle(); | 152 const Array& kNoArgumentNames = Array::Handle(); |
| 152 Smi& result = Smi::Handle(); | 153 Smi& result = Smi::Handle(); |
| 153 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 154 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
| 154 EXPECT_EQ((value1 - value2), result.Value()); | 155 EXPECT_EQ((value1 - value2), result.Value()); |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace dart | 158 } // namespace dart |
| 158 | 159 |
| 159 #endif // defined TARGET_ARCH_X64 | 160 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |