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

Side by Side Diff: vm/intermediate_language_x64.cc

Issue 10407077: Migrate {Closure,Instance,Static}Call to use location-based code generation templates. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: updated comment Created 8 years, 7 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/intermediate_language.h ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 #include "vm/locations.h" 9 #include "vm/locations.h"
10 #include "vm/stub_code.h"
10 11
11 #define __ compiler->assembler()-> 12 #define __ compiler->assembler()->
srdjan 2012/05/21 22:58:53 For next CLs: Maybe we should use a different clas
Florian Schneider 2012/05/21 23:31:15 Agree. For now until everything is transitioned, l
12 13
13 namespace dart { 14 namespace dart {
14 15
15 16
17 // True iff. the arguments to a call will be properly pushed and can
18 // be popped after the call.
19 template <typename T> static bool VerifyCallComputation(T* comp) {
20 // Argument values should be consecutive temps.
21 //
22 // TODO(kmillikin): implement stack height tracking so we can also assert
23 // they are on top of the stack.
24 intptr_t previous = -1;
25 for (int i = 0; i < comp->ArgumentCount(); ++i) {
26 Value* val = comp->ArgumentAt(i);
27 if (!val->IsUse()) return false;
28 intptr_t current = val->AsUse()->definition()->temp_index();
29 if (i != 0) {
30 if (current != (previous + 1)) return false;
31 }
32 previous = current;
33 }
34 return true;
35 }
36
37
16 static LocationSummary* MakeSimpleLocationSummary( 38 static LocationSummary* MakeSimpleLocationSummary(
17 intptr_t input_count, Location out) { 39 intptr_t input_count, Location out) {
18 LocationSummary* summary = new LocationSummary(input_count); 40 LocationSummary* summary = new LocationSummary(input_count);
19 for (intptr_t i = 0; i < input_count; i++) { 41 for (intptr_t i = 0; i < input_count; i++) {
20 summary->set_in(i, Location::RequiresRegister()); 42 summary->set_in(i, Location::RequiresRegister());
21 } 43 }
22 summary->set_out(out); 44 summary->set_out(out);
23 return summary; 45 return summary;
24 } 46 }
25 47
(...skipping 19 matching lines...) Expand all
45 __ j(NOT_EQUAL, &load_true, Assembler::kNearJump); 67 __ j(NOT_EQUAL, &load_true, Assembler::kNearJump);
46 } 68 }
47 __ LoadObject(result, bool_false); 69 __ LoadObject(result, bool_false);
48 __ jmp(&done, Assembler::kNearJump); 70 __ jmp(&done, Assembler::kNearJump);
49 __ Bind(&load_true); 71 __ Bind(&load_true);
50 __ LoadObject(result, bool_true); 72 __ LoadObject(result, bool_true);
51 __ Bind(&done); 73 __ Bind(&done);
52 } 74 }
53 75
54 76
77 // Generic summary for call instructions that have all arguments pushed
78 // on the stack and return the result in a fixed register RAX.
79 static LocationSummary* MakeCallSummary() {
80 LocationSummary* result = new LocationSummary(0);
srdjan 2012/05/21 22:58:53 What about inputs?
Florian Schneider 2012/05/21 23:31:15 Inputs (in this case outgoing arguments) are assum
81 result->set_out(Location::RegisterLocation(RAX));
82 return result;
83 }
84
85
86 LocationSummary* ClosureCallComp::MakeLocationSummary() {
87 return MakeCallSummary();
88 }
89
90
91 void ClosureCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
92 ASSERT(VerifyCallComputation(this));
93 // The arguments to the stub include the closure. The arguments
94 // descriptor describes the closure's arguments (and so does not include
95 // the closure).
96 int argument_count = ArgumentCount();
97 const Array& arguments_descriptor =
98 CodeGenerator::ArgumentsDescriptor(argument_count - 1,
99 argument_names());
100 __ LoadObject(R10, arguments_descriptor);
101
102 compiler->GenerateCall(token_index(),
103 try_index(),
104 &StubCode::CallClosureFunctionLabel(),
105 PcDescriptors::kOther);
106 __ Drop(argument_count);
107 }
108
109
110 LocationSummary* InstanceCallComp::MakeLocationSummary() {
111 return MakeCallSummary();
112 }
113
114
115 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
116 ASSERT(VerifyCallComputation(this));
117 compiler->EmitInstanceCall(cid(),
118 token_index(),
119 try_index(),
120 function_name(),
121 ArgumentCount(),
122 argument_names(),
123 checked_argument_count());
124 }
125
126
127 LocationSummary* StaticCallComp::MakeLocationSummary() {
128 return MakeCallSummary();
129 }
130
131
132 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
133 ASSERT(VerifyCallComputation(this));
134 compiler->EmitStaticCall(token_index(),
135 try_index(),
136 function(),
137 ArgumentCount(),
138 argument_names());
139 }
140
141
55 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 142 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
56 computation()->EmitNativeCode(compiler); 143 computation()->EmitNativeCode(compiler);
57 __ pushq(locs()->out().reg()); 144 __ pushq(locs()->out().reg());
58 } 145 }
59 146
60 147
61 } // namespace dart 148 } // namespace dart
62 149
63 #undef __ 150 #undef __
64 151
65 #endif // defined TARGET_ARCH_X64 152 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698