OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4029 // })(); | 4029 // })(); |
4030 | 4030 |
4031 // Now foo will be parsed eagerly and compiled eagerly (optimization: assume | 4031 // Now foo will be parsed eagerly and compiled eagerly (optimization: assume |
4032 // parenthesis before the function means that it will be called | 4032 // parenthesis before the function means that it will be called |
4033 // immediately). The inner function *must* be parsed eagerly to resolve the | 4033 // immediately). The inner function *must* be parsed eagerly to resolve the |
4034 // possible reference to the variable in foo's scope. However, it's possible | 4034 // possible reference to the variable in foo's scope. However, it's possible |
4035 // that it will be compiled lazily. | 4035 // that it will be compiled lazily. |
4036 | 4036 |
4037 // To make this additional case work, both Parser and PreParser implement a | 4037 // To make this additional case work, both Parser and PreParser implement a |
4038 // logic where only top-level functions will be parsed lazily. | 4038 // logic where only top-level functions will be parsed lazily. |
4039 bool is_lazily_parsed = (mode() == PARSE_LAZILY && | 4039 bool is_lazily_parsed = mode() == PARSE_LAZILY && |
4040 scope_->AllowsLazyCompilation() && | 4040 scope_->AllowsLazyParsing() && |
4041 !parenthesized_function_); | 4041 !parenthesized_function_; |
4042 parenthesized_function_ = false; // The bit was set for this function only. | 4042 parenthesized_function_ = false; // The bit was set for this function only. |
4043 | 4043 |
4044 // Eager or lazy parse? | 4044 // Eager or lazy parse? |
4045 // If is_lazily_parsed, we'll parse lazy. If we can set a bookmark, we'll | 4045 // If is_lazily_parsed, we'll parse lazy. If we can set a bookmark, we'll |
4046 // pass it to SkipLazyFunctionBody, which may use it to abort lazy | 4046 // pass it to SkipLazyFunctionBody, which may use it to abort lazy |
4047 // parsing if it suspect that wasn't a good idea. If so, or if we didn't | 4047 // parsing if it suspect that wasn't a good idea. If so, or if we didn't |
4048 // try to lazy parse in the first place, we'll have to parse eagerly. | 4048 // try to lazy parse in the first place, we'll have to parse eagerly. |
4049 Scanner::BookmarkScope bookmark(scanner()); | 4049 Scanner::BookmarkScope bookmark(scanner()); |
4050 if (is_lazily_parsed) { | 4050 if (is_lazily_parsed) { |
4051 for (Scope* s = scope_->outer_scope(); | |
4052 s != nullptr && (s != s->DeclarationScope()); s = s->outer_scope()) { | |
4053 s->ForceContextAllocation(); | |
4054 } | |
4055 | |
4056 Scanner::BookmarkScope* maybe_bookmark = | 4051 Scanner::BookmarkScope* maybe_bookmark = |
4057 bookmark.Set() ? &bookmark : nullptr; | 4052 bookmark.Set() ? &bookmark : nullptr; |
4058 SkipLazyFunctionBody(&materialized_literal_count, | 4053 SkipLazyFunctionBody(&materialized_literal_count, |
4059 &expected_property_count, /*CHECK_OK*/ ok, | 4054 &expected_property_count, /*CHECK_OK*/ ok, |
4060 maybe_bookmark); | 4055 maybe_bookmark); |
4061 | 4056 |
4062 if (bookmark.HasBeenReset()) { | 4057 if (bookmark.HasBeenReset()) { |
4063 // Trigger eager (re-)parsing, just below this block. | 4058 // Trigger eager (re-)parsing, just below this block. |
4064 is_lazily_parsed = false; | 4059 is_lazily_parsed = false; |
4065 | 4060 |
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5909 Expression* Parser::SpreadCallNew(Expression* function, | 5904 Expression* Parser::SpreadCallNew(Expression* function, |
5910 ZoneList<v8::internal::Expression*>* args, | 5905 ZoneList<v8::internal::Expression*>* args, |
5911 int pos) { | 5906 int pos) { |
5912 args->InsertAt(0, function, zone()); | 5907 args->InsertAt(0, function, zone()); |
5913 | 5908 |
5914 return factory()->NewCallRuntime( | 5909 return factory()->NewCallRuntime( |
5915 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5910 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5916 } | 5911 } |
5917 } // namespace internal | 5912 } // namespace internal |
5918 } // namespace v8 | 5913 } // namespace v8 |
OLD | NEW |