Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Side by Side Diff: vm/stub_code_ia32_test.cc

Issue 10874072: Use the return value of vm native methods to set the return value, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« vm/bootstrap_natives.h ('K') | « vm/native_entry_test.cc ('k') | vm/stub_code_x64_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698