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

Side by Side Diff: runtime/vm/stub_code_ia32_test.cc

Issue 10885039: Deoptimization can occur at Dart calls (includes native calls to C) but not at runtime calls. This … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/stub_code_x64_test.cc » ('j') | 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_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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const Code& code = Code::Handle(Code::FinalizeCode( 107 const Code& code = Code::Handle(Code::FinalizeCode(
108 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); 108 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_));
109 const Function& function = RegisterFakeFunction(kName, code); 109 const Function& function = RegisterFakeFunction(kName, code);
110 GrowableArray<const Object*> arguments; 110 GrowableArray<const Object*> arguments;
111 const Array& kNoArgumentNames = Array::Handle(); 111 const Array& kNoArgumentNames = Array::Handle();
112 Smi& result = Smi::Handle(); 112 Smi& result = Smi::Handle();
113 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); 113 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
114 EXPECT_EQ((value1 + value2), result.Value()); 114 EXPECT_EQ((value1 + value2), result.Value());
115 } 115 }
116 116
117
118 // Test calls to stub code which calls a native C function.
119 static void GenerateCallToCallNativeCFunctionStub(Assembler* assembler,
120 int value1, int value2) {
121 const int argc = 2;
122 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1));
123 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2));
124 const Object& result = Object::ZoneHandle();
125 const String& native_name = String::ZoneHandle(String::New("TestSmiSub"));
126 Dart_NativeFunction native_function =
127 NativeTestEntry_Lookup(native_name, argc);
128 ASSERT(native_function != NULL);
129 const Context& context = Context::ZoneHandle(Context::New(0, Heap::kOld));
130 ASSERT(context.isolate() == Isolate::Current());
131 __ enter(Immediate(0));
132 __ LoadObject(CTX, context);
133 __ PushObject(smi1); // Push argument 1 smi1.
134 __ PushObject(smi2); // Push argument 2 smi2.
135 __ PushObject(result); // Push Null object for return value.
136 // Pass a pointer to the first argument in EAX.
137 __ leal(EAX, Address(ESP, 2 * kWordSize));
138 __ movl(ECX, Immediate(reinterpret_cast<uword>(native_function)));
139 __ movl(EDX, Immediate(argc));
140 __ call(&StubCode::CallNativeCFunctionLabel());
141 __ popl(EAX); // Pop return value from return slot.
142 __ AddImmediate(ESP, Immediate(argc * kWordSize));
143 __ leave();
144 __ ret();
145 }
146
147
148 TEST_CASE(CallNativeCFunctionStubCode) {
149 extern const Function& RegisterFakeFunction(const char* name,
150 const Code& code);
151 const int value1 = 15;
152 const int value2 = 20;
153 const char* kName = "Test_CallNativeCFunctionStubCode";
154 Assembler _assembler_;
155 GenerateCallToCallNativeCFunctionStub(&_assembler_, value1, value2);
156 const Code& code = Code::Handle(Code::FinalizeCode(
157 *CreateFunction(kName), &_assembler_));
158 const Function& function = RegisterFakeFunction(kName, code);
159 GrowableArray<const Object*> arguments;
160 const Array& kNoArgumentNames = Array::Handle();
161 Smi& result = Smi::Handle();
162 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
163 EXPECT_EQ((value1 - value2), result.Value());
164 }
165
166 } // namespace dart 117 } // namespace dart
167 118
168 #endif // defined TARGET_ARCH_IA32 119 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/stub_code_x64_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698