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

Unified Diff: src/bootstrapper.cc

Issue 1499593003: [runtime] [proxy] Implementing [[Call]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updating comment Created 5 years 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/arm64/builtins-arm64.cc ('k') | src/builtins.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 26857502da6705d59e88a1d81fb8b7e74e3f8686..c7b91e24919b4173553e5ba21b28dd1d758916dc 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -218,6 +218,7 @@ class Genesis BASE_EMBEDDED {
void InstallBuiltinFunctionIds();
void InstallExperimentalBuiltinFunctionIds();
void InitializeNormalizedMapCaches();
+ void InstallJSProxyMaps();
enum ExtensionTraversalState {
UNVISITED, VISITED, INSTALLED
@@ -362,6 +363,20 @@ void Bootstrapper::DetachGlobal(Handle<Context> env) {
namespace {
+Handle<JSFunction> InstallFunction(Handle<JSObject> target,
+ Handle<Name> property_name,
+ Handle<JSFunction> function,
+ Handle<String> function_name,
+ PropertyAttributes attributes = DONT_ENUM) {
+ JSObject::AddProperty(target, property_name, function, attributes);
+ if (target->IsJSGlobalObject()) {
+ function->shared()->set_instance_class_name(*function_name);
+ }
+ function->shared()->set_native(true);
+ return function;
+}
+
+
Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name,
InstanceType type, int instance_size,
MaybeHandle<JSObject> maybe_prototype,
@@ -382,12 +397,7 @@ Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name,
kInstallConstructor, strict_function_map)
: factory->NewFunctionWithoutPrototype(name_string, call_code,
strict_function_map);
- JSObject::AddProperty(target, name, function, attributes);
- if (target->IsJSGlobalObject()) {
- function->shared()->set_instance_class_name(*name_string);
- }
- function->shared()->set_native(true);
- return function;
+ return InstallFunction(target, name, function, name_string, attributes);
}
@@ -2110,21 +2120,58 @@ void Genesis::InitializeGlobal_harmony_simd() {
}
+void Genesis::InstallJSProxyMaps() {
+ // Allocate the different maps for all Proxy types.
+ // Next to the default proxy, we need maps indicating callable and
+ // constructable proxies.
+
+ Handle<Map> proxy_function_map =
+ Map::Copy(isolate()->sloppy_function_without_prototype_map(), "Proxy");
+ proxy_function_map->set_is_constructor(true);
+ native_context()->set_proxy_function_map(*proxy_function_map);
+
+ Handle<Map> proxy_map =
+ factory()->NewMap(JS_PROXY_TYPE, JSProxy::kSize, FAST_ELEMENTS);
+ native_context()->set_proxy_map(*proxy_map);
+
+ Handle<Map> proxy_callable_map = Map::Copy(proxy_map, "callable Proxy");
+ proxy_callable_map->set_is_callable();
+ native_context()->set_proxy_callable_map(*proxy_callable_map);
+
+ Handle<Map> proxy_constructor_map =
+ Map::Copy(proxy_callable_map, "constructor Proxy");
+ proxy_constructor_map->set_is_constructor(true);
+ native_context()->set_proxy_constructor_map(*proxy_constructor_map);
+}
+
+
void Genesis::InitializeGlobal_harmony_proxies() {
if (!FLAG_harmony_proxies) return;
Handle<JSGlobalObject> global(
JSGlobalObject::cast(native_context()->global_object()));
Isolate* isolate = global->GetIsolate();
- Handle<JSFunction> proxy_fun = InstallFunction(
- global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize,
- isolate->initial_object_prototype(), Builtins::kProxyConstructor);
- // TODO(verwaest): Set to null in InstallFunction.
- proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value());
- proxy_fun->shared()->set_construct_stub(
+ Factory* factory = isolate->factory();
+
+ InstallJSProxyMaps();
+
+ // Create the Proxy object.
+ Handle<String> name = factory->Proxy_string();
+ Handle<Code> code(isolate->builtins()->ProxyConstructor());
+
+ Handle<JSFunction> proxy_function =
+ factory->NewFunction(isolate->proxy_function_map(), name, code);
+
+ JSFunction::SetInitialMap(proxy_function,
+ Handle<Map>(native_context()->proxy_map(), isolate),
+ factory->null_value());
+
+ proxy_function->shared()->set_construct_stub(
*isolate->builtins()->ProxyConstructor_ConstructStub());
- proxy_fun->shared()->set_internal_formal_parameter_count(2);
- proxy_fun->shared()->set_length(2);
- native_context()->set_proxy_function(*proxy_fun);
+ proxy_function->shared()->set_internal_formal_parameter_count(2);
+ proxy_function->shared()->set_length(2);
+
+ native_context()->set_proxy_function(*proxy_function);
+ InstallFunction(global, name, proxy_function, name);
}
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698