| 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/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler/compiler-source-position-table.h" | 10 #include "src/compiler/compiler-source-position-table.h" |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 // Output environment where the context has an extension | 837 // Output environment where the context has an extension |
| 838 Environment* slow_environment = nullptr; | 838 Environment* slow_environment = nullptr; |
| 839 | 839 |
| 840 // We only need to check up to the last-but-one depth, because the an eval in | 840 // We only need to check up to the last-but-one depth, because the an eval in |
| 841 // the same scope as the variable itself has no way of shadowing it. | 841 // the same scope as the variable itself has no way of shadowing it. |
| 842 for (uint32_t d = 0; d < depth; d++) { | 842 for (uint32_t d = 0; d < depth; d++) { |
| 843 Node* extension_slot = | 843 Node* extension_slot = |
| 844 NewNode(javascript()->LoadContext(d, Context::EXTENSION_INDEX, false)); | 844 NewNode(javascript()->LoadContext(d, Context::EXTENSION_INDEX, false)); |
| 845 | 845 |
| 846 Node* check_no_extension = | 846 Node* check_no_extension = |
| 847 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 847 NewNode(simplified()->ReferenceEqual(), extension_slot, |
| 848 extension_slot, jsgraph()->TheHoleConstant()); | 848 jsgraph()->TheHoleConstant()); |
| 849 | 849 |
| 850 NewBranch(check_no_extension); | 850 NewBranch(check_no_extension); |
| 851 Environment* true_environment = environment()->Copy(); | 851 Environment* true_environment = environment()->Copy(); |
| 852 | 852 |
| 853 { | 853 { |
| 854 NewIfFalse(); | 854 NewIfFalse(); |
| 855 // If there is an extension, merge into the slow path. | 855 // If there is an extension, merge into the slow path. |
| 856 if (slow_environment == nullptr) { | 856 if (slow_environment == nullptr) { |
| 857 slow_environment = environment(); | 857 slow_environment = environment(); |
| 858 NewMerge(); | 858 NewMerge(); |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 PrepareEagerCheckpoint(); | 1592 PrepareEagerCheckpoint(); |
| 1593 const Operator* js_op = | 1593 const Operator* js_op = |
| 1594 javascript()->Subtract(GetBinaryOperationHint(kCountOperationHintIndex)); | 1594 javascript()->Subtract(GetBinaryOperationHint(kCountOperationHintIndex)); |
| 1595 Node* node = NewNode(js_op, environment()->LookupAccumulator(), | 1595 Node* node = NewNode(js_op, environment()->LookupAccumulator(), |
| 1596 jsgraph()->OneConstant()); | 1596 jsgraph()->OneConstant()); |
| 1597 environment()->BindAccumulator(node, Environment::kAttachFrameState); | 1597 environment()->BindAccumulator(node, Environment::kAttachFrameState); |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 void BytecodeGraphBuilder::VisitLogicalNot() { | 1600 void BytecodeGraphBuilder::VisitLogicalNot() { |
| 1601 Node* value = environment()->LookupAccumulator(); | 1601 Node* value = environment()->LookupAccumulator(); |
| 1602 Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, | 1602 Node* node = NewNode(simplified()->BooleanNot(), value); |
| 1603 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); | |
| 1604 environment()->BindAccumulator(node); | 1603 environment()->BindAccumulator(node); |
| 1605 } | 1604 } |
| 1606 | 1605 |
| 1607 void BytecodeGraphBuilder::VisitToBooleanLogicalNot() { | 1606 void BytecodeGraphBuilder::VisitToBooleanLogicalNot() { |
| 1608 Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), | 1607 Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), |
| 1609 environment()->LookupAccumulator()); | 1608 environment()->LookupAccumulator()); |
| 1610 Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, | 1609 Node* node = NewNode(simplified()->BooleanNot(), value); |
| 1611 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); | |
| 1612 environment()->BindAccumulator(node); | 1610 environment()->BindAccumulator(node); |
| 1613 } | 1611 } |
| 1614 | 1612 |
| 1615 void BytecodeGraphBuilder::VisitTypeOf() { | 1613 void BytecodeGraphBuilder::VisitTypeOf() { |
| 1616 Node* node = | 1614 Node* node = |
| 1617 NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); | 1615 NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); |
| 1618 environment()->BindAccumulator(node); | 1616 environment()->BindAccumulator(node); |
| 1619 } | 1617 } |
| 1620 | 1618 |
| 1621 void BytecodeGraphBuilder::BuildDelete(LanguageMode language_mode) { | 1619 void BytecodeGraphBuilder::BuildDelete(LanguageMode language_mode) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 void BytecodeGraphBuilder::VisitTestUndetectable() { | 1689 void BytecodeGraphBuilder::VisitTestUndetectable() { |
| 1692 Node* object = | 1690 Node* object = |
| 1693 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1691 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1694 Node* node = NewNode(jsgraph()->simplified()->ObjectIsUndetectable(), object); | 1692 Node* node = NewNode(jsgraph()->simplified()->ObjectIsUndetectable(), object); |
| 1695 environment()->BindAccumulator(node); | 1693 environment()->BindAccumulator(node); |
| 1696 } | 1694 } |
| 1697 | 1695 |
| 1698 void BytecodeGraphBuilder::VisitTestNull() { | 1696 void BytecodeGraphBuilder::VisitTestNull() { |
| 1699 Node* object = | 1697 Node* object = |
| 1700 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1698 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1701 Node* result = NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 1699 Node* result = NewNode(simplified()->ReferenceEqual(), object, |
| 1702 object, jsgraph()->NullConstant()); | 1700 jsgraph()->NullConstant()); |
| 1703 environment()->BindAccumulator(result); | 1701 environment()->BindAccumulator(result); |
| 1704 } | 1702 } |
| 1705 | 1703 |
| 1706 void BytecodeGraphBuilder::VisitTestUndefined() { | 1704 void BytecodeGraphBuilder::VisitTestUndefined() { |
| 1707 Node* object = | 1705 Node* object = |
| 1708 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1706 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1709 Node* result = NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 1707 Node* result = NewNode(simplified()->ReferenceEqual(), object, |
| 1710 object, jsgraph()->UndefinedConstant()); | 1708 jsgraph()->UndefinedConstant()); |
| 1711 environment()->BindAccumulator(result); | 1709 environment()->BindAccumulator(result); |
| 1712 } | 1710 } |
| 1713 | 1711 |
| 1714 void BytecodeGraphBuilder::BuildCastOperator(const Operator* js_op) { | 1712 void BytecodeGraphBuilder::BuildCastOperator(const Operator* js_op) { |
| 1715 Node* value = NewNode(js_op, environment()->LookupAccumulator()); | 1713 Node* value = NewNode(js_op, environment()->LookupAccumulator()); |
| 1716 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value, | 1714 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value, |
| 1717 Environment::kAttachFrameState); | 1715 Environment::kAttachFrameState); |
| 1718 } | 1716 } |
| 1719 | 1717 |
| 1720 void BytecodeGraphBuilder::VisitToName() { | 1718 void BytecodeGraphBuilder::VisitToName() { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 Environment* if_true_environment = environment()->Copy(); | 2047 Environment* if_true_environment = environment()->Copy(); |
| 2050 NewIfFalse(); | 2048 NewIfFalse(); |
| 2051 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); | 2049 MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset()); |
| 2052 set_environment(if_true_environment); | 2050 set_environment(if_true_environment); |
| 2053 NewIfTrue(); | 2051 NewIfTrue(); |
| 2054 } | 2052 } |
| 2055 | 2053 |
| 2056 void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) { | 2054 void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) { |
| 2057 Node* accumulator = environment()->LookupAccumulator(); | 2055 Node* accumulator = environment()->LookupAccumulator(); |
| 2058 Node* condition = | 2056 Node* condition = |
| 2059 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 2057 NewNode(simplified()->ReferenceEqual(), accumulator, comperand); |
| 2060 accumulator, comperand); | |
| 2061 BuildJumpIf(condition); | 2058 BuildJumpIf(condition); |
| 2062 } | 2059 } |
| 2063 | 2060 |
| 2064 void BytecodeGraphBuilder::BuildJumpIfFalse() { | 2061 void BytecodeGraphBuilder::BuildJumpIfFalse() { |
| 2065 BuildJumpIfNot(environment()->LookupAccumulator()); | 2062 BuildJumpIfNot(environment()->LookupAccumulator()); |
| 2066 } | 2063 } |
| 2067 | 2064 |
| 2068 void BytecodeGraphBuilder::BuildJumpIfTrue() { | 2065 void BytecodeGraphBuilder::BuildJumpIfTrue() { |
| 2069 BuildJumpIf(environment()->LookupAccumulator()); | 2066 BuildJumpIf(environment()->LookupAccumulator()); |
| 2070 } | 2067 } |
| 2071 | 2068 |
| 2072 void BytecodeGraphBuilder::BuildJumpIfToBooleanTrue() { | 2069 void BytecodeGraphBuilder::BuildJumpIfToBooleanTrue() { |
| 2073 Node* accumulator = environment()->LookupAccumulator(); | 2070 Node* accumulator = environment()->LookupAccumulator(); |
| 2074 Node* condition = | 2071 Node* condition = |
| 2075 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); | 2072 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); |
| 2076 BuildJumpIf(condition); | 2073 BuildJumpIf(condition); |
| 2077 } | 2074 } |
| 2078 | 2075 |
| 2079 void BytecodeGraphBuilder::BuildJumpIfToBooleanFalse() { | 2076 void BytecodeGraphBuilder::BuildJumpIfToBooleanFalse() { |
| 2080 Node* accumulator = environment()->LookupAccumulator(); | 2077 Node* accumulator = environment()->LookupAccumulator(); |
| 2081 Node* condition = | 2078 Node* condition = |
| 2082 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); | 2079 NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator); |
| 2083 BuildJumpIfNot(condition); | 2080 BuildJumpIfNot(condition); |
| 2084 } | 2081 } |
| 2085 | 2082 |
| 2086 void BytecodeGraphBuilder::BuildJumpIfNotHole() { | 2083 void BytecodeGraphBuilder::BuildJumpIfNotHole() { |
| 2087 Node* accumulator = environment()->LookupAccumulator(); | 2084 Node* accumulator = environment()->LookupAccumulator(); |
| 2088 Node* condition = | 2085 Node* condition = NewNode(simplified()->ReferenceEqual(), accumulator, |
| 2089 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | 2086 jsgraph()->TheHoleConstant()); |
| 2090 accumulator, jsgraph()->TheHoleConstant()); | |
| 2091 BuildJumpIfNot(condition); | 2087 BuildJumpIfNot(condition); |
| 2092 } | 2088 } |
| 2093 | 2089 |
| 2094 void BytecodeGraphBuilder::BuildJumpIfJSReceiver() { | 2090 void BytecodeGraphBuilder::BuildJumpIfJSReceiver() { |
| 2095 Node* accumulator = environment()->LookupAccumulator(); | 2091 Node* accumulator = environment()->LookupAccumulator(); |
| 2096 Node* condition = NewNode(simplified()->ObjectIsReceiver(), accumulator); | 2092 Node* condition = NewNode(simplified()->ObjectIsReceiver(), accumulator); |
| 2097 BuildJumpIf(condition); | 2093 BuildJumpIf(condition); |
| 2098 } | 2094 } |
| 2099 | 2095 |
| 2100 Node** BytecodeGraphBuilder::EnsureInputBufferSize(int size) { | 2096 Node** BytecodeGraphBuilder::EnsureInputBufferSize(int size) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2288 it->source_position().ScriptOffset(), start_position_.InliningId())); |
| 2293 it->Advance(); | 2289 it->Advance(); |
| 2294 } else { | 2290 } else { |
| 2295 DCHECK_GT(it->code_offset(), offset); | 2291 DCHECK_GT(it->code_offset(), offset); |
| 2296 } | 2292 } |
| 2297 } | 2293 } |
| 2298 | 2294 |
| 2299 } // namespace compiler | 2295 } // namespace compiler |
| 2300 } // namespace internal | 2296 } // namespace internal |
| 2301 } // namespace v8 | 2297 } // namespace v8 |
| OLD | NEW |