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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parse-info.h ('k') | src/source-position.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parse-info.cc
diff --git a/src/parsing/parse-info.cc b/src/parsing/parse-info.cc
index d3cf86dbdff8050e527230cdb079d538950e847e..535021ee93d06c292c76cfd07bf0876fffd6fe77 100644
--- a/src/parsing/parse-info.cc
+++ b/src/parsing/parse-info.cc
@@ -100,6 +100,46 @@ ParseInfo::~ParseInfo() {
ast_value_factory_ = nullptr;
}
+// static
+ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) {
+ Isolate* isolate = shared->GetIsolate();
+ ParseInfo* p = new ParseInfo(isolate->allocator());
+ p->isolate_ = isolate;
+
+ p->set_toplevel(shared->is_toplevel());
+ p->set_allow_lazy_parsing(FLAG_lazy_inner_functions);
+ p->set_hash_seed(isolate->heap()->HashSeed());
+ p->set_is_named_expression(shared->is_named_expression());
+ p->set_calls_eval(shared->scope_info()->CallsEval());
+ p->set_compiler_hints(shared->compiler_hints());
+ p->set_start_position(shared->start_position());
+ p->set_end_position(shared->end_position());
+ p->function_literal_id_ = shared->function_literal_id();
+ p->set_stack_limit(isolate->stack_guard()->real_climit());
+ p->set_unicode_cache(isolate->unicode_cache());
+ p->set_language_mode(shared->language_mode());
+ p->set_shared_info(shared);
+ p->set_module(shared->kind() == FunctionKind::kModule);
+
+ // BUG(5946): This function exists as a workaround until we can
+ // get rid of %SetCode in our native functions. The ParseInfo
+ // is explicitly set up for the case that:
+ // a) you have a native built-in,
+ // b) it's being run for the 2nd-Nth time in an isolate,
+ // c) we've already compiled bytecode and therefore don't need
+ // to parse.
+ // We tolerate a ParseInfo without a Script in this case.
+ p->set_native(true);
+ p->set_eval(false);
+
+ Handle<HeapObject> scope_info(shared->outer_scope_info());
+ if (!scope_info->IsTheHole(isolate) &&
+ Handle<ScopeInfo>::cast(scope_info)->length() > 0) {
+ p->set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info));
+ }
+ return p;
+}
+
DeclarationScope* ParseInfo::scope() const { return literal()->scope(); }
bool ParseInfo::is_declaration() const {
« 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