15 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
18 Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
19 switch (node->opcode()) {
20 case IrOpcode::kBooleanNot: {
21 HeapObjectMatcher<HeapObject> m(node->InputAt(0));
23 return Replace(jsgraph()->TrueConstant());
26 return Replace(jsgraph()->FalseConstant());
28 if (m.IsBooleanNot())
return Replace(m.node()->InputAt(0));
31 case IrOpcode::kChangeBitToBool: {
33 if (m.Is(0))
return Replace(jsgraph()->FalseConstant());
34 if (m.Is(1))
return Replace(jsgraph()->TrueConstant());
35 if (m.IsChangeBoolToBit())
return Replace(m.node()->InputAt(0));
38 case IrOpcode::kChangeBoolToBit: {
39 HeapObjectMatcher<HeapObject> m(node->InputAt(0));
41 return ReplaceInt32(0);
44 return ReplaceInt32(1);
46 if (m.IsChangeBitToBool())
return Replace(m.node()->InputAt(0));
49 case IrOpcode::kChangeFloat64ToTagged: {
51 if (m.HasValue())
return ReplaceNumber(m.Value());
54 case IrOpcode::kChangeInt32ToTagged: {
56 if (m.HasValue())
return ReplaceNumber(m.Value());
59 case IrOpcode::kChangeTaggedToFloat64: {
61 if (m.HasValue())
return ReplaceFloat64(m.Value());
62 if (m.IsChangeFloat64ToTagged())
return Replace(m.node()->InputAt(0));
63 if (m.IsChangeInt32ToTagged()) {
64 return Change(node, machine()->ChangeInt32ToFloat64(),
65 m.node()->InputAt(0));
67 if (m.IsChangeUint32ToTagged()) {
68 return Change(node, machine()->ChangeUint32ToFloat64(),
69 m.node()->InputAt(0));
73 case IrOpcode::kChangeTaggedToInt32: {
75 if (m.HasValue())
return ReplaceInt32(
DoubleToInt32(m.Value()));
76 if (m.IsChangeFloat64ToTagged()) {
77 return Change(node, machine()->ChangeFloat64ToInt32(),
78 m.node()->InputAt(0));
80 if (m.IsChangeInt32ToTagged())
return Replace(m.node()->InputAt(0));
83 case IrOpcode::kChangeTaggedToUint32: {
86 if (m.IsChangeFloat64ToTagged()) {
87 return Change(node, machine()->ChangeFloat64ToUint32(),
88 m.node()->InputAt(0));
90 if (m.IsChangeUint32ToTagged())
return Replace(m.node()->InputAt(0));
93 case IrOpcode::kChangeUint32ToTagged: {
95 if (m.HasValue())
return ReplaceNumber(
FastUI2D(m.Value()));
105 Reduction SimplifiedOperatorReducer::Change(Node* node,
const Operator* op,
108 node->ReplaceInput(0, a);
109 return Changed(node);
113 Reduction SimplifiedOperatorReducer::ReplaceFloat64(
double value) {
114 return Replace(jsgraph()->Float64Constant(value));
118 Reduction SimplifiedOperatorReducer::ReplaceInt32(
int32_t value) {
119 return Replace(jsgraph()->Int32Constant(value));
123 Reduction SimplifiedOperatorReducer::ReplaceNumber(
double value) {
124 return Replace(jsgraph()->Constant(value));
128 Reduction SimplifiedOperatorReducer::ReplaceNumber(
int32_t value) {
129 return Replace(jsgraph()->Constant(value));
133 Graph* SimplifiedOperatorReducer::graph()
const {
return jsgraph()->graph(); }
136 Factory* SimplifiedOperatorReducer::factory()
const {
137 return jsgraph()->isolate()->factory();
141 MachineOperatorBuilder* SimplifiedOperatorReducer::machine()
const {
142 return jsgraph()->machine();
static Unique< T > CreateImmovable(Handle< T > handle)
FloatMatcher< double, IrOpcode::kFloat64Constant > Float64Matcher
IntMatcher< int32_t, IrOpcode::kInt32Constant > Int32Matcher
IntMatcher< uint32_t, IrOpcode::kInt32Constant > Uint32Matcher
FloatMatcher< double, IrOpcode::kNumberConstant > NumberMatcher
uint32_t DoubleToUint32(double x)
int32_t DoubleToInt32(double x)
double FastUI2D(unsigned x)
Debugger support for the V8 JavaScript engine.