OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/raw-machine-assembler.h" | 5 #include "src/compiler/raw-machine-assembler.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/pipeline.h" | 8 #include "src/compiler/pipeline.h" |
9 #include "src/compiler/scheduler.h" | 9 #include "src/compiler/scheduler.h" |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 for (int i = 0; i < param_count; i++) { | 145 for (int i = 0; i < param_count; i++) { |
146 buffer[index++] = args[i]; | 146 buffer[index++] = args[i]; |
147 } | 147 } |
148 buffer[index++] = frame_state; | 148 buffer[index++] = frame_state; |
149 buffer[index++] = graph()->start(); | 149 buffer[index++] = graph()->start(); |
150 buffer[index++] = graph()->start(); | 150 buffer[index++] = graph()->start(); |
151 return AddNode(common()->Call(desc), input_count, buffer); | 151 return AddNode(common()->Call(desc), input_count, buffer); |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function, | |
156 Node** args) { | |
157 int param_count = | |
158 static_cast<int>(desc->GetMachineSignature()->parameter_count()); | |
159 int input_count = param_count + 3; | |
160 Node** buffer = zone()->NewArray<Node*>(input_count); | |
161 int index = 0; | |
162 buffer[index++] = function; | |
163 for (int i = 0; i < param_count; i++) { | |
164 buffer[index++] = args[i]; | |
165 } | |
166 buffer[index++] = graph()->start(); | |
167 buffer[index++] = graph()->start(); | |
168 Node* tail_call = MakeNode(common()->TailCall(desc), input_count, buffer); | |
169 schedule()->AddTailCall(CurrentBlock(), tail_call); | |
170 current_block_ = nullptr; | |
171 return tail_call; | |
172 } | |
173 | |
174 | |
175 Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function, | 155 Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function, |
176 Node* arg1, Node* context) { | 156 Node* arg1, Node* context) { |
177 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 157 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( |
178 zone(), function, 1, Operator::kNoProperties, false); | 158 zone(), function, 1, Operator::kNoProperties, CallDescriptor::kNoFlags); |
179 | |
Michael Starzinger
2015/12/01 18:06:53
nit: Bring back empty newline just for consistency
danno
2015/12/02 07:00:19
Done.
| |
180 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 159 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); |
181 Node* ref = AddNode( | 160 Node* ref = AddNode( |
182 common()->ExternalConstant(ExternalReference(function, isolate()))); | 161 common()->ExternalConstant(ExternalReference(function, isolate()))); |
183 Node* arity = Int32Constant(1); | 162 Node* arity = Int32Constant(1); |
184 | 163 |
185 return AddNode(common()->Call(descriptor), centry, arg1, ref, arity, context, | 164 return AddNode(common()->Call(descriptor), centry, arg1, ref, arity, context, |
186 graph()->start(), graph()->start()); | 165 graph()->start(), graph()->start()); |
187 } | 166 } |
188 | 167 |
189 | 168 |
190 Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function, | 169 Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function, |
191 Node* arg1, Node* arg2, Node* context) { | 170 Node* arg1, Node* arg2, Node* context) { |
192 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 171 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( |
193 zone(), function, 2, Operator::kNoProperties, false); | 172 zone(), function, 2, Operator::kNoProperties, CallDescriptor::kNoFlags); |
194 | 173 |
195 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 174 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); |
196 Node* ref = AddNode( | 175 Node* ref = AddNode( |
197 common()->ExternalConstant(ExternalReference(function, isolate()))); | 176 common()->ExternalConstant(ExternalReference(function, isolate()))); |
198 Node* arity = Int32Constant(2); | 177 Node* arity = Int32Constant(2); |
199 | 178 |
200 return AddNode(common()->Call(descriptor), centry, arg1, arg2, ref, arity, | 179 return AddNode(common()->Call(descriptor), centry, arg1, arg2, ref, arity, |
201 context, graph()->start(), graph()->start()); | 180 context, graph()->start(), graph()->start()); |
202 } | 181 } |
203 | 182 |
204 | 183 |
205 Node* RawMachineAssembler::CallRuntime4(Runtime::FunctionId function, | 184 Node* RawMachineAssembler::CallRuntime4(Runtime::FunctionId function, |
206 Node* arg1, Node* arg2, Node* arg3, | 185 Node* arg1, Node* arg2, Node* arg3, |
207 Node* arg4, Node* context) { | 186 Node* arg4, Node* context) { |
208 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 187 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( |
209 zone(), function, 4, Operator::kNoProperties, false); | 188 zone(), function, 4, Operator::kNoProperties, CallDescriptor::kNoFlags); |
210 | 189 |
211 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 190 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); |
212 Node* ref = AddNode( | 191 Node* ref = AddNode( |
213 common()->ExternalConstant(ExternalReference(function, isolate()))); | 192 common()->ExternalConstant(ExternalReference(function, isolate()))); |
214 Node* arity = Int32Constant(4); | 193 Node* arity = Int32Constant(4); |
215 | 194 |
216 return AddNode(common()->Call(descriptor), centry, arg1, arg2, arg3, arg4, | 195 return AddNode(common()->Call(descriptor), centry, arg1, arg2, arg3, arg4, |
217 ref, arity, context, graph()->start(), graph()->start()); | 196 ref, arity, context, graph()->start(), graph()->start()); |
218 } | 197 } |
219 | 198 |
220 | 199 |
200 Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function, | |
201 Node** args) { | |
202 int param_count = | |
203 static_cast<int>(desc->GetMachineSignature()->parameter_count()); | |
204 int input_count = param_count + 3; | |
205 Node** buffer = zone()->NewArray<Node*>(input_count); | |
206 int index = 0; | |
207 buffer[index++] = function; | |
208 for (int i = 0; i < param_count; i++) { | |
209 buffer[index++] = args[i]; | |
210 } | |
211 buffer[index++] = graph()->start(); | |
212 buffer[index++] = graph()->start(); | |
213 Node* tail_call = MakeNode(common()->TailCall(desc), input_count, buffer); | |
214 schedule()->AddTailCall(CurrentBlock(), tail_call); | |
215 current_block_ = nullptr; | |
216 return tail_call; | |
217 } | |
218 | |
219 | |
220 Node* RawMachineAssembler::TailCallRuntime1(Runtime::FunctionId function, | |
221 Node* arg1, Node* context) { | |
222 const int kArity = 1; | |
223 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | |
224 zone(), function, kArity, Operator::kNoProperties, | |
225 CallDescriptor::kSupportsTailCalls); | |
226 | |
227 Node* centry = HeapConstant(CEntryStub(isolate(), kArity).GetCode()); | |
228 Node* ref = AddNode( | |
229 common()->ExternalConstant(ExternalReference(function, isolate()))); | |
230 Node* arity = Int32Constant(kArity); | |
231 | |
232 Node* nodes[] = {centry, arg1, ref, arity, context, graph()->start(), | |
233 graph()->start()}; | |
234 Node* tail_call = MakeNode(common()->TailCall(desc), arraysize(nodes), nodes); | |
235 | |
236 schedule()->AddTailCall(CurrentBlock(), tail_call); | |
237 current_block_ = nullptr; | |
238 return tail_call; | |
239 } | |
240 | |
241 | |
242 Node* RawMachineAssembler::TailCallRuntime2(Runtime::FunctionId function, | |
243 Node* arg1, Node* arg2, | |
244 Node* context) { | |
245 const int kArity = 2; | |
246 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | |
247 zone(), function, kArity, Operator::kNoProperties, | |
248 CallDescriptor::kSupportsTailCalls); | |
249 | |
250 Node* centry = HeapConstant(CEntryStub(isolate(), kArity).GetCode()); | |
251 Node* ref = AddNode( | |
252 common()->ExternalConstant(ExternalReference(function, isolate()))); | |
253 Node* arity = Int32Constant(kArity); | |
254 | |
255 Node* nodes[] = { | |
256 centry, arg1, arg2, ref, arity, context, graph()->start(), | |
257 graph()->start()}; | |
258 Node* tail_call = MakeNode(common()->TailCall(desc), arraysize(nodes), nodes); | |
259 | |
260 schedule()->AddTailCall(CurrentBlock(), tail_call); | |
261 current_block_ = nullptr; | |
262 return tail_call; | |
263 } | |
264 | |
265 | |
221 Node* RawMachineAssembler::CallCFunction0(MachineType return_type, | 266 Node* RawMachineAssembler::CallCFunction0(MachineType return_type, |
222 Node* function) { | 267 Node* function) { |
223 MachineSignature::Builder builder(zone(), 1, 0); | 268 MachineSignature::Builder builder(zone(), 1, 0); |
224 builder.AddReturn(return_type); | 269 builder.AddReturn(return_type); |
225 const CallDescriptor* descriptor = | 270 const CallDescriptor* descriptor = |
226 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build()); | 271 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build()); |
227 | 272 |
228 return AddNode(common()->Call(descriptor), function, graph()->start(), | 273 return AddNode(common()->Call(descriptor), function, graph()->start(), |
229 graph()->start()); | 274 graph()->start()); |
230 } | 275 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 | 384 |
340 RawMachineLabel::RawMachineLabel() | 385 RawMachineLabel::RawMachineLabel() |
341 : block_(NULL), used_(false), bound_(false) {} | 386 : block_(NULL), used_(false), bound_(false) {} |
342 | 387 |
343 | 388 |
344 RawMachineLabel::~RawMachineLabel() { DCHECK(bound_ || !used_); } | 389 RawMachineLabel::~RawMachineLabel() { DCHECK(bound_ || !used_); } |
345 | 390 |
346 } // namespace compiler | 391 } // namespace compiler |
347 } // namespace internal | 392 } // namespace internal |
348 } // namespace v8 | 393 } // namespace v8 |
OLD | NEW |