OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/compiler-source-position-table.h" | 10 #include "src/compiler/compiler-source-position-table.h" |
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 BuildCastOperator(javascript()->ToObject()); | 2027 BuildCastOperator(javascript()->ToObject()); |
2028 } | 2028 } |
2029 | 2029 |
2030 void BytecodeGraphBuilder::VisitToNumber() { | 2030 void BytecodeGraphBuilder::VisitToNumber() { |
2031 PrepareEagerCheckpoint(); | 2031 PrepareEagerCheckpoint(); |
2032 Node* object = environment()->LookupAccumulator(); | 2032 Node* object = environment()->LookupAccumulator(); |
2033 | 2033 |
2034 Node* node = nullptr; | 2034 Node* node = nullptr; |
2035 FeedbackSlot slot = | 2035 FeedbackSlot slot = |
2036 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); | 2036 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); |
2037 if (Node* simplified = TryBuildSimplifiedBinaryOp( | 2037 if (Node* simplified = TryBuildSimplifiedToNumber(object, slot)) { |
2038 javascript()->Multiply(), object, jsgraph()->OneConstant(), slot)) { | |
2039 node = simplified; | 2038 node = simplified; |
2040 } else { | 2039 } else { |
2041 node = NewNode(javascript()->ToNumber(), object); | 2040 node = NewNode(javascript()->ToNumber(), object); |
2042 } | 2041 } |
2043 | 2042 |
2044 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), node, | 2043 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), node, |
2045 Environment::kAttachFrameState); | 2044 Environment::kAttachFrameState); |
2046 } | 2045 } |
2047 | 2046 |
2048 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } | 2047 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2455 Node* control = environment()->GetControlDependency(); | 2454 Node* control = environment()->GetControlDependency(); |
2456 Reduction early_reduction = type_hint_lowering().ReduceBinaryOperation( | 2455 Reduction early_reduction = type_hint_lowering().ReduceBinaryOperation( |
2457 op, left, right, effect, control, slot); | 2456 op, left, right, effect, control, slot); |
2458 if (early_reduction.Changed()) { | 2457 if (early_reduction.Changed()) { |
2459 ApplyEarlyReduction(early_reduction); | 2458 ApplyEarlyReduction(early_reduction); |
2460 return early_reduction.replacement(); | 2459 return early_reduction.replacement(); |
2461 } | 2460 } |
2462 return nullptr; | 2461 return nullptr; |
2463 } | 2462 } |
2464 | 2463 |
| 2464 Node* BytecodeGraphBuilder::TryBuildSimplifiedToNumber(Node* value, |
| 2465 FeedbackSlot slot) { |
| 2466 Node* effect = environment()->GetEffectDependency(); |
| 2467 Node* control = environment()->GetControlDependency(); |
| 2468 Reduction early_reduction = type_hint_lowering().ReduceToNumberOperation( |
| 2469 value, effect, control, slot); |
| 2470 if (early_reduction.Changed()) { |
| 2471 ApplyEarlyReduction(early_reduction); |
| 2472 return early_reduction.replacement(); |
| 2473 } |
| 2474 return nullptr; |
| 2475 } |
| 2476 |
2465 Node* BytecodeGraphBuilder::TryBuildSimplifiedLoadNamed(const Operator* op, | 2477 Node* BytecodeGraphBuilder::TryBuildSimplifiedLoadNamed(const Operator* op, |
2466 Node* receiver, | 2478 Node* receiver, |
2467 FeedbackSlot slot) { | 2479 FeedbackSlot slot) { |
2468 // TODO(mstarzinger,6112): This is a workaround for OSR loop entries being | 2480 // TODO(mstarzinger,6112): This is a workaround for OSR loop entries being |
2469 // pruned from the graph by a soft-deopt. It can happen that a LoadIC that | 2481 // pruned from the graph by a soft-deopt. It can happen that a LoadIC that |
2470 // control-dominates the OSR entry is still in "uninitialized" state. | 2482 // control-dominates the OSR entry is still in "uninitialized" state. |
2471 if (!osr_ast_id_.IsNone()) return nullptr; | 2483 if (!osr_ast_id_.IsNone()) return nullptr; |
2472 Node* effect = environment()->GetEffectDependency(); | 2484 Node* effect = environment()->GetEffectDependency(); |
2473 Node* control = environment()->GetControlDependency(); | 2485 Node* control = environment()->GetControlDependency(); |
2474 Reduction early_reduction = type_hint_lowering().ReduceLoadNamedOperation( | 2486 Reduction early_reduction = type_hint_lowering().ReduceLoadNamedOperation( |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2748 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2760 it->source_position().ScriptOffset(), start_position_.InliningId())); |
2749 it->Advance(); | 2761 it->Advance(); |
2750 } else { | 2762 } else { |
2751 DCHECK_GT(it->code_offset(), offset); | 2763 DCHECK_GT(it->code_offset(), offset); |
2752 } | 2764 } |
2753 } | 2765 } |
2754 | 2766 |
2755 } // namespace compiler | 2767 } // namespace compiler |
2756 } // namespace internal | 2768 } // namespace internal |
2757 } // namespace v8 | 2769 } // namespace v8 |
OLD | NEW |