| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 Node* JSGenericLowering::ExternalConstant(ExternalReference ref) { | 56 Node* JSGenericLowering::ExternalConstant(ExternalReference ref) { |
| 57 return jsgraph()->ExternalConstant(ref); | 57 return jsgraph()->ExternalConstant(ref); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 Reduction JSGenericLowering::Reduce(Node* node) { | 61 Reduction JSGenericLowering::Reduce(Node* node) { |
| 62 switch (node->opcode()) { | 62 switch (node->opcode()) { |
| 63 #define DECLARE_CASE(x) \ | 63 #define DECLARE_CASE(x) \ |
| 64 case IrOpcode::k##x: \ | 64 case IrOpcode::k##x: \ |
| 65 Lower##x(node); \ | 65 Lower##x(node); \ |
| 66 break; | 66 break; |
| 67 DECLARE_CASE(Branch) | |
| 68 JS_OP_LIST(DECLARE_CASE) | 67 JS_OP_LIST(DECLARE_CASE) |
| 69 #undef DECLARE_CASE | 68 #undef DECLARE_CASE |
| 69 case IrOpcode::kBranch: |
| 70 // TODO(mstarzinger): If typing is enabled then simplified lowering will |
| 71 // have inserted the correct ChangeBoolToBit, otherwise we need to perform |
| 72 // poor-man's representation inference here and insert manual change. |
| 73 if (!info()->is_typing_enabled()) { |
| 74 Node* test = graph()->NewNode(machine()->WordEqual(), node->InputAt(0), |
| 75 jsgraph()->TrueConstant()); |
| 76 node->ReplaceInput(0, test); |
| 77 break; |
| 78 } |
| 79 // Fall-through. |
| 70 default: | 80 default: |
| 71 // Nothing to see. | 81 // Nothing to see. |
| 72 return NoChange(); | 82 return NoChange(); |
| 73 } | 83 } |
| 74 return Changed(node); | 84 return Changed(node); |
| 75 } | 85 } |
| 76 | 86 |
| 77 | 87 |
| 78 #define REPLACE_BINARY_OP_IC_CALL(op, token) \ | 88 #define REPLACE_BINARY_OP_IC_CALL(op, token) \ |
| 79 void JSGenericLowering::Lower##op(Node* node) { \ | 89 void JSGenericLowering::Lower##op(Node* node) { \ |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 linkage()->GetRuntimeCallDescriptor(f, nargs, properties); | 233 linkage()->GetRuntimeCallDescriptor(f, nargs, properties); |
| 224 Node* ref = ExternalConstant(ExternalReference(f, isolate())); | 234 Node* ref = ExternalConstant(ExternalReference(f, isolate())); |
| 225 Node* arity = Int32Constant(nargs); | 235 Node* arity = Int32Constant(nargs); |
| 226 PatchInsertInput(node, 0, jsgraph()->CEntryStubConstant(fun->result_size)); | 236 PatchInsertInput(node, 0, jsgraph()->CEntryStubConstant(fun->result_size)); |
| 227 PatchInsertInput(node, nargs + 1, ref); | 237 PatchInsertInput(node, nargs + 1, ref); |
| 228 PatchInsertInput(node, nargs + 2, arity); | 238 PatchInsertInput(node, nargs + 2, arity); |
| 229 PatchOperator(node, common()->Call(desc)); | 239 PatchOperator(node, common()->Call(desc)); |
| 230 } | 240 } |
| 231 | 241 |
| 232 | 242 |
| 233 void JSGenericLowering::LowerBranch(Node* node) { | |
| 234 if (!info()->is_typing_enabled()) { | |
| 235 // TODO(mstarzinger): If typing is enabled then simplified lowering will | |
| 236 // have inserted the correct ChangeBoolToBit, otherwise we need to perform | |
| 237 // poor-man's representation inference here and insert manual change. | |
| 238 Node* test = graph()->NewNode(machine()->WordEqual(), node->InputAt(0), | |
| 239 jsgraph()->TrueConstant()); | |
| 240 node->ReplaceInput(0, test); | |
| 241 } | |
| 242 } | |
| 243 | |
| 244 | |
| 245 void JSGenericLowering::LowerJSUnaryNot(Node* node) { | 243 void JSGenericLowering::LowerJSUnaryNot(Node* node) { |
| 246 Callable callable = CodeFactory::ToBoolean( | 244 Callable callable = CodeFactory::ToBoolean( |
| 247 isolate(), ToBooleanStub::RESULT_AS_INVERSE_ODDBALL); | 245 isolate(), ToBooleanStub::RESULT_AS_INVERSE_ODDBALL); |
| 248 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 246 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
| 249 } | 247 } |
| 250 | 248 |
| 251 | 249 |
| 252 void JSGenericLowering::LowerJSToBoolean(Node* node) { | 250 void JSGenericLowering::LowerJSToBoolean(Node* node) { |
| 253 Callable callable = | 251 Callable callable = |
| 254 CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL); | 252 CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 441 |
| 444 | 442 |
| 445 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 443 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
| 446 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 444 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
| 447 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 445 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
| 448 } | 446 } |
| 449 | 447 |
| 450 } // namespace compiler | 448 } // namespace compiler |
| 451 } // namespace internal | 449 } // namespace internal |
| 452 } // namespace v8 | 450 } // namespace v8 |
| OLD | NEW |