| 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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
| (...skipping 3808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3819 | 3819 |
| 3820 | 3820 |
| 3821 bool Parser::Parse(ParseInfo* info) { | 3821 bool Parser::Parse(ParseInfo* info) { |
| 3822 DCHECK(info->literal() == NULL); | 3822 DCHECK(info->literal() == NULL); |
| 3823 FunctionLiteral* result = NULL; | 3823 FunctionLiteral* result = NULL; |
| 3824 // Ok to use Isolate here; this function is only called in the main thread. | 3824 // Ok to use Isolate here; this function is only called in the main thread. |
| 3825 DCHECK(parsing_on_main_thread_); | 3825 DCHECK(parsing_on_main_thread_); |
| 3826 Isolate* isolate = info->isolate(); | 3826 Isolate* isolate = info->isolate(); |
| 3827 pre_parse_timer_ = isolate->counters()->pre_parse(); | 3827 pre_parse_timer_ = isolate->counters()->pre_parse(); |
| 3828 | 3828 |
| 3829 if (info->is_lazy()) { | 3829 if (!info->shared_info().is_null() && info->shared_info()->is_function()) { |
| 3830 DCHECK(!info->is_eval()); | 3830 DCHECK(!info->is_eval()); |
| 3831 if (info->shared_info()->is_function()) { | 3831 result = ParseLazy(isolate, info); |
| 3832 result = ParseLazy(isolate, info); | |
| 3833 } else { | |
| 3834 result = ParseProgram(isolate, info); | |
| 3835 } | |
| 3836 } else { | 3832 } else { |
| 3837 SetCachedData(info); | 3833 SetCachedData(info); |
| 3838 result = ParseProgram(isolate, info); | 3834 result = ParseProgram(isolate, info); |
| 3839 } | 3835 } |
| 3840 info->set_literal(result); | 3836 info->set_literal(result); |
| 3841 | 3837 |
| 3842 Internalize(isolate, info->script(), result == NULL); | 3838 Internalize(isolate, info->script(), result == NULL); |
| 3843 return (result != NULL); | 3839 return (result != NULL); |
| 3844 } | 3840 } |
| 3845 | 3841 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3867 DCHECK(info->maybe_outer_scope_info().is_null()); | 3863 DCHECK(info->maybe_outer_scope_info().is_null()); |
| 3868 | 3864 |
| 3869 DCHECK(original_scope_); | 3865 DCHECK(original_scope_); |
| 3870 | 3866 |
| 3871 // When streaming, we don't know the length of the source until we have parsed | 3867 // When streaming, we don't know the length of the source until we have parsed |
| 3872 // it. The raw data can be UTF-8, so we wouldn't know the source length until | 3868 // it. The raw data can be UTF-8, so we wouldn't know the source length until |
| 3873 // we have decoded it anyway even if we knew the raw data length (which we | 3869 // we have decoded it anyway even if we knew the raw data length (which we |
| 3874 // don't). We work around this by storing all the scopes which need their end | 3870 // don't). We work around this by storing all the scopes which need their end |
| 3875 // position set at the end of the script (the top scope and possible eval | 3871 // position set at the end of the script (the top scope and possible eval |
| 3876 // scopes) and set their end position after we know the script length. | 3872 // scopes) and set their end position after we know the script length. |
| 3877 if (info->is_lazy()) { | 3873 if (info->is_toplevel()) { |
| 3878 result = DoParseLazy(info, info->function_name(), stream_ptr); | |
| 3879 } else { | |
| 3880 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); | 3874 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); |
| 3881 scanner_.Initialize(stream_ptr); | 3875 scanner_.Initialize(stream_ptr); |
| 3882 result = DoParseProgram(info); | 3876 result = DoParseProgram(info); |
| 3877 } else { |
| 3878 result = DoParseLazy(info, info->function_name(), stream_ptr); |
| 3883 } | 3879 } |
| 3884 | 3880 |
| 3885 info->set_literal(result); | 3881 info->set_literal(result); |
| 3886 | 3882 |
| 3887 // We cannot internalize on a background thread; a foreground task will take | 3883 // We cannot internalize on a background thread; a foreground task will take |
| 3888 // care of calling Parser::Internalize just before compilation. | 3884 // care of calling Parser::Internalize just before compilation. |
| 3889 | 3885 |
| 3890 if (produce_cached_parse_data()) { | 3886 if (produce_cached_parse_data()) { |
| 3891 if (result != NULL) *info->cached_data() = recorder.GetScriptData(); | 3887 if (result != NULL) *info->cached_data() = recorder.GetScriptData(); |
| 3892 log_ = NULL; | 3888 log_ = NULL; |
| (...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5462 | 5458 |
| 5463 return final_loop; | 5459 return final_loop; |
| 5464 } | 5460 } |
| 5465 | 5461 |
| 5466 #undef CHECK_OK | 5462 #undef CHECK_OK |
| 5467 #undef CHECK_OK_VOID | 5463 #undef CHECK_OK_VOID |
| 5468 #undef CHECK_FAILED | 5464 #undef CHECK_FAILED |
| 5469 | 5465 |
| 5470 } // namespace internal | 5466 } // namespace internal |
| 5471 } // namespace v8 | 5467 } // namespace v8 |
| OLD | NEW |