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

Side by Side Diff: src/parsing/parsing.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/parsing.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/parsing/parsing.h"
6
7 #include <memory>
8
9 #include "src/ast/ast.h"
10 #include "src/parsing/parse-info.h"
11 #include "src/parsing/parser.h"
12
13 namespace v8 {
14 namespace internal {
15 namespace parsing {
16
17 bool ParseProgram(ParseInfo* info) {
18 DCHECK(info->is_toplevel());
19 DCHECK_NULL(info->literal());
20
21 Parser parser(info);
22
23 FunctionLiteral* result = nullptr;
24 // Ok to use Isolate here; this function is only called in the main thread.
25 DCHECK(parser.parsing_on_main_thread_);
26 Isolate* isolate = info->isolate();
27
28 parser.SetCachedData(info);
29 result = parser.ParseProgram(isolate, info);
30 info->set_literal(result);
31 parser.Internalize(isolate, info->script(), result == nullptr);
32 if (result != nullptr) {
33 info->set_language_mode(info->literal()->language_mode());
34 }
35 return (result != nullptr);
36 }
37
38 bool ParseFunction(ParseInfo* info) {
39 DCHECK(!info->is_toplevel());
40 DCHECK_NULL(info->literal());
41
42 Parser parser(info);
43
44 FunctionLiteral* result = nullptr;
45 // Ok to use Isolate here; this function is only called in the main thread.
46 DCHECK(parser.parsing_on_main_thread_);
47 Isolate* isolate = info->isolate();
48
49 result = parser.ParseFunction(isolate, info);
50 info->set_literal(result);
51 parser.Internalize(isolate, info->script(), result == nullptr);
52 return (result != nullptr);
53 }
54
55 bool ParseAny(ParseInfo* info) {
56 return info->is_toplevel() ? ParseProgram(info) : ParseFunction(info);
57 }
58
59 } // namespace parsing
60 } // namespace internal
61 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parsing.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698