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

Unified Diff: src/api-natives.cc

Issue 2162443002: Add API to create a "remote" instance of a given FunctionTemplate (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
« no previous file with comments | « src/api-natives.h ('k') | src/counters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api-natives.cc
diff --git a/src/api-natives.cc b/src/api-natives.cc
index 6e7afc31412c0bc1c2d3b732889c75bd95f94d24..cd9f0ddd5d239887c9f5f94b6059d4e86dcbe2dd 100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -486,6 +486,35 @@ MaybeHandle<JSObject> ApiNatives::InstantiateObject(
return ::v8::internal::InstantiateObject(isolate, data, new_target, false);
}
+MaybeHandle<JSObject> ApiNatives::InstantiateRemoteObject(
+ Handle<ObjectTemplateInfo> data) {
+ Isolate* isolate = data->GetIsolate();
+ InvokeScope invoke_scope(isolate);
+
+ Handle<FunctionTemplateInfo> constructor(
+ FunctionTemplateInfo::cast(data->constructor()));
+ Handle<SharedFunctionInfo> shared =
+ FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(isolate, constructor);
+ Handle<Map> initial_map = isolate->factory()->CreateSloppyFunctionMap(
+ FUNCTION_WITH_WRITEABLE_PROTOTYPE);
+ Handle<JSFunction> object_function =
+ isolate->factory()->NewFunctionFromSharedFunctionInfo(
+ initial_map, shared, isolate->factory()->undefined_value());
+ Handle<Map> object_map = isolate->factory()->NewMap(
+ JS_SPECIAL_API_OBJECT_TYPE,
+ JSObject::kHeaderSize + data->internal_field_count() * kPointerSize,
+ FAST_HOLEY_SMI_ELEMENTS);
+ JSFunction::SetInitialMap(object_function, object_map,
+ isolate->factory()->null_value());
+ object_map->set_is_access_check_needed(true);
+ object_map->set_is_callable();
+ object_map->set_is_constructor(true);
+
+ Handle<JSObject> object = isolate->factory()->NewJSObject(object_function);
+ JSObject::ForceSetPrototype(object, isolate->factory()->null_value());
+
+ return object;
+}
void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
Handle<Name> name, Handle<Object> value,
« no previous file with comments | « src/api-natives.h ('k') | src/counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698