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

Side by Side Diff: vm/stub_code_x64_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
« vm/bootstrap_natives.h ('K') | « vm/stub_code_ia32_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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
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
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
OLDNEW
« vm/bootstrap_natives.h ('K') | « vm/stub_code_ia32_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698