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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1824 // We need to load the variable into the accumulator, even when in a | 1824 // We need to load the variable into the accumulator, even when in a |
1825 // VisitForRegisterScope, in order to avoid register aliasing if | 1825 // VisitForRegisterScope, in order to avoid register aliasing if |
1826 // subsequent expressions assign to the same variable. | 1826 // subsequent expressions assign to the same variable. |
1827 builder()->LoadAccumulatorWithRegister(source); | 1827 builder()->LoadAccumulatorWithRegister(source); |
1828 if (hole_check_mode == HoleCheckMode::kRequired) { | 1828 if (hole_check_mode == HoleCheckMode::kRequired) { |
1829 BuildThrowIfHole(variable->name()); | 1829 BuildThrowIfHole(variable->name()); |
1830 } | 1830 } |
1831 break; | 1831 break; |
1832 } | 1832 } |
1833 case VariableLocation::UNALLOCATED: { | 1833 case VariableLocation::UNALLOCATED: { |
1834 builder()->LoadGlobal(variable->name(), feedback_index(slot), | 1834 // The global identifier "undefined" is immutable. Everything |
1835 typeof_mode); | 1835 // else could be reassigned. |
1836 if (variable->raw_name()->IsOneByteEqualTo("undefined")) { | |
mythria
2016/12/05 17:48:12
I took this logic from here: https://cs.chromium.o
rmcilroy
2016/12/05 19:08:09
It's possibly slow to check IsOneByteEqualTo each
mythria
2016/12/06 10:13:27
Nice one. Done.
| |
1837 builder()->LoadUndefined(); | |
1838 } else { | |
1839 builder()->LoadGlobal(variable->name(), feedback_index(slot), | |
1840 typeof_mode); | |
1841 } | |
1836 break; | 1842 break; |
1837 } | 1843 } |
1838 case VariableLocation::CONTEXT: { | 1844 case VariableLocation::CONTEXT: { |
1839 int depth = execution_context()->ContextChainDepth(variable->scope()); | 1845 int depth = execution_context()->ContextChainDepth(variable->scope()); |
1840 ContextScope* context = execution_context()->Previous(depth); | 1846 ContextScope* context = execution_context()->Previous(depth); |
1841 Register context_reg; | 1847 Register context_reg; |
1842 if (context) { | 1848 if (context) { |
1843 context_reg = context->reg(); | 1849 context_reg = context->reg(); |
1844 depth = 0; | 1850 depth = 0; |
1845 } else { | 1851 } else { |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3198 } | 3204 } |
3199 | 3205 |
3200 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3206 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3201 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3207 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3202 : Runtime::kStoreKeyedToSuper_Sloppy; | 3208 : Runtime::kStoreKeyedToSuper_Sloppy; |
3203 } | 3209 } |
3204 | 3210 |
3205 } // namespace interpreter | 3211 } // namespace interpreter |
3206 } // namespace internal | 3212 } // namespace internal |
3207 } // namespace v8 | 3213 } // namespace v8 |
OLD | NEW |