Commit 47dc8702 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[runtime] Don't swap function maps during bootstrapping.

... but use proper map for functions with readonly prototype from the start.

Bug: v8:6459
Change-Id: I432d4969822e7cc4c2ba83e103f550d1c4f2e234
Reviewed-on: https://chromium-review.googlesource.com/563199Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46487}
parent d9cb6135
...@@ -112,6 +112,7 @@ class Genesis BASE_EMBEDDED { ...@@ -112,6 +112,7 @@ class Genesis BASE_EMBEDDED {
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
Factory* factory() const { return isolate_->factory(); } Factory* factory() const { return isolate_->factory(); }
Builtins* builtins() const { return isolate_->builtins(); }
Heap* heap() const { return isolate_->heap(); } Heap* heap() const { return isolate_->heap(); }
Handle<Context> result() { return result_; } Handle<Context> result() { return result_; }
...@@ -178,9 +179,6 @@ class Genesis BASE_EMBEDDED { ...@@ -178,9 +179,6 @@ class Genesis BASE_EMBEDDED {
HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
#undef DECLARE_FEATURE_INITIALIZATION #undef DECLARE_FEATURE_INITIALIZATION
void InstallOneBuiltinFunction(Handle<Object> prototype, const char* method,
Builtins::Name name);
Handle<JSFunction> CreateArrayBuffer(Handle<String> name, Handle<JSFunction> CreateArrayBuffer(Handle<String> name,
Builtins::Name call_byteLength, Builtins::Name call_byteLength,
BuiltinFunctionId byteLength_id, BuiltinFunctionId byteLength_id,
...@@ -242,8 +240,6 @@ class Genesis BASE_EMBEDDED { ...@@ -242,8 +240,6 @@ class Genesis BASE_EMBEDDED {
void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to); void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to); void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
void MakeFunctionInstancePrototypeWritable();
static bool CallUtilsFunction(Isolate* isolate, const char* name); static bool CallUtilsFunction(Isolate* isolate, const char* name);
static bool CompileExtension(Isolate* isolate, v8::Extension* extension); static bool CompileExtension(Isolate* isolate, v8::Extension* extension);
...@@ -253,13 +249,6 @@ class Genesis BASE_EMBEDDED { ...@@ -253,13 +249,6 @@ class Genesis BASE_EMBEDDED {
Handle<Context> native_context_; Handle<Context> native_context_;
Handle<JSGlobalProxy> global_proxy_; Handle<JSGlobalProxy> global_proxy_;
// Function maps. Function maps are created initially with a read only
// prototype for the processing of JS builtins. Later the function maps are
// replaced in order to make prototype writable. These are the final, writable
// prototype, maps.
Handle<Map> sloppy_function_map_writable_prototype_;
Handle<Map> strict_function_map_writable_prototype_;
Handle<Map> class_function_map_;
Handle<JSFunction> strict_poison_function_; Handle<JSFunction> strict_poison_function_;
Handle<JSFunction> restricted_function_properties_thrower_; Handle<JSFunction> restricted_function_properties_thrower_;
...@@ -342,7 +331,7 @@ Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name, ...@@ -342,7 +331,7 @@ Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name,
Handle<JSFunction> result = Handle<JSFunction> result =
maybe_prototype.ToHandle(&prototype) maybe_prototype.ToHandle(&prototype)
? factory->NewFunction(name, call_code, prototype, type, ? factory->NewFunction(name, call_code, prototype, type,
instance_size, STRICT) instance_size, STRICT, IMMUTABLE)
: factory->NewFunctionWithoutPrototype(name, call_code, STRICT); : factory->NewFunctionWithoutPrototype(name, call_code, STRICT);
result->shared()->set_native(true); result->shared()->set_native(true);
return result; return result;
...@@ -413,8 +402,9 @@ Handle<JSFunction> SimpleInstallFunction( ...@@ -413,8 +402,9 @@ Handle<JSFunction> SimpleInstallFunction(
PropertyAttributes attrs = DONT_ENUM, PropertyAttributes attrs = DONT_ENUM,
BuiltinFunctionId id = kInvalidBuiltinFunctionId) { BuiltinFunctionId id = kInvalidBuiltinFunctionId) {
Factory* const factory = base->GetIsolate()->factory(); Factory* const factory = base->GetIsolate()->factory();
return SimpleInstallFunction(base, property_name, // Function name does not have to be internalized.
factory->InternalizeUtf8String(function_name), return SimpleInstallFunction(
base, property_name, factory->NewStringFromAsciiChecked(function_name),
call, len, adapt, attrs, id); call, len, adapt, attrs, id);
} }
...@@ -423,6 +413,8 @@ Handle<JSFunction> SimpleInstallFunction( ...@@ -423,6 +413,8 @@ Handle<JSFunction> SimpleInstallFunction(
bool adapt, PropertyAttributes attrs = DONT_ENUM, bool adapt, PropertyAttributes attrs = DONT_ENUM,
BuiltinFunctionId id = kInvalidBuiltinFunctionId) { BuiltinFunctionId id = kInvalidBuiltinFunctionId) {
Factory* const factory = base->GetIsolate()->factory(); Factory* const factory = base->GetIsolate()->factory();
// Although function name does not have to be internalized the property name
// will be internalized during property addition anyway, so do it here now.
return SimpleInstallFunction(base, factory->InternalizeUtf8String(name), call, return SimpleInstallFunction(base, factory->InternalizeUtf8String(name), call,
len, adapt, attrs, id); len, adapt, attrs, id);
} }
...@@ -511,8 +503,8 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { ...@@ -511,8 +503,8 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
// Allocate the function map first and then patch the prototype later. // Allocate the function map first and then patch the prototype later.
Handle<Map> empty_function_map = Handle<Map> empty_function_map = factory->CreateSloppyFunctionMap(
factory->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); FUNCTION_WITHOUT_PROTOTYPE, MaybeHandle<JSFunction>());
empty_function_map->set_is_prototype_map(true); empty_function_map->set_is_prototype_map(true);
DCHECK(!empty_function_map->is_dictionary_map()); DCHECK(!empty_function_map->is_dictionary_map());
...@@ -540,30 +532,18 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { ...@@ -540,30 +532,18 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
void Genesis::CreateSloppyModeFunctionMaps(Handle<JSFunction> empty) { void Genesis::CreateSloppyModeFunctionMaps(Handle<JSFunction> empty) {
Factory* factory = isolate_->factory(); Factory* factory = isolate_->factory();
Handle<Map> map;
map = factory->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty);
native_context()->set_sloppy_function_without_prototype_map(*map);
map =
factory->CreateSloppyFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty);
native_context()->set_sloppy_function_with_readonly_prototype_map(*map);
// Functions with this map will not have a 'prototype' property, and map = factory->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE,
// can not be used as constructors. empty);
Handle<Map> function_without_prototype_map = native_context()->set_sloppy_function_map(*map);
factory->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
Map::SetPrototype(function_without_prototype_map, empty);
native_context()->set_sloppy_function_without_prototype_map(
*function_without_prototype_map);
// Allocate the function map. This map is temporary, used only for processing
// of builtins.
// Later the map is replaced with writable prototype map, allocated below.
Handle<Map> function_map =
factory->CreateSloppyFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE);
Map::SetPrototype(function_map, empty);
native_context()->set_sloppy_function_map(*function_map);
native_context()->set_sloppy_function_with_readonly_prototype_map(
*function_map);
// The final map for functions. Writeable prototype.
// This map is installed in MakeFunctionInstancePrototypeWritable.
sloppy_function_map_writable_prototype_ =
factory->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE);
Map::SetPrototype(sloppy_function_map_writable_prototype_, empty);
} }
// Creates the %ThrowTypeError% function. // Creates the %ThrowTypeError% function.
...@@ -619,27 +599,22 @@ Handle<JSFunction> Genesis::GetStrictArgumentsPoisonFunction() { ...@@ -619,27 +599,22 @@ Handle<JSFunction> Genesis::GetStrictArgumentsPoisonFunction() {
void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
// Allocate map for the prototype-less strict mode instances. Factory* factory = isolate_->factory();
Handle<Map> strict_function_without_prototype_map = Handle<Map> map;
factory()->CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty);
native_context()->set_strict_function_without_prototype_map( map = factory->CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty);
*strict_function_without_prototype_map); native_context()->set_strict_function_without_prototype_map(*map);
// Allocate map for the strict mode functions. This map is temporary, used map = factory->CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE,
// only for processing of builtins. empty);
// Later the map is replaced with writable prototype map, allocated below. native_context()->set_strict_function_map(*map);
Handle<Map> strict_function_map = factory()->CreateStrictFunctionMap(
FUNCTION_WITH_READONLY_PROTOTYPE, empty); map =
native_context()->set_strict_function_map(*strict_function_map); factory->CreateStrictFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty);
native_context()->set_strict_function_with_readonly_prototype_map(*map);
// The final map for the strict mode functions. Writeable prototype.
// This map is installed in MakeFunctionInstancePrototypeWritable. map = factory->CreateClassFunctionMap(empty);
strict_function_map_writable_prototype_ = factory()->CreateStrictFunctionMap( native_context()->set_class_function_map(*map);
FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty);
// Allocate map for classes
class_function_map_ = factory()->CreateClassFunctionMap(empty);
native_context()->set_class_function_map(*class_function_map_);
// Now that the strict mode function map is available, set up the // Now that the strict mode function map is available, set up the
// restricted "arguments" and "caller" getters. // restricted "arguments" and "caller" getters.
...@@ -706,12 +681,9 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { ...@@ -706,12 +681,9 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
Handle<JSObject> iterator_prototype = Handle<JSObject> iterator_prototype =
factory()->NewJSObject(isolate()->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
Handle<JSFunction> iterator_prototype_iterator = SimpleCreateFunction( SimpleInstallFunction(iterator_prototype, factory()->iterator_symbol(),
isolate(), factory()->NewStringFromAsciiChecked("[Symbol.iterator]"), "[Symbol.iterator]", Builtins::kReturnReceiver, 0,
Builtins::kReturnReceiver, 0, true); true);
JSObject::AddProperty(iterator_prototype, factory()->iterator_symbol(),
iterator_prototype_iterator, DONT_ENUM);
native_context()->set_initial_iterator_prototype(*iterator_prototype); native_context()->set_initial_iterator_prototype(*iterator_prototype);
Handle<JSObject> generator_object_prototype = Handle<JSObject> generator_object_prototype =
...@@ -759,10 +731,9 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { ...@@ -759,10 +731,9 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
// maps in the native context. The "prototype" property descriptor is // maps in the native context. The "prototype" property descriptor is
// writable, non-enumerable, and non-configurable (as per ES6 draft // writable, non-enumerable, and non-configurable (as per ES6 draft
// 04-14-15, section 25.2.4.3). // 04-14-15, section 25.2.4.3).
Handle<Map> strict_function_map(strict_function_map_writable_prototype_);
// Generator functions do not have "caller" or "arguments" accessors. // Generator functions do not have "caller" or "arguments" accessors.
Handle<Map> generator_function_map = Handle<Map> generator_function_map =
Map::Copy(strict_function_map, "GeneratorFunction"); Map::Copy(isolate()->strict_function_map(), "GeneratorFunction");
generator_function_map->set_is_constructor(false); generator_function_map->set_is_constructor(false);
Map::SetPrototype(generator_function_map, generator_function_prototype); Map::SetPrototype(generator_function_map, generator_function_prototype);
native_context()->set_generator_function_map(*generator_function_map); native_context()->set_generator_function_map(*generator_function_map);
...@@ -780,13 +751,9 @@ void Genesis::CreateAsyncIteratorMaps(Handle<JSFunction> empty) { ...@@ -780,13 +751,9 @@ void Genesis::CreateAsyncIteratorMaps(Handle<JSFunction> empty) {
Handle<JSObject> async_iterator_prototype = Handle<JSObject> async_iterator_prototype =
factory()->NewJSObject(isolate()->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
Handle<JSFunction> async_iterator_prototype_iterator = SimpleCreateFunction( SimpleInstallFunction(
isolate(), factory()->NewStringFromAsciiChecked("[Symbol.asyncIterator]"), async_iterator_prototype, factory()->async_iterator_symbol(),
Builtins::kReturnReceiver, 0, true); "[Symbol.asyncIterator]", Builtins::kReturnReceiver, 0, true);
JSObject::AddProperty(async_iterator_prototype,
factory()->async_iterator_symbol(),
async_iterator_prototype_iterator, DONT_ENUM);
// %AsyncFromSyncIteratorPrototype% // %AsyncFromSyncIteratorPrototype%
// proposal-async-iteration/#sec-%asyncfromsynciteratorprototype%-object // proposal-async-iteration/#sec-%asyncfromsynciteratorprototype%-object
...@@ -861,10 +828,9 @@ void Genesis::CreateAsyncIteratorMaps(Handle<JSFunction> empty) { ...@@ -861,10 +828,9 @@ void Genesis::CreateAsyncIteratorMaps(Handle<JSFunction> empty) {
// maps in the native context. The "prototype" property descriptor is // maps in the native context. The "prototype" property descriptor is
// writable, non-enumerable, and non-configurable (as per ES6 draft // writable, non-enumerable, and non-configurable (as per ES6 draft
// 04-14-15, section 25.2.4.3). // 04-14-15, section 25.2.4.3).
Handle<Map> strict_function_map(strict_function_map_writable_prototype_);
// Async Generator functions do not have "caller" or "arguments" accessors. // Async Generator functions do not have "caller" or "arguments" accessors.
Handle<Map> async_generator_function_map = Handle<Map> async_generator_function_map =
Map::Copy(strict_function_map, "AsyncGeneratorFunction"); Map::Copy(isolate()->strict_function_map(), "AsyncGeneratorFunction");
async_generator_function_map->set_is_constructor(false); async_generator_function_map->set_is_constructor(false);
Map::SetPrototype(async_generator_function_map, Map::SetPrototype(async_generator_function_map,
async_generator_function_prototype); async_generator_function_prototype);
...@@ -1033,8 +999,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals( ...@@ -1033,8 +999,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals(
} }
if (js_global_object_template.is_null()) { if (js_global_object_template.is_null()) {
Handle<String> name = Handle<String>(heap()->empty_string()); Handle<String> name(factory()->empty_string());
Handle<Code> code = isolate()->builtins()->Illegal(); Handle<Code> code(builtins()->Illegal());
Handle<JSObject> prototype = Handle<JSObject> prototype =
factory()->NewFunctionPrototype(isolate()->object_function()); factory()->NewFunctionPrototype(isolate()->object_function());
js_global_object_function = js_global_object_function =
...@@ -1063,8 +1029,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals( ...@@ -1063,8 +1029,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals(
// Step 2: (re)initialize the global proxy object. // Step 2: (re)initialize the global proxy object.
Handle<JSFunction> global_proxy_function; Handle<JSFunction> global_proxy_function;
if (global_proxy_template.IsEmpty()) { if (global_proxy_template.IsEmpty()) {
Handle<String> name = Handle<String>(heap()->empty_string()); Handle<String> name(factory()->empty_string());
Handle<Code> code = isolate()->builtins()->Illegal(); Handle<Code> code(builtins()->Illegal());
global_proxy_function = global_proxy_function =
factory()->NewFunction(name, code, JS_GLOBAL_PROXY_TYPE, factory()->NewFunction(name, code, JS_GLOBAL_PROXY_TYPE,
JSGlobalProxy::SizeWithEmbedderFields(0)); JSGlobalProxy::SizeWithEmbedderFields(0));
...@@ -1201,8 +1167,9 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global, ...@@ -1201,8 +1167,9 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
} }
} }
static void InstallMakeError(Isolate* isolate, Handle<Code> code, namespace {
int context_index) {
void InstallMakeError(Isolate* isolate, Handle<Code> code, int context_index) {
Handle<JSFunction> function = Handle<JSFunction> function =
isolate->factory()->NewFunction(isolate->factory()->empty_string(), code, isolate->factory()->NewFunction(isolate->factory()->empty_string(), code,
JS_OBJECT_TYPE, JSObject::kHeaderSize); JS_OBJECT_TYPE, JSObject::kHeaderSize);
...@@ -1210,6 +1177,8 @@ static void InstallMakeError(Isolate* isolate, Handle<Code> code, ...@@ -1210,6 +1177,8 @@ static void InstallMakeError(Isolate* isolate, Handle<Code> code,
isolate->native_context()->set(context_index, *function); isolate->native_context()->set(context_index, *function);
} }
} // namespace
// This is only called if we are not using snapshots. The equivalent // This is only called if we are not using snapshots. The equivalent
// work in the snapshot case is done in HookUpGlobalObject. // work in the snapshot case is done in HookUpGlobalObject.
void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
...@@ -1228,6 +1197,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1228,6 +1197,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Isolate* isolate = global_object->GetIsolate(); Isolate* isolate = global_object->GetIsolate();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Builtins* builtins = isolate->builtins();
Handle<ScriptContextTable> script_context_table = Handle<ScriptContextTable> script_context_table =
factory->NewScriptContextTable(); factory->NewScriptContextTable();
...@@ -1346,16 +1316,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1346,16 +1316,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> function_fun = Handle<JSFunction> function_fun =
InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
prototype, Builtins::kFunctionConstructor); prototype, Builtins::kFunctionConstructor);
function_fun->set_prototype_or_initial_map( // Function instances are sloppy by default.
*sloppy_function_map_writable_prototype_); function_fun->set_prototype_or_initial_map(*isolate->sloppy_function_map());
function_fun->shared()->DontAdaptArguments(); function_fun->shared()->DontAdaptArguments();
function_fun->shared()->SetConstructStub( function_fun->shared()->SetConstructStub(*builtins->FunctionConstructor());
*isolate->builtins()->FunctionConstructor());
function_fun->shared()->set_length(1); function_fun->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate, function_fun, InstallWithIntrinsicDefaultProto(isolate, function_fun,
Context::FUNCTION_FUNCTION_INDEX); Context::FUNCTION_FUNCTION_INDEX);
// Setup the methods on the %FunctionPrototype%. // Setup the methods on the %FunctionPrototype%.
JSObject::AddProperty(prototype, factory->constructor_string(),
function_fun, DONT_ENUM);
SimpleInstallFunction(prototype, factory->apply_string(), SimpleInstallFunction(prototype, factory->apply_string(),
Builtins::kFunctionPrototypeApply, 2, false); Builtins::kFunctionPrototypeApply, 2, false);
SimpleInstallFunction(prototype, factory->bind_string(), SimpleInstallFunction(prototype, factory->bind_string(),
...@@ -1373,17 +1344,22 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1373,17 +1344,22 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
kFunctionHasInstance); kFunctionHasInstance);
native_context()->set_function_has_instance(*has_instance); native_context()->set_function_has_instance(*has_instance);
// Install the "constructor" property on the %FunctionPrototype%. // Complete setting up function maps.
JSObject::AddProperty(prototype, factory->constructor_string(), {
function_fun, DONT_ENUM); isolate->sloppy_function_map()->SetConstructor(*function_fun);
isolate->sloppy_function_with_readonly_prototype_map()->SetConstructor(
*function_fun);
sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); isolate->strict_function_map()->SetConstructor(*function_fun);
strict_function_map_writable_prototype_->SetConstructor(*function_fun); isolate->strict_function_with_readonly_prototype_map()->SetConstructor(
class_function_map_->SetConstructor(*function_fun); *function_fun);
isolate->class_function_map()->SetConstructor(*function_fun);
}
} }
{ // --- A s y n c F r o m S y n c I t e r a t o r { // --- A s y n c F r o m S y n c I t e r a t o r
Handle<Code> code = isolate->builtins()->AsyncIteratorValueUnwrap(); Handle<Code> code(builtins->AsyncIteratorValueUnwrap());
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -1402,17 +1378,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1402,17 +1378,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kAsyncGeneratorAwaitUncaught, 2, false); Builtins::kAsyncGeneratorAwaitUncaught, 2, false);
native_context()->set_async_generator_await_uncaught(*await_uncaught); native_context()->set_async_generator_await_uncaught(*await_uncaught);
Handle<Code> code = Handle<Code> code(builtins->AsyncGeneratorAwaitResolveClosure());
isolate->builtins()->AsyncGeneratorAwaitResolveClosure();
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
info->set_length(1); info->set_length(1);
native_context()->set_async_generator_await_resolve_shared_fun(*info); native_context()->set_async_generator_await_resolve_shared_fun(*info);
code = handle(isolate->builtins()->builtin( code = builtins->AsyncGeneratorAwaitRejectClosure();
Builtins::kAsyncGeneratorAwaitRejectClosure),
isolate);
info = factory->NewSharedFunctionInfo(factory->empty_string(), code, false); info = factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
info->set_length(1); info->set_length(1);
...@@ -1591,12 +1564,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1591,12 +1564,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
isolate->initial_object_prototype(), Builtins::kNumberConstructor); isolate->initial_object_prototype(), Builtins::kNumberConstructor);
number_fun->shared()->DontAdaptArguments(); number_fun->shared()->DontAdaptArguments();
number_fun->shared()->SetConstructStub( number_fun->shared()->SetConstructStub(
*isolate->builtins()->NumberConstructor_ConstructStub()); *builtins->NumberConstructor_ConstructStub());
number_fun->shared()->set_length(1); number_fun->shared()->set_length(1);
// https://tc39.github.io/ecma262/#sec-built-in-function-objects says
// that "Built-in functions that are ECMAScript function objects must
// be strict functions".
number_fun->shared()->set_language_mode(STRICT);
InstallWithIntrinsicDefaultProto(isolate, number_fun, InstallWithIntrinsicDefaultProto(isolate, number_fun,
Context::NUMBER_FUNCTION_INDEX); Context::NUMBER_FUNCTION_INDEX);
...@@ -1712,7 +1681,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1712,7 +1681,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kBooleanConstructor); Builtins::kBooleanConstructor);
boolean_fun->shared()->DontAdaptArguments(); boolean_fun->shared()->DontAdaptArguments();
boolean_fun->shared()->SetConstructStub( boolean_fun->shared()->SetConstructStub(
*isolate->builtins()->BooleanConstructor_ConstructStub()); *builtins->BooleanConstructor_ConstructStub());
boolean_fun->shared()->set_length(1); boolean_fun->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate, boolean_fun, InstallWithIntrinsicDefaultProto(isolate, boolean_fun,
Context::BOOLEAN_FUNCTION_INDEX); Context::BOOLEAN_FUNCTION_INDEX);
...@@ -1739,13 +1708,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1739,13 +1708,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
global, "String", JS_VALUE_TYPE, JSValue::kSize, global, "String", JS_VALUE_TYPE, JSValue::kSize,
isolate->initial_object_prototype(), Builtins::kStringConstructor); isolate->initial_object_prototype(), Builtins::kStringConstructor);
string_fun->shared()->SetConstructStub( string_fun->shared()->SetConstructStub(
*isolate->builtins()->StringConstructor_ConstructStub()); *builtins->StringConstructor_ConstructStub());
string_fun->shared()->DontAdaptArguments(); string_fun->shared()->DontAdaptArguments();
string_fun->shared()->set_length(1); string_fun->shared()->set_length(1);
// https://tc39.github.io/ecma262/#sec-built-in-function-objects says
// that "Built-in functions that are ECMAScript function objects must
// be strict functions".
string_fun->shared()->set_language_mode(STRICT);
InstallWithIntrinsicDefaultProto(isolate, string_fun, InstallWithIntrinsicDefaultProto(isolate, string_fun,
Context::STRING_FUNCTION_INDEX); Context::STRING_FUNCTION_INDEX);
...@@ -1884,7 +1849,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1884,7 +1849,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
factory->the_hole_value(), Builtins::kSymbolConstructor); factory->the_hole_value(), Builtins::kSymbolConstructor);
symbol_fun->shared()->SetConstructStub( symbol_fun->shared()->SetConstructStub(
*isolate->builtins()->SymbolConstructor_ConstructStub()); *builtins->SymbolConstructor_ConstructStub());
symbol_fun->shared()->set_length(0); symbol_fun->shared()->set_length(0);
symbol_fun->shared()->DontAdaptArguments(); symbol_fun->shared()->DontAdaptArguments();
native_context()->set_symbol_function(*symbol_fun); native_context()->set_symbol_function(*symbol_fun);
...@@ -1950,7 +1915,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -1950,7 +1915,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallWithIntrinsicDefaultProto(isolate, date_fun, InstallWithIntrinsicDefaultProto(isolate, date_fun,
Context::DATE_FUNCTION_INDEX); Context::DATE_FUNCTION_INDEX);
date_fun->shared()->SetConstructStub( date_fun->shared()->SetConstructStub(
*isolate->builtins()->DateConstructor_ConstructStub()); *builtins->DateConstructor_ConstructStub());
date_fun->shared()->set_length(7); date_fun->shared()->set_length(7);
date_fun->shared()->DontAdaptArguments(); date_fun->shared()->DontAdaptArguments();
...@@ -2074,10 +2039,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2074,10 +2039,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
} }
{ {
Handle<Code> code = isolate->builtins()->PromiseGetCapabilitiesExecutor(); Handle<Code> code(builtins->PromiseGetCapabilitiesExecutor());
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, true); factory->NewSharedFunctionInfo(factory->empty_string(), code, true);
info->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); info->SetConstructStub(*builtins->JSBuiltinsConstructStub());
info->set_instance_class_name(isolate->heap()->Object_string()); info->set_instance_class_name(isolate->heap()->Object_string());
info->set_internal_formal_parameter_count(2); info->set_internal_formal_parameter_count(2);
info->set_length(2); info->set_length(2);
...@@ -2098,7 +2063,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2098,7 +2063,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Context::PROMISE_FUNCTION_INDEX); Context::PROMISE_FUNCTION_INDEX);
Handle<SharedFunctionInfo> shared(promise_fun->shared(), isolate); Handle<SharedFunctionInfo> shared(promise_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); shared->SetConstructStub(*builtins->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->Object_string()); shared->set_instance_class_name(isolate->heap()->Object_string());
shared->set_internal_formal_parameter_count(1); shared->set_internal_formal_parameter_count(1);
shared->set_length(1); shared->set_length(1);
...@@ -2184,18 +2149,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2184,18 +2149,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
} }
{ {
Handle<Code> code = Handle<Code> code(builtins->PromiseResolveClosure());
handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure),
isolate);
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
info->set_length(1); info->set_length(1);
native_context()->set_promise_resolve_shared_fun(*info); native_context()->set_promise_resolve_shared_fun(*info);
code = code = builtins->PromiseRejectClosure();
handle(isolate->builtins()->builtin(Builtins::kPromiseRejectClosure),
isolate);
info = info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -2204,8 +2165,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2204,8 +2165,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
} }
{ {
Handle<Code> code = Handle<Code> code(builtins->PromiseAllResolveElementClosure());
isolate->builtins()->PromiseAllResolveElementClosure();
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -2232,7 +2192,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2232,7 +2192,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Context::REGEXP_FUNCTION_INDEX); Context::REGEXP_FUNCTION_INDEX);
Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate); Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); shared->SetConstructStub(*builtins->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->RegExp_string()); shared->set_instance_class_name(isolate->heap()->RegExp_string());
shared->set_internal_formal_parameter_count(2); shared->set_internal_formal_parameter_count(2);
shared->set_length(2); shared->set_length(2);
...@@ -2273,33 +2233,21 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2273,33 +2233,21 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(prototype, "test", Builtins::kRegExpPrototypeTest, SimpleInstallFunction(prototype, "test", Builtins::kRegExpPrototypeTest,
1, true, DONT_ENUM); 1, true, DONT_ENUM);
{ SimpleInstallFunction(prototype, factory->match_symbol(),
Handle<JSFunction> fun = SimpleCreateFunction( "[Symbol.match]", Builtins::kRegExpPrototypeMatch,
isolate, factory->InternalizeUtf8String("[Symbol.match]"), 1, true);
Builtins::kRegExpPrototypeMatch, 1, true);
InstallFunction(prototype, fun, factory->match_symbol(), DONT_ENUM);
}
{ SimpleInstallFunction(prototype, factory->replace_symbol(),
Handle<JSFunction> fun = SimpleCreateFunction( "[Symbol.replace]",
isolate, factory->InternalizeUtf8String("[Symbol.replace]"),
Builtins::kRegExpPrototypeReplace, 2, false); Builtins::kRegExpPrototypeReplace, 2, false);
InstallFunction(prototype, fun, factory->replace_symbol(), DONT_ENUM);
}
{ SimpleInstallFunction(prototype, factory->search_symbol(),
Handle<JSFunction> fun = SimpleCreateFunction( "[Symbol.search]", Builtins::kRegExpPrototypeSearch,
isolate, factory->InternalizeUtf8String("[Symbol.search]"), 1, true);
Builtins::kRegExpPrototypeSearch, 1, true);
InstallFunction(prototype, fun, factory->search_symbol(), DONT_ENUM);
}
{ SimpleInstallFunction(prototype, factory->split_symbol(),
Handle<JSFunction> fun = SimpleCreateFunction( "[Symbol.split]", Builtins::kRegExpPrototypeSplit,
isolate, factory->InternalizeUtf8String("[Symbol.split]"), 2, false);
Builtins::kRegExpPrototypeSplit, 2, false);
InstallFunction(prototype, fun, factory->split_symbol(), DONT_ENUM);
}
Handle<Map> prototype_map(prototype->map()); Handle<Map> prototype_map(prototype->map());
Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
...@@ -2420,8 +2368,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2420,8 +2368,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- E r r o r { // -- E r r o r
InstallError(isolate, global, factory->Error_string(), InstallError(isolate, global, factory->Error_string(),
Context::ERROR_FUNCTION_INDEX); Context::ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeError(), InstallMakeError(isolate, builtins->MakeError(), Context::MAKE_ERROR_INDEX);
Context::MAKE_ERROR_INDEX);
} }
{ // -- E v a l E r r o r { // -- E v a l E r r o r
...@@ -2432,7 +2379,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2432,7 +2379,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- R a n g e E r r o r { // -- R a n g e E r r o r
InstallError(isolate, global, factory->RangeError_string(), InstallError(isolate, global, factory->RangeError_string(),
Context::RANGE_ERROR_FUNCTION_INDEX); Context::RANGE_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeRangeError(), InstallMakeError(isolate, builtins->MakeRangeError(),
Context::MAKE_RANGE_ERROR_INDEX); Context::MAKE_RANGE_ERROR_INDEX);
} }
...@@ -2444,21 +2391,21 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2444,21 +2391,21 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- S y n t a x E r r o r { // -- S y n t a x E r r o r
InstallError(isolate, global, factory->SyntaxError_string(), InstallError(isolate, global, factory->SyntaxError_string(),
Context::SYNTAX_ERROR_FUNCTION_INDEX); Context::SYNTAX_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeSyntaxError(), InstallMakeError(isolate, builtins->MakeSyntaxError(),
Context::MAKE_SYNTAX_ERROR_INDEX); Context::MAKE_SYNTAX_ERROR_INDEX);
} }
{ // -- T y p e E r r o r { // -- T y p e E r r o r
InstallError(isolate, global, factory->TypeError_string(), InstallError(isolate, global, factory->TypeError_string(),
Context::TYPE_ERROR_FUNCTION_INDEX); Context::TYPE_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeTypeError(), InstallMakeError(isolate, builtins->MakeTypeError(),
Context::MAKE_TYPE_ERROR_INDEX); Context::MAKE_TYPE_ERROR_INDEX);
} }
{ // -- U R I E r r o r { // -- U R I E r r o r
InstallError(isolate, global, factory->URIError_string(), InstallError(isolate, global, factory->URIError_string(),
Context::URI_ERROR_FUNCTION_INDEX); Context::URI_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeURIError(), InstallMakeError(isolate, builtins->MakeURIError(),
Context::MAKE_URI_ERROR_INDEX); Context::MAKE_URI_ERROR_INDEX);
} }
...@@ -2870,7 +2817,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2870,7 +2817,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallWithIntrinsicDefaultProto(isolate, data_view_fun, InstallWithIntrinsicDefaultProto(isolate, data_view_fun,
Context::DATA_VIEW_FUN_INDEX); Context::DATA_VIEW_FUN_INDEX);
data_view_fun->shared()->SetConstructStub( data_view_fun->shared()->SetConstructStub(
*isolate->builtins()->DataViewConstructor_ConstructStub()); *builtins->DataViewConstructor_ConstructStub());
data_view_fun->shared()->set_length(3); data_view_fun->shared()->set_length(3);
data_view_fun->shared()->DontAdaptArguments(); data_view_fun->shared()->DontAdaptArguments();
...@@ -2949,7 +2896,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2949,7 +2896,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Context::JS_MAP_FUN_INDEX); Context::JS_MAP_FUN_INDEX);
Handle<SharedFunctionInfo> shared(js_map_fun->shared(), isolate); Handle<SharedFunctionInfo> shared(js_map_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); shared->SetConstructStub(*builtins->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->Map_string()); shared->set_instance_class_name(isolate->heap()->Map_string());
shared->DontAdaptArguments(); shared->DontAdaptArguments();
shared->set_length(0); shared->set_length(0);
...@@ -2995,7 +2942,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -2995,7 +2942,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Context::JS_SET_FUN_INDEX); Context::JS_SET_FUN_INDEX);
Handle<SharedFunctionInfo> shared(js_set_fun->shared(), isolate); Handle<SharedFunctionInfo> shared(js_set_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); shared->SetConstructStub(*builtins->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->Set_string()); shared->set_instance_class_name(isolate->heap()->Set_string());
shared->DontAdaptArguments(); shared->DontAdaptArguments();
shared->set_length(0); shared->set_length(0);
...@@ -3110,7 +3057,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -3110,7 +3057,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
proxy_function_map->set_is_constructor(true); proxy_function_map->set_is_constructor(true);
Handle<String> name = factory->Proxy_string(); Handle<String> name = factory->Proxy_string();
Handle<Code> code(isolate->builtins()->ProxyConstructor()); Handle<Code> code(builtins->ProxyConstructor());
Handle<JSFunction> proxy_function = Handle<JSFunction> proxy_function =
factory->NewFunction(proxy_function_map, name, code); factory->NewFunction(proxy_function_map, name, code);
...@@ -3118,7 +3065,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -3118,7 +3065,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->null_value()); factory->null_value());
proxy_function->shared()->SetConstructStub( proxy_function->shared()->SetConstructStub(
*isolate->builtins()->ProxyConstructor_ConstructStub()); *builtins->ProxyConstructor_ConstructStub());
proxy_function->shared()->set_internal_formal_parameter_count(2); proxy_function->shared()->set_internal_formal_parameter_count(2);
proxy_function->shared()->set_length(2); proxy_function->shared()->set_length(2);
...@@ -3208,7 +3155,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, ...@@ -3208,7 +3155,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// This is done by introducing an anonymous function with // This is done by introducing an anonymous function with
// class_name equals 'Arguments'. // class_name equals 'Arguments'.
Handle<String> arguments_string = factory->Arguments_string(); Handle<String> arguments_string = factory->Arguments_string();
Handle<Code> code = isolate->builtins()->Illegal(); Handle<Code> code(builtins->Illegal());
Handle<JSFunction> function = Handle<JSFunction> function =
factory->NewFunctionWithoutPrototype(arguments_string, code, STRICT); factory->NewFunctionWithoutPrototype(arguments_string, code, STRICT);
function->shared()->set_instance_class_name(*arguments_string); function->shared()->set_instance_class_name(*arguments_string);
...@@ -3579,6 +3526,7 @@ void Genesis::ConfigureUtilsObject(GlobalContextType context_type) { ...@@ -3579,6 +3526,7 @@ void Genesis::ConfigureUtilsObject(GlobalContextType context_type) {
void Bootstrapper::ExportFromRuntime(Isolate* isolate, void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<JSObject> container) { Handle<JSObject> container) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Builtins* builtins = isolate->builtins();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Context> native_context = isolate->native_context(); Handle<Context> native_context = isolate->native_context();
#define EXPORT_PRIVATE_SYMBOL(NAME) \ #define EXPORT_PRIVATE_SYMBOL(NAME) \
...@@ -3616,7 +3564,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, ...@@ -3616,7 +3564,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
native_context->generator_function_map()); native_context->generator_function_map());
generator_function_function->shared()->DontAdaptArguments(); generator_function_function->shared()->DontAdaptArguments();
generator_function_function->shared()->SetConstructStub( generator_function_function->shared()->SetConstructStub(
*isolate->builtins()->GeneratorFunctionConstructor()); *builtins->GeneratorFunctionConstructor());
generator_function_function->shared()->set_length(1); generator_function_function->shared()->set_length(1);
InstallWithIntrinsicDefaultProto( InstallWithIntrinsicDefaultProto(
isolate, generator_function_function, isolate, generator_function_function,
...@@ -3646,7 +3594,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, ...@@ -3646,7 +3594,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
native_context->async_generator_function_map()); native_context->async_generator_function_map());
async_generator_function_function->shared()->DontAdaptArguments(); async_generator_function_function->shared()->DontAdaptArguments();
async_generator_function_function->shared()->SetConstructStub( async_generator_function_function->shared()->SetConstructStub(
*isolate->builtins()->AsyncGeneratorFunctionConstructor()); *builtins->AsyncGeneratorFunctionConstructor());
async_generator_function_function->shared()->set_length(1); async_generator_function_function->shared()->set_length(1);
InstallWithIntrinsicDefaultProto( InstallWithIntrinsicDefaultProto(
isolate, async_generator_function_function, isolate, async_generator_function_function,
...@@ -3856,7 +3804,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, ...@@ -3856,7 +3804,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
native_context->async_function_map()); native_context->async_function_map());
async_function_constructor->shared()->DontAdaptArguments(); async_function_constructor->shared()->DontAdaptArguments();
async_function_constructor->shared()->SetConstructStub( async_function_constructor->shared()->SetConstructStub(
*isolate->builtins()->AsyncFunctionConstructor()); *builtins->AsyncFunctionConstructor());
async_function_constructor->shared()->set_length(1); async_function_constructor->shared()->set_length(1);
native_context->set_async_function_constructor(*async_function_constructor); native_context->set_async_function_constructor(*async_function_constructor);
JSObject::ForceSetPrototype(async_function_constructor, JSObject::ForceSetPrototype(async_function_constructor,
...@@ -3885,8 +3833,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, ...@@ -3885,8 +3833,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
} }
{ {
Handle<Code> code = Handle<Code> code(builtins->AsyncFunctionAwaitRejectClosure());
isolate->builtins()->AsyncFunctionAwaitRejectClosure();
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -3895,8 +3842,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, ...@@ -3895,8 +3842,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
} }
{ {
Handle<Code> code = Handle<Code> code(builtins->AsyncFunctionAwaitResolveClosure());
isolate->builtins()->AsyncFunctionAwaitResolveClosure();
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
factory->NewSharedFunctionInfo(factory->empty_string(), code, false); factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -4005,21 +3951,6 @@ void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, ...@@ -4005,21 +3951,6 @@ void InstallPublicSymbol(Factory* factory, Handle<Context> native_context,
JSObject::AddProperty(symbol, name_string, value, attributes); JSObject::AddProperty(symbol, name_string, value, attributes);
} }
void Genesis::InstallOneBuiltinFunction(Handle<Object> prototype,
const char* method_name,
Builtins::Name builtin_name) {
LookupIterator it(
prototype, isolate()->factory()->NewStringFromAsciiChecked(method_name),
LookupIterator::OWN_SKIP_INTERCEPTOR);
Handle<Object> function = Object::GetProperty(&it).ToHandleChecked();
Handle<JSFunction>::cast(function)->set_code(
isolate()->builtins()->builtin(builtin_name));
SharedFunctionInfo* info = Handle<JSFunction>::cast(function)->shared();
info->set_code(isolate()->builtins()->builtin(builtin_name));
info->set_internal_formal_parameter_count(
Builtins::GetBuiltinParameterCount(builtin_name));
}
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
if (!FLAG_harmony_sharedarraybuffer) return; if (!FLAG_harmony_sharedarraybuffer) return;
...@@ -4085,9 +4016,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() { ...@@ -4085,9 +4016,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() {
native_context()->set_promise_prototype_map(*prototype_map); native_context()->set_promise_prototype_map(*prototype_map);
{ {
Handle<Code> code = Handle<Code> code(builtins()->PromiseThenFinally());
handle(isolate()->builtins()->builtin(Builtins::kPromiseThenFinally),
isolate());
Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo( Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo(
factory()->empty_string(), code, false); factory()->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -4097,9 +4026,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() { ...@@ -4097,9 +4026,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() {
} }
{ {
Handle<Code> code = Handle<Code> code(builtins()->PromiseCatchFinally());
handle(isolate()->builtins()->builtin(Builtins::kPromiseCatchFinally),
isolate());
Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo( Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo(
factory()->empty_string(), code, false); factory()->empty_string(), code, false);
info->set_internal_formal_parameter_count(1); info->set_internal_formal_parameter_count(1);
...@@ -4109,9 +4036,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() { ...@@ -4109,9 +4036,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() {
} }
{ {
Handle<Code> code = handle( Handle<Code> code(builtins()->PromiseValueThunkFinally());
isolate()->builtins()->builtin(Builtins::kPromiseValueThunkFinally),
isolate());
Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo( Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo(
factory()->empty_string(), code, false); factory()->empty_string(), code, false);
info->set_internal_formal_parameter_count(0); info->set_internal_formal_parameter_count(0);
...@@ -4120,9 +4045,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() { ...@@ -4120,9 +4045,7 @@ void Genesis::InitializeGlobal_harmony_promise_finally() {
} }
{ {
Handle<Code> code = Handle<Code> code(builtins()->PromiseThrowerFinally());
handle(isolate()->builtins()->builtin(Builtins::kPromiseThrowerFinally),
isolate());
Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo( Handle<SharedFunctionInfo> info = factory()->NewSharedFunctionInfo(
factory()->empty_string(), code, false); factory()->empty_string(), code, false);
info->set_internal_formal_parameter_count(0); info->set_internal_formal_parameter_count(0);
...@@ -4180,7 +4103,7 @@ Handle<JSFunction> Genesis::CreateArrayBuffer(Handle<String> name, ...@@ -4180,7 +4103,7 @@ Handle<JSFunction> Genesis::CreateArrayBuffer(Handle<String> name,
JSArrayBuffer::kSizeWithEmbedderFields, prototype, JSArrayBuffer::kSizeWithEmbedderFields, prototype,
Builtins::kArrayBufferConstructor); Builtins::kArrayBufferConstructor);
array_buffer_fun->shared()->SetConstructStub( array_buffer_fun->shared()->SetConstructStub(
*isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); *builtins()->ArrayBufferConstructor_ConstructStub());
array_buffer_fun->shared()->DontAdaptArguments(); array_buffer_fun->shared()->DontAdaptArguments();
array_buffer_fun->shared()->set_length(1); array_buffer_fun->shared()->set_length(1);
array_buffer_fun->shared()->set_instance_class_name(*name); array_buffer_fun->shared()->set_instance_class_name(*name);
...@@ -5019,22 +4942,6 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { ...@@ -5019,22 +4942,6 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
JSObject::ForceSetPrototype(to, proto); JSObject::ForceSetPrototype(to, proto);
} }
void Genesis::MakeFunctionInstancePrototypeWritable() {
// The maps with writable prototype are created in CreateEmptyFunction
// and CreateStrictModeFunctionMaps respectively. Initially the maps are
// created with read-only prototype for JS builtins processing.
DCHECK(!sloppy_function_map_writable_prototype_.is_null());
DCHECK(!strict_function_map_writable_prototype_.is_null());
// Replace function instance maps to make prototype writable.
native_context()->set_sloppy_function_map(
*sloppy_function_map_writable_prototype_);
native_context()->set_strict_function_map(
*strict_function_map_writable_prototype_);
}
class NoTrackDoubleFieldsForSerializerScope { class NoTrackDoubleFieldsForSerializerScope {
public: public:
explicit NoTrackDoubleFieldsForSerializerScope(Isolate* isolate) explicit NoTrackDoubleFieldsForSerializerScope(Isolate* isolate)
...@@ -5158,9 +5065,6 @@ Genesis::Genesis( ...@@ -5158,9 +5065,6 @@ Genesis::Genesis(
InitializeNormalizedMapCaches(); InitializeNormalizedMapCaches();
if (!InstallNatives(context_type)) return; if (!InstallNatives(context_type)) return;
MakeFunctionInstancePrototypeWritable();
if (!InstallExtraNatives()) return; if (!InstallExtraNatives()) return;
if (!ConfigureGlobalObjects(global_proxy_template)) return; if (!ConfigureGlobalObjects(global_proxy_template)) return;
......
...@@ -1514,9 +1514,17 @@ Handle<JSFunction> Factory::NewFunctionWithoutPrototype( ...@@ -1514,9 +1514,17 @@ Handle<JSFunction> Factory::NewFunctionWithoutPrototype(
Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
Handle<Object> prototype, Handle<Object> prototype,
LanguageMode language_mode) { LanguageMode language_mode,
Handle<Map> map = is_strict(language_mode) ? isolate()->strict_function_map() MutableMode prototype_mutability) {
Handle<Map> map;
if (prototype_mutability == MUTABLE) {
map = is_strict(language_mode) ? isolate()->strict_function_map()
: isolate()->sloppy_function_map(); : isolate()->sloppy_function_map();
} else {
map = is_strict(language_mode)
? isolate()->strict_function_with_readonly_prototype_map()
: isolate()->sloppy_function_with_readonly_prototype_map();
}
Handle<JSFunction> result = NewFunction(map, name, code); Handle<JSFunction> result = NewFunction(map, name, code);
result->set_prototype_or_initial_map(*prototype); result->set_prototype_or_initial_map(*prototype);
result->shared()->set_language_mode(language_mode); result->shared()->set_language_mode(language_mode);
...@@ -1526,10 +1534,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, ...@@ -1526,10 +1534,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
Handle<Object> prototype, Handle<Object> prototype,
InstanceType type, int instance_size, InstanceType type, int instance_size,
LanguageMode language_mode) { LanguageMode language_mode,
MutableMode prototype_mutability) {
// Allocate the function // Allocate the function
Handle<JSFunction> function = Handle<JSFunction> function =
NewFunction(name, code, prototype, language_mode); NewFunction(name, code, prototype, language_mode, prototype_mutability);
ElementsKind elements_kind = ElementsKind elements_kind =
type == JS_ARRAY_TYPE ? PACKED_SMI_ELEMENTS : HOLEY_SMI_ELEMENTS; type == JS_ARRAY_TYPE ? PACKED_SMI_ELEMENTS : HOLEY_SMI_ELEMENTS;
...@@ -2831,11 +2840,16 @@ Handle<String> Factory::ToPrimitiveHintString(ToPrimitiveHint hint) { ...@@ -2831,11 +2840,16 @@ Handle<String> Factory::ToPrimitiveHintString(ToPrimitiveHint hint) {
UNREACHABLE(); UNREACHABLE();
} }
Handle<Map> Factory::CreateSloppyFunctionMap(FunctionMode function_mode) { Handle<Map> Factory::CreateSloppyFunctionMap(
FunctionMode function_mode, MaybeHandle<JSFunction> maybe_empty_function) {
Handle<Map> map = NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); Handle<Map> map = NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
SetFunctionInstanceDescriptor(map, function_mode); SetFunctionInstanceDescriptor(map, function_mode);
map->set_is_constructor(IsFunctionModeWithPrototype(function_mode)); map->set_is_constructor(IsFunctionModeWithPrototype(function_mode));
map->set_is_callable(); map->set_is_callable();
Handle<JSFunction> empty_function;
if (maybe_empty_function.ToHandle(&empty_function)) {
Map::SetPrototype(map, empty_function);
}
return map; return map;
} }
......
...@@ -601,7 +601,8 @@ class V8_EXPORT_PRIVATE Factory final { ...@@ -601,7 +601,8 @@ class V8_EXPORT_PRIVATE Factory final {
PretenureFlag pretenure = TENURED); PretenureFlag pretenure = TENURED);
Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code, Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code,
Handle<Object> prototype, Handle<Object> prototype,
LanguageMode language_mode = SLOPPY); LanguageMode language_mode = SLOPPY,
MutableMode prototype_mutability = MUTABLE);
Handle<JSFunction> NewFunction(Handle<String> name); Handle<JSFunction> NewFunction(Handle<String> name);
Handle<JSFunction> NewFunctionWithoutPrototype( Handle<JSFunction> NewFunctionWithoutPrototype(
Handle<String> name, Handle<Code> code, Handle<String> name, Handle<Code> code,
...@@ -627,7 +628,8 @@ class V8_EXPORT_PRIVATE Factory final { ...@@ -627,7 +628,8 @@ class V8_EXPORT_PRIVATE Factory final {
Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code, Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code,
Handle<Object> prototype, InstanceType type, Handle<Object> prototype, InstanceType type,
int instance_size, int instance_size,
LanguageMode language_mode = SLOPPY); LanguageMode language_mode = SLOPPY,
MutableMode prototype_mutability = MUTABLE);
Handle<JSFunction> NewFunction(Handle<String> name, Handle<JSFunction> NewFunction(Handle<String> name,
Handle<Code> code, Handle<Code> code,
InstanceType type, InstanceType type,
...@@ -767,7 +769,8 @@ class V8_EXPORT_PRIVATE Factory final { ...@@ -767,7 +769,8 @@ class V8_EXPORT_PRIVATE Factory final {
function_mode == FUNCTION_WITH_READONLY_PROTOTYPE); function_mode == FUNCTION_WITH_READONLY_PROTOTYPE);
} }
Handle<Map> CreateSloppyFunctionMap(FunctionMode function_mode); Handle<Map> CreateSloppyFunctionMap(
FunctionMode function_mode, MaybeHandle<JSFunction> maybe_empty_function);
Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode, Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode,
Handle<JSFunction> empty_function); Handle<JSFunction> empty_function);
......
...@@ -1502,7 +1502,7 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) { ...@@ -1502,7 +1502,7 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<String> name = factory->empty_string(); Handle<String> name = factory->empty_string();
Handle<Map> sloppy_map = Handle<Map> sloppy_map =
factory->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); Map::CopyInitialMap(isolate->sloppy_function_map());
Handle<SharedFunctionInfo> info = factory->NewSharedFunctionInfo( Handle<SharedFunctionInfo> info = factory->NewSharedFunctionInfo(
name, MaybeHandle<Code>(), sloppy_map->is_constructor()); name, MaybeHandle<Code>(), sloppy_map->is_constructor());
function_type_ = FieldType::Class(sloppy_map, isolate); function_type_ = FieldType::Class(sloppy_map, isolate);
...@@ -2640,8 +2640,7 @@ TEST(TransitionDataConstantToAnotherDataConstant) { ...@@ -2640,8 +2640,7 @@ TEST(TransitionDataConstantToAnotherDataConstant) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<String> name = factory->empty_string(); Handle<String> name = factory->empty_string();
Handle<Map> sloppy_map = Handle<Map> sloppy_map = Map::CopyInitialMap(isolate->sloppy_function_map());
factory->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE);
Handle<SharedFunctionInfo> info = factory->NewSharedFunctionInfo( Handle<SharedFunctionInfo> info = factory->NewSharedFunctionInfo(
name, MaybeHandle<Code>(), sloppy_map->is_constructor()); name, MaybeHandle<Code>(), sloppy_map->is_constructor());
Handle<FieldType> function_type = FieldType::Class(sloppy_map, isolate); Handle<FieldType> function_type = FieldType::Class(sloppy_map, isolate);
......
...@@ -3,6 +3,19 @@ ...@@ -3,6 +3,19 @@
// found in the LICENSE file. // found in the LICENSE file.
function CheckNoPrototype(object) {
var desc = Object.getOwnPropertyDescriptor(object, "prototype");
assertEquals(undefined, desc);
}
function CheckReadonlyPrototype(object) {
var desc = Object.getOwnPropertyDescriptor(object, "prototype");
assertTrue(desc != undefined);
assertFalse(desc.enumerable);
assertFalse(desc.configurable);
assertFalse(desc.writable);
}
function CheckMethodEx(object, prop_name, function_name, length) { function CheckMethodEx(object, prop_name, function_name, length) {
var desc = Object.getOwnPropertyDescriptor(object, prop_name); var desc = Object.getOwnPropertyDescriptor(object, prop_name);
assertTrue(desc != undefined); assertTrue(desc != undefined);
...@@ -41,23 +54,54 @@ function CheckGetter(object, name) { ...@@ -41,23 +54,54 @@ function CheckGetter(object, name) {
} }
(function TestIntrinsicConstructors() {
CheckReadonlyPrototype(Object);
CheckReadonlyPrototype(Function);
CheckReadonlyPrototype(Number);
CheckReadonlyPrototype(Boolean);
CheckReadonlyPrototype(Symbol);
CheckReadonlyPrototype(Date);
CheckReadonlyPrototype(RegExp);
CheckReadonlyPrototype(DataView);
CheckReadonlyPrototype(ArrayBuffer);
var AsyncFunction = (async function(){}).constructor;
CheckReadonlyPrototype(AsyncFunction);
var GeneratorFunction = (function*(){}).constructor;
CheckReadonlyPrototype(GeneratorFunction);
CheckReadonlyPrototype(Error);
CheckReadonlyPrototype(SyntaxError);
CheckReadonlyPrototype(RangeError);
CheckReadonlyPrototype(TypeError);
CheckReadonlyPrototype(ReferenceError);
CheckReadonlyPrototype(EvalError);
CheckReadonlyPrototype(URIError);
CheckReadonlyPrototype(Error);
})();
(function TestIntl() { (function TestIntl() {
if (typeof (Intl) == "undefined") return; if (typeof (Intl) == "undefined") return;
CheckMethod(Intl, "getCanonicalLocales", 1); CheckMethod(Intl, "getCanonicalLocales", 1);
CheckReadonlyPrototype(Intl.Collator);
CheckMethod(Intl.Collator, "supportedLocalesOf", 1); CheckMethod(Intl.Collator, "supportedLocalesOf", 1);
CheckGetter(Intl.Collator.prototype, "compare"); CheckGetter(Intl.Collator.prototype, "compare");
CheckMethod(Intl.Collator.prototype, "resolvedOptions", 0); CheckMethod(Intl.Collator.prototype, "resolvedOptions", 0);
CheckReadonlyPrototype(Intl.NumberFormat);
CheckMethod(Intl.NumberFormat, "supportedLocalesOf", 1); CheckMethod(Intl.NumberFormat, "supportedLocalesOf", 1);
CheckGetter(Intl.NumberFormat.prototype, "format"); CheckGetter(Intl.NumberFormat.prototype, "format");
CheckMethod(Intl.NumberFormat.prototype, "resolvedOptions", 0); CheckMethod(Intl.NumberFormat.prototype, "resolvedOptions", 0);
CheckReadonlyPrototype(Intl.DateTimeFormat);
CheckMethod(Intl.DateTimeFormat, "supportedLocalesOf", 1); CheckMethod(Intl.DateTimeFormat, "supportedLocalesOf", 1);
CheckGetter(Intl.DateTimeFormat.prototype, "format"); CheckGetter(Intl.DateTimeFormat.prototype, "format");
CheckMethod(Intl.DateTimeFormat.prototype, "resolvedOptions", 0); CheckMethod(Intl.DateTimeFormat.prototype, "resolvedOptions", 0);
CheckMethod(Intl.DateTimeFormat.prototype, "formatToParts", 1); CheckMethod(Intl.DateTimeFormat.prototype, "formatToParts", 1);
CheckReadonlyPrototype(Intl.v8BreakIterator);
CheckMethod(Intl.v8BreakIterator, "supportedLocalesOf", 1); CheckMethod(Intl.v8BreakIterator, "supportedLocalesOf", 1);
CheckMethod(Intl.v8BreakIterator.prototype, "resolvedOptions", 0); CheckMethod(Intl.v8BreakIterator.prototype, "resolvedOptions", 0);
CheckGetter(Intl.v8BreakIterator.prototype, "adoptText"); CheckGetter(Intl.v8BreakIterator.prototype, "adoptText");
...@@ -79,6 +123,7 @@ function CheckGetter(object, name) { ...@@ -79,6 +123,7 @@ function CheckGetter(object, name) {
(function TestCollection() { (function TestCollection() {
CheckReadonlyPrototype(Set);
CheckMethod(Set.prototype, "add", 1); CheckMethod(Set.prototype, "add", 1);
CheckMethod(Set.prototype, "delete", 1); CheckMethod(Set.prototype, "delete", 1);
CheckMethod(Set.prototype, "entries", 0); CheckMethod(Set.prototype, "entries", 0);
...@@ -93,6 +138,7 @@ function CheckGetter(object, name) { ...@@ -93,6 +138,7 @@ function CheckGetter(object, name) {
undefined, undefined,
Object.getOwnPropertyDescriptor(SetIteratorPrototype, "constructor")); Object.getOwnPropertyDescriptor(SetIteratorPrototype, "constructor"));
CheckReadonlyPrototype(Map);
CheckMethod(Map.prototype, "set", 2); CheckMethod(Map.prototype, "set", 2);
CheckMethod(Map.prototype, "delete", 1); CheckMethod(Map.prototype, "delete", 1);
CheckMethod(Map.prototype, "entries", 0); CheckMethod(Map.prototype, "entries", 0);
...@@ -107,11 +153,13 @@ function CheckGetter(object, name) { ...@@ -107,11 +153,13 @@ function CheckGetter(object, name) {
undefined, undefined,
Object.getOwnPropertyDescriptor(MapIteratorPrototype, "constructor")); Object.getOwnPropertyDescriptor(MapIteratorPrototype, "constructor"));
CheckReadonlyPrototype(WeakSet);
assertEquals(0, WeakSet.length); assertEquals(0, WeakSet.length);
CheckMethod(WeakSet.prototype, "add", 1); CheckMethod(WeakSet.prototype, "add", 1);
CheckMethod(WeakSet.prototype, "delete", 1); CheckMethod(WeakSet.prototype, "delete", 1);
CheckMethod(WeakSet.prototype, "has", 1); CheckMethod(WeakSet.prototype, "has", 1);
CheckReadonlyPrototype(WeakMap);
assertEquals(0, WeakMap.length); assertEquals(0, WeakMap.length);
CheckMethod(WeakMap.prototype, "delete", 1); CheckMethod(WeakMap.prototype, "delete", 1);
CheckMethod(WeakMap.prototype, "get", 1); CheckMethod(WeakMap.prototype, "get", 1);
...@@ -123,6 +171,17 @@ function CheckGetter(object, name) { ...@@ -123,6 +171,17 @@ function CheckGetter(object, name) {
(function TestTypedArrays() { (function TestTypedArrays() {
var TypedArray = Uint8Array.__proto__; var TypedArray = Uint8Array.__proto__;
CheckReadonlyPrototype(Int8Array);
CheckReadonlyPrototype(Uint8Array);
CheckReadonlyPrototype(Uint8ClampedArray);
CheckReadonlyPrototype(Int16Array);
CheckReadonlyPrototype(Uint16Array);
CheckReadonlyPrototype(Int32Array);
CheckReadonlyPrototype(Uint32Array);
CheckReadonlyPrototype(Float32Array);
CheckReadonlyPrototype(Float64Array);
CheckReadonlyPrototype(TypedArray);
CheckMethod(TypedArray, "of", 0); CheckMethod(TypedArray, "of", 0);
CheckMethod(TypedArray, "from", 1); CheckMethod(TypedArray, "from", 1);
...@@ -139,6 +198,8 @@ function CheckGetter(object, name) { ...@@ -139,6 +198,8 @@ function CheckGetter(object, name) {
(function TestArray() { (function TestArray() {
CheckReadonlyPrototype(Array);
CheckMethod(Array, "of", 0); CheckMethod(Array, "of", 0);
CheckMethod(Array, "from", 1); CheckMethod(Array, "from", 1);
...@@ -176,16 +237,22 @@ function CheckGetter(object, name) { ...@@ -176,16 +237,22 @@ function CheckGetter(object, name) {
(function TestPromise() { (function TestPromise() {
CheckReadonlyPrototype(Promise);
CheckMethod(Promise, "all", 1);
CheckMethod(Promise, "race", 1); CheckMethod(Promise, "race", 1);
CheckMethod(Promise, "reject", 1);
CheckMethod(Promise, "resolve", 1);
})(); })();
(function TestProxy() { (function TestProxy() {
CheckNoPrototype(Proxy);
CheckMethod(Proxy, "revocable", 2); CheckMethod(Proxy, "revocable", 2);
})(); })();
(function TestString() { (function TestString() {
CheckReadonlyPrototype(String);
CheckMethod(String, "raw", 1); CheckMethod(String, "raw", 1);
CheckMethod(String.prototype, "codePointAt", 1); CheckMethod(String.prototype, "codePointAt", 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment