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

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: Address review comments 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
« no previous file with comments | « src/compiler/ia32/linkage-ia32.cc ('k') | src/compiler/linkage.h » ('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 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 // A pure (strict) comparison doesn't have an effect, control or frame
309 // But for the graph, we need to add these inputs. 315 // state. But for the graph, we need to add control and effect inputs.
310 compare = graph()->NewNode(common()->Call(desc_compare), CodeConstant(ic), 316 DCHECK(!has_frame_state);
311 NodeProperties::GetValueInput(node, 0), 317 inputs.push_back(graph()->start());
312 NodeProperties::GetValueInput(node, 1), 318 inputs.push_back(graph()->start());
313 NodeProperties::GetContextInput(node),
314 graph()->start(), graph()->start());
315 } else { 319 } else {
316 compare = graph()->NewNode(common()->Call(desc_compare), CodeConstant(ic), 320 DCHECK(has_frame_state == FLAG_turbo_deoptimization);
317 NodeProperties::GetValueInput(node, 0), 321 if (FLAG_turbo_deoptimization) {
318 NodeProperties::GetValueInput(node, 1), 322 inputs.push_back(NodeProperties::GetFrameStateInput(node));
319 NodeProperties::GetContextInput(node), 323 }
320 NodeProperties::GetEffectInput(node), 324 inputs.push_back(NodeProperties::GetEffectInput(node));
321 NodeProperties::GetControlInput(node)); 325 inputs.push_back(NodeProperties::GetControlInput(node));
322 } 326 }
327 Node* compare = graph()->NewNode(common()->Call(desc_compare), inputs.size(),
328 &inputs.front());
329
323 node->ReplaceInput(0, compare); 330 node->ReplaceInput(0, compare);
324 node->ReplaceInput(1, SmiConstant(token)); 331 node->ReplaceInput(1, SmiConstant(token));
332
333 if (has_frame_state) {
334 // Remove the frame state from inputs.
335 // TODO(jarin) This should use Node::RemoveInput (which does not exist yet).
336 int dest = NodeProperties::FirstFrameStateIndex(node);
337 for (int i = NodeProperties::PastFrameStateIndex(node);
338 i < node->InputCount(); i++) {
339 node->ReplaceInput(dest, node->InputAt(i));
340 dest++;
341 }
342 node->TrimInputCount(dest);
343 }
344
325 ReplaceWithRuntimeCall(node, Runtime::kBooleanize); 345 ReplaceWithRuntimeCall(node, Runtime::kBooleanize);
326 } 346 }
327 347
328 348
329 void JSGenericLowering::ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub, 349 void JSGenericLowering::ReplaceWithStubCall(Node* node, HydrogenCodeStub* stub,
330 CallDescriptor::Flags flags) { 350 CallDescriptor::Flags flags) {
331 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor(); 351 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor();
332 CallDescriptor* desc = 352 CallDescriptor* desc =
333 linkage()->GetStubCallDescriptor(d, 0, flags | FlagsForNode(node)); 353 linkage()->GetStubCallDescriptor(d, 0, flags | FlagsForNode(node));
334 Node* stub_code = CodeConstant(stub->GetCode()); 354 Node* stub_code = CodeConstant(stub->GetCode());
(...skipping 19 matching lines...) Expand all
354 PatchOperator(node, common()->Call(desc)); 374 PatchOperator(node, common()->Call(desc));
355 } 375 }
356 376
357 377
358 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, 378 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
359 Runtime::FunctionId f, 379 Runtime::FunctionId f,
360 int nargs_override) { 380 int nargs_override) {
361 Operator::Property props = node->op()->properties(); 381 Operator::Property props = node->op()->properties();
362 const Runtime::Function* fun = Runtime::FunctionForId(f); 382 const Runtime::Function* fun = Runtime::FunctionForId(f);
363 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; 383 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
364 CallDescriptor* desc = 384 CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor(f, nargs, props);
365 linkage()->GetRuntimeCallDescriptor(f, nargs, props, FlagsForNode(node));
366 Node* ref = ExternalConstant(ExternalReference(f, isolate())); 385 Node* ref = ExternalConstant(ExternalReference(f, isolate()));
367 Node* arity = Int32Constant(nargs); 386 Node* arity = Int32Constant(nargs);
368 if (!centrystub_constant_.is_set()) { 387 if (!centrystub_constant_.is_set()) {
369 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode())); 388 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode()));
370 } 389 }
371 PatchInsertInput(node, 0, centrystub_constant_.get()); 390 PatchInsertInput(node, 0, centrystub_constant_.get());
372 PatchInsertInput(node, nargs + 1, ref); 391 PatchInsertInput(node, nargs + 1, ref);
373 PatchInsertInput(node, nargs + 2, arity); 392 PatchInsertInput(node, nargs + 2, arity);
374 PatchOperator(node, common()->Call(desc)); 393 PatchOperator(node, common()->Call(desc));
375 } 394 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { 558 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) {
540 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); 559 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node);
541 int arity = OperatorProperties::GetValueInputCount(node->op()); 560 int arity = OperatorProperties::GetValueInputCount(node->op());
542 ReplaceWithRuntimeCall(node, function, arity); 561 ReplaceWithRuntimeCall(node, function, arity);
543 return node; 562 return node;
544 } 563 }
545 564
546 } // namespace compiler 565 } // namespace compiler
547 } // namespace internal 566 } // namespace internal
548 } // namespace v8 567 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ia32/linkage-ia32.cc ('k') | src/compiler/linkage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698