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

Side by Side Diff: vm/stub_code_ia32_test.cc

Issue 10592006: Rework leaf calls as just simple C calls with a signature and not the NativeArgumentDescriptor. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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 | « vm/stub_code_ia32.cc ('k') | vm/stub_code_x64.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"
11 #include "vm/native_entry_test.h" 11 #include "vm/native_entry_test.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/runtime_entry.h" 13 #include "vm/runtime_entry.h"
14 #include "vm/stub_code.h" 14 #include "vm/stub_code.h"
15 #include "vm/unit_test.h" 15 #include "vm/unit_test.h"
16 16
17 #define __ assembler-> 17 #define __ assembler->
18 18
19 namespace dart { 19 namespace dart {
20 20
21 DECLARE_RUNTIME_ENTRY(TestSmiSub); 21 DECLARE_RUNTIME_ENTRY(TestSmiSub);
22 DECLARE_LEAF_RUNTIME_ENTRY(TestLeafSmiAdd); 22 DECLARE_LEAF_RUNTIME_ENTRY(RawObject*, TestLeafSmiAdd, RawObject*, RawObject*);
23 23
24 24
25 static Function* CreateFunction(const char* name) { 25 static Function* CreateFunction(const char* name) {
26 const String& function_name = String::ZoneHandle(String::NewSymbol(name)); 26 const String& function_name = String::ZoneHandle(String::NewSymbol(name));
27 Function& function = Function::ZoneHandle( 27 Function& function = Function::ZoneHandle(
28 Function::New(function_name, RawFunction::kFunction, true, false, 0)); 28 Function::New(function_name, RawFunction::kFunction, true, false, 0));
29 return &function; 29 return &function;
30 } 30 }
31 31
32 // Test calls to stub code which calls into the runtime. 32 // Test calls to stub code which calls into the runtime.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Smi& result = Smi::Handle(); 68 Smi& result = Smi::Handle();
69 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); 69 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
70 EXPECT_EQ((value1 - value2), result.Value()); 70 EXPECT_EQ((value1 - value2), result.Value());
71 } 71 }
72 72
73 73
74 // Test calls to stub code which calls into a leaf runtime entry. 74 // Test calls to stub code which calls into a leaf runtime entry.
75 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, 75 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler,
76 int value1, 76 int value1,
77 int value2) { 77 int value2) {
78 const int argc = 2;
79 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); 78 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1));
80 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); 79 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2));
81 const Object& result = Object::ZoneHandle();
82 const Context& context = Context::ZoneHandle(Context::New(0));
83 ASSERT(context.isolate() == Isolate::Current());
84 __ enter(Immediate(0)); 80 __ enter(Immediate(0));
85 __ LoadObject(CTX, context); 81 __ ReserveAlignedFrameSpace(2 * kWordSize);
86 __ PushObject(result); // Push Null object for return value. 82 __ LoadObject(EAX, smi1);
87 __ PushObject(smi1); // Push argument 1 smi1. 83 __ movl(Address(ESP, 0), EAX); // Push argument 1 smi1.
88 __ PushObject(smi2); // Push argument 2 smi2. 84 __ LoadObject(EAX, smi2);
89 ASSERT(kTestLeafSmiAddRuntimeEntry.argument_count() == argc); 85 __ movl(Address(ESP, kWordSize), EAX); // Push argument 2 smi2.
90 __ CallRuntime(kTestLeafSmiAddRuntimeEntry); // Call SmiAdd runtime func. 86 __ CallRuntime(kTestLeafSmiAddRuntimeEntry); // Call SmiAdd runtime func.
91 __ AddImmediate(ESP, Immediate(argc * kWordSize));
92 __ popl(EAX); // Pop return value from return slot.
93 __ leave(); 87 __ leave();
94 __ ret(); 88 __ ret(); // Return value is in EAX.
95 } 89 }
96 90
97 91
98 TEST_CASE(CallLeafRuntimeStubCode) { 92 TEST_CASE(CallLeafRuntimeStubCode) {
99 extern const Function& RegisterFakeFunction(const char* name, 93 extern const Function& RegisterFakeFunction(const char* name,
100 const Code& code); 94 const Code& code);
101 const int value1 = 10; 95 const int value1 = 10;
102 const int value2 = 20; 96 const int value2 = 20;
103 const char* kName = "Test_CallLeafRuntimeStubCode"; 97 const char* kName = "Test_CallLeafRuntimeStubCode";
104 Assembler _assembler_; 98 Assembler _assembler_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 GrowableArray<const Object*> arguments; 151 GrowableArray<const Object*> arguments;
158 const Array& kNoArgumentNames = Array::Handle(); 152 const Array& kNoArgumentNames = Array::Handle();
159 Smi& result = Smi::Handle(); 153 Smi& result = Smi::Handle();
160 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); 154 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
161 EXPECT_EQ((value1 - value2), result.Value()); 155 EXPECT_EQ((value1 - value2), result.Value());
162 } 156 }
163 157
164 } // namespace dart 158 } // namespace dart
165 159
166 #endif // defined TARGET_ARCH_IA32 160 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « vm/stub_code_ia32.cc ('k') | vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698