Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/parsing/parser.cc

Issue 2534393002: Split parsing of functions and top-level code into two separate methods (Closed)
Patch Set: updates Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parsing.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after
3822 FLAG_runtime_stats == 3822 FLAG_runtime_stats ==
3823 v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE) { 3823 v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE) {
3824 // Copy over the counters from the background thread to the main counters on 3824 // Copy over the counters from the background thread to the main counters on
3825 // the isolate. 3825 // the isolate.
3826 // TODO(cbruni,lpy): properly attach the runtime stats to the trace for 3826 // TODO(cbruni,lpy): properly attach the runtime stats to the trace for
3827 // background parsing. 3827 // background parsing.
3828 isolate->counters()->runtime_call_stats()->Add(runtime_call_stats_); 3828 isolate->counters()->runtime_call_stats()->Add(runtime_call_stats_);
3829 } 3829 }
3830 } 3830 }
3831 3831
3832
3833 // ----------------------------------------------------------------------------
3834 // The Parser interface.
3835
3836
3837 bool Parser::ParseStatic(ParseInfo* info) {
3838 Parser parser(info);
3839 if (parser.Parse(info)) {
3840 info->set_language_mode(info->literal()->language_mode());
3841 return true;
3842 }
3843 return false;
3844 }
3845
3846
3847 bool Parser::Parse(ParseInfo* info) {
3848 DCHECK(info->literal() == NULL);
3849 FunctionLiteral* result = NULL;
3850 // Ok to use Isolate here; this function is only called in the main thread.
3851 DCHECK(parsing_on_main_thread_);
3852 Isolate* isolate = info->isolate();
3853
3854 if (info->is_toplevel()) {
3855 SetCachedData(info);
3856 result = ParseProgram(isolate, info);
3857 } else {
3858 result = ParseFunction(isolate, info);
3859 }
3860 info->set_literal(result);
3861
3862 Internalize(isolate, info->script(), result == NULL);
3863 return (result != NULL);
3864 }
3865
3866
3867 void Parser::ParseOnBackground(ParseInfo* info) { 3832 void Parser::ParseOnBackground(ParseInfo* info) {
3868 parsing_on_main_thread_ = false; 3833 parsing_on_main_thread_ = false;
3869 3834
3870 DCHECK(info->literal() == NULL); 3835 DCHECK(info->literal() == NULL);
3871 FunctionLiteral* result = NULL; 3836 FunctionLiteral* result = NULL;
3872 3837
3873 ParserLogger logger; 3838 ParserLogger logger;
3874 if (produce_cached_parse_data()) { 3839 if (produce_cached_parse_data()) {
3875 if (allow_lazy_) { 3840 if (allow_lazy_) {
3876 log_ = &logger; 3841 log_ = &logger;
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5500 5465
5501 return final_loop; 5466 return final_loop;
5502 } 5467 }
5503 5468
5504 #undef CHECK_OK 5469 #undef CHECK_OK
5505 #undef CHECK_OK_VOID 5470 #undef CHECK_OK_VOID
5506 #undef CHECK_FAILED 5471 #undef CHECK_FAILED
5507 5472
5508 } // namespace internal 5473 } // namespace internal
5509 } // namespace v8 5474 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parsing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698