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

Side by Side Diff: src/parsing/parse-info.cc

Issue 2684033007: Allow a ParseInfo without a script for %SetCode users (Closed)
Patch Set: nit Created 3 years, 10 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
« no previous file with comments | « src/parsing/parse-info.h ('k') | src/source-position.cc » ('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 2016 the V8 project authors. All rights reserved. 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 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/parse-info.h" 5 #include "src/parsing/parse-info.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/heap/heap-inl.h" 10 #include "src/heap/heap-inl.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 ParseInfo::~ParseInfo() { 95 ParseInfo::~ParseInfo() {
96 if (ast_value_factory_owned()) { 96 if (ast_value_factory_owned()) {
97 delete ast_value_factory_; 97 delete ast_value_factory_;
98 set_ast_value_factory_owned(false); 98 set_ast_value_factory_owned(false);
99 } 99 }
100 ast_value_factory_ = nullptr; 100 ast_value_factory_ = nullptr;
101 } 101 }
102 102
103 // static
104 ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) {
105 Isolate* isolate = shared->GetIsolate();
106 ParseInfo* p = new ParseInfo(isolate->allocator());
107 p->isolate_ = isolate;
108
109 p->set_toplevel(shared->is_toplevel());
110 p->set_allow_lazy_parsing(FLAG_lazy_inner_functions);
111 p->set_hash_seed(isolate->heap()->HashSeed());
112 p->set_is_named_expression(shared->is_named_expression());
113 p->set_calls_eval(shared->scope_info()->CallsEval());
114 p->set_compiler_hints(shared->compiler_hints());
115 p->set_start_position(shared->start_position());
116 p->set_end_position(shared->end_position());
117 p->function_literal_id_ = shared->function_literal_id();
118 p->set_stack_limit(isolate->stack_guard()->real_climit());
119 p->set_unicode_cache(isolate->unicode_cache());
120 p->set_language_mode(shared->language_mode());
121 p->set_shared_info(shared);
122 p->set_module(shared->kind() == FunctionKind::kModule);
123
124 // BUG(5946): This function exists as a workaround until we can
125 // get rid of %SetCode in our native functions. The ParseInfo
126 // is explicitly set up for the case that:
127 // a) you have a native built-in,
128 // b) it's being run for the 2nd-Nth time in an isolate,
129 // c) we've already compiled bytecode and therefore don't need
130 // to parse.
131 // We tolerate a ParseInfo without a Script in this case.
132 p->set_native(true);
133 p->set_eval(false);
134
135 Handle<HeapObject> scope_info(shared->outer_scope_info());
136 if (!scope_info->IsTheHole(isolate) &&
137 Handle<ScopeInfo>::cast(scope_info)->length() > 0) {
138 p->set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info));
139 }
140 return p;
141 }
142
103 DeclarationScope* ParseInfo::scope() const { return literal()->scope(); } 143 DeclarationScope* ParseInfo::scope() const { return literal()->scope(); }
104 144
105 bool ParseInfo::is_declaration() const { 145 bool ParseInfo::is_declaration() const {
106 return (compiler_hints_ & (1 << SharedFunctionInfo::kIsDeclaration)) != 0; 146 return (compiler_hints_ & (1 << SharedFunctionInfo::kIsDeclaration)) != 0;
107 } 147 }
108 148
109 FunctionKind ParseInfo::function_kind() const { 149 FunctionKind ParseInfo::function_kind() const {
110 return SharedFunctionInfo::FunctionKindBits::decode(compiler_hints_); 150 return SharedFunctionInfo::FunctionKindBits::decode(compiler_hints_);
111 } 151 }
112 152
113 void ParseInfo::set_deferred_handles( 153 void ParseInfo::set_deferred_handles(
114 std::shared_ptr<DeferredHandles> deferred_handles) { 154 std::shared_ptr<DeferredHandles> deferred_handles) {
115 DCHECK(deferred_handles_.get() == nullptr); 155 DCHECK(deferred_handles_.get() == nullptr);
116 deferred_handles_.swap(deferred_handles); 156 deferred_handles_.swap(deferred_handles);
117 } 157 }
118 158
119 void ParseInfo::set_deferred_handles(DeferredHandles* deferred_handles) { 159 void ParseInfo::set_deferred_handles(DeferredHandles* deferred_handles) {
120 DCHECK(deferred_handles_.get() == nullptr); 160 DCHECK(deferred_handles_.get() == nullptr);
121 deferred_handles_.reset(deferred_handles); 161 deferred_handles_.reset(deferred_handles);
122 } 162 }
123 163
124 #ifdef DEBUG 164 #ifdef DEBUG
125 bool ParseInfo::script_is_native() const { 165 bool ParseInfo::script_is_native() const {
126 return script_->type() == Script::TYPE_NATIVE; 166 return script_->type() == Script::TYPE_NATIVE;
127 } 167 }
128 #endif // DEBUG 168 #endif // DEBUG
129 169
130 } // namespace internal 170 } // namespace internal
131 } // namespace v8 171 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parse-info.h ('k') | src/source-position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698