Преглед изворни кода

LibJS: Convert Object::construct() to NonnullGCPtr

Linus Groh пре 2 година
родитељ
комит
6ae79a84df
100 измењених фајлова са 193 додато и 193 уклоњено
  1. 3 3
      Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
  2. 2 2
      Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
  3. 2 2
      Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h
  4. 2 2
      Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
  5. 1 1
      Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h
  6. 4 4
      Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
  7. 1 1
      Userland/Libraries/LibJS/Runtime/ArrayConstructor.h
  8. 2 2
      Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
  9. 1 1
      Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h
  10. 2 2
      Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
  11. 1 1
      Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h
  12. 1 1
      Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
  13. 1 1
      Userland/Libraries/LibJS/Runtime/BigIntConstructor.h
  14. 2 2
      Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
  15. 1 1
      Userland/Libraries/LibJS/Runtime/BooleanConstructor.h
  16. 2 2
      Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
  17. 1 1
      Userland/Libraries/LibJS/Runtime/DataViewConstructor.h
  18. 2 2
      Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
  19. 1 1
      Userland/Libraries/LibJS/Runtime/DateConstructor.h
  20. 4 4
      Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
  21. 19 19
      Userland/Libraries/LibJS/Runtime/ErrorConstructor.h
  22. 2 2
      Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
  23. 1 1
      Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h
  24. 2 2
      Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
  25. 1 1
      Userland/Libraries/LibJS/Runtime/FunctionConstructor.h
  26. 2 2
      Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
  27. 1 1
      Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h
  28. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
  29. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h
  30. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
  31. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h
  32. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
  33. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h
  34. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
  35. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h
  36. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
  37. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h
  38. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
  39. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h
  40. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
  41. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h
  42. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
  43. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h
  44. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
  45. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h
  46. 2 2
      Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
  47. 1 1
      Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h
  48. 3 3
      Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
  49. 1 1
      Userland/Libraries/LibJS/Runtime/MapConstructor.h
  50. 1 1
      Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
  51. 1 1
      Userland/Libraries/LibJS/Runtime/NativeFunction.h
  52. 2 2
      Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
  53. 1 1
      Userland/Libraries/LibJS/Runtime/NumberConstructor.h
  54. 4 4
      Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
  55. 2 2
      Userland/Libraries/LibJS/Runtime/ObjectConstructor.h
  56. 2 2
      Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
  57. 2 2
      Userland/Libraries/LibJS/Runtime/PromiseConstructor.h
  58. 2 2
      Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
  59. 2 2
      Userland/Libraries/LibJS/Runtime/ProxyConstructor.h
  60. 2 2
      Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
  61. 1 1
      Userland/Libraries/LibJS/Runtime/RegExpConstructor.h
  62. 3 3
      Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
  63. 1 1
      Userland/Libraries/LibJS/Runtime/SetConstructor.h
  64. 2 2
      Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
  65. 2 2
      Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h
  66. 2 2
      Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
  67. 1 1
      Userland/Libraries/LibJS/Runtime/StringConstructor.h
  68. 1 1
      Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
  69. 1 1
      Userland/Libraries/LibJS/Runtime/SymbolConstructor.h
  70. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
  71. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h
  72. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
  73. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h
  74. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
  75. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h
  76. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
  77. 1 1
      Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h
  78. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
  79. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h
  80. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
  81. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h
  82. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
  83. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h
  84. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
  85. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h
  86. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
  87. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h
  88. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
  89. 2 2
      Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h
  90. 4 4
      Userland/Libraries/LibJS/Runtime/TypedArray.cpp
  91. 1 1
      Userland/Libraries/LibJS/Runtime/TypedArray.h
  92. 1 1
      Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
  93. 1 1
      Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h
  94. 3 3
      Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
  95. 1 1
      Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h
  96. 3 3
      Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
  97. 1 1
      Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h
  98. 3 3
      Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
  99. 1 1
      Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h
  100. 2 2
      Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp

+ 3 - 3
Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp

@@ -2004,7 +2004,7 @@ public:
     virtual ~@constructor_class@() override;
 
     virtual JS::ThrowCompletionOr<JS::Value> call() override;
-    virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override;
+    virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override;
 
 private:
     virtual bool has_constructor() const override { return true; }
@@ -2135,7 +2135,7 @@ JS::ThrowCompletionOr<JS::Value> @constructor_class@::call()
     return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "@name@");
 }
 
-JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject&)
+JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::construct(FunctionObject&)
 {
 )~~~");
 
@@ -2172,7 +2172,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject
 )~~~");
         }
         generator.append(R"~~~(
-    return &(*impl);
+    return *impl;
 )~~~");
     } else {
         // Multiple constructor overloads - can't do that yet.

+ 2 - 2
Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp

@@ -38,7 +38,7 @@ ThrowCompletionOr<Value> AggregateErrorConstructor::call()
 }
 
 // 20.5.7.1.1 AggregateError ( errors, message [ , options ] ), https://tc39.es/ecma262/#sec-aggregate-error
-ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> AggregateErrorConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
     auto& realm = *vm.current_realm();
@@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject&
     MUST(aggregate_error->define_property_or_throw(vm.names.errors, { .value = Array::create_from(realm, errors_list), .writable = true, .enumerable = false, .configurable = true }));
 
     // 7. Return O.
-    return aggregate_error.ptr();
+    return aggregate_error;
 }
 
 }

+ 2 - 2
Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~AggregateErrorConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit AggregateErrorConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp

@@ -44,7 +44,7 @@ ThrowCompletionOr<Value> ArrayBufferConstructor::call()
 }
 
 // 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length
-ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ArrayBufferConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
     auto byte_length_or_error = vm.argument(0).to_index(vm);
@@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new
         }
         return error;
     }
-    return TRY(allocate_array_buffer(vm, new_target, byte_length_or_error.release_value()));
+    return *TRY(allocate_array_buffer(vm, new_target, byte_length_or_error.release_value()));
 }
 
 // 25.1.4.1 ArrayBuffer.isView ( arg ), https://tc39.es/ecma262/#sec-arraybuffer.isview

+ 1 - 1
Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~ArrayBufferConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ArrayBufferConstructor(Realm&);

+ 4 - 4
Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp

@@ -47,7 +47,7 @@ ThrowCompletionOr<Value> ArrayConstructor::call()
 }
 
 // 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array
-ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ArrayConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
     auto& realm = *vm.current_realm();
@@ -55,7 +55,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
     auto* proto = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::array_prototype));
 
     if (vm.argument_count() == 0)
-        return MUST(Array::create(realm, 0, proto)).ptr();
+        return MUST(Array::create(realm, 0, proto));
 
     if (vm.argument_count() == 1) {
         auto length = vm.argument(0);
@@ -70,7 +70,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
                 return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array");
         }
         TRY(array->set(vm.names.length, Value(int_length), Object::ShouldThrowExceptions::Yes));
-        return array.ptr();
+        return array;
     }
 
     auto array = TRY(Array::create(realm, vm.argument_count(), proto));
@@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
     for (size_t k = 0; k < vm.argument_count(); ++k)
         MUST(array->create_data_property_or_throw(k, vm.argument(k)));
 
-    return array.ptr();
+    return array;
 }
 
 // 23.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-array.from

+ 1 - 1
Userland/Libraries/LibJS/Runtime/ArrayConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~ArrayConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ArrayConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp

@@ -35,7 +35,7 @@ ThrowCompletionOr<Value> AsyncFunctionConstructor::call()
 }
 
 // 27.7.1.1 AsyncFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-async-function-constructor-arguments
-ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> AsyncFunctionConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -46,7 +46,7 @@ ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& n
     auto& args = vm.running_execution_context().arguments;
 
     // 3. Return CreateDynamicFunction(C, NewTarget, async, args).
-    return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args));
+    return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~AsyncFunctionConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit AsyncFunctionConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp

@@ -36,7 +36,7 @@ ThrowCompletionOr<Value> AsyncGeneratorFunctionConstructor::call()
 }
 
 // 27.4.1.1 AsyncGeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-asyncgeneratorfunction
-ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -47,7 +47,7 @@ ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(Function
     auto& args = vm.running_execution_context().arguments;
 
     // 3. Return ? CreateDynamicFunction(C, NewTarget, asyncGenerator, args).
-    return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args));
+    return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~AsyncGeneratorFunctionConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit AsyncGeneratorFunctionConstructor(Realm&);

+ 1 - 1
Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp

@@ -56,7 +56,7 @@ ThrowCompletionOr<Value> BigIntConstructor::call()
 }
 
 // 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value
-ThrowCompletionOr<Object*> BigIntConstructor::construct(FunctionObject&)
+ThrowCompletionOr<NonnullGCPtr<Object>> BigIntConstructor::construct(FunctionObject&)
 {
     return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "BigInt");
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/BigIntConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~BigIntConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit BigIntConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp

@@ -37,12 +37,12 @@ ThrowCompletionOr<Value> BooleanConstructor::call()
 }
 
 // 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value
-ThrowCompletionOr<Object*> BooleanConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> BooleanConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
     auto b = vm.argument(0).to_boolean();
-    return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b)).ptr();
+    return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/BooleanConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~BooleanConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit BooleanConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp

@@ -38,7 +38,7 @@ ThrowCompletionOr<Value> DataViewConstructor::call()
 }
 
 // 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength
-ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> DataViewConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -72,7 +72,7 @@ ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_ta
     if (array_buffer.is_detached())
         return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer);
 
-    return data_view.ptr();
+    return data_view;
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/DataViewConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~DataViewConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit DataViewConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/DateConstructor.cpp

@@ -208,7 +208,7 @@ ThrowCompletionOr<Value> DateConstructor::call()
 }
 
 // 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date
-ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> DateConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -299,7 +299,7 @@ ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target
     // 6. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »).
     // 7. Set O.[[DateValue]] to dv.
     // 8. Return O.
-    return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value)).ptr();
+    return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value));
 }
 
 // 21.4.3.1 Date.now ( ), https://tc39.es/ecma262/#sec-date.now

+ 1 - 1
Userland/Libraries/LibJS/Runtime/DateConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~DateConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit DateConstructor(Realm&);

+ 4 - 4
Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp

@@ -35,7 +35,7 @@ ThrowCompletionOr<Value> ErrorConstructor::call()
 }
 
 // 20.5.1.1 Error ( message [ , options ] ), https://tc39.es/ecma262/#sec-error-message
-ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -58,7 +58,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
     TRY(error->install_error_cause(options));
 
     // 5. Return O.
-    return error.ptr();
+    return error;
 }
 
 #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType)                                        \
@@ -88,7 +88,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
     }                                                                                                                           \
                                                                                                                                 \
     /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */                            \
-    ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target)                                           \
+    ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target)                              \
     {                                                                                                                           \
         auto& vm = this->vm();                                                                                                  \
                                                                                                                                 \
@@ -111,7 +111,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
         TRY(error->install_error_cause(options));                                                                               \
                                                                                                                                 \
         /* 5. Return O. */                                                                                                      \
-        return error.ptr();                                                                                                     \
+        return error;                                                                                                           \
     }
 
 JS_ENUMERATE_NATIVE_ERRORS

+ 19 - 19
Userland/Libraries/LibJS/Runtime/ErrorConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -19,7 +19,7 @@ public:
     virtual ~ErrorConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ErrorConstructor(Realm&);
@@ -27,23 +27,23 @@ private:
     virtual bool has_constructor() const override { return true; }
 };
 
-#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
-    class ConstructorName final : public NativeFunction {                                       \
-        JS_OBJECT(ConstructorName, NativeFunction);                                             \
-                                                                                                \
-    public:                                                                                     \
-        virtual void initialize(Realm&) override;                                               \
-        virtual ~ConstructorName() override;                                                    \
-        virtual ThrowCompletionOr<Value> call() override;                                       \
-        virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;      \
-                                                                                                \
-    private:                                                                                    \
-        explicit ConstructorName(Realm&);                                                       \
-                                                                                                \
-        virtual bool has_constructor() const override                                           \
-        {                                                                                       \
-            return true;                                                                        \
-        }                                                                                       \
+#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName)         \
+    class ConstructorName final : public NativeFunction {                                               \
+        JS_OBJECT(ConstructorName, NativeFunction);                                                     \
+                                                                                                        \
+    public:                                                                                             \
+        virtual void initialize(Realm&) override;                                                       \
+        virtual ~ConstructorName() override;                                                            \
+        virtual ThrowCompletionOr<Value> call() override;                                               \
+        virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \
+                                                                                                        \
+    private:                                                                                            \
+        explicit ConstructorName(Realm&);                                                               \
+                                                                                                        \
+        virtual bool has_constructor() const override                                                   \
+        {                                                                                               \
+            return true;                                                                                \
+        }                                                                                               \
     };
 
 #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \

+ 2 - 2
Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp

@@ -37,7 +37,7 @@ ThrowCompletionOr<Value> FinalizationRegistryConstructor::call()
 }
 
 // 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback
-ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> FinalizationRegistryConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionOb
     // 7. Set finalizationRegistry.[[Cells]] to a new empty List.
     // NOTE: This is done inside FinalizationRegistry instead of here.
     // 8. Return finalizationRegistry.
-    return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function()))).ptr();
+    return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function())));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~FinalizationRegistryConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit FinalizationRegistryConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp

@@ -265,7 +265,7 @@ ThrowCompletionOr<Value> FunctionConstructor::call()
 }
 
 // 20.2.1.1 Function ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-function-p1-p2-pn-body
-ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> FunctionConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -276,7 +276,7 @@ ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_ta
     auto& args = vm.running_execution_context().arguments;
 
     // 3. Return ? CreateDynamicFunction(C, NewTarget, normal, args).
-    return TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args));
+    return *TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/FunctionConstructor.h

@@ -21,7 +21,7 @@ public:
     virtual ~FunctionConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit FunctionConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp

@@ -34,7 +34,7 @@ ThrowCompletionOr<Value> GeneratorFunctionConstructor::call()
 }
 
 // 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction
-ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> GeneratorFunctionConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -45,7 +45,7 @@ ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObjec
     auto& args = vm.running_execution_context().arguments;
 
     // 3. Return ? CreateDynamicFunction(C, NewTarget, generator, args).
-    return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args));
+    return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h

@@ -19,7 +19,7 @@ public:
     virtual ~GeneratorFunctionConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit GeneratorFunctionConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp

@@ -157,7 +157,7 @@ ThrowCompletionOr<Value> CollatorConstructor::call()
 }
 
 // 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator
-ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> CollatorConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -174,7 +174,7 @@ ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_ta
     auto collator = TRY(ordinary_create_from_constructor<Collator>(vm, new_target, &Intrinsics::intl_collator_prototype));
 
     // 6. Return ? InitializeCollator(collator, locales, options).
-    return TRY(initialize_collator(vm, collator, locales, options));
+    return *TRY(initialize_collator(vm, collator, locales, options));
 }
 
 // 10.2.2 Intl.Collator.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.collator.supportedlocalesof

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~CollatorConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit CollatorConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> DateTimeFormatConstructor::call()
 }
 
 // 11.1.1 Intl.DateTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat
-ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> DateTimeFormatConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -64,7 +64,7 @@ ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject&
     //     b. Return ? ChainDateTimeFormat(dateTimeFormat, NewTarget, this).
 
     // 5. Return dateTimeFormat.
-    return date_time_format.ptr();
+    return date_time_format;
 }
 
 // 11.2.2 Intl.DateTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat.supportedlocalesof

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~DateTimeFormatConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit DateTimeFormatConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp

@@ -44,7 +44,7 @@ ThrowCompletionOr<Value> DisplayNamesConstructor::call()
 }
 
 // 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames
-ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> DisplayNamesConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -130,7 +130,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne
     // 29. Set displayNames.[[Fields]] to styleFields.
 
     // 30. Return displayNames.
-    return display_names.ptr();
+    return display_names;
 }
 
 // 12.2.2 Intl.DisplayNames.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.supportedLocalesOf

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~DisplayNamesConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit DisplayNamesConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp

@@ -42,7 +42,7 @@ ThrowCompletionOr<Value> DurationFormatConstructor::call()
 }
 
 // 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat
-ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> DurationFormatConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -138,7 +138,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
     duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, 0))));
 
     // 19. Return durationFormat.
-    return duration_format.ptr();
+    return duration_format;
 }
 
 // 1.3.2 Intl.DurationFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.supportedLocalesOf

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~DurationFormatConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit DurationFormatConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp

@@ -43,7 +43,7 @@ ThrowCompletionOr<Value> ListFormatConstructor::call()
 }
 
 // 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat
-ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ListFormatConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -91,7 +91,7 @@ ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_
     // Note: The remaining steps are skipped in favor of deferring to LibUnicode.
 
     // 19. Return listFormat.
-    return list_format.ptr();
+    return list_format;
 }
 
 // 13.2.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~ListFormatConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ListFormatConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp

@@ -241,7 +241,7 @@ ThrowCompletionOr<Value> LocaleConstructor::call()
 }
 
 // 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale
-ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> LocaleConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -362,7 +362,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ
         locale->set_numbering_system(result.nu.release_value());
 
     // 37. Return locale.
-    return locale.ptr();
+    return locale;
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~LocaleConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit LocaleConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp

@@ -42,7 +42,7 @@ ThrowCompletionOr<Value> NumberFormatConstructor::call()
 }
 
 // 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat
-ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> NumberFormatConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -60,7 +60,7 @@ ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& ne
     //     b. Return ? ChainNumberFormat(numberFormat, NewTarget, this).
 
     // 5. Return numberFormat.
-    return number_format.ptr();
+    return number_format;
 }
 
 // 15.2.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h

@@ -19,7 +19,7 @@ public:
     virtual ~NumberFormatConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit NumberFormatConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp

@@ -43,7 +43,7 @@ ThrowCompletionOr<Value> PluralRulesConstructor::call()
 }
 
 // 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules
-ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PluralRulesConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -54,7 +54,7 @@ ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new
     auto plural_rules = TRY(ordinary_create_from_constructor<PluralRules>(vm, new_target, &Intrinsics::intl_plural_rules_prototype));
 
     // 3. Return ? InitializePluralRules(pluralRules, locales, options).
-    return TRY(initialize_plural_rules(vm, plural_rules, locales, options));
+    return *TRY(initialize_plural_rules(vm, plural_rules, locales, options));
 }
 
 // 16.2.2 Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.pluralrules.supportedlocalesof

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~PluralRulesConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PluralRulesConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> RelativeTimeFormatConstructor::call()
 }
 
 // 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat
-ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> RelativeTimeFormatConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObje
     auto relative_time_format = TRY(ordinary_create_from_constructor<RelativeTimeFormat>(vm, new_target, &Intrinsics::intl_relative_time_format_prototype));
 
     // 3. Return ? InitializeRelativeTimeFormat(relativeTimeFormat, locales, options).
-    return TRY(initialize_relative_time_format(vm, relative_time_format, locales, options));
+    return *TRY(initialize_relative_time_format(vm, relative_time_format, locales, options));
 }
 
 // 17.2.2 Intl.RelativeTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~RelativeTimeFormatConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit RelativeTimeFormatConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp

@@ -42,7 +42,7 @@ ThrowCompletionOr<Value> SegmenterConstructor::call()
 }
 
 // 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter
-ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> SegmenterConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -83,7 +83,7 @@ ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_t
     segmenter->set_segmenter_granularity(granularity.as_string().deprecated_string());
 
     // 14. Return segmenter.
-    return segmenter.ptr();
+    return segmenter;
 }
 
 // 18.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.segmenter.supportedlocalesof

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~SegmenterConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit SegmenterConstructor(Realm&);

+ 3 - 3
Userland/Libraries/LibJS/Runtime/MapConstructor.cpp

@@ -39,14 +39,14 @@ ThrowCompletionOr<Value> MapConstructor::call()
 }
 
 // 24.1.1.1 Map ( [ iterable ] ), https://tc39.es/ecma262/#sec-map-iterable
-ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
     auto map = TRY(ordinary_create_from_constructor<Map>(vm, new_target, &Intrinsics::map_prototype));
 
     if (vm.argument(0).is_nullish())
-        return map.ptr();
+        return map;
 
     auto adder = TRY(map->get(vm.names.set));
     if (!adder.is_function())
@@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target)
         return {};
     }));
 
-    return map.ptr();
+    return map;
 }
 
 // 24.1.2.2 get Map [ @@species ], https://tc39.es/ecma262/#sec-get-map-@@species

+ 1 - 1
Userland/Libraries/LibJS/Runtime/MapConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~MapConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit MapConstructor(Realm&);

+ 1 - 1
Userland/Libraries/LibJS/Runtime/NativeFunction.cpp

@@ -227,7 +227,7 @@ ThrowCompletionOr<Value> NativeFunction::call()
     return m_native_function(vm());
 }
 
-ThrowCompletionOr<Object*> NativeFunction::construct(FunctionObject&)
+ThrowCompletionOr<NonnullGCPtr<Object>> NativeFunction::construct(FunctionObject&)
 {
     // Needs to be overridden if [[Construct]] is needed.
     VERIFY_NOT_REACHED();

+ 1 - 1
Userland/Libraries/LibJS/Runtime/NativeFunction.h

@@ -32,7 +32,7 @@ public:
     // Used for [[Call]] / [[Construct]]'s "...result of evaluating F in a manner that conforms to the specification of F".
     // Needs to be overridden by all NativeFunctions without an m_native_function.
     virtual ThrowCompletionOr<Value> call();
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target);
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target);
 
     virtual FlyString const& name() const override { return m_name; };
     virtual bool is_strict_mode() const override;

+ 2 - 2
Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp

@@ -90,7 +90,7 @@ ThrowCompletionOr<Value> NumberConstructor::call()
 }
 
 // 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value
-ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> NumberConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
     // NOTE: get_value_from_constructor_argument performs steps 1 and 2 and returns n.
@@ -99,7 +99,7 @@ ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_targ
     // 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Number.prototype%", « [[NumberData]] »).
     // 5. Set O.[[NumberData]] to n.
     // 6. Return O.
-    return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double())).ptr();
+    return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double()));
 }
 
 // 21.1.2.2 Number.isFinite ( number ), https://tc39.es/ecma262/#sec-number.isfinite

+ 1 - 1
Userland/Libraries/LibJS/Runtime/NumberConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~NumberConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit NumberConstructor(Realm&);

+ 4 - 4
Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp

@@ -64,17 +64,17 @@ ThrowCompletionOr<Value> ObjectConstructor::call()
 }
 
 // 20.1.1.1 Object ( [ value ] ), https://tc39.es/ecma262/#sec-object-value
-ThrowCompletionOr<Object*> ObjectConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ObjectConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
     auto& realm = *vm.current_realm();
 
     if (&new_target != this)
-        return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag)).ptr();
+        return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag));
     auto value = vm.argument(0);
     if (value.is_nullish())
-        return Object::create(realm, realm.intrinsics().object_prototype()).ptr();
-    return value.to_object(vm);
+        return Object::create(realm, realm.intrinsics().object_prototype());
+    return *TRY(value.to_object(vm));
 }
 
 enum class GetOwnPropertyKeysType {

+ 2 - 2
Userland/Libraries/LibJS/Runtime/ObjectConstructor.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -19,7 +19,7 @@ public:
     virtual ~ObjectConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ObjectConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp

@@ -275,7 +275,7 @@ ThrowCompletionOr<Value> PromiseConstructor::call()
 }
 
 // 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor
-ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PromiseConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -305,7 +305,7 @@ ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_tar
     }
 
     // 11. Return promise.
-    return promise.ptr();
+    return promise;
 }
 
 // 27.2.4.1 Promise.all ( iterable ), https://tc39.es/ecma262/#sec-promise.all

+ 2 - 2
Userland/Libraries/LibJS/Runtime/PromiseConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~PromiseConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PromiseConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp

@@ -47,10 +47,10 @@ ThrowCompletionOr<Value> ProxyConstructor::call()
 }
 
 // 28.2.1.1 Proxy ( target, handler ), https://tc39.es/ecma262/#sec-proxy-target-handler
-ThrowCompletionOr<Object*> ProxyConstructor::construct(FunctionObject&)
+ThrowCompletionOr<NonnullGCPtr<Object>> ProxyConstructor::construct(FunctionObject&)
 {
     auto& vm = this->vm();
-    return TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
+    return *TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
 }
 
 // 28.2.2.1 Proxy.revocable ( target, handler ), https://tc39.es/ecma262/#sec-proxy.revocable

+ 2 - 2
Userland/Libraries/LibJS/Runtime/ProxyConstructor.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -19,7 +19,7 @@ public:
     virtual ~ProxyConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ProxyConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp

@@ -80,7 +80,7 @@ ThrowCompletionOr<Value> RegExpConstructor::call()
 }
 
 // 22.2.3.1 RegExp ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp-pattern-flags
-ThrowCompletionOr<Object*> RegExpConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> RegExpConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -137,7 +137,7 @@ ThrowCompletionOr<Object*> RegExpConstructor::construct(FunctionObject& new_targ
     auto regexp_object = TRY(regexp_alloc(vm, new_target));
 
     // 8. Return ? RegExpInitialize(O, P, F).
-    return TRY(regexp_object->regexp_initialize(vm, pattern_value, flags_value)).ptr();
+    return TRY(regexp_object->regexp_initialize(vm, pattern_value, flags_value));
 }
 
 // 22.2.4.2 get RegExp [ @@species ], https://tc39.es/ecma262/#sec-get-regexp-@@species

+ 1 - 1
Userland/Libraries/LibJS/Runtime/RegExpConstructor.h

@@ -19,7 +19,7 @@ public:
     virtual ~RegExpConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
     RegExpLegacyStaticProperties& legacy_static_properties() { return m_legacy_static_properties; }
 

+ 3 - 3
Userland/Libraries/LibJS/Runtime/SetConstructor.cpp

@@ -39,14 +39,14 @@ ThrowCompletionOr<Value> SetConstructor::call()
 }
 
 // 24.2.1.1 Set ( [ iterable ] ), https://tc39.es/ecma262/#sec-set-iterable
-ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> SetConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
     auto set = TRY(ordinary_create_from_constructor<Set>(vm, new_target, &Intrinsics::set_prototype));
 
     if (vm.argument(0).is_nullish())
-        return set.ptr();
+        return set;
 
     auto adder = TRY(set->get(vm.names.add));
     if (!adder.is_function())
@@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target)
         return {};
     }));
 
-    return set.ptr();
+    return set;
 }
 
 // 24.2.2.2 get Set [ @@species ], https://tc39.es/ecma262/#sec-get-set-@@species

+ 1 - 1
Userland/Libraries/LibJS/Runtime/SetConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~SetConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit SetConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp

@@ -37,7 +37,7 @@ ThrowCompletionOr<Value> ShadowRealmConstructor::call()
 }
 
 // 3.2.1 ShadowRealm ( ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm
-ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -71,7 +71,7 @@ ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new
     global_object.initialize(object->shadow_realm());
 
     // 13. Return O.
-    return object.ptr();
+    return object;
 }
 
 }

+ 2 - 2
Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~ShadowRealmConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ShadowRealmConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/StringConstructor.cpp

@@ -50,7 +50,7 @@ ThrowCompletionOr<Value> StringConstructor::call()
 }
 
 // 22.1.1.1 String ( value ), https://tc39.es/ecma262/#sec-string-constructor-string-value
-ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> StringConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
     auto& realm = *vm.current_realm();
@@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_targ
     else
         primitive_string = TRY(vm.argument(0).to_primitive_string(vm));
     auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype));
-    return StringObject::create(realm, *primitive_string, *prototype).ptr();
+    return StringObject::create(realm, *primitive_string, *prototype);
 }
 
 // 22.1.2.4 String.raw ( template, ...substitutions ), https://tc39.es/ecma262/#sec-string.raw

+ 1 - 1
Userland/Libraries/LibJS/Runtime/StringConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~StringConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit StringConstructor(Realm&);

+ 1 - 1
Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> SymbolConstructor::call()
 }
 
 // 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description
-ThrowCompletionOr<Object*> SymbolConstructor::construct(FunctionObject&)
+ThrowCompletionOr<NonnullGCPtr<Object>> SymbolConstructor::construct(FunctionObject&)
 {
     return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "Symbol");
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/SymbolConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~SymbolConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit SymbolConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp

@@ -42,7 +42,7 @@ ThrowCompletionOr<Value> CalendarConstructor::call()
 }
 
 // 12.2.1 Temporal.Calendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal.calendar
-ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> CalendarConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_ta
     }
 
     // 4. Return ? CreateTemporalCalendar(id, NewTarget).
-    return TRY(create_temporal_calendar(vm, identifier, &new_target));
+    return *TRY(create_temporal_calendar(vm, identifier, &new_target));
 }
 
 // 12.3.2 Temporal.Calendar.from ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~CalendarConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit CalendarConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> DurationConstructor::call()
 }
 
 // 7.1.1 Temporal.Duration ( [ years [ , months [ , weeks [ , days [ , hours [ , minutes [ , seconds [ , milliseconds [ , microseconds [ , nanoseconds ] ] ] ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration
-ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> DurationConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -81,7 +81,7 @@ ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_ta
     auto ns = TRY(to_integer_if_integral(vm, vm.argument(9), ErrorType::TemporalInvalidDuration));
 
     // 12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).
-    return TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
+    return *TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
 }
 
 // 7.2.2 Temporal.Duration.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.duration.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~DurationConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit DurationConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp

@@ -49,7 +49,7 @@ ThrowCompletionOr<Value> InstantConstructor::call()
 }
 
 // 8.1.1 Temporal.Instant ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant
-ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> InstantConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_tar
         return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
 
     // 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget).
-    return TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target));
+    return *TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target));
 }
 
 // 8.2.2 Temporal.Instant.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~InstantConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit InstantConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainDateConstructor::call()
 }
 
 // 3.1.1 Temporal.PlainDate ( isoYear, isoMonth, isoDay [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate
-ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PlainDateConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_t
         return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate);
 
     // 6. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget).
-    return TRY(create_temporal_date(vm, y, m, d, *calendar, &new_target));
+    return *TRY(create_temporal_date(vm, y, m, d, *calendar, &new_target));
 }
 
 // 3.2.2 Temporal.PlainDate.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.from

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~PlainDateConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PlainDateConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainDateTimeConstructor::call()
 }
 
 // 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime
-ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PlainDateTimeConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -88,7 +88,7 @@ ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& n
         return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime);
 
     // 12. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, NewTarget).
-    return TRY(create_temporal_date_time(vm, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target));
+    return *TRY(create_temporal_date_time(vm, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target));
 }
 
 // 5.2.2 Temporal.PlainDateTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~PlainDateTimeConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PlainDateTimeConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp

@@ -44,7 +44,7 @@ ThrowCompletionOr<Value> PlainMonthDayConstructor::call()
 }
 
 // 10.1.1 Temporal.PlainMonthDay ( isoMonth, isoDay [ , calendarLike [ , referenceISOYear ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday
-ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PlainMonthDayConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& n
         return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay);
 
     // 7. Return ? CreateTemporalMonthDay(m, d, calendar, ref, NewTarget).
-    return TRY(create_temporal_month_day(vm, m, d, *calendar, ref, &new_target));
+    return *TRY(create_temporal_month_day(vm, m, d, *calendar, ref, &new_target));
 }
 
 // 10.2.2 Temporal.PlainMonthDay.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~PlainMonthDayConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PlainMonthDayConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp

@@ -44,7 +44,7 @@ ThrowCompletionOr<Value> PlainTimeConstructor::call()
 }
 
 // 4.1.1 Temporal.PlainTime ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime
-ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PlainTimeConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -74,7 +74,7 @@ ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_t
         return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainTime);
 
     // 8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget).
-    return TRY(create_temporal_time(vm, hour, minute, second, millisecond, microsecond, nanosecond, &new_target));
+    return *TRY(create_temporal_time(vm, hour, minute, second, millisecond, microsecond, nanosecond, &new_target));
 }
 
 // 4.2.2 Temporal.PlainTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~PlainTimeConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PlainTimeConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp

@@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainYearMonthConstructor::call()
 }
 
 // 9.1.1 Temporal.PlainYearMonth ( isoYear, isoMonth [ , calendarLike [ , referenceISODay ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth
-ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> PlainYearMonthConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -80,7 +80,7 @@ ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject&
         return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth);
 
     // 7. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget).
-    return TRY(create_temporal_year_month(vm, y, m, *calendar, ref, &new_target));
+    return *TRY(create_temporal_year_month(vm, y, m, *calendar, ref, &new_target));
 }
 
 // 9.2.2 Temporal.PlainYearMonth.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~PlainYearMonthConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit PlainYearMonthConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp

@@ -43,7 +43,7 @@ ThrowCompletionOr<Value> TimeZoneConstructor::call()
 }
 
 // 11.2.1 Temporal.TimeZone ( identifier ), https://tc39.es/proposal-temporal/#sec-temporal.timezone
-ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> TimeZoneConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_ta
     }
 
     // 4. Return ? CreateTemporalTimeZone(identifier, NewTarget).
-    return TRY(create_temporal_time_zone(vm, identifier, &new_target));
+    return *TRY(create_temporal_time_zone(vm, identifier, &new_target));
 }
 
 // 11.3.2 Temporal.TimeZone.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~TimeZoneConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit TimeZoneConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp

@@ -48,7 +48,7 @@ ThrowCompletionOr<Value> ZonedDateTimeConstructor::call()
 }
 
 // 6.1.1 Temporal.ZonedDateTime ( epochNanoseconds, timeZoneLike [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime
-ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> ZonedDateTimeConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -66,7 +66,7 @@ ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& n
     auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, vm.argument(2)));
 
     // 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget).
-    return TRY(create_temporal_zoned_date_time(vm, *epoch_nanoseconds, *time_zone, *calendar, &new_target));
+    return *TRY(create_temporal_zoned_date_time(vm, *epoch_nanoseconds, *time_zone, *calendar, &new_target));
 }
 
 // 6.2.2 Temporal.ZonedDateTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.from

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -18,7 +18,7 @@ public:
     virtual ~ZonedDateTimeConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 private:
     explicit ZonedDateTimeConstructor(Realm&);

+ 4 - 4
Userland/Libraries/LibJS/Runtime/TypedArray.cpp

@@ -505,13 +505,13 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
     }                                                                                                                            \
                                                                                                                                  \
     /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */                                               \
-    ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target)                                            \
+    ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target)                               \
     {                                                                                                                            \
         auto& vm = this->vm();                                                                                                   \
         auto& realm = *vm.current_realm();                                                                                       \
                                                                                                                                  \
         if (vm.argument_count() == 0)                                                                                            \
-            return TRY(ClassName::create(realm, 0, new_target)).ptr();                                                           \
+            return TRY(ClassName::create(realm, 0, new_target));                                                                 \
                                                                                                                                  \
         auto first_argument = vm.argument(0);                                                                                    \
         if (first_argument.is_object()) {                                                                                        \
@@ -532,7 +532,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
                     TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object()));                   \
                 }                                                                                                                \
             }                                                                                                                    \
-            return typed_array.ptr();                                                                                            \
+            return typed_array;                                                                                                  \
         }                                                                                                                        \
                                                                                                                                  \
         auto array_length_or_error = first_argument.to_index(vm);                                                                \
@@ -550,7 +550,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
         /* FIXME: What is the best/correct behavior here? */                                                                     \
         if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type)))                                             \
             return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array");                                     \
-        return TRY(ClassName::create(realm, array_length, new_target)).ptr();                                                    \
+        return TRY(ClassName::create(realm, array_length, new_target));                                                          \
     }
 
 #undef __JS_ENUMERATE

+ 1 - 1
Userland/Libraries/LibJS/Runtime/TypedArray.h

@@ -493,7 +493,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(VM&, Value x, Value y, Fu
         virtual ~ConstructorName() override;                                                                      \
                                                                                                                   \
         virtual ThrowCompletionOr<Value> call() override;                                                         \
-        virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;                        \
+        virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;           \
                                                                                                                   \
     private:                                                                                                      \
         explicit ConstructorName(Realm&, Object& prototype);                                                      \

+ 1 - 1
Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp

@@ -45,7 +45,7 @@ ThrowCompletionOr<Value> TypedArrayConstructor::call()
 }
 
 // 23.2.1.1 %TypedArray% ( ), https://tc39.es/ecma262/#sec-%typedarray%
-ThrowCompletionOr<Object*> TypedArrayConstructor::construct(FunctionObject&)
+ThrowCompletionOr<NonnullGCPtr<Object>> TypedArrayConstructor::construct(FunctionObject&)
 {
     return vm().throw_completion<TypeError>(ErrorType::ClassIsAbstract, "TypedArray");
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h

@@ -19,7 +19,7 @@ public:
     virtual ~TypedArrayConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
 
 protected:
     TypedArrayConstructor(FlyString const& name, Object& prototype);

+ 3 - 3
Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp

@@ -37,14 +37,14 @@ ThrowCompletionOr<Value> WeakMapConstructor::call()
 }
 
 // 24.3.1.1 WeakMap ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakmap-iterable
-ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> WeakMapConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
     auto weak_map = TRY(ordinary_create_from_constructor<WeakMap>(vm, new_target, &Intrinsics::weak_map_prototype));
 
     if (vm.argument(0).is_nullish())
-        return weak_map.ptr();
+        return weak_map;
 
     auto adder = TRY(weak_map->get(vm.names.set));
     if (!adder.is_function())
@@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_tar
         return {};
     }));
 
-    return weak_map.ptr();
+    return weak_map;
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~WeakMapConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit WeakMapConstructor(Realm&);

+ 3 - 3
Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp

@@ -36,7 +36,7 @@ ThrowCompletionOr<Value> WeakRefConstructor::call()
 }
 
 // 26.1.1.1 WeakRef ( target ), https://tc39.es/ecma262/#sec-weak-ref-target
-ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> WeakRefConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
@@ -45,9 +45,9 @@ ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_tar
         return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects());
 
     if (target.is_object())
-        return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object())).ptr();
+        return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object()));
     VERIFY(target.is_symbol());
-    return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol())).ptr();
+    return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol()));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~WeakRefConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit WeakRefConstructor(Realm&);

+ 3 - 3
Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp

@@ -37,14 +37,14 @@ ThrowCompletionOr<Value> WeakSetConstructor::call()
 }
 
 // 24.4.1.1 WeakSet ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakset-iterable
-ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_target)
+ThrowCompletionOr<NonnullGCPtr<Object>> WeakSetConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
 
     auto weak_set = TRY(ordinary_create_from_constructor<WeakSet>(vm, new_target, &Intrinsics::weak_set_prototype));
 
     if (vm.argument(0).is_nullish())
-        return weak_set.ptr();
+        return weak_set;
 
     auto adder = TRY(weak_set->get(vm.names.add));
     if (!adder.is_function())
@@ -55,7 +55,7 @@ ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_tar
         return {};
     }));
 
-    return weak_set.ptr();
+    return weak_set;
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h

@@ -18,7 +18,7 @@ public:
     virtual ~WeakSetConstructor() override = default;
 
     virtual ThrowCompletionOr<Value> call() override;
-    virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
+    virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
 
 private:
     explicit WeakSetConstructor(Realm&);

+ 2 - 2
Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp

@@ -33,7 +33,7 @@ JS::ThrowCompletionOr<JS::Value> AudioConstructor::call()
 }
 
 // https://html.spec.whatwg.org/multipage/media.html#dom-audio
-JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
+JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> AudioConstructor::construct(FunctionObject&)
 {
     auto& vm = this->vm();
 
@@ -57,7 +57,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
     }
 
     // 5. Return audio.
-    return audio.ptr();
+    return audio;
 }
 
 }

Неке датотеке нису приказане због велике количине промена