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

Side by Side Diff: src/compiler/change-lowering.cc

Issue 1712563002: [turbofan] Move lowering of ObjectIs* nodes to ChangeLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « src/compiler/change-lowering.h ('k') | src/compiler/simplified-lowering.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/compiler/change-lowering.h" 5 #include "src/compiler/change-lowering.h"
6 6
7 #include "src/address-map.h" 7 #include "src/address-map.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 case IrOpcode::kLoadField: 42 case IrOpcode::kLoadField:
43 return LoadField(node); 43 return LoadField(node);
44 case IrOpcode::kStoreField: 44 case IrOpcode::kStoreField:
45 return StoreField(node); 45 return StoreField(node);
46 case IrOpcode::kLoadElement: 46 case IrOpcode::kLoadElement:
47 return LoadElement(node); 47 return LoadElement(node);
48 case IrOpcode::kStoreElement: 48 case IrOpcode::kStoreElement:
49 return StoreElement(node); 49 return StoreElement(node);
50 case IrOpcode::kAllocate: 50 case IrOpcode::kAllocate:
51 return Allocate(node); 51 return Allocate(node);
52 case IrOpcode::kObjectIsReceiver:
53 return ObjectIsReceiver(node);
54 case IrOpcode::kObjectIsSmi:
55 return ObjectIsSmi(node);
56 case IrOpcode::kObjectIsNumber:
57 return ObjectIsNumber(node);
52 default: 58 default:
53 return NoChange(); 59 return NoChange();
54 } 60 }
55 UNREACHABLE(); 61 UNREACHABLE();
56 return NoChange(); 62 return NoChange();
57 } 63 }
58 64
59 65
60 Node* ChangeLowering::HeapNumberValueIndexConstant() { 66 Node* ChangeLowering::HeapNumberValueIndexConstant() {
61 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag); 67 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag);
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1)); 581 node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1));
576 node->InsertInput(graph()->zone(), 2, jsgraph()->SmiConstant(flags)); 582 node->InsertInput(graph()->zone(), 2, jsgraph()->SmiConstant(flags));
577 node->InsertInput(graph()->zone(), 3, jsgraph()->ExternalConstant(ref)); 583 node->InsertInput(graph()->zone(), 3, jsgraph()->ExternalConstant(ref));
578 node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2)); 584 node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2));
579 node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant()); 585 node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant());
580 NodeProperties::ChangeOp(node, common()->Call(desc)); 586 NodeProperties::ChangeOp(node, common()->Call(desc));
581 } 587 }
582 return Changed(node); 588 return Changed(node);
583 } 589 }
584 590
591 Node* ChangeLowering::IsSmi(Node* value) {
592 return graph()->NewNode(
593 machine()->WordEqual(),
594 graph()->NewNode(machine()->WordAnd(), value,
595 jsgraph()->IntPtrConstant(kSmiTagMask)),
596 jsgraph()->IntPtrConstant(kSmiTag));
597 }
598
599 Node* ChangeLowering::LoadHeapObjectMap(Node* object, Node* control) {
600 return graph()->NewNode(
601 machine()->Load(MachineType::AnyTagged()), object,
602 jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag),
603 graph()->start(), control);
604 }
605
606 Node* ChangeLowering::LoadMapInstanceType(Node* map) {
607 return graph()->NewNode(
608 machine()->Load(MachineType::Uint8()), map,
609 jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag),
610 graph()->start(), graph()->start());
611 }
612
613 Reduction ChangeLowering::ObjectIsNumber(Node* node) {
614 Node* input = NodeProperties::GetValueInput(node, 0);
615 // TODO(bmeurer): Optimize somewhat based on input type.
616 Node* check = IsSmi(input);
617 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start());
618 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
619 Node* vtrue = jsgraph()->Int32Constant(1);
620 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
621 Node* vfalse = graph()->NewNode(
622 machine()->WordEqual(), LoadHeapObjectMap(input, if_false),
623 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map()));
624 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
625 node->ReplaceInput(0, vtrue);
626 node->AppendInput(graph()->zone(), vfalse);
627 node->AppendInput(graph()->zone(), control);
628 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2));
629 return Changed(node);
630 }
631
632 Reduction ChangeLowering::ObjectIsReceiver(Node* node) {
633 Node* input = NodeProperties::GetValueInput(node, 0);
634 // TODO(bmeurer): Optimize somewhat based on input type.
635 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
636 Node* check = IsSmi(input);
637 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start());
638 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
639 Node* vtrue = jsgraph()->Int32Constant(0);
640 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
641 Node* vfalse =
642 graph()->NewNode(machine()->Uint32LessThanOrEqual(),
643 jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE),
644 LoadMapInstanceType(LoadHeapObjectMap(input, if_false)));
645 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
646 node->ReplaceInput(0, vtrue);
647 node->AppendInput(graph()->zone(), vfalse);
648 node->AppendInput(graph()->zone(), control);
649 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2));
650 return Changed(node);
651 }
652
653 Reduction ChangeLowering::ObjectIsSmi(Node* node) {
654 node->ReplaceInput(0,
655 graph()->NewNode(machine()->WordAnd(), node->InputAt(0),
656 jsgraph()->IntPtrConstant(kSmiTagMask)));
657 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
658 NodeProperties::ChangeOp(node, machine()->WordEqual());
659 return Changed(node);
660 }
585 661
586 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } 662 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); }
587 663
588 664
589 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); } 665 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); }
590 666
591 667
592 CommonOperatorBuilder* ChangeLowering::common() const { 668 CommonOperatorBuilder* ChangeLowering::common() const {
593 return jsgraph()->common(); 669 return jsgraph()->common();
594 } 670 }
595 671
596 672
597 MachineOperatorBuilder* ChangeLowering::machine() const { 673 MachineOperatorBuilder* ChangeLowering::machine() const {
598 return jsgraph()->machine(); 674 return jsgraph()->machine();
599 } 675 }
600 676
601 } // namespace compiler 677 } // namespace compiler
602 } // namespace internal 678 } // namespace internal
603 } // namespace v8 679 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/change-lowering.h ('k') | src/compiler/simplified-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698