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

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: 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
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 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 3832
3833 // ---------------------------------------------------------------------------- 3833 // ----------------------------------------------------------------------------
marja 2016/11/30 11:30:29 This comment is now obsolete & doesn't belong here
3834 // The Parser interface. 3834 // The Parser interface.
3835 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()) {
marja 2016/11/30 11:30:29 Could you add DCHECKs into the relevant parse func
jochen (gone - plz use gerrit) 2016/11/30 11:49:58 those DCHECKs are already in place
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) { 3836 void Parser::ParseOnBackground(ParseInfo* info) {
3868 parsing_on_main_thread_ = false; 3837 parsing_on_main_thread_ = false;
3869 3838
3870 DCHECK(info->literal() == NULL); 3839 DCHECK(info->literal() == NULL);
3871 FunctionLiteral* result = NULL; 3840 FunctionLiteral* result = NULL;
3872 3841
3873 ParserLogger logger; 3842 ParserLogger logger;
3874 if (produce_cached_parse_data()) { 3843 if (produce_cached_parse_data()) {
3875 if (allow_lazy_) { 3844 if (allow_lazy_) {
3876 log_ = &logger; 3845 log_ = &logger;
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5500 5469
5501 return final_loop; 5470 return final_loop;
5502 } 5471 }
5503 5472
5504 #undef CHECK_OK 5473 #undef CHECK_OK
5505 #undef CHECK_OK_VOID 5474 #undef CHECK_OK_VOID
5506 #undef CHECK_FAILED 5475 #undef CHECK_FAILED
5507 5476
5508 } // namespace internal 5477 } // namespace internal
5509 } // namespace v8 5478 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parsing.h » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698