| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Test calls to stub code which calls a native C function. | 111 // Test calls to stub code which calls a native C function. |
| 112 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler, | 112 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler, |
| 113 int value1, int value2) { | 113 int value1, int value2) { |
| 114 const int argc = 2; | 114 const int argc = 2; |
| 115 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 115 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
| 116 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 116 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
| 117 const Object& result = Object::ZoneHandle(); | 117 const Object& result = Object::ZoneHandle(); |
| 118 const String& native_name = String::ZoneHandle(String::New("TestSmiSub")); | 118 const String& native_name = String::ZoneHandle(String::New("TestSmiSub")); |
| 119 Dart_NativeFunction native_function = | 119 Dart_NativeFunction native_function = |
| 120 NativeTestEntry_Lookup(native_name, argc); | 120 NativeTestEntry_Lookup(native_name, argc); |
| 121 ASSERT(native_function != NULL); |
| 121 const Context& context = Context::ZoneHandle(Context::New(0)); | 122 const Context& context = Context::ZoneHandle(Context::New(0)); |
| 122 ASSERT(context.isolate() == Isolate::Current()); | 123 ASSERT(context.isolate() == Isolate::Current()); |
| 123 __ enter(Immediate(0)); | 124 __ enter(Immediate(0)); |
| 124 __ LoadObject(CTX, context); | 125 __ LoadObject(CTX, context); |
| 125 __ PushObject(smi1); // Push argument 1 smi1. | 126 __ PushObject(smi1); // Push argument 1 smi1. |
| 126 __ PushObject(smi2); // Push argument 2 smi2. | 127 __ PushObject(smi2); // Push argument 2 smi2. |
| 127 __ PushObject(result); // Push Null object for return value. | 128 __ PushObject(result); // Push Null object for return value. |
| 128 // Pass a pointer to the first argument in EAX. | 129 // Pass a pointer to the first argument in EAX. |
| 129 __ leal(EAX, Address(ESP, 2 * kWordSize)); | 130 __ leal(EAX, Address(ESP, 2 * kWordSize)); |
| 130 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_function))); | 131 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_function))); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 151 GrowableArray<const Object*> arguments; | 152 GrowableArray<const Object*> arguments; |
| 152 const Array& kNoArgumentNames = Array::Handle(); | 153 const Array& kNoArgumentNames = Array::Handle(); |
| 153 Smi& result = Smi::Handle(); | 154 Smi& result = Smi::Handle(); |
| 154 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 155 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
| 155 EXPECT_EQ((value1 - value2), result.Value()); | 156 EXPECT_EQ((value1 - value2), result.Value()); |
| 156 } | 157 } |
| 157 | 158 |
| 158 } // namespace dart | 159 } // namespace dart |
| 159 | 160 |
| 160 #endif // defined TARGET_ARCH_IA32 | 161 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |