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