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

Side by Side Diff: src/bootstrapper.cc

Issue 1499593003: [runtime] [proxy] Implementing [[Call]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding dcheck 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 void InstallTypedArray(const char* name, ElementsKind elements_kind, 212 void InstallTypedArray(const char* name, ElementsKind elements_kind,
213 Handle<JSFunction>* fun); 213 Handle<JSFunction>* fun);
214 bool InstallExperimentalNatives(); 214 bool InstallExperimentalNatives();
215 bool InstallExtraNatives(); 215 bool InstallExtraNatives();
216 bool InstallExperimentalExtraNatives(); 216 bool InstallExperimentalExtraNatives();
217 bool InstallDebuggerNatives(); 217 bool InstallDebuggerNatives();
218 void InstallBuiltinFunctionIds(); 218 void InstallBuiltinFunctionIds();
219 void InstallExperimentalBuiltinFunctionIds(); 219 void InstallExperimentalBuiltinFunctionIds();
220 void InitializeNormalizedMapCaches(); 220 void InitializeNormalizedMapCaches();
221 void InstallJSProxyMaps();
221 222
222 enum ExtensionTraversalState { 223 enum ExtensionTraversalState {
223 UNVISITED, VISITED, INSTALLED 224 UNVISITED, VISITED, INSTALLED
224 }; 225 };
225 226
226 class ExtensionStates { 227 class ExtensionStates {
227 public: 228 public:
228 ExtensionStates(); 229 ExtensionStates();
229 ExtensionTraversalState get_state(RegisteredExtension* extension); 230 ExtensionTraversalState get_state(RegisteredExtension* extension);
230 void set_state(RegisteredExtension* extension, 231 void set_state(RegisteredExtension* extension,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 SetObjectPrototype(global_proxy, factory->null_value()); 356 SetObjectPrototype(global_proxy, factory->null_value());
356 global_proxy->map()->SetConstructor(*factory->null_value()); 357 global_proxy->map()->SetConstructor(*factory->null_value());
357 if (FLAG_track_detached_contexts) { 358 if (FLAG_track_detached_contexts) {
358 env->GetIsolate()->AddDetachedContext(env); 359 env->GetIsolate()->AddDetachedContext(env);
359 } 360 }
360 } 361 }
361 362
362 363
363 namespace { 364 namespace {
364 365
366 Handle<JSFunction> InstallFunction(Handle<JSObject> target,
367 Handle<Name> property_name,
368 Handle<JSFunction> function,
369 Handle<String> function_name,
370 PropertyAttributes attributes = DONT_ENUM) {
371 JSObject::AddProperty(target, property_name, function, attributes);
372 if (target->IsJSGlobalObject()) {
373 function->shared()->set_instance_class_name(*function_name);
374 }
375 function->shared()->set_native(true);
376 return function;
377 }
378
379
365 Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name, 380 Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name,
366 InstanceType type, int instance_size, 381 InstanceType type, int instance_size,
367 MaybeHandle<JSObject> maybe_prototype, 382 MaybeHandle<JSObject> maybe_prototype,
368 Builtins::Name call, 383 Builtins::Name call,
369 PropertyAttributes attributes, 384 PropertyAttributes attributes,
370 bool strict_function_map = false) { 385 bool strict_function_map = false) {
371 Isolate* isolate = target->GetIsolate(); 386 Isolate* isolate = target->GetIsolate();
372 Factory* factory = isolate->factory(); 387 Factory* factory = isolate->factory();
373 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked(); 388 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked();
374 Handle<Code> call_code(isolate->builtins()->builtin(call)); 389 Handle<Code> call_code(isolate->builtins()->builtin(call));
375 Handle<JSObject> prototype; 390 Handle<JSObject> prototype;
376 static const bool kReadOnlyPrototype = false; 391 static const bool kReadOnlyPrototype = false;
377 static const bool kInstallConstructor = false; 392 static const bool kInstallConstructor = false;
378 Handle<JSFunction> function = 393 Handle<JSFunction> function =
379 maybe_prototype.ToHandle(&prototype) 394 maybe_prototype.ToHandle(&prototype)
380 ? factory->NewFunction(name_string, call_code, prototype, type, 395 ? factory->NewFunction(name_string, call_code, prototype, type,
381 instance_size, kReadOnlyPrototype, 396 instance_size, kReadOnlyPrototype,
382 kInstallConstructor, strict_function_map) 397 kInstallConstructor, strict_function_map)
383 : factory->NewFunctionWithoutPrototype(name_string, call_code, 398 : factory->NewFunctionWithoutPrototype(name_string, call_code,
384 strict_function_map); 399 strict_function_map);
385 JSObject::AddProperty(target, name, function, attributes); 400 return InstallFunction(target, name, function, name_string, attributes);
386 if (target->IsJSGlobalObject()) {
387 function->shared()->set_instance_class_name(*name_string);
388 }
389 function->shared()->set_native(true);
390 return function;
391 } 401 }
392 402
393 403
394 Handle<JSFunction> InstallFunction(Handle<JSObject> target, const char* name, 404 Handle<JSFunction> InstallFunction(Handle<JSObject> target, const char* name,
395 InstanceType type, int instance_size, 405 InstanceType type, int instance_size,
396 MaybeHandle<JSObject> maybe_prototype, 406 MaybeHandle<JSObject> maybe_prototype,
397 Builtins::Name call, 407 Builtins::Name call,
398 bool strict_function_map = false) { 408 bool strict_function_map = false) {
399 Factory* const factory = target->GetIsolate()->factory(); 409 Factory* const factory = target->GetIsolate()->factory();
400 PropertyAttributes attributes = DONT_ENUM; 410 PropertyAttributes attributes = DONT_ENUM;
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 Handle<JSFunction> type##_function = InstallFunction( \ 2113 Handle<JSFunction> type##_function = InstallFunction( \
2104 simd_object, #Type, JS_VALUE_TYPE, JSValue::kSize, \ 2114 simd_object, #Type, JS_VALUE_TYPE, JSValue::kSize, \
2105 isolate->initial_object_prototype(), Builtins::kIllegal); \ 2115 isolate->initial_object_prototype(), Builtins::kIllegal); \
2106 native_context()->set_##type##_function(*type##_function); \ 2116 native_context()->set_##type##_function(*type##_function); \
2107 type##_function->shared()->set_instance_class_name(*factory->Type##_string()); 2117 type##_function->shared()->set_instance_class_name(*factory->Type##_string());
2108 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION) 2118 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION)
2109 #undef SIMD128_INSTALL_FUNCTION 2119 #undef SIMD128_INSTALL_FUNCTION
2110 } 2120 }
2111 2121
2112 2122
2123 void Genesis::InstallJSProxyMaps() {
2124 // Allocate the different maps for all Proxy types.
2125 // Next to the default proxy, we need maps indicating callable and
2126 // constructable proxies.
2127
2128 Handle<Map> proxy_map =
2129 factory()->NewMap(JS_PROXY_TYPE, JSProxy::kSize, FAST_ELEMENTS);
2130 native_context()->set_proxy_map(*proxy_map);
2131
2132 Handle<Map> proxy_callable_map = Map::Copy(proxy_map, "callable Proxy");
2133 proxy_callable_map->set_is_callable();
2134 native_context()->set_proxy_callable_map(*proxy_callable_map);
2135
2136 Handle<Map> proxy_constructor_map =
2137 Map::Copy(proxy_callable_map, "constructor Proxy");
2138 proxy_constructor_map->set_is_constructor(true);
2139 native_context()->set_proxy_constructor_map(*proxy_constructor_map);
2140 }
2141
2142
2113 void Genesis::InitializeGlobal_harmony_proxies() { 2143 void Genesis::InitializeGlobal_harmony_proxies() {
2114 if (!FLAG_harmony_proxies) return; 2144 if (!FLAG_harmony_proxies) return;
2115 Handle<JSGlobalObject> global( 2145 Handle<JSGlobalObject> global(
2116 JSGlobalObject::cast(native_context()->global_object())); 2146 JSGlobalObject::cast(native_context()->global_object()));
2117 Isolate* isolate = global->GetIsolate(); 2147 Isolate* isolate = global->GetIsolate();
2118 Handle<JSFunction> proxy_fun = InstallFunction( 2148 Factory* factory = isolate->factory();
2119 global, "Proxy", JS_PROXY_TYPE, JSProxy::kSize, 2149
2120 isolate->initial_object_prototype(), Builtins::kProxyConstructor); 2150 InstallJSProxyMaps();
2121 // TODO(verwaest): Set to null in InstallFunction. 2151
2122 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value()); 2152 // Create the Proxy object.
2153 Handle<String> name = factory->InternalizeUtf8String("Proxy");
Jakob Kummerow 2015/12/07 15:55:07 "Proxy" should probably be in the INTERNALIZED_STR
Camillo Bruni 2015/12/07 16:54:10 indeed, better.
2154 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked();
Jakob Kummerow 2015/12/07 15:55:07 This doesn't do anything, feel free to drop it.
2155 Handle<Code> code(isolate->builtins()->builtin(Builtins::kProxyConstructor));
2156 Handle<JSFunction> proxy_fun =
2157 factory->NewFunctionWithoutPrototype(name_string, code, false);
2158 JSFunction::SetInitialMap(proxy_fun,
2159 Handle<Map>(native_context()->proxy_map(), isolate),
2160 factory->null_value());
2161 proxy_fun->map()->set_is_constructor(true);
Toon Verwaest 2015/12/07 16:32:57 this turns all sloppy functions without prototype
Camillo Bruni 2015/12/07 16:54:10 no no, it wont :(... changed
2123 proxy_fun->shared()->set_construct_stub( 2162 proxy_fun->shared()->set_construct_stub(
2124 *isolate->builtins()->ProxyConstructor_ConstructStub()); 2163 *isolate->builtins()->ProxyConstructor_ConstructStub());
2125 proxy_fun->shared()->set_internal_formal_parameter_count(2); 2164 proxy_fun->shared()->set_internal_formal_parameter_count(2);
2126 proxy_fun->shared()->set_length(2); 2165 proxy_fun->shared()->set_length(2);
2166
2127 native_context()->set_proxy_function(*proxy_fun); 2167 native_context()->set_proxy_function(*proxy_fun);
2168 InstallFunction(global, name, proxy_fun, name_string);
2128 } 2169 }
2129 2170
2130 2171
2131 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, 2172 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
2132 const char* name, 2173 const char* name,
2133 ElementsKind elements_kind) { 2174 ElementsKind elements_kind) {
2134 // --- I n t e r n a l A r r a y --- 2175 // --- I n t e r n a l A r r a y ---
2135 // An array constructor on the builtins object that works like 2176 // An array constructor on the builtins object that works like
2136 // the public Array constructor, except that its prototype 2177 // the public Array constructor, except that its prototype
2137 // doesn't inherit from Object.prototype. 2178 // doesn't inherit from Object.prototype.
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 } 3192 }
3152 3193
3153 3194
3154 // Called when the top-level V8 mutex is destroyed. 3195 // Called when the top-level V8 mutex is destroyed.
3155 void Bootstrapper::FreeThreadResources() { 3196 void Bootstrapper::FreeThreadResources() {
3156 DCHECK(!IsActive()); 3197 DCHECK(!IsActive());
3157 } 3198 }
3158 3199
3159 } // namespace internal 3200 } // namespace internal
3160 } // namespace v8 3201 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/builtins.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698