Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/init/bootstrapper.cc')
-rw-r--r--deps/v8/src/init/bootstrapper.cc547
1 files changed, 168 insertions, 379 deletions
diff --git a/deps/v8/src/init/bootstrapper.cc b/deps/v8/src/init/bootstrapper.cc
index 22d33eaf919..f4049e328ec 100644
--- a/deps/v8/src/init/bootstrapper.cc
+++ b/deps/v8/src/init/bootstrapper.cc
@@ -25,6 +25,7 @@
#endif // ENABLE_VTUNE_TRACEMARK
#include "src/heap/heap-inl.h"
#include "src/logging/counters.h"
+#include "src/logging/log.h"
#include "src/numbers/math-random.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/arguments.h"
@@ -33,6 +34,7 @@
#ifdef V8_INTL_SUPPORT
#include "src/objects/intl-objects.h"
#endif // V8_INTL_SUPPORT
+#include "src/objects/js-aggregate-error.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#ifdef V8_INTL_SUPPORT
@@ -188,7 +190,7 @@ class Genesis {
// Creates the global objects using the global proxy and the template passed
// in through the API. We call this regardless of whether we are building a
- // context from scratch or using a deserialized one from the partial snapshot
+ // context from scratch or using a deserialized one from the context snapshot
// but in the latter case we don't use the objects it produces directly, as
// we have to use the deserialized ones that are linked together with the
// rest of the context snapshot. At the end we link the global proxy and the
@@ -361,32 +363,11 @@ void Bootstrapper::DetachGlobal(Handle<Context> env) {
isolate_->AddDetachedContext(env);
}
- env->native_context().set_microtask_queue(nullptr);
+ env->native_context().set_microtask_queue(isolate_, nullptr);
}
namespace {
-V8_NOINLINE Handle<SharedFunctionInfo> SimpleCreateSharedFunctionInfo(
- Isolate* isolate, Builtins::Name builtin_id, Handle<String> name, int len,
- FunctionKind kind = FunctionKind::kNormalFunction) {
- Handle<SharedFunctionInfo> shared =
- isolate->factory()->NewSharedFunctionInfoForBuiltin(name, builtin_id,
- kind);
- shared->set_internal_formal_parameter_count(len);
- shared->set_length(len);
- return shared;
-}
-
-V8_NOINLINE Handle<SharedFunctionInfo> SimpleCreateBuiltinSharedFunctionInfo(
- Isolate* isolate, Builtins::Name builtin_id, Handle<String> name, int len) {
- Handle<SharedFunctionInfo> shared =
- isolate->factory()->NewSharedFunctionInfoForBuiltin(name, builtin_id,
- kNormalFunction);
- shared->set_internal_formal_parameter_count(len);
- shared->set_length(len);
- return shared;
-}
-
V8_NOINLINE Handle<JSFunction> CreateFunction(
Isolate* isolate, Handle<String> name, InstanceType type, int instance_size,
int inobject_properties, Handle<HeapObject> prototype,
@@ -1334,21 +1315,24 @@ static void InstallWithIntrinsicDefaultProto(Isolate* isolate,
isolate->native_context()->set(context_index, *function);
}
-static void InstallError(Isolate* isolate, Handle<JSObject> global,
- Handle<String> name, int context_index) {
+static void InstallError(
+ Isolate* isolate, Handle<JSObject> global, Handle<String> name,
+ int context_index,
+ Builtins::Name error_constructor = Builtins::kErrorConstructor,
+ InstanceType error_type = JS_ERROR_TYPE, int error_function_length = 1,
+ int header_size = JSObject::kHeaderSize) {
Factory* factory = isolate->factory();
// Most Error objects consist of a message and a stack trace.
// Reserve two in-object properties for these.
const int kInObjectPropertiesCount = 2;
const int kErrorObjectSize =
- JSObject::kHeaderSize + kInObjectPropertiesCount * kTaggedSize;
- Handle<JSFunction> error_fun =
- InstallFunction(isolate, global, name, JS_ERROR_TYPE, kErrorObjectSize,
- kInObjectPropertiesCount, factory->the_hole_value(),
- Builtins::kErrorConstructor);
+ header_size + kInObjectPropertiesCount * kTaggedSize;
+ Handle<JSFunction> error_fun = InstallFunction(
+ isolate, global, name, error_type, kErrorObjectSize,
+ kInObjectPropertiesCount, factory->the_hole_value(), error_constructor);
error_fun->shared().DontAdaptArguments();
- error_fun->shared().set_length(1);
+ error_fun->shared().set_length(error_function_length);
if (context_index == Context::ERROR_FUNCTION_INDEX) {
SimpleInstallFunction(isolate, error_fun, "captureStackTrace",
@@ -1396,20 +1380,6 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
}
}
-namespace {
-
-void InstallMakeError(Isolate* isolate, int builtin_id, int context_index) {
- NewFunctionArgs args = NewFunctionArgs::ForBuiltinWithPrototype(
- isolate->factory()->empty_string(), isolate->factory()->the_hole_value(),
- JS_OBJECT_TYPE, JSObject::kHeaderSize, 0, builtin_id, MUTABLE);
-
- Handle<JSFunction> function = isolate->factory()->NewFunction(args);
- function->shared().DontAdaptArguments();
- isolate->native_context()->set(context_index, *function);
-}
-
-} // namespace
-
// This is only called if we are not using snapshots. The equivalent
// work in the snapshot case is done in HookUpGlobalObject.
void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
@@ -1622,47 +1592,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
}
}
- { // --- A s y n c F r o m S y n c I t e r a t o r
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncIteratorValueUnwrap, factory->empty_string(),
- 1);
- native_context()->set_async_iterator_value_unwrap_shared_fun(*info);
- }
-
- { // --- A s y n c G e n e r a t o r ---
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncGeneratorAwaitResolveClosure,
- factory->empty_string(), 1);
- native_context()->set_async_generator_await_resolve_shared_fun(*info);
-
- info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncGeneratorAwaitRejectClosure,
- factory->empty_string(), 1);
- native_context()->set_async_generator_await_reject_shared_fun(*info);
-
- info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncGeneratorYieldResolveClosure,
- factory->empty_string(), 1);
- native_context()->set_async_generator_yield_resolve_shared_fun(*info);
-
- info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncGeneratorReturnResolveClosure,
- factory->empty_string(), 1);
- native_context()->set_async_generator_return_resolve_shared_fun(*info);
-
- info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncGeneratorReturnClosedResolveClosure,
- factory->empty_string(), 1);
- native_context()->set_async_generator_return_closed_resolve_shared_fun(
- *info);
-
- info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kAsyncGeneratorReturnClosedRejectClosure,
- factory->empty_string(), 1);
- native_context()->set_async_generator_return_closed_reject_shared_fun(
- *info);
- }
-
Handle<JSFunction> array_prototype_to_string_fun;
{ // --- A r r a y ---
Handle<JSFunction> array_function = InstallFunction(
@@ -2345,13 +2274,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
}
- {
- Handle<SharedFunctionInfo> info = SimpleCreateBuiltinSharedFunctionInfo(
- isolate_, Builtins::kPromiseGetCapabilitiesExecutor,
- factory->empty_string(), 2);
- native_context()->set_promise_get_capabilities_executor_shared_fun(*info);
- }
-
{ // -- P r o m i s e
Handle<JSFunction> promise_fun = InstallFunction(
isolate_, global, "Promise", JS_PROMISE_TYPE,
@@ -2398,89 +2320,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallFunctionWithBuiltinId(isolate_, prototype, "finally",
Builtins::kPromisePrototypeFinally, 1, true);
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate(), Builtins::kPromiseThenFinally,
- isolate_->factory()->empty_string(), 1);
- info->set_native(true);
- native_context()->set_promise_then_finally_shared_fun(*info);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate(), Builtins::kPromiseCatchFinally,
- isolate_->factory()->empty_string(), 1);
- info->set_native(true);
- native_context()->set_promise_catch_finally_shared_fun(*info);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate(), Builtins::kPromiseValueThunkFinally,
- isolate_->factory()->empty_string(), 0);
- native_context()->set_promise_value_thunk_finally_shared_fun(*info);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate(), Builtins::kPromiseThrowerFinally,
- isolate_->factory()->empty_string(), 0);
- native_context()->set_promise_thrower_finally_shared_fun(*info);
- }
-
- // Force the Promise constructor to fast properties, so that we can use the
- // fast paths for various things like
- //
- // x instanceof Promise
- //
- // etc. We should probably come up with a more principled approach once
- // the JavaScript builtins are gone.
- JSObject::MigrateSlowToFast(Handle<JSObject>::cast(promise_fun), 0,
- "Bootstrapping");
+ DCHECK(promise_fun->HasFastProperties());
Handle<Map> prototype_map(prototype->map(), isolate());
Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate_);
- { // Internal: IsPromise
- Handle<JSFunction> function = SimpleCreateFunction(
- isolate_, factory->empty_string(), Builtins::kIsPromise, 1, false);
- native_context()->set_is_promise(*function);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kPromiseCapabilityDefaultResolve,
- factory->empty_string(), 1, FunctionKind::kConciseMethod);
- info->set_native(true);
- info->set_function_map_index(
- Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
- native_context()->set_promise_capability_default_resolve_shared_fun(
- *info);
-
- info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kPromiseCapabilityDefaultReject,
- factory->empty_string(), 1, FunctionKind::kConciseMethod);
- info->set_native(true);
- info->set_function_map_index(
- Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
- native_context()->set_promise_capability_default_reject_shared_fun(*info);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kPromiseAllResolveElementClosure,
- factory->empty_string(), 1);
- native_context()->set_promise_all_resolve_element_shared_fun(*info);
- }
-
- // Force the Promise constructor to fast properties, so that we can use the
- // fast paths for various things like
- //
- // x instanceof Promise
- //
- // etc. We should probably come up with a more principled approach once
- // the JavaScript builtins are gone.
- JSObject::MigrateSlowToFast(promise_fun, 0, "Bootstrapping");
+ DCHECK(promise_fun->HasFastProperties());
}
{ // -- R e g E x p
@@ -2674,14 +2519,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
native_context()->set_regexp_species_protector(*cell);
}
- // Force the RegExp constructor to fast properties, so that we can use the
- // fast paths for various things like
- //
- // x instanceof RegExp
- //
- // etc. We should probably come up with a more principled approach once
- // the JavaScript builtins are gone.
- JSObject::MigrateSlowToFast(regexp_fun, 0, "Bootstrapping");
+ DCHECK(regexp_fun->HasFastProperties());
}
{ // --- R e g E x p S t r i n g I t e r a t o r ---
@@ -2709,49 +2547,33 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
regexp_string_iterator_function->initial_map());
}
- { // -- E r r o r
- InstallError(isolate_, global, factory->Error_string(),
- Context::ERROR_FUNCTION_INDEX);
- InstallMakeError(isolate_, Builtins::kMakeError, Context::MAKE_ERROR_INDEX);
- }
+ // -- E r r o r
+ InstallError(isolate_, global, factory->Error_string(),
+ Context::ERROR_FUNCTION_INDEX);
- { // -- E v a l E r r o r
- InstallError(isolate_, global, factory->EvalError_string(),
- Context::EVAL_ERROR_FUNCTION_INDEX);
- }
+ // -- E v a l E r r o r
+ InstallError(isolate_, global, factory->EvalError_string(),
+ Context::EVAL_ERROR_FUNCTION_INDEX);
- { // -- R a n g e E r r o r
- InstallError(isolate_, global, factory->RangeError_string(),
- Context::RANGE_ERROR_FUNCTION_INDEX);
- InstallMakeError(isolate_, Builtins::kMakeRangeError,
- Context::MAKE_RANGE_ERROR_INDEX);
- }
+ // -- R a n g e E r r o r
+ InstallError(isolate_, global, factory->RangeError_string(),
+ Context::RANGE_ERROR_FUNCTION_INDEX);
- { // -- R e f e r e n c e E r r o r
- InstallError(isolate_, global, factory->ReferenceError_string(),
- Context::REFERENCE_ERROR_FUNCTION_INDEX);
- }
+ // -- R e f e r e n c e E r r o r
+ InstallError(isolate_, global, factory->ReferenceError_string(),
+ Context::REFERENCE_ERROR_FUNCTION_INDEX);
- { // -- S y n t a x E r r o r
- InstallError(isolate_, global, factory->SyntaxError_string(),
- Context::SYNTAX_ERROR_FUNCTION_INDEX);
- InstallMakeError(isolate_, Builtins::kMakeSyntaxError,
- Context::MAKE_SYNTAX_ERROR_INDEX);
- }
+ // -- S y n t a x E r r o r
+ InstallError(isolate_, global, factory->SyntaxError_string(),
+ Context::SYNTAX_ERROR_FUNCTION_INDEX);
- { // -- T y p e E r r o r
- InstallError(isolate_, global, factory->TypeError_string(),
- Context::TYPE_ERROR_FUNCTION_INDEX);
- InstallMakeError(isolate_, Builtins::kMakeTypeError,
- Context::MAKE_TYPE_ERROR_INDEX);
- }
+ // -- T y p e E r r o r
+ InstallError(isolate_, global, factory->TypeError_string(),
+ Context::TYPE_ERROR_FUNCTION_INDEX);
- { // -- U R I E r r o r
- InstallError(isolate_, global, factory->URIError_string(),
- Context::URI_ERROR_FUNCTION_INDEX);
- InstallMakeError(isolate_, Builtins::kMakeURIError,
- Context::MAKE_URI_ERROR_INDEX);
- }
+ // -- U R I E r r o r
+ InstallError(isolate_, global, factory->URIError_string(),
+ Context::URI_ERROR_FUNCTION_INDEX);
{ // -- C o m p i l e E r r o r
Handle<JSObject> dummy = factory->NewJSObject(isolate_->object_function());
@@ -3203,6 +3025,37 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->numberingSystem_string(),
Builtins::kLocalePrototypeNumberingSystem, true);
}
+
+ { // -- D i s p l a y N a m e s
+ Handle<JSFunction> display_names_fun = InstallFunction(
+ isolate(), intl, "DisplayNames", JS_DISPLAY_NAMES_TYPE,
+ JSDisplayNames::kHeaderSize, 0, factory->the_hole_value(),
+ Builtins::kDisplayNamesConstructor);
+ display_names_fun->shared().set_length(0);
+ display_names_fun->shared().DontAdaptArguments();
+ InstallWithIntrinsicDefaultProto(
+ isolate(), display_names_fun,
+ Context::INTL_DISPLAY_NAMES_FUNCTION_INDEX);
+
+ SimpleInstallFunction(isolate(), display_names_fun, "supportedLocalesOf",
+ Builtins::kDisplayNamesSupportedLocalesOf, 1,
+ false);
+
+ {
+ // Setup %DisplayNamesPrototype%.
+ Handle<JSObject> prototype(
+ JSObject::cast(display_names_fun->instance_prototype()), isolate());
+
+ InstallToStringTag(isolate(), prototype, "Intl.DisplayNames");
+
+ SimpleInstallFunction(isolate(), prototype, "resolvedOptions",
+ Builtins::kDisplayNamesPrototypeResolvedOptions,
+ 0, false);
+
+ SimpleInstallFunction(isolate(), prototype, "of",
+ Builtins::kDisplayNamesPrototypeOf, 1, false);
+ }
+ }
}
#endif // V8_INTL_SUPPORT
@@ -3494,6 +3347,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
native_context()->set_initial_map_prototype_map(prototype->map());
InstallSpeciesGetter(isolate_, js_map_fun);
+
+ DCHECK(js_map_fun->HasFastProperties());
+
+ native_context()->set_js_map_map(js_map_fun->initial_map());
}
{ // -- B i g I n t
@@ -3586,6 +3443,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
native_context()->set_initial_set_prototype(*prototype);
InstallSpeciesGetter(isolate_, js_set_fun);
+
+ DCHECK(js_set_fun->HasFastProperties());
+
+ native_context()->set_js_set_map(js_set_fun->initial_map());
}
{ // -- J S M o d u l e N a m e s p a c e
@@ -3734,12 +3595,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(isolate_, proxy_function, "revocable",
Builtins::kProxyRevocable, 2, true);
-
- { // Internal: ProxyRevoke
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kProxyRevoke, factory->empty_string(), 0);
- native_context()->set_proxy_revoke_shared_fun(*info);
- }
}
{ // -- R e f l e c t
@@ -3748,11 +3603,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->NewJSObject(isolate_->object_function(), AllocationType::kOld);
JSObject::AddProperty(isolate_, global, reflect_string, reflect, DONT_ENUM);
- SimpleInstallFunction(isolate_, reflect, "defineProperty",
- Builtins::kReflectDefineProperty, 3, true);
+ SimpleInstallFunction(isolate_, reflect, "defineProperty",
+ Builtins::kReflectDefineProperty, 3, true);
- SimpleInstallFunction(isolate_, reflect, "deleteProperty",
- Builtins::kReflectDeleteProperty, 2, true);
+ SimpleInstallFunction(isolate_, reflect, "deleteProperty",
+ Builtins::kReflectDeleteProperty, 2, true);
Handle<JSFunction> apply = SimpleInstallFunction(
isolate_, reflect, "apply", Builtins::kReflectApply, 3, false);
@@ -3975,9 +3830,12 @@ Handle<JSFunction> Genesis::InstallTypedArray(const char* name,
void Genesis::InitializeExperimentalGlobal() {
#define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id();
- HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL)
- HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
+ // Initialize features from more mature to less mature, because less mature
+ // features may depend on more mature features having been initialized
+ // already.
HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL)
+ HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
+ HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL)
#undef FEATURE_INITIALIZE_GLOBAL
}
@@ -4191,20 +4049,6 @@ void Genesis::InitializeIteratorFunctions() {
Handle<Map> async_function_object_map = factory->NewMap(
JS_ASYNC_FUNCTION_OBJECT_TYPE, JSAsyncFunctionObject::kHeaderSize);
native_context->set_async_function_object_map(*async_function_object_map);
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate, Builtins::kAsyncFunctionAwaitRejectClosure,
- factory->empty_string(), 1);
- native_context->set_async_function_await_reject_shared_fun(*info);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate, Builtins::kAsyncFunctionAwaitResolveClosure,
- factory->empty_string(), 1);
- native_context->set_async_function_await_resolve_shared_fun(*info);
- }
}
}
@@ -4273,17 +4117,14 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_private_methods)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_dynamic_import)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_import_meta)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_sequence)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_optional_chaining)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_nullish)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_top_level_await)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_logical_assignment)
#ifdef V8_INTL_SUPPORT
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_add_calendar_numbering_system)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_displaynames_date_types)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_dateformat_day_period)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(
harmony_intl_dateformat_fractional_second_digits)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_other_calendars)
#endif // V8_INTL_SUPPORT
#undef EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE
@@ -4308,17 +4149,11 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
{
- // Create %FinalizationRegistryPrototype%
- Handle<String> finalization_registry_name =
- factory->NewStringFromStaticChars("FinalizationRegistry");
- Handle<JSObject> finalization_registry_prototype = factory->NewJSObject(
- isolate()->object_function(), AllocationType::kOld);
-
// Create %FinalizationRegistry%
- Handle<JSFunction> finalization_registry_fun = CreateFunction(
- isolate(), finalization_registry_name, JS_FINALIZATION_REGISTRY_TYPE,
- JSFinalizationRegistry::kHeaderSize, 0, finalization_registry_prototype,
- Builtins::kFinalizationRegistryConstructor);
+ Handle<JSFunction> finalization_registry_fun = InstallFunction(
+ isolate(), global, factory->FinalizationRegistry_string(),
+ JS_FINALIZATION_REGISTRY_TYPE, JSFinalizationRegistry::kHeaderSize, 0,
+ factory->the_hole_value(), Builtins::kFinalizationRegistryConstructor);
InstallWithIntrinsicDefaultProto(
isolate(), finalization_registry_fun,
Context::JS_FINALIZATION_REGISTRY_FUNCTION_INDEX);
@@ -4326,16 +4161,12 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
finalization_registry_fun->shared().DontAdaptArguments();
finalization_registry_fun->shared().set_length(1);
- // Install the "constructor" property on the prototype.
- JSObject::AddProperty(isolate(), finalization_registry_prototype,
- factory->constructor_string(),
- finalization_registry_fun, DONT_ENUM);
+ Handle<JSObject> finalization_registry_prototype(
+ JSObject::cast(finalization_registry_fun->instance_prototype()),
+ isolate());
InstallToStringTag(isolate(), finalization_registry_prototype,
- finalization_registry_name);
-
- JSObject::AddProperty(isolate(), global, finalization_registry_name,
- finalization_registry_fun, DONT_ENUM);
+ factory->FinalizationRegistry_string());
SimpleInstallFunction(isolate(), finalization_registry_prototype,
"register", Builtins::kFinalizationRegistryRegister,
@@ -4345,89 +4176,100 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
"unregister",
Builtins::kFinalizationRegistryUnregister, 1, false);
- SimpleInstallFunction(isolate(), finalization_registry_prototype,
- "cleanupSome",
- Builtins::kFinalizationRegistryCleanupSome, 0, false);
+ // The cleanupSome function is created but not exposed, as it is used
+ // internally by InvokeFinalizationRegistryCleanupFromTask.
+ //
+ // It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
+ Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction(
+ isolate(), factory->InternalizeUtf8String("cleanupSome"),
+ Builtins::kFinalizationRegistryPrototypeCleanupSome, 0, false);
+ native_context()->set_finalization_registry_cleanup_some(*cleanup_some_fun);
}
{
- // Create %WeakRefPrototype%
- Handle<Map> weak_ref_map =
- factory->NewMap(JS_WEAK_REF_TYPE, JSWeakRef::kHeaderSize);
- DCHECK(weak_ref_map->IsJSObjectMap());
+ // Create %WeakRef%
+ Handle<JSFunction> weak_ref_fun = InstallFunction(
+ isolate(), global, factory->WeakRef_string(), JS_WEAK_REF_TYPE,
+ JSWeakRef::kHeaderSize, 0, factory->the_hole_value(),
+ Builtins::kWeakRefConstructor);
+ InstallWithIntrinsicDefaultProto(isolate(), weak_ref_fun,
+ Context::JS_WEAK_REF_FUNCTION_INDEX);
- Handle<JSObject> weak_ref_prototype = factory->NewJSObject(
- isolate()->object_function(), AllocationType::kOld);
- Map::SetPrototype(isolate(), weak_ref_map, weak_ref_prototype);
+ weak_ref_fun->shared().DontAdaptArguments();
+ weak_ref_fun->shared().set_length(1);
+
+ Handle<JSObject> weak_ref_prototype(
+ JSObject::cast(weak_ref_fun->instance_prototype()), isolate());
InstallToStringTag(isolate(), weak_ref_prototype,
factory->WeakRef_string());
SimpleInstallFunction(isolate(), weak_ref_prototype, "deref",
Builtins::kWeakRefDeref, 0, false);
+ }
+}
- // Create %WeakRef%
- Handle<String> weak_ref_name = factory->InternalizeUtf8String("WeakRef");
- Handle<JSFunction> weak_ref_fun = CreateFunction(
- isolate(), weak_ref_name, JS_WEAK_REF_TYPE, JSWeakRef::kHeaderSize, 0,
- weak_ref_prototype, Builtins::kWeakRefConstructor);
- InstallWithIntrinsicDefaultProto(isolate(), weak_ref_fun,
- Context::JS_WEAK_REF_FUNCTION_INDEX);
+void Genesis::InitializeGlobal_harmony_weak_refs_with_cleanup_some() {
+ if (!FLAG_harmony_weak_refs_with_cleanup_some) return;
+ DCHECK(FLAG_harmony_weak_refs);
- weak_ref_fun->shared().DontAdaptArguments();
- weak_ref_fun->shared().set_length(1);
+ Handle<JSFunction> finalization_registry_fun =
+ isolate()->js_finalization_registry_fun();
+ Handle<JSObject> finalization_registry_prototype(
+ JSObject::cast(finalization_registry_fun->instance_prototype()),
+ isolate());
- // Install the "constructor" property on the prototype.
- JSObject::AddProperty(isolate(), weak_ref_prototype,
- factory->constructor_string(), weak_ref_fun,
- DONT_ENUM);
+ JSObject::AddProperty(isolate(), finalization_registry_prototype,
+ factory()->InternalizeUtf8String("cleanupSome"),
+ isolate()->finalization_registry_cleanup_some(),
+ DONT_ENUM);
+}
- JSObject::AddProperty(isolate(), global, weak_ref_name, weak_ref_fun,
- DONT_ENUM);
+void Genesis::InitializeGlobal_harmony_promise_any() {
+ if (!FLAG_harmony_promise_any) {
+ return;
}
- {
- // Create cleanup iterator for JSFinalizationRegistry.
- Handle<JSObject> iterator_prototype(
- native_context()->initial_iterator_prototype(), isolate());
+ Factory* factory = isolate()->factory();
+ Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
- Handle<JSObject> cleanup_iterator_prototype = factory->NewJSObject(
- isolate()->object_function(), AllocationType::kOld);
- JSObject::ForceSetPrototype(cleanup_iterator_prototype, iterator_prototype);
+ InstallError(isolate_, global, factory->AggregateError_string(),
+ Context::AGGREGATE_ERROR_FUNCTION_INDEX,
+ Builtins::kAggregateErrorConstructor, JS_AGGREGATE_ERROR_TYPE, 2,
+ JSAggregateError::kHeaderSize);
- InstallToStringTag(isolate(), cleanup_iterator_prototype,
- "FinalizationRegistry Cleanup Iterator");
+ // Setup %AggregateErrorPrototype%.
+ Handle<JSFunction> aggregate_error_function(
+ native_context()->aggregate_error_function(), isolate());
+ Handle<JSObject> prototype(
+ JSObject::cast(aggregate_error_function->instance_prototype()),
+ isolate());
- SimpleInstallFunction(isolate(), cleanup_iterator_prototype, "next",
- Builtins::kFinalizationRegistryCleanupIteratorNext, 0,
- true);
- Handle<Map> cleanup_iterator_map =
- factory->NewMap(JS_FINALIZATION_REGISTRY_CLEANUP_ITERATOR_TYPE,
- JSFinalizationRegistryCleanupIterator::kHeaderSize);
- Map::SetPrototype(isolate(), cleanup_iterator_map,
- cleanup_iterator_prototype);
- native_context()->set_js_finalization_registry_cleanup_iterator_map(
- *cleanup_iterator_map);
- }
+ Handle<String> getter_name =
+ Name::ToFunctionName(isolate_, factory->errors_string(),
+ isolate_->factory()->get_string())
+ .ToHandleChecked();
+
+ Handle<JSFunction> getter = SimpleCreateFunction(
+ isolate(), getter_name, Builtins::kAggregateErrorPrototypeErrorsGetter, 0,
+ true);
+
+ JSObject::DefineAccessor(prototype, factory->errors_string(), getter,
+ factory->undefined_value(), DONT_ENUM);
+
+ Handle<JSFunction> promise_fun(
+ JSFunction::cast(
+ isolate()->native_context()->get(Context::PROMISE_FUNCTION_INDEX)),
+ isolate());
+ InstallFunctionWithBuiltinId(isolate_, promise_fun, "any",
+ Builtins::kPromiseAny, 1, true);
+
+ DCHECK(promise_fun->HasFastProperties());
}
void Genesis::InitializeGlobal_harmony_promise_all_settled() {
if (!FLAG_harmony_promise_all_settled) return;
SimpleInstallFunction(isolate(), isolate()->promise_function(), "allSettled",
Builtins::kPromiseAllSettled, 1, true);
- Factory* factory = isolate()->factory();
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kPromiseAllSettledResolveElementClosure,
- factory->empty_string(), 1);
- native_context()->set_promise_all_settled_resolve_element_shared_fun(*info);
- }
-
- {
- Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
- isolate_, Builtins::kPromiseAllSettledRejectElementClosure,
- factory->empty_string(), 1);
- native_context()->set_promise_all_settled_reject_element_shared_fun(*info);
- }
}
void Genesis::InitializeGlobal_harmony_regexp_match_indices() {
@@ -4535,43 +4377,6 @@ void Genesis::InitializeGlobal_harmony_intl_segmenter() {
}
}
-void Genesis::InitializeGlobal_harmony_intl_displaynames() {
- if (!FLAG_harmony_intl_displaynames) return;
- Handle<JSObject> intl = Handle<JSObject>::cast(
- JSReceiver::GetProperty(
- isolate(),
- Handle<JSReceiver>(native_context()->global_object(), isolate()),
- factory()->InternalizeUtf8String("Intl"))
- .ToHandleChecked());
-
- Handle<JSFunction> display_names_fun = InstallFunction(
- isolate(), intl, "DisplayNames", JS_DISPLAY_NAMES_TYPE,
- JSDisplayNames::kHeaderSize, 0, factory()->the_hole_value(),
- Builtins::kDisplayNamesConstructor);
- display_names_fun->shared().set_length(0);
- display_names_fun->shared().DontAdaptArguments();
- InstallWithIntrinsicDefaultProto(isolate_, display_names_fun,
- Context::INTL_DISPLAY_NAMES_FUNCTION_INDEX);
-
- SimpleInstallFunction(isolate(), display_names_fun, "supportedLocalesOf",
- Builtins::kDisplayNamesSupportedLocalesOf, 1, false);
-
- {
- // Setup %DisplayNamesPrototype%.
- Handle<JSObject> prototype(
- JSObject::cast(display_names_fun->instance_prototype()), isolate());
-
- InstallToStringTag(isolate(), prototype, "Intl.DisplayNames");
-
- SimpleInstallFunction(isolate(), prototype, "resolvedOptions",
- Builtins::kDisplayNamesPrototypeResolvedOptions, 0,
- false);
-
- SimpleInstallFunction(isolate(), prototype, "of",
- Builtins::kDisplayNamesPrototypeOf, 1, false);
- }
-}
-
#endif // V8_INTL_SUPPORT
Handle<JSFunction> Genesis::CreateArrayBuffer(
@@ -5152,22 +4957,6 @@ bool Genesis::ConfigureGlobalObjects(
native_context()->set_array_buffer_map(
native_context()->array_buffer_fun().initial_map());
- Handle<JSFunction> js_map_fun(native_context()->js_map_fun(), isolate());
- Handle<JSFunction> js_set_fun(native_context()->js_set_fun(), isolate());
- // Force the Map/Set constructor to fast properties, so that we can use the
- // fast paths for various things like
- //
- // x instanceof Map
- // x instanceof Set
- //
- // etc. We should probably come up with a more principled approach once
- // the JavaScript builtins are gone.
- JSObject::MigrateSlowToFast(js_map_fun, 0, "Bootstrapping");
- JSObject::MigrateSlowToFast(js_set_fun, 0, "Bootstrapping");
-
- native_context()->set_js_map_map(js_map_fun->initial_map());
- native_context()->set_js_set_map(js_set_fun->initial_map());
-
return true;
}
@@ -5451,8 +5240,8 @@ Genesis::Genesis(
}
native_context()->set_microtask_queue(
- microtask_queue ? static_cast<MicrotaskQueue*>(microtask_queue)
- : isolate->default_microtask_queue());
+ isolate, microtask_queue ? static_cast<MicrotaskQueue*>(microtask_queue)
+ : isolate->default_microtask_queue());
// Install experimental natives. Do not include them into the
// snapshot as we should be able to turn them off at runtime. Re-installing