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/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
9 #include "src/compiler/js-generic-lowering.h" | 9 #include "src/compiler/js-generic-lowering.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR) | 72 REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR) |
73 REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR) | 73 REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR) |
74 REPLACE_BINARY_OP_IC_CALL(JSAdd, Token::ADD) | 74 REPLACE_BINARY_OP_IC_CALL(JSAdd, Token::ADD) |
75 REPLACE_BINARY_OP_IC_CALL(JSSubtract, Token::SUB) | 75 REPLACE_BINARY_OP_IC_CALL(JSSubtract, Token::SUB) |
76 REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL) | 76 REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL) |
77 REPLACE_BINARY_OP_IC_CALL(JSDivide, Token::DIV) | 77 REPLACE_BINARY_OP_IC_CALL(JSDivide, Token::DIV) |
78 REPLACE_BINARY_OP_IC_CALL(JSModulus, Token::MOD) | 78 REPLACE_BINARY_OP_IC_CALL(JSModulus, Token::MOD) |
79 #undef REPLACE_BINARY_OP_IC_CALL | 79 #undef REPLACE_BINARY_OP_IC_CALL |
80 | 80 |
81 | 81 |
82 #define REPLACE_COMPARE_IC_CALL(op, token, pure) \ | 82 #define REPLACE_COMPARE_IC_CALL(op, token) \ |
83 void JSGenericLowering::Lower##op(Node* node) { \ | 83 void JSGenericLowering::Lower##op(Node* node) { \ |
84 ReplaceWithCompareIC(node, token, pure); \ | 84 ReplaceWithCompareIC(node, token); \ |
85 } | 85 } |
86 REPLACE_COMPARE_IC_CALL(JSEqual, Token::EQ, false) | 86 REPLACE_COMPARE_IC_CALL(JSEqual, Token::EQ) |
87 REPLACE_COMPARE_IC_CALL(JSNotEqual, Token::NE, false) | 87 REPLACE_COMPARE_IC_CALL(JSNotEqual, Token::NE) |
88 REPLACE_COMPARE_IC_CALL(JSStrictEqual, Token::EQ_STRICT, true) | 88 REPLACE_COMPARE_IC_CALL(JSStrictEqual, Token::EQ_STRICT) |
89 REPLACE_COMPARE_IC_CALL(JSStrictNotEqual, Token::NE_STRICT, true) | 89 REPLACE_COMPARE_IC_CALL(JSStrictNotEqual, Token::NE_STRICT) |
90 REPLACE_COMPARE_IC_CALL(JSLessThan, Token::LT, false) | 90 REPLACE_COMPARE_IC_CALL(JSLessThan, Token::LT) |
91 REPLACE_COMPARE_IC_CALL(JSGreaterThan, Token::GT, false) | 91 REPLACE_COMPARE_IC_CALL(JSGreaterThan, Token::GT) |
92 REPLACE_COMPARE_IC_CALL(JSLessThanOrEqual, Token::LTE, false) | 92 REPLACE_COMPARE_IC_CALL(JSLessThanOrEqual, Token::LTE) |
93 REPLACE_COMPARE_IC_CALL(JSGreaterThanOrEqual, Token::GTE, false) | 93 REPLACE_COMPARE_IC_CALL(JSGreaterThanOrEqual, Token::GTE) |
94 #undef REPLACE_COMPARE_IC_CALL | 94 #undef REPLACE_COMPARE_IC_CALL |
95 | 95 |
96 | 96 |
97 #define REPLACE_RUNTIME_CALL(op, fun) \ | 97 #define REPLACE_RUNTIME_CALL(op, fun) \ |
98 void JSGenericLowering::Lower##op(Node* node) { \ | 98 void JSGenericLowering::Lower##op(Node* node) { \ |
99 ReplaceWithRuntimeCall(node, fun); \ | 99 ReplaceWithRuntimeCall(node, fun); \ |
100 } | 100 } |
101 REPLACE_RUNTIME_CALL(JSTypeOf, Runtime::kTypeof) | 101 REPLACE_RUNTIME_CALL(JSTypeOf, Runtime::kTypeof) |
102 REPLACE_RUNTIME_CALL(JSCreate, Runtime::kAbort) | 102 REPLACE_RUNTIME_CALL(JSCreate, Runtime::kAbort) |
103 REPLACE_RUNTIME_CALL(JSCreateFunctionContext, Runtime::kNewFunctionContext) | 103 REPLACE_RUNTIME_CALL(JSCreateFunctionContext, Runtime::kNewFunctionContext) |
(...skipping 15 matching lines...) Expand all Loading... |
119 | 119 |
120 static CallDescriptor::Flags FlagsForNode(Node* node) { | 120 static CallDescriptor::Flags FlagsForNode(Node* node) { |
121 CallDescriptor::Flags result = CallDescriptor::kNoFlags; | 121 CallDescriptor::Flags result = CallDescriptor::kNoFlags; |
122 if (OperatorProperties::HasFrameStateInput(node->op())) { | 122 if (OperatorProperties::HasFrameStateInput(node->op())) { |
123 result |= CallDescriptor::kNeedsFrameState; | 123 result |= CallDescriptor::kNeedsFrameState; |
124 } | 124 } |
125 return result; | 125 return result; |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, | 129 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) { |
130 bool pure) { | |
131 Callable callable = CodeFactory::CompareIC(isolate(), token); | 130 Callable callable = CodeFactory::CompareIC(isolate(), token); |
132 bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op()); | 131 bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op()); |
133 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor( | 132 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor( |
134 callable.descriptor(), 0, | 133 callable.descriptor(), 0, |
135 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node)); | 134 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node)); |
136 NodeVector inputs(zone()); | 135 NodeVector inputs(zone()); |
137 inputs.reserve(node->InputCount() + 1); | 136 inputs.reserve(node->InputCount() + 1); |
138 inputs.push_back(jsgraph()->HeapConstant(callable.code())); | 137 inputs.push_back(jsgraph()->HeapConstant(callable.code())); |
139 inputs.push_back(NodeProperties::GetValueInput(node, 0)); | 138 inputs.push_back(NodeProperties::GetValueInput(node, 0)); |
140 inputs.push_back(NodeProperties::GetValueInput(node, 1)); | 139 inputs.push_back(NodeProperties::GetValueInput(node, 1)); |
141 inputs.push_back(NodeProperties::GetContextInput(node)); | 140 inputs.push_back(NodeProperties::GetContextInput(node)); |
142 if (pure) { | 141 if (node->op()->HasProperty(Operator::kPure)) { |
143 // A pure (strict) comparison doesn't have an effect, control or frame | 142 // A pure (strict) comparison doesn't have an effect, control or frame |
144 // state. But for the graph, we need to add control and effect inputs. | 143 // state. But for the graph, we need to add control and effect inputs. |
145 DCHECK(!has_frame_state); | 144 DCHECK(!has_frame_state); |
146 inputs.push_back(graph()->start()); | 145 inputs.push_back(graph()->start()); |
147 inputs.push_back(graph()->start()); | 146 inputs.push_back(graph()->start()); |
148 } else { | 147 } else { |
149 DCHECK(has_frame_state == FLAG_turbo_deoptimization); | 148 DCHECK(has_frame_state == FLAG_turbo_deoptimization); |
150 if (FLAG_turbo_deoptimization) { | 149 if (FLAG_turbo_deoptimization) { |
151 inputs.push_back(NodeProperties::GetFrameStateInput(node)); | 150 inputs.push_back(NodeProperties::GetFrameStateInput(node)); |
152 } | 151 } |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 417 |
419 | 418 |
420 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 419 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
421 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 420 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
422 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 421 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
423 } | 422 } |
424 | 423 |
425 } // namespace compiler | 424 } // namespace compiler |
426 } // namespace internal | 425 } // namespace internal |
427 } // namespace v8 | 426 } // namespace v8 |
OLD | NEW |