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

Unified Diff: src/factory.cc

Issue 2107673003: Add an API to create a detached global object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 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
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 85a974a5a3f24548148a4ebb40b670db7fa3c139..4140159f9312ffb8ce5c83fa4a536997c99fd8cf 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1217,19 +1217,20 @@ DEFINE_ERROR(SyntaxError, syntax_error)
DEFINE_ERROR(TypeError, type_error)
#undef DEFINE_ERROR
-
Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<SharedFunctionInfo> info,
- Handle<Context> context,
+ Handle<Object> context_or_undefined,
PretenureFlag pretenure) {
AllocationSpace space = pretenure == TENURED ? OLD_SPACE : NEW_SPACE;
Handle<JSFunction> function = New<JSFunction>(map, space);
+ DCHECK(context_or_undefined->IsContext() ||
+ context_or_undefined->IsUndefined(isolate()));
function->initialize_properties();
function->initialize_elements();
function->set_shared(*info);
function->set_code(info->code());
- function->set_context(*context);
+ function->set_context(*context_or_undefined);
function->set_prototype_or_initial_map(*the_hole_value());
function->set_literals(LiteralsArray::cast(*empty_literals_array()));
function->set_next_function_link(*undefined_value(), SKIP_WRITE_BARRIER);
@@ -1362,20 +1363,21 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
pretenure);
}
-
Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
- Handle<Context> context, PretenureFlag pretenure) {
+ Handle<Object> context_or_undefined, PretenureFlag pretenure) {
DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type());
Handle<JSFunction> result =
- NewFunction(initial_map, info, context, pretenure);
+ NewFunction(initial_map, info, context_or_undefined, pretenure);
if (info->ic_age() != isolate()->heap()->global_ic_age()) {
info->ResetForNewContext(isolate()->heap()->global_ic_age());
}
- // Give compiler a chance to pre-initialize.
- Compiler::PostInstantiation(result, pretenure);
+ if (context_or_undefined->IsContext()) {
+ // Give compiler a chance to pre-initialize.
+ Compiler::PostInstantiation(result, pretenure);
+ }
return result;
}
« include/v8.h ('K') | « src/factory.h ('k') | test/cctest/test-access-checks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698