OLD | NEW |
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-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 REPLACE_STUB_CALL(Modulus) | 81 REPLACE_STUB_CALL(Modulus) |
82 REPLACE_STUB_CALL(BitwiseAnd) | 82 REPLACE_STUB_CALL(BitwiseAnd) |
83 REPLACE_STUB_CALL(BitwiseOr) | 83 REPLACE_STUB_CALL(BitwiseOr) |
84 REPLACE_STUB_CALL(BitwiseXor) | 84 REPLACE_STUB_CALL(BitwiseXor) |
85 REPLACE_STUB_CALL(LessThan) | 85 REPLACE_STUB_CALL(LessThan) |
86 REPLACE_STUB_CALL(LessThanOrEqual) | 86 REPLACE_STUB_CALL(LessThanOrEqual) |
87 REPLACE_STUB_CALL(GreaterThan) | 87 REPLACE_STUB_CALL(GreaterThan) |
88 REPLACE_STUB_CALL(GreaterThanOrEqual) | 88 REPLACE_STUB_CALL(GreaterThanOrEqual) |
89 REPLACE_STUB_CALL(Equal) | 89 REPLACE_STUB_CALL(Equal) |
90 REPLACE_STUB_CALL(NotEqual) | 90 REPLACE_STUB_CALL(NotEqual) |
91 REPLACE_STUB_CALL(StrictEqual) | |
92 REPLACE_STUB_CALL(StrictNotEqual) | |
93 REPLACE_STUB_CALL(ToBoolean) | |
94 REPLACE_STUB_CALL(ToInteger) | 91 REPLACE_STUB_CALL(ToInteger) |
95 REPLACE_STUB_CALL(ToLength) | 92 REPLACE_STUB_CALL(ToLength) |
96 REPLACE_STUB_CALL(ToNumber) | 93 REPLACE_STUB_CALL(ToNumber) |
97 REPLACE_STUB_CALL(ToName) | 94 REPLACE_STUB_CALL(ToName) |
98 REPLACE_STUB_CALL(ToObject) | 95 REPLACE_STUB_CALL(ToObject) |
99 REPLACE_STUB_CALL(ToString) | 96 REPLACE_STUB_CALL(ToString) |
100 #undef REPLACE_STUB_CALL | 97 #undef REPLACE_STUB_CALL |
101 | 98 |
102 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, | 99 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, |
103 CallDescriptor::Flags flags) { | 100 CallDescriptor::Flags flags) { |
104 Operator::Properties properties = node->op()->properties(); | 101 ReplaceWithStubCall(node, callable, flags, node->op()->properties()); |
| 102 } |
| 103 |
| 104 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, |
| 105 CallDescriptor::Flags flags, |
| 106 Operator::Properties properties) { |
105 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 107 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
106 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 108 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
107 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 109 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
108 node->InsertInput(zone(), 0, stub_code); | 110 node->InsertInput(zone(), 0, stub_code); |
109 NodeProperties::ChangeOp(node, common()->Call(desc)); | 111 NodeProperties::ChangeOp(node, common()->Call(desc)); |
110 } | 112 } |
111 | 113 |
112 | 114 |
113 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 115 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
114 Runtime::FunctionId f, | 116 Runtime::FunctionId f, |
115 int nargs_override) { | 117 int nargs_override) { |
116 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 118 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
117 Operator::Properties properties = node->op()->properties(); | 119 Operator::Properties properties = node->op()->properties(); |
118 const Runtime::Function* fun = Runtime::FunctionForId(f); | 120 const Runtime::Function* fun = Runtime::FunctionForId(f); |
119 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 121 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
120 CallDescriptor* desc = | 122 CallDescriptor* desc = |
121 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags); | 123 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags); |
122 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); | 124 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); |
123 Node* arity = jsgraph()->Int32Constant(nargs); | 125 Node* arity = jsgraph()->Int32Constant(nargs); |
124 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size)); | 126 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size)); |
125 node->InsertInput(zone(), nargs + 1, ref); | 127 node->InsertInput(zone(), nargs + 1, ref); |
126 node->InsertInput(zone(), nargs + 2, arity); | 128 node->InsertInput(zone(), nargs + 2, arity); |
127 NodeProperties::ChangeOp(node, common()->Call(desc)); | 129 NodeProperties::ChangeOp(node, common()->Call(desc)); |
128 } | 130 } |
129 | 131 |
| 132 void JSGenericLowering::LowerJSStrictEqual(Node* node) { |
| 133 Callable callable = CodeFactory::StrictEqual(isolate()); |
| 134 node->AppendInput(zone(), graph()->start()); |
| 135 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags, |
| 136 Operator::kEliminatable); |
| 137 } |
| 138 |
| 139 void JSGenericLowering::LowerJSStrictNotEqual(Node* node) { |
| 140 Callable callable = CodeFactory::StrictNotEqual(isolate()); |
| 141 node->AppendInput(zone(), graph()->start()); |
| 142 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags, |
| 143 Operator::kEliminatable); |
| 144 } |
| 145 |
| 146 void JSGenericLowering::LowerJSToBoolean(Node* node) { |
| 147 Callable callable = CodeFactory::ToBoolean(isolate()); |
| 148 node->AppendInput(zone(), graph()->start()); |
| 149 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags, |
| 150 Operator::kEliminatable); |
| 151 } |
130 | 152 |
131 void JSGenericLowering::LowerJSTypeOf(Node* node) { | 153 void JSGenericLowering::LowerJSTypeOf(Node* node) { |
132 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | |
133 Callable callable = CodeFactory::Typeof(isolate()); | 154 Callable callable = CodeFactory::Typeof(isolate()); |
134 ReplaceWithStubCall(node, callable, flags); | 155 node->AppendInput(zone(), graph()->start()); |
| 156 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags, |
| 157 Operator::kEliminatable); |
135 } | 158 } |
136 | 159 |
137 | 160 |
138 void JSGenericLowering::LowerJSLoadProperty(Node* node) { | 161 void JSGenericLowering::LowerJSLoadProperty(Node* node) { |
139 Node* closure = NodeProperties::GetValueInput(node, 2); | 162 Node* closure = NodeProperties::GetValueInput(node, 2); |
140 Node* effect = NodeProperties::GetEffectInput(node); | 163 Node* effect = NodeProperties::GetEffectInput(node); |
141 Node* control = NodeProperties::GetControlInput(node); | 164 Node* control = NodeProperties::GetControlInput(node); |
142 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 165 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
143 const PropertyAccess& p = PropertyAccessOf(node->op()); | 166 const PropertyAccess& p = PropertyAccessOf(node->op()); |
144 Callable callable = | 167 Callable callable = |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 753 } |
731 | 754 |
732 | 755 |
733 MachineOperatorBuilder* JSGenericLowering::machine() const { | 756 MachineOperatorBuilder* JSGenericLowering::machine() const { |
734 return jsgraph()->machine(); | 757 return jsgraph()->machine(); |
735 } | 758 } |
736 | 759 |
737 } // namespace compiler | 760 } // namespace compiler |
738 } // namespace internal | 761 } // namespace internal |
739 } // namespace v8 | 762 } // namespace v8 |
OLD | NEW |