[cleanup] Audit uses of InstallWithIntrinsicDefaultProto.

We only need to use this for certain Intrinsics defined in the spec.
This CL removes unnecessary uses.

Bug: v8:6474
Change-Id: I13a9f0c57d877dd65a883a38f9683d55623030d3
Reviewed-on: https://chromium-review.googlesource.com/529224
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46012}
This commit is contained in:
Peter Marshall 2017-06-19 17:17:22 +02:00 committed by Commit Bot
parent 658609c92a
commit 71582719c1
3 changed files with 67 additions and 90 deletions

View File

@ -1414,14 +1414,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> await_caught = Handle<JSFunction> await_caught =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kAsyncGeneratorAwaitCaught, 2, false); Builtins::kAsyncGeneratorAwaitCaught, 2, false);
InstallWithIntrinsicDefaultProto(isolate, await_caught, native_context()->set_async_generator_await_caught(*await_caught);
Context::ASYNC_GENERATOR_AWAIT_CAUGHT);
Handle<JSFunction> await_uncaught = Handle<JSFunction> await_uncaught =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kAsyncGeneratorAwaitUncaught, 2, false); Builtins::kAsyncGeneratorAwaitUncaught, 2, false);
InstallWithIntrinsicDefaultProto(isolate, await_uncaught, native_context()->set_async_generator_await_uncaught(*await_uncaught);
Context::ASYNC_GENERATOR_AWAIT_UNCAUGHT);
Handle<Code> code = Handle<Code> code =
isolate->builtins()->AsyncGeneratorAwaitResolveClosure(); isolate->builtins()->AsyncGeneratorAwaitResolveClosure();
@ -2099,8 +2097,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> new_promise_capability = Handle<JSFunction> new_promise_capability =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kNewPromiseCapability, 2, false); Builtins::kNewPromiseCapability, 2, false);
InstallWithIntrinsicDefaultProto(isolate, new_promise_capability, native_context()->set_new_promise_capability(*new_promise_capability);
Context::NEW_PROMISE_CAPABILITY_INDEX);
} }
{ // -- P r o m i s e { // -- P r o m i s e
@ -2130,13 +2127,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> promise_then = Handle<JSFunction> promise_then =
SimpleInstallFunction(prototype, isolate->factory()->then_string(), SimpleInstallFunction(prototype, isolate->factory()->then_string(),
Builtins::kPromiseThen, 2, true); Builtins::kPromiseThen, 2, true);
InstallWithIntrinsicDefaultProto(isolate, promise_then, native_context()->set_promise_then(*promise_then);
Context::PROMISE_THEN_INDEX);
Handle<JSFunction> promise_catch = SimpleInstallFunction( Handle<JSFunction> promise_catch = SimpleInstallFunction(
prototype, "catch", Builtins::kPromiseCatch, 1, true, DONT_ENUM); prototype, "catch", Builtins::kPromiseCatch, 1, true, DONT_ENUM);
InstallWithIntrinsicDefaultProto(isolate, promise_catch, native_context()->set_promise_catch(*promise_catch);
Context::PROMISE_CATCH_INDEX);
InstallSpeciesGetter(promise_fun); InstallSpeciesGetter(promise_fun);
@ -2162,15 +2157,13 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kPromiseInternalConstructor, 1, true); Builtins::kPromiseInternalConstructor, 1, true);
function->shared()->set_native(false); function->shared()->set_native(false);
InstallWithIntrinsicDefaultProto( native_context()->set_promise_internal_constructor(*function);
isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX);
} }
{ // Internal: IsPromise { // Internal: IsPromise
Handle<JSFunction> function = SimpleCreateFunction( Handle<JSFunction> function = SimpleCreateFunction(
isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); isolate, factory->empty_string(), Builtins::kIsPromise, 1, false);
InstallWithIntrinsicDefaultProto(isolate, function, native_context()->set_is_promise(*function);
Context::IS_PROMISE_INDEX);
} }
{ // Internal: ResolvePromise { // Internal: ResolvePromise
@ -2178,23 +2171,20 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> function = SimpleCreateFunction( Handle<JSFunction> function = SimpleCreateFunction(
isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true); isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true);
function->shared()->set_native(false); function->shared()->set_native(false);
InstallWithIntrinsicDefaultProto(isolate, function, native_context()->set_promise_resolve(*function);
Context::PROMISE_RESOLVE_INDEX);
} }
{ // Internal: PromiseHandle { // Internal: PromiseHandle
Handle<JSFunction> function = SimpleCreateFunction( Handle<JSFunction> function = SimpleCreateFunction(
isolate, factory->empty_string(), Builtins::kPromiseHandle, 5, false); isolate, factory->empty_string(), Builtins::kPromiseHandle, 5, false);
InstallWithIntrinsicDefaultProto(isolate, function, native_context()->set_promise_handle(*function);
Context::PROMISE_HANDLE_INDEX);
} }
{ // Internal: PromiseHandleReject { // Internal: PromiseHandleReject
Handle<JSFunction> function = Handle<JSFunction> function =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kPromiseHandleReject, 3, false); Builtins::kPromiseHandleReject, 3, false);
InstallWithIntrinsicDefaultProto(isolate, function, native_context()->set_promise_handle_reject(*function);
Context::PROMISE_HANDLE_REJECT_INDEX);
} }
{ // Internal: InternalPromiseReject { // Internal: InternalPromiseReject
@ -2202,8 +2192,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kInternalPromiseReject, 3, true); Builtins::kInternalPromiseReject, 3, true);
function->shared()->set_native(false); function->shared()->set_native(false);
InstallWithIntrinsicDefaultProto(isolate, function, native_context()->set_promise_internal_reject(*function);
Context::PROMISE_INTERNAL_REJECT_INDEX);
} }
{ {
@ -2665,9 +2654,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSObject::AddProperty(date_time_format_prototype, JSObject::AddProperty(date_time_format_prototype,
factory->constructor_string(), factory->constructor_string(),
date_time_format_constructor, DONT_ENUM); date_time_format_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto( native_context()->set_intl_date_time_format_function(
isolate, date_time_format_constructor, *date_time_format_constructor);
Context::INTL_DATE_TIME_FORMAT_FUNCTION_INDEX);
Handle<JSObject> number_format_prototype = Handle<JSObject> number_format_prototype =
factory->NewJSObject(isolate->object_function(), TENURED); factory->NewJSObject(isolate->object_function(), TENURED);
@ -2682,9 +2670,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSObject::AddProperty(number_format_prototype, JSObject::AddProperty(number_format_prototype,
factory->constructor_string(), factory->constructor_string(),
number_format_constructor, DONT_ENUM); number_format_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto( native_context()->set_intl_number_format_function(
isolate, number_format_constructor, *number_format_constructor);
Context::INTL_NUMBER_FORMAT_FUNCTION_INDEX);
Handle<JSObject> collator_prototype = Handle<JSObject> collator_prototype =
factory->NewJSObject(isolate->object_function(), TENURED); factory->NewJSObject(isolate->object_function(), TENURED);
@ -2698,8 +2685,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
collator_prototype, Builtins::kIllegal); collator_prototype, Builtins::kIllegal);
JSObject::AddProperty(collator_prototype, factory->constructor_string(), JSObject::AddProperty(collator_prototype, factory->constructor_string(),
collator_constructor, DONT_ENUM); collator_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto(isolate, collator_constructor, native_context()->set_intl_collator_function(*collator_constructor);
Context::INTL_COLLATOR_FUNCTION_INDEX);
Handle<JSObject> v8_break_iterator_prototype = Handle<JSObject> v8_break_iterator_prototype =
factory->NewJSObject(isolate->object_function(), TENURED); factory->NewJSObject(isolate->object_function(), TENURED);
@ -2714,9 +2700,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
JSObject::AddProperty(v8_break_iterator_prototype, JSObject::AddProperty(v8_break_iterator_prototype,
factory->constructor_string(), factory->constructor_string(),
v8_break_iterator_constructor, DONT_ENUM); v8_break_iterator_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto( native_context()->set_intl_v8_break_iterator_function(
isolate, v8_break_iterator_constructor, *v8_break_iterator_constructor);
Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX);
} }
#endif // V8_INTL_SUPPORT #endif // V8_INTL_SUPPORT
@ -3000,13 +2985,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> map_get = Handle<JSFunction> map_get =
SimpleInstallFunction(prototype, "get", Builtins::kMapGet, 1, true); SimpleInstallFunction(prototype, "get", Builtins::kMapGet, 1, true);
InstallWithIntrinsicDefaultProto(isolate, map_get, native_context()->set_map_get(*map_get);
Context::MAP_GET_METHOD_INDEX);
Handle<JSFunction> map_has = Handle<JSFunction> map_has =
SimpleInstallFunction(prototype, "has", Builtins::kMapHas, 1, true); SimpleInstallFunction(prototype, "has", Builtins::kMapHas, 1, true);
InstallWithIntrinsicDefaultProto(isolate, map_has, native_context()->set_map_has(*map_has);
Context::MAP_HAS_METHOD_INDEX);
SimpleInstallFunction(prototype, "clear", Builtins::kMapClear, 0, true); SimpleInstallFunction(prototype, "clear", Builtins::kMapClear, 0, true);
SimpleInstallFunction(prototype, "forEach", Builtins::kMapForEach, 1, SimpleInstallFunction(prototype, "forEach", Builtins::kMapForEach, 1,
@ -3042,8 +3025,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> set_has = Handle<JSFunction> set_has =
SimpleInstallFunction(prototype, "has", Builtins::kSetHas, 1, true); SimpleInstallFunction(prototype, "has", Builtins::kSetHas, 1, true);
InstallWithIntrinsicDefaultProto(isolate, set_has, native_context()->set_set_has(*set_has);
Context::SET_HAS_METHOD_INDEX);
SimpleInstallFunction(prototype, "clear", Builtins::kSetClear, 0, true); SimpleInstallFunction(prototype, "clear", Builtins::kSetClear, 0, true);
SimpleInstallFunction(prototype, "forEach", Builtins::kSetForEach, 1, SimpleInstallFunction(prototype, "forEach", Builtins::kSetForEach, 1,
false); false);
@ -3849,8 +3831,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
async_function_constructor->shared()->SetConstructStub( async_function_constructor->shared()->SetConstructStub(
*isolate->builtins()->AsyncFunctionConstructor()); *isolate->builtins()->AsyncFunctionConstructor());
async_function_constructor->shared()->set_length(1); async_function_constructor->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate, async_function_constructor, native_context->set_async_function_constructor(*async_function_constructor);
Context::ASYNC_FUNCTION_FUNCTION_INDEX);
JSObject::ForceSetPrototype(async_function_constructor, JSObject::ForceSetPrototype(async_function_constructor,
isolate->function_function()); isolate->function_function());
@ -3866,16 +3847,14 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<JSFunction> function = Handle<JSFunction> function =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kAsyncFunctionAwaitCaught, 3, false); Builtins::kAsyncFunctionAwaitCaught, 3, false);
InstallWithIntrinsicDefaultProto( native_context->set_async_function_await_caught(*function);
isolate, function, Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX);
} }
{ {
Handle<JSFunction> function = Handle<JSFunction> function =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kAsyncFunctionAwaitUncaught, 3, false); Builtins::kAsyncFunctionAwaitUncaught, 3, false);
InstallWithIntrinsicDefaultProto( native_context->set_async_function_await_uncaught(*function);
isolate, function, Context::ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX);
} }
{ {
@ -3902,16 +3881,14 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<JSFunction> function = Handle<JSFunction> function =
SimpleCreateFunction(isolate, factory->empty_string(), SimpleCreateFunction(isolate, factory->empty_string(),
Builtins::kAsyncFunctionPromiseCreate, 0, false); Builtins::kAsyncFunctionPromiseCreate, 0, false);
InstallWithIntrinsicDefaultProto( native_context->set_async_function_promise_create(*function);
isolate, function, Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX);
} }
{ {
Handle<JSFunction> function = SimpleCreateFunction( Handle<JSFunction> function = SimpleCreateFunction(
isolate, factory->empty_string(), isolate, factory->empty_string(),
Builtins::kAsyncFunctionPromiseRelease, 1, false); Builtins::kAsyncFunctionPromiseRelease, 1, false);
InstallWithIntrinsicDefaultProto( native_context->set_async_function_promise_release(*function);
isolate, function, Context::ASYNC_FUNCTION_PROMISE_RELEASE_INDEX);
} }
} }

View File

@ -87,44 +87,44 @@ enum ContextLookupFlags {
V(ASYNC_GENERATOR_AWAIT_CAUGHT, JSFunction, async_generator_await_caught) \ V(ASYNC_GENERATOR_AWAIT_CAUGHT, JSFunction, async_generator_await_caught) \
V(ASYNC_GENERATOR_AWAIT_UNCAUGHT, JSFunction, async_generator_await_uncaught) V(ASYNC_GENERATOR_AWAIT_UNCAUGHT, JSFunction, async_generator_await_uncaught)
#define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \ #define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \
V(ARRAY_CONCAT_INDEX, JSFunction, array_concat) \ V(ARRAY_CONCAT_INDEX, JSFunction, array_concat) \
V(ARRAY_POP_INDEX, JSFunction, array_pop) \ V(ARRAY_POP_INDEX, JSFunction, array_pop) \
V(ARRAY_PUSH_INDEX, JSFunction, array_push) \ V(ARRAY_PUSH_INDEX, JSFunction, array_push) \
V(ARRAY_SHIFT_INDEX, JSFunction, array_shift) \ V(ARRAY_SHIFT_INDEX, JSFunction, array_shift) \
V(ARRAY_SPLICE_INDEX, JSFunction, array_splice) \ V(ARRAY_SPLICE_INDEX, JSFunction, array_splice) \
V(ARRAY_SLICE_INDEX, JSFunction, array_slice) \ V(ARRAY_SLICE_INDEX, JSFunction, array_slice) \
V(ARRAY_UNSHIFT_INDEX, JSFunction, array_unshift) \ V(ARRAY_UNSHIFT_INDEX, JSFunction, array_unshift) \
V(ARRAY_ENTRIES_ITERATOR_INDEX, JSFunction, array_entries_iterator) \ V(ARRAY_ENTRIES_ITERATOR_INDEX, JSFunction, array_entries_iterator) \
V(ARRAY_FOR_EACH_ITERATOR_INDEX, JSFunction, array_for_each_iterator) \ V(ARRAY_FOR_EACH_ITERATOR_INDEX, JSFunction, array_for_each_iterator) \
V(ARRAY_KEYS_ITERATOR_INDEX, JSFunction, array_keys_iterator) \ V(ARRAY_KEYS_ITERATOR_INDEX, JSFunction, array_keys_iterator) \
V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \
V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \ V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \
V(ERROR_FUNCTION_INDEX, JSFunction, error_function) \ V(ERROR_FUNCTION_INDEX, JSFunction, error_function) \
V(ERROR_TO_STRING, JSFunction, error_to_string) \ V(ERROR_TO_STRING, JSFunction, error_to_string) \
V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function) \ V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function) \
V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \ V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \
V(GLOBAL_PROXY_FUNCTION_INDEX, JSFunction, global_proxy_function) \ V(GLOBAL_PROXY_FUNCTION_INDEX, JSFunction, global_proxy_function) \
V(MAP_DELETE_METHOD_INDEX, JSFunction, map_delete) \ V(MAP_DELETE_INDEX, JSFunction, map_delete) \
V(MAP_GET_METHOD_INDEX, JSFunction, map_get) \ V(MAP_GET_INDEX, JSFunction, map_get) \
V(MAP_HAS_METHOD_INDEX, JSFunction, map_has) \ V(MAP_HAS_INDEX, JSFunction, map_has) \
V(MAP_SET_METHOD_INDEX, JSFunction, map_set) \ V(MAP_SET_INDEX, JSFunction, map_set) \
V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \ V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \
V(OBJECT_VALUE_OF, JSFunction, object_value_of) \ V(OBJECT_VALUE_OF, JSFunction, object_value_of) \
V(OBJECT_TO_STRING, JSFunction, object_to_string) \ V(OBJECT_TO_STRING, JSFunction, object_to_string) \
V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \ V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \
V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \ V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \
V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function) \ V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function) \
V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function) \ V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function) \
V(SET_ADD_METHOD_INDEX, JSFunction, set_add) \ V(SET_ADD_INDEX, JSFunction, set_add) \
V(SET_DELETE_METHOD_INDEX, JSFunction, set_delete) \ V(SET_DELETE_INDEX, JSFunction, set_delete) \
V(SET_HAS_METHOD_INDEX, JSFunction, set_has) \ V(SET_HAS_INDEX, JSFunction, set_has) \
V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function) \ V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function) \
V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function) \ V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function) \
V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function) \ V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function) \
V(WASM_COMPILE_ERROR_FUNCTION_INDEX, JSFunction, \ V(WASM_COMPILE_ERROR_FUNCTION_INDEX, JSFunction, \
wasm_compile_error_function) \ wasm_compile_error_function) \
V(WASM_LINK_ERROR_FUNCTION_INDEX, JSFunction, wasm_link_error_function) \ V(WASM_LINK_ERROR_FUNCTION_INDEX, JSFunction, wasm_link_error_function) \
V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, wasm_runtime_error_function) V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, wasm_runtime_error_function)
#define NATIVE_CONTEXT_JS_ARRAY_ITERATOR_MAPS(V) \ #define NATIVE_CONTEXT_JS_ARRAY_ITERATOR_MAPS(V) \

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Flags: --allow-unsafe-function-constructor // Flags: --allow-unsafe-function-constructor --harmony-async-iteration
(function testReflectConstructArity() { (function testReflectConstructArity() {
@ -322,10 +322,10 @@
"Float64Array", "Float64Array",
["Function", ["return 153;"]], ["Function", ["return 153;"]],
["Function", ["'use strict'; return 153;"]], ["Function", ["'use strict'; return 153;"]],
["Function", ["'use strong'; return 153;"]],
["((function*(){}).constructor)", ["yield 153;"]], // GeneratorFunction ["((function*(){}).constructor)", ["yield 153;"]], // GeneratorFunction
["((function*(){}).constructor)", ["'use strict'; yield 153;"]], ["((function*(){}).constructor)", ["'use strict'; yield 153;"]],
["((function*(){}).constructor)", ["'use strong'; yield 153;"]], // AsyncGeneratorFunction
["((async function*(){}).constructor)", ["return 153;"]],
"Int8Array", "Int8Array",
"Int16Array", "Int16Array",
"Int32Array", "Int32Array",