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

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

Issue 1641753002: [turbofan] Stay in optimized code for SMI inputs to %_ToInteger. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/js-intrinsic-lowering.h" 5 #include "src/compiler/js-intrinsic-lowering.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 500 }
501 501
502 502
503 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) { 503 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
504 return Change(node, CodeFactory::SubString(isolate()), 3); 504 return Change(node, CodeFactory::SubString(isolate()), 3);
505 } 505 }
506 506
507 507
508 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { 508 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
509 Node* value = NodeProperties::GetValueInput(node, 0); 509 Node* value = NodeProperties::GetValueInput(node, 0);
510 Node* context = NodeProperties::GetContextInput(node);
511 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
512 Node* effect = NodeProperties::GetEffectInput(node);
513 Node* control = NodeProperties::GetControlInput(node);
514
515 // ToInteger is a no-op on integer values and -0.
510 Type* value_type = NodeProperties::GetType(value); 516 Type* value_type = NodeProperties::GetType(value);
511 if (value_type->Is(type_cache().kIntegerOrMinusZero)) { 517 if (value_type->Is(type_cache().kIntegerOrMinusZero)) {
512 ReplaceWithValue(node, value); 518 ReplaceWithValue(node, value);
513 return Replace(value); 519 return Replace(value);
514 } 520 }
515 return NoChange(); 521
522 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
523 Node* branch =
524 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
525
526 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
527 Node* etrue = effect;
528 Node* vtrue = value;
529
530 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
531 Node* efalse = effect;
532 Node* vfalse;
533 {
534 vfalse = efalse =
535 graph()->NewNode(javascript()->CallRuntime(Runtime::kToInteger), value,
536 context, frame_state, efalse, if_false);
537 if_false = graph()->NewNode(common()->IfSuccess(), vfalse);
538 }
539
540 control = graph()->NewNode(common()->Merge(2), if_true, if_false);
541 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
542 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
543 vtrue, vfalse, control);
544 // TODO(bmeurer, mstarzinger): Rewire IfException inputs to {vfalse}.
545 ReplaceWithValue(node, value, effect, control);
546 return Changed(value);
516 } 547 }
517 548
518 549
519 Reduction JSIntrinsicLowering::ReduceToName(Node* node) { 550 Reduction JSIntrinsicLowering::ReduceToName(Node* node) {
520 NodeProperties::ChangeOp(node, javascript()->ToName()); 551 NodeProperties::ChangeOp(node, javascript()->ToName());
521 return Changed(node); 552 return Changed(node);
522 } 553 }
523 554
524 555
525 Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) { 556 Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 724 }
694 725
695 726
696 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 727 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
697 return jsgraph()->simplified(); 728 return jsgraph()->simplified();
698 } 729 }
699 730
700 } // namespace compiler 731 } // namespace compiler
701 } // namespace internal 732 } // namespace internal
702 } // namespace v8 733 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698