OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8608 {"function inner() { for (let {x: my_var} of []) { } my_var; }", true}, | 8608 {"function inner() { for (let {x: my_var} of []) { } my_var; }", true}, |
8609 {"function inner() { for (let {my_var} in {}) { } my_var; }", true}, | 8609 {"function inner() { for (let {my_var} in {}) { } my_var; }", true}, |
8610 {"function inner() { for (let {my_var} of []) { } my_var; }", true}, | 8610 {"function inner() { for (let {my_var} of []) { } my_var; }", true}, |
8611 {"function inner() { for (let {y, x: my_var} in {}) { } my_var; }", true}, | 8611 {"function inner() { for (let {y, x: my_var} in {}) { } my_var; }", true}, |
8612 {"function inner() { for (let {y, x: my_var} of []) { } my_var; }", true}, | 8612 {"function inner() { for (let {y, x: my_var} of []) { } my_var; }", true}, |
8613 {"function inner() { for (let {a, my_var} in {}) { } my_var; }", true}, | 8613 {"function inner() { for (let {a, my_var} in {}) { } my_var; }", true}, |
8614 {"function inner() { for (let {a, my_var} of []) { } my_var; }", true}, | 8614 {"function inner() { for (let {a, my_var} of []) { } my_var; }", true}, |
8615 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { } " | 8615 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { } " |
8616 "my_var }", | 8616 "my_var }", |
8617 true}, | 8617 true}, |
| 8618 {"function inner() { 'use strict'; if (true) { function my_var() {} } " |
| 8619 "my_var; }", |
| 8620 true}, |
| 8621 {"function inner() { 'use strict'; function inner2() { if (true) { " |
| 8622 "function my_var() {} } my_var; } }", |
| 8623 true}, |
| 8624 {"function inner() { function inner2() { 'use strict'; if (true) { " |
| 8625 "function my_var() {} } my_var; } }", |
| 8626 true}, |
| 8627 {"function inner() { () => { 'use strict'; if (true) { function my_var() " |
| 8628 "{} } my_var; } }", |
| 8629 true}, |
| 8630 {"function inner() { if (true) { let my_var; if (true) { function " |
| 8631 "my_var() {} } } my_var; }", |
| 8632 true}, |
8618 // No pessimistic context allocation: | 8633 // No pessimistic context allocation: |
8619 {"function inner() { var my_var; my_var; }", false}, | 8634 {"function inner() { var my_var; my_var; }", false}, |
8620 {"function inner() { var my_var; }", false}, | 8635 {"function inner() { var my_var; }", false}, |
8621 {"function inner() { var my_var = 0; }", false}, | 8636 {"function inner() { var my_var = 0; }", false}, |
8622 {"function inner() { if (true) { var my_var; } my_var; }", false}, | 8637 {"function inner() { if (true) { var my_var; } my_var; }", false}, |
8623 {"function inner() { let my_var; my_var; }", false}, | 8638 {"function inner() { let my_var; my_var; }", false}, |
8624 {"function inner() { let my_var; }", false}, | 8639 {"function inner() { let my_var; }", false}, |
8625 {"function inner() { let my_var = 0; }", false}, | 8640 {"function inner() { let my_var = 0; }", false}, |
8626 {"function inner() { const my_var = 0; my_var; }", false}, | 8641 {"function inner() { const my_var = 0; my_var; }", false}, |
8627 {"function inner() { const my_var = 0; }", false}, | 8642 {"function inner() { const my_var = 0; }", false}, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8799 {"function inner() { for (var my_var = 0; my_var < 1; ++my_var) { } " | 8814 {"function inner() { for (var my_var = 0; my_var < 1; ++my_var) { } " |
8800 "my_var }", | 8815 "my_var }", |
8801 false}, | 8816 false}, |
8802 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { " | 8817 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { " |
8803 "my_var } }", | 8818 "my_var } }", |
8804 false}, | 8819 false}, |
8805 {"function inner() { for (var a = 0, my_var = 0; my_var < 1; ++my_var) { " | 8820 {"function inner() { for (var a = 0, my_var = 0; my_var < 1; ++my_var) { " |
8806 "my_var } }", | 8821 "my_var } }", |
8807 false}, | 8822 false}, |
8808 {"function inner() { class my_var {}; my_var }", false}, | 8823 {"function inner() { class my_var {}; my_var }", false}, |
8809 // In the following cases we still context allocate pessimistically: | 8824 {"function inner() { function my_var() {} my_var; }", false}, |
8810 {"function inner() { function my_var() {} my_var; }", true}, | |
8811 {"function inner() { if (true) { function my_var() {} } my_var; }", | 8825 {"function inner() { if (true) { function my_var() {} } my_var; }", |
8812 true}, | 8826 false}, |
| 8827 {"function inner() { function inner2() { if (true) { function my_var() " |
| 8828 "{} } my_var; } }", |
| 8829 false}, |
| 8830 {"function inner() { () => { if (true) { function my_var() {} } my_var; " |
| 8831 "} }", |
| 8832 false}, |
| 8833 {"function inner() { if (true) { var my_var; if (true) { function " |
| 8834 "my_var() {} } } my_var; }", |
| 8835 false}, |
8813 }; | 8836 }; |
8814 | 8837 |
8815 for (unsigned i = 0; i < arraysize(inners); ++i) { | 8838 for (unsigned i = 0; i < arraysize(inners); ++i) { |
8816 const char* inner = inners[i].source; | 8839 const char* inner = inners[i].source; |
8817 int inner_len = Utf8LengthHelper(inner); | 8840 int inner_len = Utf8LengthHelper(inner); |
8818 int len = prefix_len + inner_len + suffix_len; | 8841 int len = prefix_len + inner_len + suffix_len; |
8819 i::ScopedVector<char> program(len + 1); | 8842 i::ScopedVector<char> program(len + 1); |
8820 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); | 8843 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); |
8821 i::Handle<i::String> source = | 8844 i::Handle<i::String> source = |
8822 factory->InternalizeUtf8String(program.start()); | 8845 factory->InternalizeUtf8String(program.start()); |
(...skipping 12 matching lines...) Expand all Loading... |
8835 DCHECK_NOT_NULL(scope); | 8858 DCHECK_NOT_NULL(scope); |
8836 DCHECK_NULL(scope->sibling()); | 8859 DCHECK_NULL(scope->sibling()); |
8837 DCHECK(scope->is_function_scope()); | 8860 DCHECK(scope->is_function_scope()); |
8838 const i::AstRawString* var_name = | 8861 const i::AstRawString* var_name = |
8839 info.ast_value_factory()->GetOneByteString("my_var"); | 8862 info.ast_value_factory()->GetOneByteString("my_var"); |
8840 i::Variable* var = scope->Lookup(var_name); | 8863 i::Variable* var = scope->Lookup(var_name); |
8841 CHECK_EQ(inners[i].ctxt_allocate, | 8864 CHECK_EQ(inners[i].ctxt_allocate, |
8842 i::ScopeTestHelper::MustAllocateInContext(var)); | 8865 i::ScopeTestHelper::MustAllocateInContext(var)); |
8843 } | 8866 } |
8844 } | 8867 } |
OLD | NEW |