LibJS: Remove OOM handling from JS intrinsics initialization

This commit is contained in:
Timothy Flynn 2025-02-03 21:33:19 -05:00 committed by Tim Flynn
commit 49f1ef52ad
Notes: github-actions[bot] 2025-02-05 13:06:19 +00:00
3 changed files with 6 additions and 8 deletions

View file

@ -143,7 +143,7 @@ static void initialize_constructor(VM& vm, PropertyKey const& property_key, Obje
} }
// 9.3.2 CreateIntrinsics ( realmRec ), https://tc39.es/ecma262/#sec-createintrinsics // 9.3.2 CreateIntrinsics ( realmRec ), https://tc39.es/ecma262/#sec-createintrinsics
ThrowCompletionOr<GC::Ref<Intrinsics>> Intrinsics::create(Realm& realm) GC::Ref<Intrinsics> Intrinsics::create(Realm& realm)
{ {
auto& vm = realm.vm(); auto& vm = realm.vm();
@ -165,7 +165,7 @@ ThrowCompletionOr<GC::Ref<Intrinsics>> Intrinsics::create(Realm& realm)
// is the specified value of the function's [[Prototype]] internal slot. The // is the specified value of the function's [[Prototype]] internal slot. The
// creation of the intrinsics and their properties must be ordered to avoid // creation of the intrinsics and their properties must be ordered to avoid
// any dependencies upon objects that have not yet been created. // any dependencies upon objects that have not yet been created.
MUST_OR_THROW_OOM(intrinsics->initialize_intrinsics(realm)); intrinsics->initialize_intrinsics(realm);
// 3. Perform AddRestrictedFunctionProperties(realmRec.[[Intrinsics]].[[%Function.prototype%]], realmRec). // 3. Perform AddRestrictedFunctionProperties(realmRec.[[Intrinsics]].[[%Function.prototype%]], realmRec).
add_restricted_function_properties(static_cast<FunctionObject&>(*realm.intrinsics().function_prototype()), realm); add_restricted_function_properties(static_cast<FunctionObject&>(*realm.intrinsics().function_prototype()), realm);
@ -174,7 +174,7 @@ ThrowCompletionOr<GC::Ref<Intrinsics>> Intrinsics::create(Realm& realm)
return *intrinsics; return *intrinsics;
} }
ThrowCompletionOr<void> Intrinsics::initialize_intrinsics(Realm& realm) void Intrinsics::initialize_intrinsics(Realm& realm)
{ {
auto& vm = this->vm(); auto& vm = this->vm();
@ -271,8 +271,6 @@ ThrowCompletionOr<void> Intrinsics::initialize_intrinsics(Realm& realm)
m_json_parse_function = &json_object()->get_without_side_effects(vm.names.parse).as_function(); m_json_parse_function = &json_object()->get_without_side_effects(vm.names.parse).as_function();
m_json_stringify_function = &json_object()->get_without_side_effects(vm.names.stringify).as_function(); m_json_stringify_function = &json_object()->get_without_side_effects(vm.names.stringify).as_function();
m_object_prototype_to_string_function = &object_prototype()->get_without_side_effects(vm.names.toString).as_function(); m_object_prototype_to_string_function = &object_prototype()->get_without_side_effects(vm.names.toString).as_function();
return {};
} }
template<typename T> template<typename T>

View file

@ -18,7 +18,7 @@ class Intrinsics final : public Cell {
GC_DECLARE_ALLOCATOR(Intrinsics); GC_DECLARE_ALLOCATOR(Intrinsics);
public: public:
static ThrowCompletionOr<GC::Ref<Intrinsics>> create(Realm&); static GC::Ref<Intrinsics> create(Realm&);
GC::Ref<Shape> empty_object_shape() { return *m_empty_object_shape; } GC::Ref<Shape> empty_object_shape() { return *m_empty_object_shape; }
@ -107,7 +107,7 @@ private:
virtual void visit_edges(Visitor&) override; virtual void visit_edges(Visitor&) override;
ThrowCompletionOr<void> initialize_intrinsics(Realm&); void initialize_intrinsics(Realm&);
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
void initialize_##snake_name(); void initialize_##snake_name();

View file

@ -25,7 +25,7 @@ ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> Realm::initialize_host_define
auto realm = vm.heap().allocate<Realm>(); auto realm = vm.heap().allocate<Realm>();
// 2. Perform CreateIntrinsics(realm). // 2. Perform CreateIntrinsics(realm).
MUST(Intrinsics::create(*realm)); Intrinsics::create(*realm);
// FIXME: 3. Set realm.[[AgentSignifier]] to AgentSignifier(). // FIXME: 3. Set realm.[[AgentSignifier]] to AgentSignifier().