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

Side by Side Diff: src/compiler/js-generic-lowering.cc

Issue 526953004: Lazy deoptimization for comparisons in Turbofan. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
OLDNEW
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/code-stubs.h" 5 #include "src/code-stubs.h"
6 #include "src/compiler/common-operator.h" 6 #include "src/compiler/common-operator.h"
7 #include "src/compiler/graph-inl.h" 7 #include "src/compiler/graph-inl.h"
8 #include "src/compiler/js-generic-lowering.h" 8 #include "src/compiler/js-generic-lowering.h"
9 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-aux-data-inl.h" 10 #include "src/compiler/node-aux-data-inl.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 result |= CallDescriptor::kNeedsFrameState; 293 result |= CallDescriptor::kNeedsFrameState;
294 } 294 }
295 return result; 295 return result;
296 } 296 }
297 297
298 298
299 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, 299 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
300 bool pure) { 300 bool pure) {
301 BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack. 301 BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack.
302 CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor(); 302 CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor();
303 bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op());
303 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor( 304 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(
304 d, 0, CallDescriptor::kPatchableCallSiteWithNop); 305 d, 0, CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node));
305 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token); 306 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token);
306 Node* compare; 307 NodeVector inputs(zone());
308 inputs.reserve(node->InputCount() + 1);
309 inputs.push_back(CodeConstant(ic));
310 inputs.push_back(NodeProperties::GetValueInput(node, 0));
311 inputs.push_back(NodeProperties::GetValueInput(node, 1));
312 inputs.push_back(NodeProperties::GetContextInput(node));
307 if (pure) { 313 if (pure) {
308 // A pure (strict) comparison doesn't have an effect or control. 314 DCHECK(!has_frame_state);
Michael Starzinger 2014/09/01 23:10:46 Ouch, this is getting complex, but we can always c
309 // But for the graph, we need to add these inputs. 315 inputs.push_back(graph()->start());
310 compare = graph()->NewNode(common()->Call(desc_compare), CodeConstant(ic), 316 inputs.push_back(graph()->start());
311 NodeProperties::GetValueInput(node, 0),
312 NodeProperties::GetValueInput(node, 1),
313 NodeProperties::GetContextInput(node),
314 graph()->start(), graph()->start());
315 } else { 317 } else {
316 compare = graph()->NewNode(common()->Call(desc_compare), CodeConstant(ic), 318 DCHECK(has_frame_state == FLAG_turbo_deoptimization);
317 NodeProperties::GetValueInput(node, 0), 319 if (FLAG_turbo_deoptimization) {
318 NodeProperties::GetValueInput(node, 1), 320 inputs.push_back(NodeProperties::GetFrameStateInput(node));
319 NodeProperties::GetContextInput(node), 321 }
320 NodeProperties::GetEffectInput(node), 322 inputs.push_back(NodeProperties::GetEffectInput(node));
321 NodeProperties::GetControlInput(node)); 323 inputs.push_back(NodeProperties::GetControlInput(node));
322 } 324 }
325 Node* compare = graph()->NewNode(common()->Call(desc_compare), inputs.size(),
326 &inputs.front());
327
323 node->ReplaceInput(0, compare); 328 node->ReplaceInput(0, compare);
324 node->ReplaceInput(1, SmiConstant(token)); 329 node->ReplaceInput(1, SmiConstant(token));
330
331 if (has_frame_state) {
332 // Remove the frame state from inputs.
333 // TODO(jarin) This should use Node::RemoveInput (which does not exist yet).
334 int dest = NodeProperties::FirstFrameStateIndex(node);
335 for (int i = NodeProperties::PastFrameStateIndex(node);
336 i < node->InputCount(); i++) {
337 node->ReplaceInput(dest, node->InputAt(i));
338 dest++;
339 }
340 node->TrimInputCount(dest);
341 }
342
325 ReplaceWithRuntimeCall(node, Runtime::kBooleanize); 343 ReplaceWithRuntimeCall(node, Runtime::kBooleanize);
326 } 344 }
327 345
328 346
329 void JSGenericLowering::ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub, 347 void JSGenericLowering::ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub,
330 CallDescriptor::Flags flags) { 348 CallDescriptor::Flags flags) {
331 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor(); 349 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor();
332 CallDescriptor* desc = 350 CallDescriptor* desc =
333 linkage()->GetStubCallDescriptor(d, 0, flags | FlagsForNode(node)); 351 linkage()->GetStubCallDescriptor(d, 0, flags | FlagsForNode(node));
334 Node* stub_code = CodeConstant(stub->GetCode()); 352 Node* stub_code = CodeConstant(stub->GetCode());
(...skipping 19 matching lines...) Expand all
354 PatchOperator(node, common()->Call(desc)); 372 PatchOperator(node, common()->Call(desc));
355 } 373 }
356 374
357 375
358 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, 376 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
359 Runtime::FunctionId f, 377 Runtime::FunctionId f,
360 int nargs_override) { 378 int nargs_override) {
361 Operator::Property props = node->op()->properties(); 379 Operator::Property props = node->op()->properties();
362 const Runtime::Function* fun = Runtime::FunctionForId(f); 380 const Runtime::Function* fun = Runtime::FunctionForId(f);
363 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; 381 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
364 CallDescriptor* desc = 382 CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor(f, nargs, props);
365 linkage()->GetRuntimeCallDescriptor(f, nargs, props, FlagsForNode(node)); 383 Operator* new_op = common()->Call(desc);
Michael Starzinger 2014/09/01 23:10:46 nit: Please keep this consistent with the other Re
366 Node* ref = ExternalConstant(ExternalReference(f, isolate())); 384 Node* ref = ExternalConstant(ExternalReference(f, isolate()));
367 Node* arity = Int32Constant(nargs); 385 Node* arity = Int32Constant(nargs);
368 if (!centrystub_constant_.is_set()) { 386 if (!centrystub_constant_.is_set()) {
369 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode())); 387 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode()));
370 } 388 }
371 PatchInsertInput(node, 0, centrystub_constant_.get()); 389 PatchInsertInput(node, 0, centrystub_constant_.get());
372 PatchInsertInput(node, nargs + 1, ref); 390 PatchInsertInput(node, nargs + 1, ref);
373 PatchInsertInput(node, nargs + 2, arity); 391 PatchInsertInput(node, nargs + 2, arity);
374 PatchOperator(node, common()->Call(desc)); 392 PatchOperator(node, new_op);
375 } 393 }
376 394
377 395
378 Node* JSGenericLowering::LowerBranch(Node* node) { 396 Node* JSGenericLowering::LowerBranch(Node* node) {
379 if (!info()->is_typing_enabled()) { 397 if (!info()->is_typing_enabled()) {
380 // TODO(mstarzinger): If typing is enabled then simplified lowering will 398 // TODO(mstarzinger): If typing is enabled then simplified lowering will
381 // have inserted the correct ChangeBoolToBit, otherwise we need to perform 399 // have inserted the correct ChangeBoolToBit, otherwise we need to perform
382 // poor-man's representation inference here and insert manual change. 400 // poor-man's representation inference here and insert manual change.
383 Node* test = graph()->NewNode(machine()->WordEqual(), node->InputAt(0), 401 Node* test = graph()->NewNode(machine()->WordEqual(), node->InputAt(0),
384 jsgraph()->TrueConstant()); 402 jsgraph()->TrueConstant());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { 557 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) {
540 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); 558 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node);
541 int arity = OperatorProperties::GetValueInputCount(node->op()); 559 int arity = OperatorProperties::GetValueInputCount(node->op());
542 ReplaceWithRuntimeCall(node, function, arity); 560 ReplaceWithRuntimeCall(node, function, arity);
543 return node; 561 return node;
544 } 562 }
545 563
546 } // namespace compiler 564 } // namespace compiler
547 } // namespace internal 565 } // namespace internal
548 } // namespace v8 566 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698