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

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

Issue 2268513002: Cleanup: Move ParseInfo to a separate file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months 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.h"
11 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
12 #include "src/ast/ast-literal-reindexer.h" 11 #include "src/ast/ast-literal-reindexer.h"
13 #include "src/ast/ast-traversal-visitor.h" 12 #include "src/ast/ast-traversal-visitor.h"
13 #include "src/ast/ast.h"
14 #include "src/bailout-reason.h" 14 #include "src/bailout-reason.h"
15 #include "src/base/platform/platform.h" 15 #include "src/base/platform/platform.h"
16 #include "src/bootstrapper.h"
17 #include "src/char-predicates-inl.h" 16 #include "src/char-predicates-inl.h"
18 #include "src/codegen.h"
19 #include "src/compiler.h"
20 #include "src/messages.h" 17 #include "src/messages.h"
21 #include "src/parsing/parameter-initializer-rewriter.h" 18 #include "src/parsing/parameter-initializer-rewriter.h"
22 #include "src/parsing/parser-base.h" 19 #include "src/parsing/parse-info.h"
23 #include "src/parsing/rewriter.h" 20 #include "src/parsing/rewriter.h"
24 #include "src/parsing/scanner-character-streams.h" 21 #include "src/parsing/scanner-character-streams.h"
25 #include "src/runtime/runtime.h" 22 #include "src/runtime/runtime.h"
26 #include "src/string-stream.h" 23 #include "src/string-stream.h"
27 #include "src/tracing/trace-event.h" 24 #include "src/tracing/trace-event.h"
28 25
29 namespace v8 { 26 namespace v8 {
30 namespace internal { 27 namespace internal {
31 28
32 ScriptData::ScriptData(const byte* data, int length) 29 ScriptData::ScriptData(const byte* data, int length)
33 : owns_data_(false), rejected_(false), data_(data), length_(length) { 30 : owns_data_(false), rejected_(false), data_(data), length_(length) {
34 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) { 31 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) {
35 byte* copy = NewArray<byte>(length); 32 byte* copy = NewArray<byte>(length);
36 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment)); 33 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment));
37 CopyBytes(copy, data, length); 34 CopyBytes(copy, data, length);
38 data_ = copy; 35 data_ = copy;
39 AcquireDataOwnership(); 36 AcquireDataOwnership();
40 } 37 }
41 } 38 }
42 39
43 ParseInfo::ParseInfo(Zone* zone)
44 : zone_(zone),
45 flags_(0),
46 source_stream_(nullptr),
47 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE),
48 character_stream_(nullptr),
49 extension_(nullptr),
50 compile_options_(ScriptCompiler::kNoCompileOptions),
51 script_scope_(nullptr),
52 unicode_cache_(nullptr),
53 stack_limit_(0),
54 hash_seed_(0),
55 compiler_hints_(0),
56 start_position_(0),
57 end_position_(0),
58 isolate_(nullptr),
59 cached_data_(nullptr),
60 ast_value_factory_(nullptr),
61 function_name_(nullptr),
62 literal_(nullptr) {}
63
64 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function)
65 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {
66 set_context(Handle<Context>(function->context()));
67 }
68
69
70 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
71 : ParseInfo(zone) {
72 isolate_ = shared->GetIsolate();
73
74 set_lazy();
75 set_hash_seed(isolate_->heap()->HashSeed());
76 set_is_named_expression(shared->is_named_expression());
77 set_calls_eval(shared->scope_info()->CallsEval());
78 set_compiler_hints(shared->compiler_hints());
79 set_start_position(shared->start_position());
80 set_end_position(shared->end_position());
81 set_stack_limit(isolate_->stack_guard()->real_climit());
82 set_unicode_cache(isolate_->unicode_cache());
83 set_language_mode(shared->language_mode());
84 set_shared_info(shared);
85
86 Handle<Script> script(Script::cast(shared->script()));
87 set_script(script);
88 if (!script.is_null() && script->type() == Script::TYPE_NATIVE) {
89 set_native();
90 }
91 }
92
93
94 ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) {
95 isolate_ = script->GetIsolate();
96
97 set_hash_seed(isolate_->heap()->HashSeed());
98 set_stack_limit(isolate_->stack_guard()->real_climit());
99 set_unicode_cache(isolate_->unicode_cache());
100 set_script(script);
101
102 if (script->type() == Script::TYPE_NATIVE) {
103 set_native();
104 }
105 }
106
107 bool ParseInfo::is_declaration() const {
108 return (compiler_hints_ & (1 << SharedFunctionInfo::kIsDeclaration)) != 0;
109 }
110
111 bool ParseInfo::is_arrow() const {
112 return (compiler_hints_ & (1 << SharedFunctionInfo::kIsArrow)) != 0;
113 }
114
115 bool ParseInfo::is_async() const {
116 return (compiler_hints_ & (1 << SharedFunctionInfo::kIsAsyncFunction)) != 0;
117 }
118
119 bool ParseInfo::is_default_constructor() const {
120 return (compiler_hints_ & (1 << SharedFunctionInfo::kIsDefaultConstructor)) !=
121 0;
122 }
123
124 FunctionKind ParseInfo::function_kind() const {
125 return SharedFunctionInfo::FunctionKindBits::decode(compiler_hints_);
126 }
127
128 FunctionEntry ParseData::GetFunctionEntry(int start) { 40 FunctionEntry ParseData::GetFunctionEntry(int start) {
129 // The current pre-data entry must be a FunctionEntry with the given 41 // The current pre-data entry must be a FunctionEntry with the given
130 // start position. 42 // start position.
131 if ((function_index_ + FunctionEntry::kSize <= Length()) && 43 if ((function_index_ + FunctionEntry::kSize <= Length()) &&
132 (static_cast<int>(Data()[function_index_]) == start)) { 44 (static_cast<int>(Data()[function_index_]) == start)) {
133 int index = function_index_; 45 int index = function_index_;
134 function_index_ += FunctionEntry::kSize; 46 function_index_ += FunctionEntry::kSize;
135 Vector<unsigned> subvector(&(Data()[index]), FunctionEntry::kSize); 47 Vector<unsigned> subvector(&(Data()[index]), FunctionEntry::kSize);
136 return FunctionEntry(subvector); 48 return FunctionEntry(subvector);
137 } 49 }
(...skipping 6884 matching lines...) Expand 10 before | Expand all | Expand 10 after
7022 node->Print(Isolate::Current()); 6934 node->Print(Isolate::Current());
7023 } 6935 }
7024 #endif // DEBUG 6936 #endif // DEBUG
7025 6937
7026 #undef CHECK_OK 6938 #undef CHECK_OK
7027 #undef CHECK_OK_VOID 6939 #undef CHECK_OK_VOID
7028 #undef CHECK_FAILED 6940 #undef CHECK_FAILED
7029 6941
7030 } // namespace internal 6942 } // namespace internal
7031 } // namespace v8 6943 } // namespace v8
OLDNEW
« src/parsing/parse-info.cc ('K') | « src/parsing/parser.h ('k') | src/parsing/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698