Chromium Code Reviews| Index: src/compiler/js-generic-lowering.cc |
| diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc |
| index a2253bf53ab2be4862da414c383d89ccfaccfbde..d104b5358ec7b3641b1ec74e9a8f5cfa2858e8a7 100644 |
| --- a/src/compiler/js-generic-lowering.cc |
| +++ b/src/compiler/js-generic-lowering.cc |
| @@ -300,28 +300,46 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, |
| bool pure) { |
| BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack. |
| CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor(); |
| + bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op()); |
| CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor( |
| - d, 0, CallDescriptor::kPatchableCallSiteWithNop); |
| + d, 0, CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node)); |
| Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token); |
| - Node* compare; |
| + NodeVector inputs(zone()); |
| + inputs.reserve(node->InputCount() + 1); |
| + inputs.push_back(CodeConstant(ic)); |
| + inputs.push_back(NodeProperties::GetValueInput(node, 0)); |
| + inputs.push_back(NodeProperties::GetValueInput(node, 1)); |
| + inputs.push_back(NodeProperties::GetContextInput(node)); |
| if (pure) { |
| - // A pure (strict) comparison doesn't have an effect or control. |
| - // But for the graph, we need to add these inputs. |
| - compare = graph()->NewNode(common()->Call(desc_compare), CodeConstant(ic), |
| - NodeProperties::GetValueInput(node, 0), |
| - NodeProperties::GetValueInput(node, 1), |
| - NodeProperties::GetContextInput(node), |
| - graph()->start(), graph()->start()); |
| + DCHECK(!has_frame_state); |
|
Michael Starzinger
2014/09/01 23:10:46
Ouch, this is getting complex, but we can always c
|
| + inputs.push_back(graph()->start()); |
| + inputs.push_back(graph()->start()); |
| } else { |
| - compare = graph()->NewNode(common()->Call(desc_compare), CodeConstant(ic), |
| - NodeProperties::GetValueInput(node, 0), |
| - NodeProperties::GetValueInput(node, 1), |
| - NodeProperties::GetContextInput(node), |
| - NodeProperties::GetEffectInput(node), |
| - NodeProperties::GetControlInput(node)); |
| + DCHECK(has_frame_state == FLAG_turbo_deoptimization); |
| + if (FLAG_turbo_deoptimization) { |
| + inputs.push_back(NodeProperties::GetFrameStateInput(node)); |
| + } |
| + inputs.push_back(NodeProperties::GetEffectInput(node)); |
| + inputs.push_back(NodeProperties::GetControlInput(node)); |
| } |
| + Node* compare = graph()->NewNode(common()->Call(desc_compare), inputs.size(), |
| + &inputs.front()); |
| + |
| node->ReplaceInput(0, compare); |
| node->ReplaceInput(1, SmiConstant(token)); |
| + |
| + if (has_frame_state) { |
| + // Remove the frame state from inputs. |
| + // TODO(jarin) This should use Node::RemoveInput (which does not exist yet). |
| + int dest = NodeProperties::FirstFrameStateIndex(node); |
| + for (int i = NodeProperties::PastFrameStateIndex(node); |
| + i < node->InputCount(); i++) { |
| + node->ReplaceInput(dest, node->InputAt(i)); |
| + dest++; |
| + } |
| + node->TrimInputCount(dest); |
| + } |
| + |
| ReplaceWithRuntimeCall(node, Runtime::kBooleanize); |
| } |
| @@ -361,8 +379,8 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
| Operator::Property props = node->op()->properties(); |
| const Runtime::Function* fun = Runtime::FunctionForId(f); |
| int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
| - CallDescriptor* desc = |
| - linkage()->GetRuntimeCallDescriptor(f, nargs, props, FlagsForNode(node)); |
| + CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor(f, nargs, props); |
| + Operator* new_op = common()->Call(desc); |
|
Michael Starzinger
2014/09/01 23:10:46
nit: Please keep this consistent with the other Re
|
| Node* ref = ExternalConstant(ExternalReference(f, isolate())); |
| Node* arity = Int32Constant(nargs); |
| if (!centrystub_constant_.is_set()) { |
| @@ -371,7 +389,7 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
| PatchInsertInput(node, 0, centrystub_constant_.get()); |
| PatchInsertInput(node, nargs + 1, ref); |
| PatchInsertInput(node, nargs + 2, arity); |
| - PatchOperator(node, common()->Call(desc)); |
| + PatchOperator(node, new_op); |
| } |