Jelajahi Sumber

Rename ExceptionHelper to Throw and shorter method names (#2148)

Marko Lahma 1 Minggu lalu
induk
melakukan
8f106a7c1f
100 mengubah file dengan 460 tambahan dan 460 penghapusan
  1. 1 1
      Jint.Tests.Test262/Test262ModuleLoader.cs
  2. 3 3
      Jint/AstExtensions.cs
  3. 1 1
      Jint/Collections/ListDictionary.cs
  4. 2 2
      Jint/Collections/ObjectTraverseStack.cs
  5. 1 1
      Jint/Collections/RefStack.cs
  6. 1 1
      Jint/Constraints/CancellationConstraint.cs
  7. 1 1
      Jint/Constraints/MaxStatementsConstraint.cs
  8. 2 2
      Jint/Constraints/MemoryLimitConstraint.cs
  9. 1 1
      Jint/Constraints/TimeConstraint.cs
  10. 4 4
      Jint/Engine.Modules.cs
  11. 19 19
      Jint/Engine.cs
  12. 3 3
      Jint/Extensions/AcornimaExtensions.cs
  13. 1 1
      Jint/Extensions/ReflectionExtensions.cs
  14. 13 13
      Jint/JsValueExtensions.cs
  15. 4 4
      Jint/Native/Array/ArrayConstructor.cs
  16. 6 6
      Jint/Native/Array/ArrayInstance.cs
  17. 1 1
      Jint/Native/Array/ArrayIteratorPrototype.cs
  18. 2 2
      Jint/Native/Array/ArrayOperations.cs
  19. 19 19
      Jint/Native/Array/ArrayPrototype.cs
  20. 2 2
      Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs
  21. 14 14
      Jint/Native/ArrayBuffer/ArrayBufferPrototype.cs
  22. 1 1
      Jint/Native/AsyncGenerator/AsyncGeneratorPrototype.cs
  23. 3 3
      Jint/Native/Atomics/AtomicsInstance.cs
  24. 1 1
      Jint/Native/BigInt/BigIntConstructor.cs
  25. 3 3
      Jint/Native/BigInt/BigIntPrototype.cs
  26. 1 1
      Jint/Native/Boolean/BooleanPrototype.cs
  27. 1 1
      Jint/Native/Constructor.cs
  28. 8 8
      Jint/Native/DataView/DataViewConstructor.cs
  29. 11 11
      Jint/Native/DataView/DataViewPrototype.cs
  30. 8 8
      Jint/Native/Date/DatePrototype.cs
  31. 1 1
      Jint/Native/Disposable/AsyncDisposableStackConstructor.cs
  32. 1 1
      Jint/Native/Disposable/AsyncDisposableStackPrototype.cs
  33. 2 2
      Jint/Native/Disposable/DisposableStack.cs
  34. 1 1
      Jint/Native/Disposable/DisposableStackConstructor.cs
  35. 1 1
      Jint/Native/Disposable/DisposableStackPrototype.cs
  36. 2 2
      Jint/Native/Disposable/DisposeCapability.cs
  37. 1 1
      Jint/Native/Error/ErrorPrototype.cs
  38. 2 2
      Jint/Native/FinalizationRegistry/FinalizationRegistryConstructor.cs
  39. 5 5
      Jint/Native/FinalizationRegistry/FinalizationRegistryPrototype.cs
  40. 3 3
      Jint/Native/Function/BindFunction.cs
  41. 3 3
      Jint/Native/Function/ClassDefinition.cs
  42. 5 5
      Jint/Native/Function/EvalFunction.cs
  43. 1 1
      Jint/Native/Function/Function.cs
  44. 4 4
      Jint/Native/Function/FunctionInstance.Dynamic.cs
  45. 5 5
      Jint/Native/Function/FunctionPrototype.cs
  46. 4 4
      Jint/Native/Function/ScriptFunction.cs
  47. 1 1
      Jint/Native/Function/ThrowTypeError.cs
  48. 5 5
      Jint/Native/Generator/GeneratorInstance.cs
  49. 1 1
      Jint/Native/Generator/GeneratorPrototype.cs
  50. 3 3
      Jint/Native/Global/GlobalObject.cs
  51. 1 1
      Jint/Native/GroupByHelper.cs
  52. 8 8
      Jint/Native/Intl/NumberFormatConstructor.cs
  53. 5 5
      Jint/Native/Iterator/IteratorInstance.cs
  54. 2 2
      Jint/Native/Iterator/IteratorProtocol.cs
  55. 1 1
      Jint/Native/Iterator/IteratorPrototype.cs
  56. 10 10
      Jint/Native/JsArrayBuffer.cs
  57. 1 1
      Jint/Native/JsDate.cs
  58. 2 2
      Jint/Native/JsPromise.cs
  59. 34 34
      Jint/Native/JsProxy.cs
  60. 2 2
      Jint/Native/JsSharedArrayBuffer.cs
  61. 1 1
      Jint/Native/JsTypedArray.cs
  62. 9 9
      Jint/Native/JsValue.cs
  63. 1 1
      Jint/Native/JsWeakMap.cs
  64. 1 1
      Jint/Native/JsWeakSet.cs
  65. 1 1
      Jint/Native/Json/JsonParser.cs
  66. 1 1
      Jint/Native/Json/JsonSerializer.cs
  67. 1 1
      Jint/Native/Map/MapConstructor.cs
  68. 1 1
      Jint/Native/Map/MapPrototype.cs
  69. 4 4
      Jint/Native/Math/MathInstance.cs
  70. 2 2
      Jint/Native/Number/Dtoa/Bignum.cs
  71. 1 1
      Jint/Native/Number/Dtoa/BignumDtoa.cs
  72. 2 2
      Jint/Native/Number/Dtoa/DtoaNumberFormatter.cs
  73. 1 1
      Jint/Native/Number/Dtoa/FastDtoa.cs
  74. 11 11
      Jint/Native/Number/NumberPrototype.cs
  75. 8 8
      Jint/Native/Object/ObjectConstructor.cs
  76. 7 7
      Jint/Native/Object/ObjectInstance.Private.cs
  77. 10 10
      Jint/Native/Object/ObjectInstance.cs
  78. 3 3
      Jint/Native/Object/ObjectPrototype.cs
  79. 16 16
      Jint/Native/Promise/PromiseConstructor.cs
  80. 1 1
      Jint/Native/Promise/PromiseOperations.cs
  81. 2 2
      Jint/Native/Promise/PromisePrototype.cs
  82. 3 3
      Jint/Native/Proxy/ProxyConstructor.cs
  83. 13 13
      Jint/Native/Reflect/ReflectInstance.cs
  84. 2 2
      Jint/Native/RegExp/RegExpConstructor.cs
  85. 5 5
      Jint/Native/RegExp/RegExpPrototype.cs
  86. 2 2
      Jint/Native/Set/SetConstructor.cs
  87. 6 6
      Jint/Native/Set/SetPrototype.cs
  88. 7 7
      Jint/Native/ShadowRealm/ShadowRealm.cs
  89. 1 1
      Jint/Native/ShadowRealm/ShadowRealmConstructor.cs
  90. 4 4
      Jint/Native/ShadowRealm/ShadowRealmPrototype.cs
  91. 3 3
      Jint/Native/SharedArrayBuffer/SharedArrayBufferConstructor.cs
  92. 11 11
      Jint/Native/SharedArrayBuffer/SharedArrayBufferPrototype.cs
  93. 1 1
      Jint/Native/String/StringConstructor.cs
  94. 10 10
      Jint/Native/String/StringPrototype.cs
  95. 2 2
      Jint/Native/Symbol/SymbolConstructor.cs
  96. 1 1
      Jint/Native/Symbol/SymbolPrototype.cs
  97. 9 9
      Jint/Native/TypedArray/IntrinsicTypedArrayConstructor.cs
  98. 22 22
      Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs
  99. 2 2
      Jint/Native/TypedArray/TypeArrayHelper.cs
  100. 17 17
      Jint/Native/TypedArray/TypedArrayConstructor.Uint8Array.cs

+ 1 - 1
Jint.Tests.Test262/Test262ModuleLoader.cs

@@ -29,7 +29,7 @@ internal sealed class Test262ModuleLoader : ModuleLoader
             var fileName = Path.Combine(_basePath, resolved.Key).Replace('\\', '/');
             if (!_fileSystem.FileExists(fileName))
             {
-                ExceptionHelper.ThrowModuleResolutionException("Module Not Found", resolved.ModuleRequest.Specifier, parent: null, fileName);
+                Throw.ModuleResolutionException("Module Not Found", resolved.ModuleRequest.Specifier, parent: null, fileName);
             }
             using var stream = new StreamReader(_fileSystem.OpenFile(fileName, FileMode.Open, FileAccess.Read));
             return stream.ReadToEnd();

+ 3 - 3
Jint/AstExtensions.cs

@@ -27,7 +27,7 @@ public static class AstExtensions
             return TypeConverter.ToPropertyKey(key);
         }
 
-        ExceptionHelper.ThrowArgumentException("Unable to extract correct key, node type: " + expression.Type);
+        Throw.ArgumentException("Unable to extract correct key, node type: " + expression.Type);
         return JsValue.Undefined;
     }
 
@@ -324,7 +324,7 @@ public static class AstExtensions
         var function = m.Value as IFunction;
         if (function is null)
         {
-            ExceptionHelper.ThrowSyntaxError(engine.Realm);
+            Throw.SyntaxError(engine.Realm);
         }
 
         var definition = new JintFunctionDefinition(function);
@@ -552,7 +552,7 @@ public static class AstExtensions
         [MethodImpl(MethodImplOptions.NoInlining)]
         private static void Throw(Realm r, PrivateIdentifier id)
         {
-            ExceptionHelper.ThrowSyntaxError(r, $"Private field '#{id.Name}' must be declared in an enclosing class");
+            Runtime.Throw.SyntaxError(r, $"Private field '#{id.Name}' must be declared in an enclosing class");
         }
     }
 }

+ 1 - 1
Jint/Collections/ListDictionary.cs

@@ -85,7 +85,7 @@ internal sealed class ListDictionary<TValue> : DictionaryBase<TValue>, IEnumerab
                 {
                     return false;
                 }
-                ExceptionHelper.ThrowArgumentException();
+                Throw.ArgumentException();
             }
 
             last = node;

+ 2 - 2
Jint/Collections/ObjectTraverseStack.cs

@@ -20,7 +20,7 @@ internal sealed class ObjectTraverseStack
     {
         if (value is null)
         {
-            ExceptionHelper.ThrowArgumentNullException(nameof(value));
+            Throw.ArgumentNullException(nameof(value));
         }
 
         if (_stack.Contains(value))
@@ -37,7 +37,7 @@ internal sealed class ObjectTraverseStack
     {
         if (!TryEnter(value))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Cyclic reference detected.");
+            Throw.TypeError(_engine.Realm, "Cyclic reference detected.");
         }
     }
 

+ 1 - 1
Jint/Collections/RefStack.cs

@@ -54,7 +54,7 @@ internal sealed class RefStack<T> : IEnumerable<T> where T : struct
     {
         if (_size == 0)
         {
-            ExceptionHelper.ThrowInvalidOperationException("stack is empty");
+            Throw.InvalidOperationException("stack is empty");
         }
 
         _size--;

+ 1 - 1
Jint/Constraints/CancellationConstraint.cs

@@ -16,7 +16,7 @@ public sealed class CancellationConstraint : Constraint
     {
         if (_cancellationToken.IsCancellationRequested)
         {
-            ExceptionHelper.ThrowExecutionCanceledException();
+            Throw.ExecutionCanceledException();
         }
     }
 

+ 1 - 1
Jint/Constraints/MaxStatementsConstraint.cs

@@ -20,7 +20,7 @@ public sealed class MaxStatementsConstraint : Constraint
     {
         if (MaxStatements > 0 && ++_statementsCount > MaxStatements)
         {
-            ExceptionHelper.ThrowStatementsCountOverflowException();
+            Throw.StatementsCountOverflowException();
         }
     }
 

+ 2 - 2
Jint/Constraints/MemoryLimitConstraint.cs

@@ -38,14 +38,14 @@ public sealed class MemoryLimitConstraint : Constraint
 #else
         if (_getAllocatedBytesForCurrentThread == null)
         {
-            ExceptionHelper.ThrowPlatformNotSupportedException("The current platform doesn't support MemoryLimit.");
+            Throw.PlatformNotSupportedException("The current platform doesn't support MemoryLimit.");
         }
 
         var usage = _getAllocatedBytesForCurrentThread();
 #endif
         if (usage - _initialMemoryUsage > _memoryLimit)
         {
-            ExceptionHelper.ThrowMemoryLimitExceededException($"Script has allocated {usage - _initialMemoryUsage} but is limited to {_memoryLimit}");
+            Throw.MemoryLimitExceededException($"Script has allocated {usage - _initialMemoryUsage} but is limited to {_memoryLimit}");
         }
     }
 

+ 1 - 1
Jint/Constraints/TimeConstraint.cs

@@ -19,7 +19,7 @@ internal sealed class TimeConstraint : Constraint
     {
         if (_cts?.IsCancellationRequested == true)
         {
-            ExceptionHelper.ThrowTimeoutException();
+            Throw.TimeoutException();
         }
     }
 

+ 4 - 4
Jint/Engine.Modules.cs

@@ -131,7 +131,7 @@ public partial class Engine
 
                 if (cyclicModule.Status != ModuleStatus.Evaluated)
                 {
-                    ExceptionHelper.ThrowNotSupportedException($"Error while evaluating module: Module is in an invalid state: '{cyclicModule.Status}'");
+                    Throw.NotSupportedException($"Error while evaluating module: Module is in an invalid state: '{cyclicModule.Status}'");
                 }
             }
 
@@ -165,7 +165,7 @@ public partial class Engine
             // This should instead be returned and resolved in ImportModule(specifier) only so Host.ImportModuleDynamically can use this promise
             if (evaluationResult is not JsPromise promise)
             {
-                ExceptionHelper.ThrowInvalidOperationException($"Error while evaluating module: Module evaluation did not return a promise: {evaluationResult.Type}");
+                Throw.InvalidOperationException($"Error while evaluating module: Module evaluation did not return a promise: {evaluationResult.Type}");
             }
             else if (promise.State == PromiseState.Rejected)
             {
@@ -174,11 +174,11 @@ public partial class Engine
                     : SourceLocation.From(new Position(), new Position());
 
                 var node = AstExtensions.CreateLocationNode(location);
-                ExceptionHelper.ThrowJavaScriptException(_engine, promise.Value, node.Location);
+                Throw.JavaScriptException(_engine, promise.Value, node.Location);
             }
             else if (promise.State != PromiseState.Fulfilled)
             {
-                ExceptionHelper.ThrowInvalidOperationException($"Error while evaluating module: Module evaluation did not return a fulfilled promise: {promise.State}");
+                Throw.InvalidOperationException($"Error while evaluating module: Module evaluation did not return a fulfilled promise: {promise.State}");
             }
 
             return evaluationResult;

+ 19 - 19
Jint/Engine.cs

@@ -404,7 +404,7 @@ public sealed partial class Engine : IDisposable
     {
         if (!preparedScript.IsValid)
         {
-            ExceptionHelper.ThrowInvalidPreparedScriptArgumentException(nameof(preparedScript));
+            Throw.InvalidPreparedScriptArgumentException(nameof(preparedScript));
         }
 
         var script = preparedScript.Program;
@@ -578,7 +578,7 @@ public sealed partial class Engine : IDisposable
                 }
             }
 
-            ExceptionHelper.ThrowReferenceError(Realm, reference);
+            Throw.ReferenceError(Realm, reference);
         }
 
         if ((baseValue._type & InternalTypes.ObjectEnvironmentRecord) == InternalTypes.Empty && _customResolver)
@@ -687,7 +687,7 @@ public sealed partial class Engine : IDisposable
         {
             if (reference.Strict && property != CommonProperties.Arguments)
             {
-                ExceptionHelper.ThrowReferenceError(Realm, reference);
+                Throw.ReferenceError(Realm, reference);
             }
 
             Realm.GlobalObject.Set(property, value, throwOnError: false);
@@ -705,7 +705,7 @@ public sealed partial class Engine : IDisposable
             var succeeded = baseObject.Set(reference.ReferencedName, value, reference.ThisValue);
             if (!succeeded && reference.Strict)
             {
-                ExceptionHelper.ThrowTypeError(Realm, $"Cannot assign to read only property '{property}' of {baseObject}");
+                Throw.TypeError(Realm, $"Cannot assign to read only property '{property}' of {baseObject}");
             }
         }
         else
@@ -762,7 +762,7 @@ public sealed partial class Engine : IDisposable
         var callable = value as ICallable;
         if (callable is null)
         {
-            ExceptionHelper.ThrowJavaScriptException(Realm.Intrinsics.TypeError, "Can only invoke functions");
+            Throw.JavaScriptException(Realm.Intrinsics.TypeError, "Can only invoke functions");
         }
 
         JsValue DoInvoke()
@@ -843,7 +843,7 @@ public sealed partial class Engine : IDisposable
             var callable = func as ICallable;
             if (callable is null)
             {
-                ExceptionHelper.ThrowTypeErrorNoEngine("Can only invoke functions");
+                Throw.TypeErrorNoEngine("Can only invoke functions");
             }
 
             return callable.Call(v, arguments);
@@ -970,7 +970,7 @@ public sealed partial class Engine : IDisposable
                     var fnDefinable = env.CanDeclareGlobalFunction(fn);
                     if (!fnDefinable)
                     {
-                        ExceptionHelper.ThrowTypeError(realm, "Cannot declare global function " + fn);
+                        Throw.TypeError(realm, "Cannot declare global function " + fn);
                     }
 
                     declaredFunctionNames.Add(fn);
@@ -985,7 +985,7 @@ public sealed partial class Engine : IDisposable
             var vn = varNames[j];
             if (env.HasLexicalDeclaration(vn))
             {
-                ExceptionHelper.ThrowSyntaxError(realm, $"Identifier '{vn}' has already been declared");
+                Throw.SyntaxError(realm, $"Identifier '{vn}' has already been declared");
             }
 
             if (!declaredFunctionNames.Contains(vn))
@@ -993,7 +993,7 @@ public sealed partial class Engine : IDisposable
                 var vnDefinable = env.CanDeclareGlobalVar(vn);
                 if (!vnDefinable)
                 {
-                    ExceptionHelper.ThrowTypeError(realm);
+                    Throw.TypeError(realm);
                 }
 
                 declaredVarNames.Add(vn);
@@ -1009,7 +1009,7 @@ public sealed partial class Engine : IDisposable
             {
                 if (env.HasLexicalDeclaration(dn) || env.HasRestrictedGlobalProperty(dn))
                 {
-                    ExceptionHelper.ThrowSyntaxError(realm, $"Identifier '{dn}' has already been declared");
+                    Throw.SyntaxError(realm, $"Identifier '{dn}' has already been declared");
                 }
 
                 if (declaration.IsConstantDeclaration)
@@ -1031,7 +1031,7 @@ public sealed partial class Engine : IDisposable
 
             if (env.HasLexicalDeclaration(fn))
             {
-                ExceptionHelper.ThrowSyntaxError(realm, $"Identifier '{fn}' has already been declared");
+                Throw.SyntaxError(realm, $"Identifier '{fn}' has already been declared");
             }
 
             var fo = realm.Intrinsics.Function.InstantiateFunctionObject(f, env, privateEnv);
@@ -1235,7 +1235,7 @@ public sealed partial class Engine : IDisposable
                     var identifier = (Identifier) variablesDeclaration.Declarations[0].Id;
                     if (globalEnvironmentRecord.HasLexicalDeclaration(identifier.Name))
                     {
-                        ExceptionHelper.ThrowSyntaxError(realm, "Identifier '" + identifier.Name + "' has already been declared");
+                        Throw.SyntaxError(realm, "Identifier '" + identifier.Name + "' has already been declared");
                     }
                 }
             }
@@ -1253,7 +1253,7 @@ public sealed partial class Engine : IDisposable
                         var identifier = (Identifier) variablesDeclaration.Declarations[0].Id;
                         if (thisEnvRec!.HasBinding(identifier.Name))
                         {
-                            ExceptionHelper.ThrowSyntaxError(realm);
+                            Throw.SyntaxError(realm);
                         }
                     }
                 }
@@ -1294,7 +1294,7 @@ public sealed partial class Engine : IDisposable
                         var fnDefinable = ger.CanDeclareGlobalFunction(fn);
                         if (!fnDefinable)
                         {
-                            ExceptionHelper.ThrowTypeError(realm);
+                            Throw.TypeError(realm);
                         }
                     }
 
@@ -1323,7 +1323,7 @@ public sealed partial class Engine : IDisposable
                         var vnDefinable = ger.CanDeclareGlobalFunction(vn);
                         if (!vnDefinable)
                         {
-                            ExceptionHelper.ThrowTypeError(realm);
+                            Throw.TypeError(realm);
                         }
                     }
 
@@ -1452,7 +1452,7 @@ public sealed partial class Engine : IDisposable
         {
             if (!callable.IsCallable)
             {
-                ExceptionHelper.ThrowArgumentException(callable + " is not callable");
+                Throw.ArgumentException(callable + " is not callable");
             }
 
             return Call((ICallable) callable, thisObject, arguments, null);
@@ -1496,7 +1496,7 @@ public sealed partial class Engine : IDisposable
         {
             if (!constructor.IsConstructor)
             {
-                ExceptionHelper.ThrowArgumentException(constructor + " is not a constructor");
+                Throw.ArgumentException(constructor + " is not a constructor");
             }
 
             return Construct(constructor, arguments, constructor, null);
@@ -1535,7 +1535,7 @@ public sealed partial class Engine : IDisposable
         if (recursionDepth > Options.Constraints.MaxRecursionDepth)
         {
             // automatically pops the current element as it was never reached
-            ExceptionHelper.ThrowRecursionDepthOverflowException(CallStack);
+            Throw.RecursionDepthOverflowException(CallStack);
         }
 
         JsValue result;
@@ -1568,7 +1568,7 @@ public sealed partial class Engine : IDisposable
         if (recursionDepth > Options.Constraints.MaxRecursionDepth)
         {
             // automatically pops the current element as it was never reached
-            ExceptionHelper.ThrowRecursionDepthOverflowException(CallStack);
+            Throw.RecursionDepthOverflowException(CallStack);
         }
 
         ObjectInstance result;

+ 3 - 3
Jint/Extensions/AcornimaExtensions.cs

@@ -12,7 +12,7 @@ internal static class AcornimaExtensions
         }
         catch (ParseErrorException e)
         {
-            ExceptionHelper.ThrowSyntaxError(realm, e.Message, ToLocation(e, source));
+            Throw.SyntaxError(realm, e.Message, ToLocation(e, source));
             return default;
         }
     }
@@ -25,12 +25,12 @@ internal static class AcornimaExtensions
         }
         catch (ParseErrorException ex)
         {
-            ExceptionHelper.ThrowSyntaxError(engine.Realm, $"Error while loading module: error in module '{source}': {ex.Error}", ToLocation(ex, source));
+            Throw.SyntaxError(engine.Realm, $"Error while loading module: error in module '{source}': {ex.Error}", ToLocation(ex, source));
             return default;
         }
         catch (Exception)
         {
-            ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {source}", AstExtensions.DefaultLocation);
+            Throw.JavaScriptException(engine, $"Could not load module {source}", AstExtensions.DefaultLocation);
             return default;
         }
     }

+ 1 - 1
Jint/Extensions/ReflectionExtensions.cs

@@ -130,7 +130,7 @@ internal static class ReflectionExtensions
             case TypeCode.Int64:
                 return (long) d;
             default:
-                ExceptionHelper.ThrowArgumentException("Cannot convert " + type);
+                Throw.ArgumentException("Cannot convert " + type);
                 return null;
         }
     }

+ 13 - 13
Jint/JsValueExtensions.cs

@@ -149,7 +149,7 @@ public static class JsValueExtensions
     {
         if (!value.IsDate())
         {
-            ExceptionHelper.ThrowArgumentException("The value is not a date");
+            Throw.ArgumentException("The value is not a date");
         }
 
         return (JsDate) value;
@@ -160,7 +160,7 @@ public static class JsValueExtensions
     {
         if (!value.IsRegExp())
         {
-            ExceptionHelper.ThrowArgumentException("The value is not a regex");
+            Throw.ArgumentException("The value is not a regex");
         }
 
         return (JsRegExp) value;
@@ -172,7 +172,7 @@ public static class JsValueExtensions
     {
         if (!value.IsObject())
         {
-            ExceptionHelper.ThrowArgumentException("The value is not an object");
+            Throw.ArgumentException("The value is not an object");
         }
 
         return (ObjectInstance) value;
@@ -184,7 +184,7 @@ public static class JsValueExtensions
     {
         if (!value.IsObject())
         {
-            ExceptionHelper.ThrowArgumentException("The value is not an object");
+            Throw.ArgumentException("The value is not an object");
         }
 
         return (value as TInstance)!;
@@ -196,7 +196,7 @@ public static class JsValueExtensions
     {
         if (!value.IsArray())
         {
-            ExceptionHelper.ThrowArgumentException("The value is not an array");
+            Throw.ArgumentException("The value is not an array");
         }
 
         return (JsArray) value;
@@ -633,7 +633,7 @@ public static class JsValueExtensions
     [MethodImpl(MethodImplOptions.NoInlining)]
     private static JsValue ThrowNotObject(JsValue value)
     {
-        ExceptionHelper.ThrowArgumentException(value + " is not object");
+        Throw.ArgumentException(value + " is not object");
         return null;
     }
 
@@ -670,21 +670,21 @@ public static class JsValueExtensions
             engine.RunAvailableContinuations();
             if (!completedEvent.Wait(timeout))
             {
-                ExceptionHelper.ThrowPromiseRejectedException($"Timeout of {timeout} reached");
+                Throw.PromiseRejectedException($"Timeout of {timeout} reached");
             }
 
             switch (promise.State)
             {
                 case PromiseState.Pending:
-                    ExceptionHelper.ThrowInvalidOperationException("'UnwrapIfPromise' called before Promise was settled");
+                    Throw.InvalidOperationException("'UnwrapIfPromise' called before Promise was settled");
                     return null;
                 case PromiseState.Fulfilled:
                     return promise.Value;
                 case PromiseState.Rejected:
-                    ExceptionHelper.ThrowPromiseRejectedException(promise.Value);
+                    Throw.PromiseRejectedException(promise.Value);
                     return null;
                 default:
-                    ExceptionHelper.ThrowArgumentOutOfRangeException();
+                    Throw.ArgumentOutOfRangeException();
                     return null;
             }
         }
@@ -695,7 +695,7 @@ public static class JsValueExtensions
     [MethodImpl(MethodImplOptions.NoInlining)]
     private static void ThrowWrongTypeException(JsValue value, string expectedType)
     {
-        ExceptionHelper.ThrowArgumentException($"Expected {expectedType} but got {value._type}");
+        Throw.ArgumentException($"Expected {expectedType} but got {value._type}");
     }
 
     internal static BigInteger ToBigInteger(this JsValue value, Engine engine)
@@ -706,7 +706,7 @@ public static class JsValueExtensions
         }
         catch (ParseErrorException ex)
         {
-            ExceptionHelper.ThrowSyntaxError(engine.Realm, ex.Message);
+            Throw.SyntaxError(engine.Realm, ex.Message);
             return default;
         }
     }
@@ -718,7 +718,7 @@ public static class JsValueExtensions
             return callable;
         }
 
-        ExceptionHelper.ThrowTypeError(realm, "Argument must be callable");
+        Throw.TypeError(realm, "Argument must be callable");
         return null;
     }
 

+ 4 - 4
Jint/Native/Array/ArrayConstructor.cs

@@ -59,7 +59,7 @@ public sealed class ArrayConstructor : Constructor
 
         if (items.IsNullOrUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Cannot convert undefined or null to object");
+            Throw.TypeError(_realm, "Cannot convert undefined or null to object");
         }
 
         var usingIterator = GetMethod(_realm, items, GlobalSymbolRegistry.Iterator);
@@ -338,7 +338,7 @@ public sealed class ArrayConstructor : Constructor
     {
         if (length > ArrayOperations.MaxArrayLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid array length " + length);
+            Throw.RangeError(_realm, "Invalid array length " + length);
         }
 
         proto ??= PrototypeObject;
@@ -420,7 +420,7 @@ public sealed class ArrayConstructor : Constructor
 
         if (!c.IsConstructor)
         {
-            ExceptionHelper.ThrowTypeError(_realm, $"{c} is not a constructor");
+            Throw.TypeError(_realm, $"{c} is not a constructor");
         }
 
         return ((IConstructor) c).Construct([JsNumber.Create(length)], c);
@@ -458,7 +458,7 @@ public sealed class ArrayConstructor : Constructor
     {
         if (length < 0 || length > ArrayOperations.MaxArrayLikeLength || ((long) length) != length)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid array length");
+            Throw.RangeError(_realm, "Invalid array length");
         }
     }
 }

+ 6 - 6
Jint/Native/Array/ArrayInstance.cs

@@ -139,7 +139,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
         uint newLen = TypeConverter.ToUint32(value);
         if (newLen != TypeConverter.ToNumber(value))
         {
-            ExceptionHelper.ThrowRangeError(_engine.Realm);
+            Throw.RangeError(_engine.Realm);
         }
 
         var oldLenDesc = _length;
@@ -661,7 +661,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
     {
         if (!Delete(index))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
         return true;
     }
@@ -1053,7 +1053,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
         {
             if (!Set(CommonProperties.Length, newLength))
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
         }
     }
@@ -1100,7 +1100,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
         {
             if (!Set(CommonProperties.Length, newLength))
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
         }
 
@@ -1120,7 +1120,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
 
         if (!Delete(newLength, unwrapFromNonDataDescriptor: true, out var element))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         SetLength(newLength);
@@ -1360,7 +1360,7 @@ public class ArrayInstance : ObjectInstance, IEnumerable<JsValue>
 
     private static void ThrowMaximumArraySizeReachedException(Engine engine, uint capacity)
     {
-        ExceptionHelper.ThrowMemoryLimitExceededException(
+        Throw.MemoryLimitExceededException(
             $"The array size {capacity} is larger than maximum allowed ({engine.Options.Constraints.MaxArraySize})"
         );
     }

+ 1 - 1
Jint/Native/Array/ArrayIteratorPrototype.cs

@@ -123,7 +123,7 @@ internal sealed class ArrayIteratorPrototype : IteratorPrototype
                 var taRecord = IntrinsicTypedArrayPrototype.MakeTypedArrayWithBufferWitnessRecord(_typedArray, ArrayBufferOrder.SeqCst);
                 if (!_closed && taRecord.IsTypedArrayOutOfBounds)
                 {
-                    ExceptionHelper.ThrowTypeError(_typedArray.Engine.Realm, "TypedArray is out of bounds");
+                    Throw.TypeError(_typedArray.Engine.Realm, "TypedArray is out of bounds");
                 }
                 len = taRecord.TypedArrayLength;
             }

+ 2 - 2
Jint/Native/Array/ArrayOperations.cs

@@ -90,7 +90,7 @@ internal abstract class ArrayOperations : IEnumerable<JsValue>
             var jsValue = skipHoles && !HasProperty(i) ? JsValue.Undefined : Get(i);
             if ((jsValue.Type & elementTypes) == Types.Empty)
             {
-                ExceptionHelper.ThrowTypeErrorNoEngine("invalid type");
+                Throw.TypeErrorNoEngine("invalid type");
             }
 
             jsValues[writeIndex++] = jsValue;
@@ -289,7 +289,7 @@ internal abstract class ArrayOperations : IEnumerable<JsValue>
 
                 if ((value.Type & elementTypes) == Types.Empty)
                 {
-                    ExceptionHelper.ThrowTypeErrorNoEngine("invalid type");
+                    Throw.TypeErrorNoEngine("invalid type");
                 }
 
                 jsValues[writeIndex++] = (JsValue?) value ?? JsValue.Undefined;

+ 19 - 19
Jint/Native/Array/ArrayPrototype.cs

@@ -126,7 +126,7 @@ public sealed class ArrayPrototype : ArrayInstance
             return _realm.Intrinsics.ArrayIteratorPrototype.Construct(oi, ArrayIteratorType.Key);
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "cannot construct iterator");
+        Throw.TypeError(_realm, "cannot construct iterator");
         return null;
     }
 
@@ -137,7 +137,7 @@ public sealed class ArrayPrototype : ArrayInstance
             return _realm.Intrinsics.ArrayIteratorPrototype.Construct(oi, ArrayIteratorType.Value);
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "cannot construct iterator");
+        Throw.TypeError(_realm, "cannot construct iterator");
         return null;
     }
 
@@ -160,7 +160,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (actualIndex >= (long) len || actualIndex < 0)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid start index");
+            Throw.RangeError(_realm, "Invalid start index");
         }
 
         var a = CreateBackingArray(len);
@@ -180,7 +180,7 @@ public sealed class ArrayPrototype : ArrayInstance
             return _realm.Intrinsics.ArrayIteratorPrototype.Construct(oi, ArrayIteratorType.KeyAndValue);
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "cannot construct iterator");
+        Throw.TypeError(_realm, "cannot construct iterator");
         return null;
     }
 
@@ -388,7 +388,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (len == 0 && arguments.Length < 2)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var k = 0;
@@ -412,7 +412,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
             if (kPresent == false)
             {
-                ExceptionHelper.ThrowTypeError(_realm);
+                Throw.TypeError(_realm);
             }
         }
 
@@ -491,7 +491,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (len > ArrayOperations.MaxArrayLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid array length");
+            Throw.RangeError(_realm, "Invalid array length");
         }
 
         var callbackfn = arguments.At(0);
@@ -552,7 +552,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (!mapperFunction.IsCallable)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "flatMap mapper function is not callable");
+            Throw.TypeError(_realm, "flatMap mapper function is not callable");
         }
 
         var A = _realm.Intrinsics.Array.ArraySpeciesCreate(O.Target, 0);
@@ -615,7 +615,7 @@ public sealed class ArrayPrototype : ArrayInstance
                 {
                     if (targetIndex >= NumberConstructor.MaxSafeInteger)
                     {
-                        ExceptionHelper.ThrowTypeError(_realm);
+                        Throw.TypeError(_realm);
                     }
 
                     target.CreateDataPropertyOrThrow(targetIndex, element);
@@ -939,7 +939,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (len + insertCount - actualDeleteCount > ArrayOperations.MaxArrayLikeLength)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid array length");
+            Throw.TypeError(_realm, "Invalid array length");
         }
 
         var instance = _realm.Intrinsics.Array.ArraySpeciesCreate(obj, actualDeleteCount);
@@ -1018,7 +1018,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (len + argCount > ArrayOperations.MaxArrayLikeLength)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid array length");
+            Throw.TypeError(_realm, "Invalid array length");
         }
 
         // only prepare for larger if we cannot rely on default growth algorithm
@@ -1163,7 +1163,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (k < final && final - k > ArrayOperations.MaxArrayLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid array length");
+            Throw.RangeError(_realm, "Invalid array length");
         }
 
         var length = (uint) System.Math.Max(0, (long) final - (long) k);
@@ -1377,7 +1377,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
                     if (n + len > ArrayOperations.MaxArrayLikeLength)
                     {
-                        ExceptionHelper.ThrowTypeError(_realm, "Invalid array length");
+                        Throw.TypeError(_realm, "Invalid array length");
                     }
 
                     for (uint k = 0; k < len; k++)
@@ -1513,7 +1513,7 @@ public sealed class ArrayPrototype : ArrayInstance
         var newLen = len + insertCount - actualDeleteCount;
         if (newLen > ArrayOperations.MaxArrayLikeLength)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid input length");
+            Throw.TypeError(_realm, "Invalid input length");
         }
 
         ValidateArrayLength(newLen);
@@ -1568,7 +1568,7 @@ public sealed class ArrayPrototype : ArrayInstance
         {
             if (compareArg is not ICallable callable)
             {
-                ExceptionHelper.ThrowTypeError(_realm, "The comparison function must be either a function or undefined");
+                Throw.TypeError(_realm, "The comparison function must be either a function or undefined");
                 return null;
             }
             compareFn = callable;
@@ -1592,7 +1592,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (len == 0 && arguments.Length < 2)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         long k = (long) (len - 1);
@@ -1616,7 +1616,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
             if (kPresent == false)
             {
-                ExceptionHelper.ThrowTypeError(_realm);
+                Throw.TypeError(_realm);
             }
         }
 
@@ -1651,7 +1651,7 @@ public sealed class ArrayPrototype : ArrayInstance
 
         if (n + (ulong) arguments.Length > ArrayOperations.MaxArrayLikeLength)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid array length");
+            Throw.TypeError(_realm, "Invalid array length");
         }
 
         foreach (var a in arguments)
@@ -1696,7 +1696,7 @@ public sealed class ArrayPrototype : ArrayInstance
     {
         if (length > ArrayOperations.MaxArrayLength)
         {
-            ExceptionHelper.ThrowRangeError(_engine.Realm, "Invalid array length " + length);
+            Throw.RangeError(_engine.Realm, "Invalid array length " + length);
         }
     }
 

+ 2 - 2
Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs

@@ -65,7 +65,7 @@ public sealed class ArrayBufferConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var length = arguments.At(0);
@@ -102,7 +102,7 @@ public sealed class ArrayBufferConstructor : Constructor
 
         if (allocatingResizableBuffer && byteLength > maxByteLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm);
+            Throw.RangeError(_realm);
         }
 
         return CreateJsArrayBuffer(constructor, block: null, byteLength, maxByteLength);

+ 14 - 14
Jint/Native/ArrayBuffer/ArrayBufferPrototype.cs

@@ -50,7 +50,7 @@ internal sealed class ArrayBufferPrototype : Prototype
         var o = thisObject as JsArrayBuffer;
         if (o is null || o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.detached called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.detached called on incompatible receiver " + thisObject);
         }
 
         return o.IsDetachedBuffer;
@@ -64,7 +64,7 @@ internal sealed class ArrayBufferPrototype : Prototype
         var o = thisObject as JsArrayBuffer;
         if (o is null || o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.maxByteLength called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.maxByteLength called on incompatible receiver " + thisObject);
         }
 
         if (o.IsDetachedBuffer)
@@ -87,7 +87,7 @@ internal sealed class ArrayBufferPrototype : Prototype
         var o = thisObject as JsArrayBuffer;
         if (o is null || o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.resizable called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.resizable called on incompatible receiver " + thisObject);
         }
 
         return !o.IsFixedLengthArrayBuffer;
@@ -101,7 +101,7 @@ internal sealed class ArrayBufferPrototype : Prototype
         var o = thisObject as JsArrayBuffer;
         if (o is null || o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.resize called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.resize called on incompatible receiver " + thisObject);
         }
 
         var newLength = arguments.At(0);
@@ -122,7 +122,7 @@ internal sealed class ArrayBufferPrototype : Prototype
         var o = thisObject as JsArrayBuffer;
         if (o is null || o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.byteLength called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.byteLength called on incompatible receiver " + thisObject);
         }
 
         if (o.IsDetachedBuffer)
@@ -141,7 +141,7 @@ internal sealed class ArrayBufferPrototype : Prototype
         var o = thisObject as JsArrayBuffer;
         if (o is null || o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.slice called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.slice called on incompatible receiver " + thisObject);
         }
 
         o.AssertNotDetached();
@@ -181,34 +181,34 @@ internal sealed class ArrayBufferPrototype : Prototype
 
         if (bufferInstance is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (bufferInstance.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (bufferInstance.IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (ReferenceEquals(bufferInstance, o))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (bufferInstance.ArrayBufferByteLength < newLen)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         // NOTE: Side-effects of the above steps may have detached O.
 
         if (bufferInstance.IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var fromBuf = o.ArrayBufferData;
@@ -237,7 +237,7 @@ internal sealed class ArrayBufferPrototype : Prototype
     {
         if (o is not JsArrayBuffer arrayBuffer || arrayBuffer.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method ArrayBuffer.prototype.ArrayBufferCopyAndDetach called on incompatible receiver " + o);
+            Throw.TypeError(_realm, "Method ArrayBuffer.prototype.ArrayBufferCopyAndDetach called on incompatible receiver " + o);
             return Undefined;
         }
 
@@ -261,7 +261,7 @@ internal sealed class ArrayBufferPrototype : Prototype
 
         if (!arrayBuffer._arrayBufferDetachKey.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var newBuffer = _engine.Realm.Intrinsics.ArrayBuffer.AllocateArrayBuffer(_engine.Realm.Intrinsics.ArrayBuffer, newByteLength, newMaxByteLength);

+ 1 - 1
Jint/Native/AsyncGenerator/AsyncGeneratorPrototype.cs

@@ -80,7 +80,7 @@ internal sealed class AsyncGeneratorPrototype : ObjectInstance
         var generatorInstance = thisObj as GeneratorInstance;
         if (generatorInstance is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "object must be a Generator instance");
+            Runtime.Throw.TypeError(_engine.Realm, "object must be a Generator instance");
         }
 
         return generatorInstance;

+ 3 - 3
Jint/Native/Atomics/AtomicsInstance.cs

@@ -38,18 +38,18 @@ internal sealed class AtomicsInstance : ObjectInstance
         {
             if (!iterationNumber.IsNumber())
             {
-                ExceptionHelper.ThrowTypeError(_realm, "Invalid iteration count");
+                Throw.TypeError(_realm, "Invalid iteration count");
             }
 
             var n = TypeConverter.ToNumber(iterationNumber);
             if (!TypeConverter.IsIntegralNumber(n))
             {
-                ExceptionHelper.ThrowTypeError(_realm, "Invalid iteration count");
+                Throw.TypeError(_realm, "Invalid iteration count");
             }
 
             if (n < 0)
             {
-                ExceptionHelper.ThrowRangeError(_realm, "Invalid iteration count");
+                Throw.RangeError(_realm, "Invalid iteration count");
             }
 
             n = System.Math.Min(n, _engine.Options.Constraints.MaxAtomicsPauseIterations);

+ 1 - 1
Jint/Native/BigInt/BigIntConstructor.cs

@@ -93,7 +93,7 @@ internal sealed class BigIntConstructor : Constructor
             return JsBigInt.Create((long) value._value);
         }
 
-        ExceptionHelper.ThrowRangeError(_realm, "The number " + value + " cannot be converted to a BigInt because it is not an integer");
+        Throw.RangeError(_realm, "The number " + value + " cannot be converted to a BigInt because it is not an integer");
         return null;
     }
 

+ 3 - 3
Jint/Native/BigInt/BigIntPrototype.cs

@@ -73,7 +73,7 @@ internal sealed class BigIntPrototype : Prototype
             return thisObject;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm);
+        Throw.TypeError(_realm);
         return null;
     }
 
@@ -92,7 +92,7 @@ internal sealed class BigIntPrototype : Prototype
 
         if (radixMV is < 2 or > 36)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "radix must be between 2 and 36");
+            Throw.RangeError(_realm, "radix must be between 2 and 36");
         }
 
         var value = x._value;
@@ -145,7 +145,7 @@ internal sealed class BigIntPrototype : Prototype
             case BigIntInstance bigIntInstance:
                 return bigIntInstance.BigIntData;
             default:
-                ExceptionHelper.ThrowTypeError(_realm);
+                Throw.TypeError(_realm);
                 return default;
         }
     }

+ 1 - 1
Jint/Native/Boolean/BooleanPrototype.cs

@@ -47,7 +47,7 @@ internal sealed class BooleanPrototype : BooleanInstance
             return bi.BooleanData;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm);
+        Throw.TypeError(_realm);
         return Undefined;
     }
 

+ 1 - 1
Jint/Native/Constructor.cs

@@ -15,7 +15,7 @@ public abstract class Constructor : Function.Function, IConstructor
 
     protected internal override JsValue Call(JsValue thisObject, JsCallArguments arguments)
     {
-        ExceptionHelper.ThrowTypeError(_realm, $"Constructor {_nameDescriptor?.Value} requires 'new'");
+        Throw.TypeError(_realm, $"Constructor {_nameDescriptor?.Value} requires 'new'");
         return null;
     }
 

+ 8 - 8
Jint/Native/DataView/DataViewConstructor.cs

@@ -31,7 +31,7 @@ internal sealed class DataViewConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var buffer = arguments.At(0) as JsArrayBuffer;
@@ -40,20 +40,20 @@ internal sealed class DataViewConstructor : Constructor
 
         if (buffer is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "First argument to DataView constructor must be an ArrayBuffer");
+            Throw.TypeError(_realm, "First argument to DataView constructor must be an ArrayBuffer");
         }
 
         var offset = TypeConverter.ToIndex(_realm, byteOffset);
 
         if (buffer.IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var bufferByteLength = (uint) buffer.ArrayBufferByteLength;
         if (offset > bufferByteLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Start offset " + offset + " is outside the bounds of the buffer");
+            Throw.RangeError(_realm, "Start offset " + offset + " is outside the bounds of the buffer");
         }
 
         var bufferIsFixedLength = buffer.IsFixedLengthArrayBuffer;
@@ -74,7 +74,7 @@ internal sealed class DataViewConstructor : Constructor
             viewByteLength = TypeConverter.ToIndex(_realm, byteLength);
             if (offset + viewByteLength > bufferByteLength)
             {
-                ExceptionHelper.ThrowRangeError(_realm, "Invalid DataView length");
+                Throw.RangeError(_realm, "Invalid DataView length");
             }
         }
 
@@ -85,20 +85,20 @@ internal sealed class DataViewConstructor : Constructor
 
         if (buffer.IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         bufferByteLength = (uint) buffer.ArrayBufferByteLength;
         if (offset > bufferByteLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid DataView offset");
+            Throw.RangeError(_realm, "Invalid DataView offset");
         }
 
         if (!byteLength.IsUndefined())
         {
             if (offset + viewByteLength > bufferByteLength)
             {
-                ExceptionHelper.ThrowRangeError(_realm, "Invalid DataView length");
+                Throw.RangeError(_realm, "Invalid DataView length");
             }
         }
 

+ 11 - 11
Jint/Native/DataView/DataViewPrototype.cs

@@ -73,7 +73,7 @@ internal sealed class DataViewPrototype : Prototype
         var o = thisObject as JsDataView;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method get DataView.prototype.buffer called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method get DataView.prototype.buffer called on incompatible receiver " + thisObject);
         }
 
         return o._viewedArrayBuffer!;
@@ -87,13 +87,13 @@ internal sealed class DataViewPrototype : Prototype
         var o = thisObject as JsDataView;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method get DataView.prototype.byteLength called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method get DataView.prototype.byteLength called on incompatible receiver " + thisObject);
         }
 
         var viewRecord = MakeDataViewWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
         if (viewRecord.IsViewOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Offset is outside the bounds of the DataView");
+            Throw.TypeError(_realm, "Offset is outside the bounds of the DataView");
         }
 
         var buffer = o._viewedArrayBuffer!;
@@ -110,13 +110,13 @@ internal sealed class DataViewPrototype : Prototype
         var o = thisObject as JsDataView;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method get DataView.prototype.byteOffset called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method get DataView.prototype.byteOffset called on incompatible receiver " + thisObject);
         }
 
         var viewRecord = MakeDataViewWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
         if (viewRecord.IsViewOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Offset is outside the bounds of the DataView");
+            Throw.TypeError(_realm, "Offset is outside the bounds of the DataView");
         }
 
         var buffer = o._viewedArrayBuffer!;
@@ -246,7 +246,7 @@ internal sealed class DataViewPrototype : Prototype
     {
         if (view is not JsDataView dataView)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method called on incompatible receiver " + view);
+            Throw.TypeError(_realm, "Method called on incompatible receiver " + view);
             return Undefined;
         }
 
@@ -260,14 +260,14 @@ internal sealed class DataViewPrototype : Prototype
         var viewRecord = MakeDataViewWithBufferWitnessRecord(dataView, ArrayBufferOrder.Unordered);
         if (viewRecord.IsViewOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Offset is outside the bounds of the DataView");
+            Throw.TypeError(_realm, "Offset is outside the bounds of the DataView");
         }
 
         var viewSize = viewRecord.ViewByteLength;
         var elementSize = type.GetElementSize();
         if (getIndex + elementSize > viewSize)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Offset is outside the bounds of the DataView");
+            Throw.RangeError(_realm, "Offset is outside the bounds of the DataView");
         }
 
         var bufferIndex = (int) (getIndex + viewOffset);
@@ -362,7 +362,7 @@ internal sealed class DataViewPrototype : Prototype
         var dataView = view as JsDataView;
         if (dataView is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method called on incompatible receiver " + view);
+            Throw.TypeError(_realm, "Method called on incompatible receiver " + view);
         }
 
         var getIndex = TypeConverter.ToIndex(_realm, requestIndex);
@@ -385,14 +385,14 @@ internal sealed class DataViewPrototype : Prototype
         var viewRecord = MakeDataViewWithBufferWitnessRecord(dataView, ArrayBufferOrder.Unordered);
         if (viewRecord.IsViewOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Offset is outside the bounds of the DataView");
+            Throw.TypeError(_realm, "Offset is outside the bounds of the DataView");
         }
 
         var viewSize = viewRecord.ViewByteLength;
         var elementSize = type.GetElementSize();
         if (getIndex + elementSize > viewSize)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Offset is outside the bounds of the DataView");
+            Throw.RangeError(_realm, "Offset is outside the bounds of the DataView");
         }
 
         var bufferIndex = (int) (getIndex + viewOffset);

+ 8 - 8
Jint/Native/Date/DatePrototype.cs

@@ -107,13 +107,13 @@ internal sealed class DatePrototype : Prototype
         var oi = thisObject as ObjectInstance;
         if (oi is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var hint = arguments.At(0);
         if (!hint.IsString())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var hintString = hint.ToString();
@@ -128,7 +128,7 @@ internal sealed class DatePrototype : Prototype
         }
         else
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return TypeConverter.OrdinaryToPrimitive(oi, tryFirst);
@@ -149,7 +149,7 @@ internal sealed class DatePrototype : Prototype
             return dateInstance._dateValue;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "this is not a Date object");
+        Throw.TypeError(_realm, "this is not a Date object");
         return default;
     }
 
@@ -794,7 +794,7 @@ internal sealed class DatePrototype : Prototype
         var t = thisTime;
         if (t.IsNaN)
         {
-            ExceptionHelper.ThrowRangeError(_realm);
+            Throw.RangeError(_realm);
         }
 
         if (((JsDate) thisObject).DateTimeRangeValid)
@@ -941,7 +941,7 @@ internal sealed class DatePrototype : Prototype
             return 1;
         }
 
-        ExceptionHelper.ThrowArgumentException();
+        Throw.ArgumentException();
         return 0;
     }
 
@@ -1013,7 +1013,7 @@ internal sealed class DatePrototype : Prototype
             return 11;
         }
 
-        ExceptionHelper.ThrowInvalidOperationException();
+        Throw.InvalidOperationException();
         return 0;
     }
 
@@ -1087,7 +1087,7 @@ internal sealed class DatePrototype : Prototype
             return dayWithinYear - 333 - InLeapYear(t);
         }
 
-        ExceptionHelper.ThrowInvalidOperationException();
+        Throw.InvalidOperationException();
         return 0;
     }
 

+ 1 - 1
Jint/Native/Disposable/AsyncDisposableStackConstructor.cs

@@ -21,7 +21,7 @@ internal sealed class AsyncDisposableStackConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var stack = OrdinaryCreateFromConstructor(

+ 1 - 1
Jint/Native/Disposable/AsyncDisposableStackPrototype.cs

@@ -92,7 +92,7 @@ internal sealed class AsyncDisposableStackPrototype : Prototype
     {
         if (thisObject is not DisposableStack { _hint: DisposeHint.Async } stack)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "This is not a AsyncDisposableStack instance.");
+            Throw.TypeError(_engine.Realm, "This is not a AsyncDisposableStack instance.");
             return null!;
         }
 

+ 2 - 2
Jint/Native/Disposable/DisposableStack.cs

@@ -35,7 +35,7 @@ internal sealed class DisposableStack : ObjectInstance
         var completion = _disposeCapability.DisposeResources(new Completion(CompletionType.Normal, Undefined, _engine.GetLastSyntaxElement()));
         if (completion.Type == CompletionType.Throw)
         {
-            ExceptionHelper.ThrowJavaScriptException(_engine, completion.Value, completion);
+            Throw.JavaScriptException(_engine, completion.Value, completion);
         }
         return completion.Value;
     }
@@ -89,7 +89,7 @@ internal sealed class DisposableStack : ObjectInstance
     {
         if (State == DisposableState.Disposed)
         {
-            ExceptionHelper.ThrowReferenceError(_engine.Realm, "Stack already disposed.");
+            Throw.ReferenceError(_engine.Realm, "Stack already disposed.");
         }
     }
 }

+ 1 - 1
Jint/Native/Disposable/DisposableStackConstructor.cs

@@ -21,7 +21,7 @@ internal sealed class DisposableStackConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var stack = OrdinaryCreateFromConstructor(

+ 1 - 1
Jint/Native/Disposable/DisposableStackPrototype.cs

@@ -93,7 +93,7 @@ internal sealed class DisposableStackPrototype : Prototype
     {
         if (thisObject is not DisposableStack { _hint: DisposeHint.Sync } stack)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "This is not a DisposableStack instance.");
+            Throw.TypeError(_engine.Realm, "This is not a DisposableStack instance.");
             return null!;
         }
 

+ 2 - 2
Jint/Native/Disposable/DisposeCapability.cs

@@ -45,13 +45,13 @@ internal sealed class DisposeCapability
             {
                 if (!v.IsObject())
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, "Expected an object for disposable resource.");
+                    Throw.TypeError(_engine.Realm, "Expected an object for disposable resource.");
                     return default;
                 }
                 method = v.AsObject().GetDisposeMethod(hint);
                 if (method is null)
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, "No dispose method found for the resource.");
+                    Throw.TypeError(_engine.Realm, "No dispose method found for the resource.");
                     return default;
                 }
             }

+ 1 - 1
Jint/Native/Error/ErrorPrototype.cs

@@ -45,7 +45,7 @@ internal sealed class ErrorPrototype : ErrorInstance
         var o = thisObject.TryCast<ObjectInstance>();
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var nameProp = o.Get("name", this);

+ 2 - 2
Jint/Native/FinalizationRegistry/FinalizationRegistryConstructor.cs

@@ -35,13 +35,13 @@ internal sealed class FinalizationRegistryConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var cleanupCallback = arguments.At(0);
         if (cleanupCallback is not ICallable callable)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "cleanup must be callable");
+            Throw.TypeError(_realm, "cleanup must be callable");
             return null;
         }
 

+ 5 - 5
Jint/Native/FinalizationRegistry/FinalizationRegistryPrototype.cs

@@ -51,19 +51,19 @@ internal sealed class FinalizationRegistryPrototype : Prototype
 
         if (!target.CanBeHeldWeakly(_engine.GlobalSymbolRegistry))
         {
-            ExceptionHelper.ThrowTypeError(_realm, "target must be an object or symbol");
+            Throw.TypeError(_realm, "target must be an object or symbol");
         }
 
         if (SameValue(target, heldValue))
         {
-            ExceptionHelper.ThrowTypeError(_realm, "target and holdings must not be same");
+            Throw.TypeError(_realm, "target and holdings must not be same");
         }
 
         if (!unregisterToken.CanBeHeldWeakly(_engine.GlobalSymbolRegistry))
         {
             if (!unregisterToken.IsUndefined())
             {
-                ExceptionHelper.ThrowTypeError(_realm, unregisterToken + " must be an object");
+                Throw.TypeError(_realm, unregisterToken + " must be an object");
             }
         }
 
@@ -83,7 +83,7 @@ internal sealed class FinalizationRegistryPrototype : Prototype
 
         if (!unregisterToken.CanBeHeldWeakly(_engine.GlobalSymbolRegistry))
         {
-            ExceptionHelper.ThrowTypeError(_realm, unregisterToken + " must be an object or symbol");
+            Throw.TypeError(_realm, unregisterToken + " must be an object or symbol");
         }
 
         return finalizationRegistry.Remove(unregisterToken);
@@ -96,7 +96,7 @@ internal sealed class FinalizationRegistryPrototype : Prototype
             return finalizationRegistryInstance;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "object must be a FinalizationRegistry");
+        Throw.TypeError(_realm, "object must be a FinalizationRegistry");
         return default;
     }
 }

+ 3 - 3
Jint/Native/Function/BindFunction.cs

@@ -45,7 +45,7 @@ public sealed class BindFunction : ObjectInstance, IConstructor, ICallable
         var f = BoundTargetFunction as Function;
         if (f is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var args = CreateArguments(arguments);
@@ -60,7 +60,7 @@ public sealed class BindFunction : ObjectInstance, IConstructor, ICallable
         var target = BoundTargetFunction as IConstructor;
         if (target is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var args = CreateArguments(arguments);
@@ -81,7 +81,7 @@ public sealed class BindFunction : ObjectInstance, IConstructor, ICallable
         var f = BoundTargetFunction as Function;
         if (f is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return f.OrdinaryHasInstance(v);

+ 3 - 3
Jint/Native/Function/ClassDefinition.cs

@@ -85,7 +85,7 @@ internal sealed class ClassDefinition
             }
             else if (!superclass.IsConstructor)
             {
-                ExceptionHelper.ThrowTypeError(engine.Realm, "super class is not a constructor");
+                Throw.TypeError(engine.Realm, "super class is not a constructor");
             }
             else
             {
@@ -100,7 +100,7 @@ internal sealed class ClassDefinition
                 }
                 else
                 {
-                    ExceptionHelper.ThrowTypeError(engine.Realm, "cannot resolve super class prototype chain");
+                    Throw.TypeError(engine.Realm, "cannot resolve super class prototype chain");
                     return default;
                 }
 
@@ -350,7 +350,7 @@ internal sealed class ClassDefinition
         var function = method.Value as IFunction;
         if (function is null)
         {
-            ExceptionHelper.ThrowSyntaxError(obj.Engine.Realm);
+            Throw.SyntaxError(obj.Engine.Realm);
         }
 
         if (method.Kind != PropertyKind.Get && method.Kind != PropertyKind.Set && !function.Generator)

+ 5 - 5
Jint/Native/Function/EvalFunction.cs

@@ -99,7 +99,7 @@ public sealed class EvalFunction : Function
             // if body Contains NewTarget, throw a SyntaxError exception.
             if (analyzer._containsNewTarget)
             {
-                ExceptionHelper.ThrowSyntaxError(evalRealm, "new.target expression is not allowed here");
+                Throw.SyntaxError(evalRealm, "new.target expression is not allowed here");
             }
         }
 
@@ -108,7 +108,7 @@ public sealed class EvalFunction : Function
             // if body Contains SuperProperty, throw a SyntaxError exception.
             if (analyzer._containsSuperProperty)
             {
-                ExceptionHelper.ThrowSyntaxError(evalRealm, "'super' keyword unexpected here");
+                Throw.SyntaxError(evalRealm, "'super' keyword unexpected here");
             }
         }
 
@@ -117,7 +117,7 @@ public sealed class EvalFunction : Function
             // if body Contains SuperCall, throw a SyntaxError exception.
             if (analyzer._containsSuperCall)
             {
-                ExceptionHelper.ThrowSyntaxError(evalRealm, "'super' keyword unexpected here");
+                Throw.SyntaxError(evalRealm, "'super' keyword unexpected here");
             }
         }
 
@@ -126,7 +126,7 @@ public sealed class EvalFunction : Function
             // if ContainsArguments of body is true, throw a SyntaxError exception.
             if (analyzer._containsArguments)
             {
-                ExceptionHelper.ThrowSyntaxError(evalRealm, "'arguments' is not allowed in class field initializer or static initialization block");
+                Throw.SyntaxError(evalRealm, "'arguments' is not allowed in class field initializer or static initialization block");
             }
         }
 
@@ -172,7 +172,7 @@ public sealed class EvalFunction : Function
 
                 if (result.Type == CompletionType.Throw)
                 {
-                    ExceptionHelper.ThrowJavaScriptException(_engine, value, result);
+                    Throw.JavaScriptException(_engine, value, result);
                     return null!;
                 }
                 else

+ 1 - 1
Jint/Native/Function/Function.cs

@@ -263,7 +263,7 @@ public abstract partial class Function : ObjectInstance, ICallable
         {
             if (proxyInstance._handler is null)
             {
-                ExceptionHelper.ThrowTypeErrorNoEngine();
+                Throw.TypeErrorNoEngine();
             }
 
             return GetFunctionRealm(proxyInstance._target);

+ 4 - 4
Jint/Native/Function/FunctionInstance.Dynamic.cs

@@ -50,7 +50,7 @@ public partial class Function
                 fallbackProto = static intrinsics => intrinsics.AsyncGeneratorFunction.PrototypeObject;
                 break;
             default:
-                ExceptionHelper.ThrowArgumentOutOfRangeException(nameof(kind), kind.ToString());
+                Throw.ArgumentOutOfRangeException(nameof(kind), kind.ToString());
                 break;
         }
 
@@ -96,7 +96,7 @@ public partial class Function
                         functionExpression = "async function* f(){}";
                         break;
                     default:
-                        ExceptionHelper.ThrowArgumentOutOfRangeException(nameof(kind), kind.ToString());
+                        Throw.ArgumentOutOfRangeException(nameof(kind), kind.ToString());
                         break;
                 }
             }
@@ -117,7 +117,7 @@ public partial class Function
                         functionExpression = "async function* f(";
                         break;
                     default:
-                        ExceptionHelper.ThrowArgumentOutOfRangeException(nameof(kind), kind.ToString());
+                        Throw.ArgumentOutOfRangeException(nameof(kind), kind.ToString());
                         break;
                 }
 
@@ -154,7 +154,7 @@ public partial class Function
         }
         catch (ParseErrorException ex)
         {
-            ExceptionHelper.ThrowSyntaxError(_engine.ExecutionContext.Realm, ex.Message);
+            Throw.SyntaxError(_engine.ExecutionContext.Realm, ex.Message);
         }
 
         var proto = GetPrototypeFromConstructor(newTarget, fallbackProto);

+ 5 - 5
Jint/Native/Function/FunctionPrototype.cs

@@ -63,7 +63,7 @@ internal sealed class FunctionPrototype : Function
     {
         if (thisObject is not (ICallable and ObjectInstance oi))
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Bind must be called on a function");
+            Throw.TypeError(_realm, "Bind must be called on a function");
             return default;
         }
 
@@ -136,7 +136,7 @@ internal sealed class FunctionPrototype : Function
             return thisObject.ToString();
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "Function.prototype.toString requires that 'this' be a Function");
+        Throw.TypeError(_realm, "Function.prototype.toString requires that 'this' be a Function");
         return null;
     }
 
@@ -148,7 +148,7 @@ internal sealed class FunctionPrototype : Function
         var func = thisObject as ICallable;
         if (func is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
         var thisArg = arguments.At(0);
         var argArray = arguments.At(1);
@@ -173,7 +173,7 @@ internal sealed class FunctionPrototype : Function
         var argArrayObj = argArray as ObjectInstance;
         if (argArrayObj is null)
         {
-            ExceptionHelper.ThrowTypeError(realm);
+            Throw.TypeError(realm);
         }
         var operations = ArrayOperations.For(argArrayObj, forWrite: false);
         var argList = elementTypes is null ? operations.GetAll() : operations.GetAll(elementTypes.Value);
@@ -188,7 +188,7 @@ internal sealed class FunctionPrototype : Function
         var func = thisObject as ICallable;
         if (func is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
         JsValue[] values = [];
         if (arguments.Length > 1)

+ 4 - 4
Jint/Native/Function/ScriptFunction.cs

@@ -67,7 +67,7 @@ public sealed class ScriptFunction : Function, IConstructor
 
                 if (_isClassConstructor)
                 {
-                    ExceptionHelper.ThrowTypeError(calleeContext.Realm, $"Class constructor {_functionDefinition.Name} cannot be invoked without 'new'");
+                    Throw.TypeError(calleeContext.Realm, $"Class constructor {_functionDefinition.Name} cannot be invoked without 'new'");
                 }
 
                 OrdinaryCallBindThis(calleeContext, thisObject);
@@ -80,7 +80,7 @@ public sealed class ScriptFunction : Function, IConstructor
 
                 if (result.Type == CompletionType.Throw)
                 {
-                    ExceptionHelper.ThrowJavaScriptException(_engine, result.Value, result);
+                    Throw.JavaScriptException(_engine, result.Value, result);
                 }
 
                 // The DebugHandler needs the current execution context before the return for stepping through the return point
@@ -191,12 +191,12 @@ public sealed class ScriptFunction : Function, IConstructor
 
                     if (!result.Value.IsUndefined())
                     {
-                        ExceptionHelper.ThrowTypeError(callerContext.Realm);
+                        Throw.TypeError(callerContext.Realm);
                     }
                 }
                 else if (result.Type == CompletionType.Throw)
                 {
-                    ExceptionHelper.ThrowJavaScriptException(_engine, result.Value, result);
+                    Throw.JavaScriptException(_engine, result.Value, result);
                 }
             }
             finally

+ 1 - 1
Jint/Native/Function/ThrowTypeError.cs

@@ -16,7 +16,7 @@ internal sealed class ThrowTypeError : Function
 
     protected internal override JsValue Call(JsValue thisObject, JsCallArguments arguments)
     {
-        ExceptionHelper.ThrowTypeError(_realm);
+        Throw.TypeError(_realm);
         return null;
     }
 }

+ 5 - 5
Jint/Native/Generator/GeneratorInstance.cs

@@ -80,7 +80,7 @@ internal sealed class GeneratorInstance : ObjectInstance
                 return new IteratorResult(_engine, abruptCompletion.Value, JsBoolean.True);
             }
 
-            ExceptionHelper.ThrowJavaScriptException(_engine, abruptCompletion.Value, AstExtensions.DefaultLocation);
+            Throw.JavaScriptException(_engine, abruptCompletion.Value, AstExtensions.DefaultLocation);
         }
 
         var genContext = _generatorContext;
@@ -97,7 +97,7 @@ internal sealed class GeneratorInstance : ObjectInstance
 
         if (_error is not null)
         {
-            ExceptionHelper.ThrowJavaScriptException(_engine, _error, AstExtensions.DefaultLocation);
+            Throw.JavaScriptException(_engine, _error, AstExtensions.DefaultLocation);
         }
 
         return ResumeExecution(genContext, new EvaluationContext(_engine));
@@ -133,7 +133,7 @@ internal sealed class GeneratorInstance : ObjectInstance
         if (result.Type == CompletionType.Throw)
         {
             _generatorState = GeneratorState.Completed;
-            ExceptionHelper.ThrowJavaScriptException(_engine, result.Value, result);
+            Throw.JavaScriptException(_engine, result.Value, result);
         }
 
         return resultValue!;
@@ -143,12 +143,12 @@ internal sealed class GeneratorInstance : ObjectInstance
     {
         if (!ReferenceEquals(generatorBrand, _generatorBrand))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Generator brand differs from attached brand");
+            Throw.TypeError(_engine.Realm, "Generator brand differs from attached brand");
         }
 
         if (_generatorState == GeneratorState.Executing)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Generator state was unexpectedly executing");
+            Throw.TypeError(_engine.Realm, "Generator state was unexpectedly executing");
         }
 
         return _generatorState;

+ 1 - 1
Jint/Native/Generator/GeneratorPrototype.cs

@@ -80,7 +80,7 @@ internal sealed class GeneratorPrototype : ObjectInstance
         var generatorInstance = thisObj as GeneratorInstance;
         if (generatorInstance is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "object must be a Generator instance");
+            Runtime.Throw.TypeError(_engine.Realm, "object must be a Generator instance");
         }
 
         return generatorInstance;

+ 3 - 3
Jint/Native/Global/GlobalObject.cs

@@ -391,7 +391,7 @@ public sealed partial class GlobalObject : ObjectInstance
         return builder.ToString();
 
 uriError:
-        _engine.SignalError(ExceptionHelper.CreateUriError(_realm, "URI malformed"));
+        _engine.SignalError(Throw.CreateUriError(_realm, "URI malformed"));
         return JsEmpty.Instance;
     }
 
@@ -569,7 +569,7 @@ uriError:
         return _stringBuilder.ToString();
 
 uriError:
-        _engine.SignalError(ExceptionHelper.CreateUriError(_realm, "URI malformed"));
+        _engine.SignalError(Throw.CreateUriError(_realm, "URI malformed"));
         return JsEmpty.Instance;
     }
 
@@ -759,7 +759,7 @@ uriError:
         {
             if (strict)
             {
-                ExceptionHelper.ThrowReferenceNameError(_realm, property.Name);
+                Throw.ReferenceNameError(_realm, property.Name);
             }
             _properties[property] = new PropertyDescriptor(value, PropertyFlag.ConfigurableEnumerableWritable | PropertyFlag.MutableBinding);
             return true;

+ 1 - 1
Jint/Native/GroupByHelper.cs

@@ -46,7 +46,7 @@ internal static class GroupByHelper
         {
             if (_k >= ArrayOperations.MaxArrayLength)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
 
             _callArgs[0] = currentValue;

+ 8 - 8
Jint/Native/Intl/NumberFormatConstructor.cs

@@ -159,12 +159,12 @@ internal sealed class NumberFormatConstructor : Constructor
         {
             if (style == "currency")
             {
-                ExceptionHelper.ThrowTypeError(_realm, "No currency found when style currency requested");
+                Throw.TypeError(_realm, "No currency found when style currency requested");
             }
         }
         else if (!IsWellFormedCurrencyCode(currency))
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid currency code");
+            Throw.RangeError(_realm, "Invalid currency code");
         }
 
         var currencyDisplay = GetOption(options, "currencyDisplay", OptionType.String, new JsValue[] { "code", "symbol", "narrowSymbol", "name" }, "symbol");
@@ -175,12 +175,12 @@ internal sealed class NumberFormatConstructor : Constructor
         {
             if (style == "unit")
             {
-                ExceptionHelper.ThrowTypeError(_realm, "No unit found when style unit requested");
+                Throw.TypeError(_realm, "No unit found when style unit requested");
             }
         }
         else if (!IsWellFormedUnitIdentifier(unit))
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid unit");
+            Throw.RangeError(_realm, "Invalid unit");
         }
 
         var unitDisplay = GetOption(options, "unitDisplay", OptionType.String, new JsValue[] { "short", "narrow", "long" }, "short");
@@ -327,7 +327,7 @@ internal sealed class NumberFormatConstructor : Constructor
         {
             if (defaultValue == "required")
             {
-                ExceptionHelper.ThrowRangeError(_realm, "Required value missing");
+                Throw.RangeError(_realm, "Required value missing");
             }
 
             return defaultValue;
@@ -343,7 +343,7 @@ internal sealed class NumberFormatConstructor : Constructor
                     var number = TypeConverter.ToNumber(value);
                     if (double.IsNaN(number))
                     {
-                        ExceptionHelper.ThrowRangeError(_realm, "Invalid number value");
+                        Throw.RangeError(_realm, "Invalid number value");
                     }
                     value = number;
                     break;
@@ -352,13 +352,13 @@ internal sealed class NumberFormatConstructor : Constructor
                 value = TypeConverter.ToString(value);
                 break;
             default:
-                ExceptionHelper.ThrowArgumentOutOfRangeException(nameof(type), "Unknown type");
+                Throw.ArgumentOutOfRangeException(nameof(type), "Unknown type");
                 break;
         }
 
         if (values.Length > 0 && System.Array.IndexOf(values, value) == -1)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Value not part of list");
+            Throw.RangeError(_realm, "Value not part of list");
         }
 
         return value;

+ 5 - 5
Jint/Native/Iterator/IteratorInstance.cs

@@ -15,7 +15,7 @@ internal abstract class IteratorInstance : ObjectInstance
 
     public override object ToObject()
     {
-        ExceptionHelper.ThrowNotImplementedException();
+        Throw.NotImplementedException();
         return null;
     }
 
@@ -43,7 +43,7 @@ internal abstract class IteratorInstance : ObjectInstance
             _target = target;
             if (target.Get(CommonProperties.Next) is not ICallable callable)
             {
-                ExceptionHelper.ThrowTypeError(target.Engine.Realm);
+                Throw.TypeError(target.Engine.Realm);
                 return;
             }
 
@@ -69,7 +69,7 @@ internal abstract class IteratorInstance : ObjectInstance
             var instance = jsValue as ObjectInstance;
             if (instance is null)
             {
-                ExceptionHelper.ThrowTypeError(_target.Engine.Realm, $"Iterator result {jsValue} is not an object");
+                Throw.TypeError(_target.Engine.Realm, $"Iterator result {jsValue} is not an object");
             }
 
             return instance;
@@ -95,7 +95,7 @@ internal abstract class IteratorInstance : ObjectInstance
 
             if (completion != CompletionType.Throw && !innerResult.IsObject())
             {
-                ExceptionHelper.ThrowTypeError(_target.Engine.Realm, "Iterator returned non-object");
+                Throw.TypeError(_target.Engine.Realm, "Iterator returned non-object");
             }
         }
     }
@@ -136,7 +136,7 @@ internal abstract class IteratorInstance : ObjectInstance
             var r = iteratingRegExp as JsRegExp;
             if (r is null)
             {
-                ExceptionHelper.ThrowTypeError(engine.Realm);
+                Throw.TypeError(engine.Realm);
             }
 
             _iteratingRegExp = r;

+ 2 - 2
Jint/Native/Iterator/IteratorProtocol.cs

@@ -73,7 +73,7 @@ internal abstract class IteratorProtocol
         var callable = adder as ICallable;
         if (callable is null)
         {
-            ExceptionHelper.ThrowTypeError(target.Engine.Realm, "adder must be callable");
+            Throw.TypeError(target.Engine.Realm, "adder must be callable");
         }
 
         var args = target.Engine._jsValueArrayPool.RentArray(2);
@@ -94,7 +94,7 @@ internal abstract class IteratorProtocol
                 var oi = temp as ObjectInstance;
                 if (oi is null)
                 {
-                    ExceptionHelper.ThrowTypeError(target.Engine.Realm, "iterator's value must be an object");
+                    Throw.TypeError(target.Engine.Realm, "iterator's value must be an object");
                 }
 
                 var k = oi.Get(JsString.NumberZeroString);

+ 1 - 1
Jint/Native/Iterator/IteratorPrototype.cs

@@ -49,7 +49,7 @@ internal class IteratorPrototype : Prototype
         var iterator = thisObject as IteratorInstance;
         if (iterator is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         iterator.TryIteratorStep(out var result);

+ 10 - 10
Jint/Native/JsArrayBuffer.cs

@@ -25,7 +25,7 @@ public class JsArrayBuffer : ObjectInstance
     {
         if (arrayBufferMaxByteLength is > int.MaxValue)
         {
-            ExceptionHelper.ThrowRangeError(engine.Realm, "arrayBufferMaxByteLength cannot be larger than int32.MaxValue");
+            Throw.RangeError(engine.Realm, "arrayBufferMaxByteLength cannot be larger than int32.MaxValue");
         }
 
         _prototype = engine.Intrinsics.ArrayBuffer.PrototypeObject;
@@ -37,7 +37,7 @@ public class JsArrayBuffer : ObjectInstance
     {
         if (byteLength > int.MaxValue)
         {
-            ExceptionHelper.ThrowRangeError(realm, "Array buffer allocation failed");
+            Throw.RangeError(realm, "Array buffer allocation failed");
         }
 
         return new byte[byteLength];
@@ -61,7 +61,7 @@ public class JsArrayBuffer : ObjectInstance
 
         if (!SameValue(_arrayBufferDetachKey, key))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         _arrayBufferData = null;
@@ -142,7 +142,7 @@ public class JsArrayBuffer : ObjectInstance
 
             return value;
 #else
-            ExceptionHelper.ThrowNotImplementedException("Float16/Half type is not supported in this build");
+            Throw.NotImplementedException("Float16/Half type is not supported in this build");
             return default;
 #endif
 
@@ -201,7 +201,7 @@ public class JsArrayBuffer : ObjectInstance
 
         if (arrayValue is null)
         {
-            ExceptionHelper.ThrowArgumentOutOfRangeException(nameof(type), type.ToString());
+            Throw.ArgumentOutOfRangeException(nameof(type), type.ToString());
         }
 
         return arrayValue.Value;
@@ -243,7 +243,7 @@ public class JsArrayBuffer : ObjectInstance
 #if SUPPORTS_HALF
             rawBytes = BitConverter.GetBytes((Half) value.DoubleValue);
 #else
-            ExceptionHelper.ThrowNotImplementedException("Float16/Half type is not supported in this build");
+            Throw.NotImplementedException("Float16/Half type is not supported in this build");
             return default!;
 #endif
         }
@@ -314,7 +314,7 @@ public class JsArrayBuffer : ObjectInstance
 #endif
                     break;
                 default:
-                    ExceptionHelper.ThrowArgumentOutOfRangeException();
+                    Throw.ArgumentOutOfRangeException();
                     return null;
             }
         }
@@ -332,12 +332,12 @@ public class JsArrayBuffer : ObjectInstance
     {
         if (_arrayBufferMaxByteLength is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         if (newByteLength > _arrayBufferMaxByteLength)
         {
-            ExceptionHelper.ThrowRangeError(_engine.Realm);
+            Throw.RangeError(_engine.Realm);
         }
 
         var oldBlock = _arrayBufferData ?? [];
@@ -352,7 +352,7 @@ public class JsArrayBuffer : ObjectInstance
     {
         if (IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "ArrayBuffer has been detached");
+            Throw.TypeError(_engine.Realm, "ArrayBuffer has been detached");
         }
     }
 }

+ 1 - 1
Jint/Native/JsDate.cs

@@ -55,7 +55,7 @@ public sealed class JsDate : ObjectInstance
             return dateTime;
         }
 
-        ExceptionHelper.ThrowRangeError(_engine.Realm);
+        Throw.RangeError(_engine.Realm);
         return DateTime.MinValue;
     }
 

+ 2 - 2
Jint/Native/JsPromise.cs

@@ -120,7 +120,7 @@ internal sealed class JsPromise : ObjectInstance
     {
         if (State != PromiseState.Pending)
         {
-            ExceptionHelper.ThrowInvalidOperationException("Promise should be in Pending state");
+            Throw.InvalidOperationException("Promise should be in Pending state");
         }
 
         Settle(PromiseState.Rejected, reason);
@@ -141,7 +141,7 @@ internal sealed class JsPromise : ObjectInstance
     {
         if (State != PromiseState.Pending)
         {
-            ExceptionHelper.ThrowInvalidOperationException("Promise should be in Pending state");
+            Throw.InvalidOperationException("Promise should be in Pending state");
         }
 
         Settle(PromiseState.Fulfilled, result);

+ 34 - 34
Jint/Native/JsProxy.cs

@@ -45,7 +45,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
     {
         if (_target is not ICallable)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "(intermediate value) is not a function");
+            Throw.TypeError(_engine.Realm, "(intermediate value) is not a function");
         }
 
         var jsValues = new[] { _target, thisObject, _engine.Realm.Intrinsics.Array.ConstructFast(arguments) };
@@ -57,7 +57,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
         var callable = _target as ICallable;
         if (callable is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, _target + " is not a function");
+            Throw.TypeError(_engine.Realm, _target + " is not a function");
         }
 
         return callable.Call(thisObject, arguments);
@@ -70,7 +70,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
     {
         if (_target is not ICallable)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "(intermediate value) is not a constructor");
+            Throw.TypeError(_engine.Realm, "(intermediate value) is not a constructor");
         }
 
         var argArray = _engine.Realm.Intrinsics.Array.Construct(arguments, _engine.Realm.Intrinsics.Array);
@@ -80,7 +80,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             var constructor = _target as IConstructor;
             if (constructor is null)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
             return constructor.Construct(arguments, newTarget);
         }
@@ -88,7 +88,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
         var oi = result as ObjectInstance;
         if (oi is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return oi;
@@ -141,7 +141,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
                 var targetValue = targetDesc.Value;
                 if (!targetDesc.Configurable && !targetDesc.Writable && !SameValue(result, targetValue))
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, $"'get' on proxy: property '{property}' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '{targetValue}' but got '{result}')");
+                    Throw.TypeError(_engine.Realm, $"'get' on proxy: property '{property}' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '{targetValue}' but got '{result}')");
                 }
             }
 
@@ -149,7 +149,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             {
                 if (!targetDesc.Configurable && (targetDesc.Get ?? Undefined).IsUndefined() && !result.IsUndefined())
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, $"'get' on proxy: property '{property}' is a non-configurable accessor property on the proxy target and does not have a getter function, but the trap did not return 'undefined' (got '{result}')");
+                    Throw.TypeError(_engine.Realm, $"'get' on proxy: property '{property}' is a non-configurable accessor property on the proxy target and does not have a getter function, but the trap did not return 'undefined' (got '{result}')");
                 }
             }
         }
@@ -171,7 +171,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (trapResult.Count != new HashSet<JsValue>(trapResult).Count)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         var extensibleTarget = _target.Extensible;
@@ -198,7 +198,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             var key = targetNonconfigurableKeys[i];
             if (!uncheckedResultKeys.Remove(key))
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
         }
 
@@ -212,13 +212,13 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             var key = targetConfigurableKeys[i];
             if (!uncheckedResultKeys.Remove(key))
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
         }
 
         if (uncheckedResultKeys.Count > 0)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return trapResult;
@@ -236,7 +236,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (!trapResultObj.IsObject() && !trapResultObj.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         var targetDesc = _target.GetOwnProperty(property);
@@ -250,7 +250,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
             if (!targetDesc.Configurable || !_target.Extensible)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
 
             return PropertyDescriptor.Undefined;
@@ -263,21 +263,21 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
         var valid = IsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc);
         if (!valid)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         if (!resultDesc.Configurable)
         {
             if (targetDesc == PropertyDescriptor.Undefined || targetDesc.Configurable)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
 
             if (resultDesc.WritableSet && !resultDesc.Writable)
             {
                 if (targetDesc.Writable)
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm);
+                    Throw.TypeError(_engine.Realm);
                 }
             }
         }
@@ -339,7 +339,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
                 var targetValue = targetDesc.Value;
                 if (!SameValue(targetValue, value))
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, $"'set' on proxy: trap returned truish for property '{property}' which exists in the proxy target as a non-configurable and non-writable data property with a different value");
+                    Throw.TypeError(_engine.Realm, $"'set' on proxy: trap returned truish for property '{property}' which exists in the proxy target as a non-configurable and non-writable data property with a different value");
                 }
             }
 
@@ -347,7 +347,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             {
                 if ((targetDesc.Set ?? Undefined).IsUndefined())
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, $"'set' on proxy: trap returned truish for property '{property}' which exists in the proxy target as a non-configurable and non-writable accessor property without a setter");
+                    Throw.TypeError(_engine.Realm, $"'set' on proxy: trap returned truish for property '{property}' which exists in the proxy target as a non-configurable and non-writable accessor property without a setter");
                 }
             }
         }
@@ -380,25 +380,25 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
         {
             if (!extensibleTarget || settingConfigFalse)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
         }
         else
         {
             if (!IsCompatiblePropertyDescriptor(extensibleTarget, desc, targetDesc))
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
             if (targetDesc.Configurable && settingConfigFalse)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
 
             if (targetDesc.IsDataDescriptor() && !targetDesc.Configurable && targetDesc.Writable)
             {
                 if (desc.WritableSet && !desc.Writable)
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm);
+                    Throw.TypeError(_engine.Realm);
                 }
             }
         }
@@ -430,12 +430,12 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             {
                 if (!targetDesc.Configurable)
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm);
+                    Throw.TypeError(_engine.Realm);
                 }
 
                 if (!_target.Extensible)
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm);
+                    Throw.TypeError(_engine.Realm);
                 }
             }
         }
@@ -469,12 +469,12 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (!targetDesc.Configurable)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, $"'deleteProperty' on proxy: trap returned truish for property '{property}' which is non-configurable in the proxy target");
+            Throw.TypeError(_engine.Realm, $"'deleteProperty' on proxy: trap returned truish for property '{property}' which is non-configurable in the proxy target");
         }
 
         if (!_target.Extensible)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return true;
@@ -494,7 +494,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (success && _target.Extensible)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return success;
@@ -516,7 +516,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             var targetResult = _target.Extensible;
             if (booleanTrapResult != targetResult)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm);
+                Throw.TypeError(_engine.Realm);
             }
             return booleanTrapResult;
         }
@@ -534,7 +534,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (!handlerProto.IsObject() && !handlerProto.IsNull())
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "'getPrototypeOf' on proxy: trap returned neither object nor null");
+            Throw.TypeError(_engine.Realm, "'getPrototypeOf' on proxy: trap returned neither object nor null");
         }
 
         if (_target.Extensible)
@@ -544,7 +544,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (!ReferenceEquals(handlerProto, _target.Prototype))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return (ObjectInstance) handlerProto;
@@ -574,7 +574,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
 
         if (!ReferenceEquals(value, _target.Prototype))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return true;
@@ -593,7 +593,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
             var callable = handlerFunction as ICallable;
             if (callable is null)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm, $"{_handler} returned for property '{propertyName}' of object '{_target}' is not a function");
+                Throw.TypeError(_engine.Realm, $"{_handler} returned for property '{propertyName}' of object '{_target}' is not a function");
             }
 
             result = callable.Call(_handler, arguments);
@@ -607,7 +607,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
     {
         if (_handler is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, $"Cannot perform '{key}' on a proxy that has been revoked");
+            Throw.TypeError(_engine.Realm, $"Cannot perform '{key}' on a proxy that has been revoked");
         }
     }
 
@@ -615,7 +615,7 @@ internal sealed class JsProxy : ObjectInstance, IConstructor, ICallable
     {
         if (_target is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, $"Cannot perform '{key}' on a proxy that has been revoked");
+            Throw.TypeError(_engine.Realm, $"Cannot perform '{key}' on a proxy that has been revoked");
         }
     }
 

+ 2 - 2
Jint/Native/JsSharedArrayBuffer.cs

@@ -17,7 +17,7 @@ internal sealed class JsSharedArrayBuffer : JsArrayBuffer
     {
         if (arrayBufferByteLengthData > int.MaxValue)
         {
-            ExceptionHelper.ThrowRangeError(engine.Realm, "arrayBufferByteLengthData cannot be larger than int32.MaxValue");
+            Throw.RangeError(engine.Realm, "arrayBufferByteLengthData cannot be larger than int32.MaxValue");
         }
         this._arrayBufferByteLengthData = (int) arrayBufferByteLengthData;
     }
@@ -31,7 +31,7 @@ internal sealed class JsSharedArrayBuffer : JsArrayBuffer
     {
         if (byteLength > int.MaxValue)
         {
-            ExceptionHelper.ThrowRangeError(realm, "Array buffer allocation failed");
+            Throw.RangeError(realm, "Array buffer allocation failed");
         }
 
         return new byte[byteLength];

+ 1 - 1
Jint/Native/JsTypedArray.cs

@@ -358,7 +358,7 @@ public sealed class JsTypedArray : ObjectInstance
             }
             catch (ParseErrorException ex)
             {
-                ExceptionHelper.ThrowSyntaxError(_engine.Realm, ex.Message);
+                Throw.SyntaxError(_engine.Realm, ex.Message);
             }
         }
     }

+ 9 - 9
Jint/Native/JsValue.cs

@@ -48,7 +48,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
     {
         if (!TryGetIterator(realm, out var iterator, hint, method))
         {
-            ExceptionHelper.ThrowTypeError(realm, "The value is not iterable");
+            Throw.TypeError(realm, "The value is not iterable");
             return null!;
         }
 
@@ -61,7 +61,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
         var iterator = method.Call(this);
         if (iterator is not ObjectInstance objectInstance)
         {
-            ExceptionHelper.ThrowTypeError(realm);
+            Throw.TypeError(realm);
             return null!;
         }
         return new IteratorInstance.ObjectIterator(objectInstance);
@@ -86,7 +86,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
                     var syncMethod = obj.GetMethod(GlobalSymbolRegistry.Iterator);
                     var syncIteratorRecord = obj.GetIterator(realm, GeneratorKind.Sync, syncMethod);
                     // TODO async CreateAsyncFromSyncIterator(syncIteratorRecord);
-                    ExceptionHelper.ThrowNotImplementedException("async");
+                    Throw.NotImplementedException("async");
                 }
             }
             else
@@ -104,7 +104,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
         var iteratorResult = method.Call(obj, Arguments.Empty) as ObjectInstance;
         if (iteratorResult is null)
         {
-            ExceptionHelper.ThrowTypeError(realm, "Result of the Symbol.iterator method is not an object");
+            Throw.TypeError(realm, "Result of the Symbol.iterator method is not an object");
         }
 
         if (iteratorResult is IteratorInstance i)
@@ -273,7 +273,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
     /// </summary>
     public virtual bool Set(JsValue property, JsValue value, JsValue receiver)
     {
-        ExceptionHelper.ThrowNotSupportedException();
+        Throw.NotSupportedException();
         return false;
     }
 
@@ -284,7 +284,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
     {
         if (target is not ObjectInstance oi)
         {
-            ExceptionHelper.ThrowTypeErrorNoEngine("Right-hand side of 'instanceof' is not an object");
+            Throw.TypeErrorNoEngine("Right-hand side of 'instanceof' is not an object");
             return false;
         }
 
@@ -296,7 +296,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
 
         if (!target.IsCallable)
         {
-            ExceptionHelper.ThrowTypeErrorNoEngine("Right-hand side of 'instanceof' is not callable");
+            Throw.TypeErrorNoEngine("Right-hand side of 'instanceof' is not callable");
         }
 
         return target.OrdinaryHasInstance(this);
@@ -464,7 +464,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
         var p = Get(CommonProperties.Prototype);
         if (p is not ObjectInstance)
         {
-            ExceptionHelper.ThrowTypeError(o.Engine.Realm, $"Function has non-object prototype '{TypeConverter.ToString(p)}' in instanceof check");
+            Throw.TypeError(o.Engine.Realm, $"Function has non-object prototype '{TypeConverter.ToString(p)}' in instanceof check");
         }
 
         while (true)
@@ -546,7 +546,7 @@ public abstract partial class JsValue : IEquatable<JsValue>
     {
         if (!c.IsConstructor)
         {
-            ExceptionHelper.ThrowTypeError(engine.Realm, c + " is not a constructor");
+            Throw.TypeError(engine.Realm, c + " is not a constructor");
         }
 
         return (IConstructor) c;

+ 1 - 1
Jint/Native/JsWeakMap.cs

@@ -27,7 +27,7 @@ internal sealed class JsWeakMap : ObjectInstance
     {
         if (!key.CanBeHeldWeakly(_engine.GlobalSymbolRegistry))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "WeakMap key must be an object, got " + key);
+            Throw.TypeError(_engine.Realm, "WeakMap key must be an object, got " + key);
         }
 
 #if SUPPORTS_WEAK_TABLE_ADD_OR_UPDATE

+ 1 - 1
Jint/Native/JsWeakSet.cs

@@ -27,7 +27,7 @@ internal sealed class JsWeakSet : ObjectInstance
     {
         if (!value.CanBeHeldWeakly(_engine.GlobalSymbolRegistry))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "WeakSet value must be an object or symbol, got " + value);
+            Throw.TypeError(_engine.Realm, "WeakSet value must be an object or symbol, got " + value);
         }
 
 #if SUPPORTS_WEAK_TABLE_ADD_OR_UPDATE

+ 1 - 1
Jint/Native/Json/JsonParser.cs

@@ -457,7 +457,7 @@ public sealed class JsonParser
     private void ThrowError(int position, string messageFormat, params object[] arguments)
     {
         var msg = string.Format(CultureInfo.InvariantCulture, messageFormat, arguments);
-        ExceptionHelper.ThrowSyntaxError(_engine.Realm, $"{msg} at position {position}");
+        Throw.SyntaxError(_engine.Realm, $"{msg} at position {position}");
     }
 
     // Throw an exception because of the token.

+ 1 - 1
Jint/Native/Json/JsonSerializer.cs

@@ -207,7 +207,7 @@ public sealed class JsonSerializer
 
         if (value.IsBigInt())
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Do not know how to serialize a BigInt");
+            Throw.TypeError(_engine.Realm, "Do not know how to serialize a BigInt");
         }
 
         if (value is ObjectInstance { IsCallable: false } objectInstance)

+ 1 - 1
Jint/Native/Map/MapConstructor.cs

@@ -63,7 +63,7 @@ public sealed class MapConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var map = OrdinaryCreateFromConstructor(

+ 1 - 1
Jint/Native/Map/MapPrototype.cs

@@ -151,7 +151,7 @@ internal sealed class MapPrototype : Prototype
             return map;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "object must be a Map");
+        Throw.TypeError(_realm, "object must be a Map");
         return default;
     }
 }

+ 4 - 4
Jint/Native/Math/MathInstance.cs

@@ -868,7 +868,7 @@ internal sealed class MathInstance : ObjectInstance
 
         return (double) (Half) n;
 #else
-        ExceptionHelper.ThrowNotImplementedException("Float16/Half type is not supported in this build");
+        Throw.NotImplementedException("Float16/Half type is not supported in this build");
         return default;
 #endif
     }
@@ -1074,7 +1074,7 @@ internal sealed class MathInstance : ObjectInstance
         var items = arguments.At(0);
         if (items.IsNullOrUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         var iteratorRecord = items.GetIterator(_engine.Realm);
@@ -1090,12 +1090,12 @@ internal sealed class MathInstance : ObjectInstance
                 count++;
                 if (count > 9007199254740992)
                 {
-                    ExceptionHelper.ThrowRangeError(_engine.Realm);
+                    Throw.RangeError(_engine.Realm);
                 }
 
                 if (value is not JsNumber jsNumber)
                 {
-                    ExceptionHelper.ThrowTypeError(_engine.Realm, "Input is not a number: " + next);
+                    Throw.TypeError(_engine.Realm, "Input is not a number: " + next);
                     return default;
                 }
 

+ 2 - 2
Jint/Native/Number/Dtoa/Bignum.cs

@@ -130,7 +130,7 @@ internal sealed class Bignum
     {
         if (size > kBigitCapacity)
         {
-            ExceptionHelper.ThrowInvalidOperationException();
+            Throw.InvalidOperationException();
         }
     }
 
@@ -594,7 +594,7 @@ internal sealed class Bignum
         // sum up used_digits of Bigit*Bigit.
         if ((1 << (2 * (kChunkSize - kBigitSize))) <= used_digits_)
         {
-            ExceptionHelper.ThrowNotImplementedException();
+            Throw.NotImplementedException();
         }
 
         ulong accumulator = 0;

+ 1 - 1
Jint/Native/Number/Dtoa/BignumDtoa.cs

@@ -92,7 +92,7 @@ internal static class BignumDtoa
                     ref builder);
                 break;
             default:
-                ExceptionHelper.ThrowArgumentOutOfRangeException();
+                Throw.ArgumentOutOfRangeException();
                 break;
         }
     }

+ 2 - 2
Jint/Native/Number/Dtoa/DtoaNumberFormatter.cs

@@ -49,13 +49,13 @@ internal static class DtoaNumberFormatter
                 break;
             case DtoaMode.Fixed:
                 //fast_worked = FastFixedDtoa(v, requested_digits, buffer, length, point);
-                ExceptionHelper.ThrowNotImplementedException();
+                Throw.NotImplementedException();
                 break;
             case DtoaMode.Precision:
                 fast_worked = FastDtoa.NumberToString(v, DtoaMode.Precision, requested_digits, out point, ref buffer);
                 break;
             default:
-                ExceptionHelper.ThrowArgumentOutOfRangeException();
+                Throw.ArgumentOutOfRangeException();
                 return;
         }
 

+ 1 - 1
Jint/Native/Number/Dtoa/FastDtoa.cs

@@ -753,7 +753,7 @@ internal sealed class FastDtoa
                 result = Grisu3Counted(v, requested_digits, ref buffer, out decimal_exponent);
                 break;
             default:
-                ExceptionHelper.ThrowArgumentOutOfRangeException();
+                Throw.ArgumentOutOfRangeException();
                 break;
         }
 

+ 11 - 11
Jint/Native/Number/NumberPrototype.cs

@@ -54,7 +54,7 @@ internal sealed class NumberPrototype : NumberInstance
     {
         if (!thisObject.IsNumber() && thisObject is not NumberInstance)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var m = TypeConverter.ToNumber(thisObject);
@@ -99,7 +99,7 @@ internal sealed class NumberPrototype : NumberInstance
         }
         catch (CultureNotFoundException)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Incorrect locale information provided");
+            Throw.RangeError(_realm, "Incorrect locale information provided");
         }
 
         return m.ToString("n", numberFormat);
@@ -117,7 +117,7 @@ internal sealed class NumberPrototype : NumberInstance
             return thisObject;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm);
+        Throw.TypeError(_realm);
         return null;
     }
 
@@ -128,13 +128,13 @@ internal sealed class NumberPrototype : NumberInstance
         var f = (int) TypeConverter.ToInteger(arguments.At(0, 0));
         if (f < 0 || f > 100)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "fractionDigits argument must be between 0 and 100");
+            Throw.RangeError(_realm, "fractionDigits argument must be between 0 and 100");
         }
 
         // limitation with .NET, max is 99
         if (f == 100)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "100 fraction digits is not supported due to .NET format specifier limitation");
+            Throw.RangeError(_realm, "100 fraction digits is not supported due to .NET format specifier limitation");
         }
 
         var x = TypeConverter.ToNumber(thisObject);
@@ -165,7 +165,7 @@ internal sealed class NumberPrototype : NumberInstance
     {
         if (!thisObject.IsNumber() && ReferenceEquals(thisObject.TryCast<NumberInstance>(), null))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var x = TypeConverter.ToNumber(thisObject);
@@ -189,7 +189,7 @@ internal sealed class NumberPrototype : NumberInstance
 
         if (f < 0 || f > 100)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "fractionDigits argument must be between 0 and 100");
+            Throw.RangeError(_realm, "fractionDigits argument must be between 0 and 100");
         }
 
         if (arguments.At(0).IsUndefined())
@@ -241,7 +241,7 @@ internal sealed class NumberPrototype : NumberInstance
     {
         if (!thisObject.IsNumber() && ReferenceEquals(thisObject.TryCast<NumberInstance>(), null))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var x = TypeConverter.ToNumber(thisObject);
@@ -266,7 +266,7 @@ internal sealed class NumberPrototype : NumberInstance
 
         if (p < 1 || p > 100)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "precision must be between 1 and 100");
+            Throw.RangeError(_realm, "precision must be between 1 and 100");
         }
 
         var dtoaBuilder = new DtoaBuilder(stackalloc char[LargeDtoaLength]);
@@ -361,7 +361,7 @@ internal sealed class NumberPrototype : NumberInstance
     {
         if (!thisObject.IsNumber() && (ReferenceEquals(thisObject.TryCast<NumberInstance>(), null)))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var radix = arguments.At(0).IsUndefined()
@@ -370,7 +370,7 @@ internal sealed class NumberPrototype : NumberInstance
 
         if (radix < 2 || radix > 36)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "radix must be between 2 and 36");
+            Throw.RangeError(_realm, "radix must be between 2 and 36");
         }
 
         var x = TypeConverter.ToNumber(thisObject);

+ 8 - 8
Jint/Native/Object/ObjectConstructor.cs

@@ -210,7 +210,7 @@ public sealed class ObjectConstructor : Constructor
         var prototype = arguments.At(1);
         if (!prototype.IsObject() && !prototype.IsNull())
         {
-            ExceptionHelper.ThrowTypeError(_realm, $"Object prototype may only be an Object or null: {prototype}");
+            Throw.TypeError(_realm, $"Object prototype may only be an Object or null: {prototype}");
         }
 
         if (oArg is not ObjectInstance o)
@@ -220,7 +220,7 @@ public sealed class ObjectConstructor : Constructor
 
         if (!o.SetPrototypeOf(prototype))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
         return o;
     }
@@ -297,7 +297,7 @@ public sealed class ObjectConstructor : Constructor
         var prototype = arguments.At(0);
         if (!prototype.IsObject() && !prototype.IsNull())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Object prototype may only be an Object or null: " + prototype);
+            Throw.TypeError(_realm, "Object prototype may only be an Object or null: " + prototype);
         }
 
         var obj = Engine.Realm.Intrinsics.Object.Construct(Arguments.Empty);
@@ -319,7 +319,7 @@ public sealed class ObjectConstructor : Constructor
     {
         if (arguments.At(0) is not ObjectInstance o)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Object.defineProperty called on non-object");
+            Throw.TypeError(_realm, "Object.defineProperty called on non-object");
             return null;
         }
 
@@ -342,7 +342,7 @@ public sealed class ObjectConstructor : Constructor
         var o = arguments.At(0) as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Object.defineProperty called on non-object");
+            Throw.TypeError(_realm, "Object.defineProperty called on non-object");
         }
 
         var properties = arguments.At(1);
@@ -393,7 +393,7 @@ public sealed class ObjectConstructor : Constructor
 
         if (!status)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return o;
@@ -413,7 +413,7 @@ public sealed class ObjectConstructor : Constructor
 
         if (!status)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return o;
@@ -431,7 +431,7 @@ public sealed class ObjectConstructor : Constructor
 
         if (!o.PreventExtensions())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return o;

+ 7 - 7
Jint/Native/Object/ObjectInstance.Private.cs

@@ -43,7 +43,7 @@ public partial class ObjectInstance
         var entry = PrivateElementFind(method.Key);
         if (entry is not null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Already present");
+            Throw.TypeError(_engine.Realm, "Already present");
         }
 
         _privateElements ??= new Dictionary<PrivateName, PrivateElement>();
@@ -61,7 +61,7 @@ public partial class ObjectInstance
         var entry = PrivateElementFind(property);
         if (entry is not null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Already present");
+            Throw.TypeError(_engine.Realm, "Already present");
         }
 
         _privateElements ??= new Dictionary<PrivateName, PrivateElement>();
@@ -76,7 +76,7 @@ public partial class ObjectInstance
         var entry = PrivateElementFind(property);
         if (entry is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, $"Cannot read private member #{property} from an object whose class did not declare it");
+            Throw.TypeError(_engine.Realm, $"Cannot read private member #{property} from an object whose class did not declare it");
         }
 
         if (entry.Kind is PrivateElementKind.Field or PrivateElementKind.Method)
@@ -87,7 +87,7 @@ public partial class ObjectInstance
         var getter = entry.Get;
         if (getter is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, $"'#{property}' was defined without a getter");
+            Throw.TypeError(_engine.Realm, $"'#{property}' was defined without a getter");
         }
 
         var functionInstance = (Function.Function) getter;
@@ -103,7 +103,7 @@ public partial class ObjectInstance
         var entry = PrivateElementFind(property);
         if (entry is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Not found");
+            Throw.TypeError(_engine.Realm, "Not found");
         }
 
         if (entry.Kind == PrivateElementKind.Field)
@@ -112,14 +112,14 @@ public partial class ObjectInstance
         }
         else if (entry.Kind == PrivateElementKind.Method)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Cannot set method");
+            Throw.TypeError(_engine.Realm, "Cannot set method");
         }
         else
         {
             var setter = entry.Set;
             if (setter is null)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm, $"'#{property}' was defined without a setter");
+                Throw.TypeError(_engine.Realm, $"'#{property}' was defined without a setter");
             }
 
             _engine.Call(setter, this, [value]);

+ 10 - 10
Jint/Native/Object/ObjectInstance.cs

@@ -129,7 +129,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
         var oi = c as ObjectInstance;
         if (oi is null)
         {
-            ExceptionHelper.ThrowTypeError(o._engine.Realm);
+            Throw.TypeError(o._engine.Realm);
         }
 
         var s = oi.Get(GlobalSymbolRegistry.Species);
@@ -143,7 +143,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
             return (IConstructor) s;
         }
 
-        ExceptionHelper.ThrowTypeError(o._engine.Realm);
+        Throw.TypeError(o._engine.Realm);
         return null;
     }
 
@@ -487,7 +487,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
     {
         if (!Set(p, v) && throwOnError)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return true;
@@ -689,7 +689,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
     {
         if (!Delete(property))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
         return true;
     }
@@ -721,7 +721,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
     {
         if (!DefineOwnProperty(property, desc))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Cannot redefine property: " + property);
+            Throw.TypeError(_engine.Realm, "Cannot redefine property: " + property);
         }
 
         return true;
@@ -1260,7 +1260,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
     {
         if (!value.IsObject() && !value.IsNull())
         {
-            ExceptionHelper.ThrowArgumentException();
+            Throw.ArgumentException();
         }
 
         var current = _prototype ?? Null;
@@ -1348,7 +1348,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
     {
         if (!CreateDataProperty(p, v))
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         return true;
@@ -1392,7 +1392,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
         var callable = jsValue as ICallable;
         if (callable is null)
         {
-            ExceptionHelper.ThrowTypeError(realm, $"Value returned for property '{p}' of object is not a function");
+            Throw.TypeError(realm, $"Value returned for property '{p}' of object is not a function");
         }
         return callable;
     }
@@ -1519,7 +1519,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
     [MethodImpl(MethodImplOptions.NoInlining)]
     private void ThrowIncompatibleReceiver(JsValue value, string methodName)
     {
-        ExceptionHelper.ThrowTypeError(_engine.Realm, $"Method {methodName} called on incompatible receiver {value}");
+        Throw.TypeError(_engine.Realm, $"Method {methodName} called on incompatible receiver {value}");
     }
 
     public override bool Equals(object? obj) => Equals(obj as ObjectInstance);
@@ -1617,7 +1617,7 @@ public partial class ObjectInstance : JsValue, IEquatable<ObjectInstance>
         var func = v.GetV(_engine.Realm, p);
         if (func is not ICallable callable)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm, "Can only invoke functions");
+            Throw.TypeError(_engine.Realm, "Can only invoke functions");
             return default;
         }
 

+ 3 - 3
Jint/Native/Object/ObjectPrototype.cs

@@ -47,7 +47,7 @@ public sealed class ObjectPrototype : Prototype
 
                     if (!objectInstance.SetPrototypeOf(proto))
                     {
-                        ExceptionHelper.ThrowTypeError(_realm, "Invalid prototype");
+                        Throw.TypeError(_realm, "Invalid prototype");
                     }
 
                     return Undefined;
@@ -104,7 +104,7 @@ public sealed class ObjectPrototype : Prototype
 
         if (!getter.IsCallable)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Target is not callable");
+            Throw.TypeError(_realm, "Target is not callable");
         }
 
         var desc = new GetSetPropertyDescriptor(getter, null, enumerable: true, configurable: true);
@@ -125,7 +125,7 @@ public sealed class ObjectPrototype : Prototype
 
         if (!setter.IsCallable)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Target is not callable");
+            Throw.TypeError(_realm, "Target is not callable");
         }
 
         var desc = new GetSetPropertyDescriptor(null, setter, enumerable: true, configurable: true);

+ 16 - 16
Jint/Native/Promise/PromiseConstructor.cs

@@ -67,12 +67,12 @@ internal sealed class PromiseConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Constructor Promise requires 'new'");
+            Throw.TypeError(_realm, "Constructor Promise requires 'new'");
         }
 
         if (arguments.At(0) is not ICallable executor)
         {
-            ExceptionHelper.ThrowTypeError(_realm, $"Promise executor {(arguments.At(0))} is not a function");
+            Throw.TypeError(_realm, $"Promise executor {(arguments.At(0))} is not a function");
             return null;
         }
 
@@ -101,12 +101,12 @@ internal sealed class PromiseConstructor : Constructor
     {
         if (!thisObject.IsObject())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "PromiseResolve called on non-object");
+            Throw.TypeError(_realm, "PromiseResolve called on non-object");
         }
 
         if (thisObject is not IConstructor)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Promise.resolve invoked on a non-constructor value");
+            Throw.TypeError(_realm, "Promise.resolve invoked on a non-constructor value");
         }
 
         var x = arguments.At(0);
@@ -151,12 +151,12 @@ internal sealed class PromiseConstructor : Constructor
     {
         if (!thisObject.IsObject())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Promise.reject called on non-object");
+            Throw.TypeError(_realm, "Promise.reject called on non-object");
         }
 
         if (thisObject is not IConstructor)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Promise.reject invoked on a non-constructor value");
+            Throw.TypeError(_realm, "Promise.reject invoked on a non-constructor value");
         }
 
         var r = arguments.At(0);
@@ -175,7 +175,7 @@ internal sealed class PromiseConstructor : Constructor
     {
         if (!thisObject.IsObject())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Promise.try called on non-object");
+            Throw.TypeError(_realm, "Promise.try called on non-object");
         }
 
         var callbackfn = arguments.At(0);
@@ -201,7 +201,7 @@ internal sealed class PromiseConstructor : Constructor
     {
         if (!thisObject.IsObject())
         {
-            ExceptionHelper.ThrowTypeError(_realm, $"{callerName} called on non-object");
+            Throw.TypeError(_realm, $"{callerName} called on non-object");
         }
 
         //2. Let promiseCapability be ? NewPromiseCapability(C).
@@ -230,7 +230,7 @@ internal sealed class PromiseConstructor : Constructor
         {
             if (arguments.Length == 0)
             {
-                ExceptionHelper.ThrowTypeError(_realm, $"no arguments were passed to {callerName}");
+                Throw.TypeError(_realm, $"no arguments were passed to {callerName}");
             }
 
             var iterable = arguments.At(0);
@@ -325,7 +325,7 @@ internal sealed class PromiseConstructor : Constructor
                 }
                 else
                 {
-                    ExceptionHelper.ThrowTypeError(_realm, "Passed non Promise-like value");
+                    Throw.TypeError(_realm, "Passed non Promise-like value");
                 }
 
                 index += 1;
@@ -448,7 +448,7 @@ internal sealed class PromiseConstructor : Constructor
                 }
                 else
                 {
-                    ExceptionHelper.ThrowTypeError(_realm, "Passed non Promise-like value");
+                    Throw.TypeError(_realm, "Passed non Promise-like value");
                 }
 
                 index += 1;
@@ -557,7 +557,7 @@ internal sealed class PromiseConstructor : Constructor
                 }
                 else
                 {
-                    ExceptionHelper.ThrowTypeError(_realm, "Passed non Promise-like value");
+                    Throw.TypeError(_realm, "Passed non Promise-like value");
                 }
 
                 index += 1;
@@ -654,7 +654,7 @@ internal sealed class PromiseConstructor : Constructor
             return resolve;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "resolve is not a function");
+        Throw.TypeError(_realm, "resolve is not a function");
         // Note: throws right before return
         return null;
     }
@@ -695,7 +695,7 @@ internal sealed class PromiseConstructor : Constructor
             if (resolveArg is not null && resolveArg != Undefined ||
                 rejectArg is not null && rejectArg != Undefined)
             {
-                ExceptionHelper.ThrowTypeError(engine.Realm, "executor was already called with not undefined args");
+                Throw.TypeError(engine.Realm, "executor was already called with not undefined args");
             }
 
             resolveArg = arguments.At(0);
@@ -717,7 +717,7 @@ internal sealed class PromiseConstructor : Constructor
         }
         else
         {
-            ExceptionHelper.ThrowTypeError(engine.Realm, "resolve is not a function");
+            Throw.TypeError(engine.Realm, "resolve is not a function");
         }
 
         if (rejectArg is ICallable rejFunc)
@@ -726,7 +726,7 @@ internal sealed class PromiseConstructor : Constructor
         }
         else
         {
-            ExceptionHelper.ThrowTypeError(engine.Realm, "reject is not a function");
+            Throw.TypeError(engine.Realm, "reject is not a function");
         }
 
         return new PromiseCapability(

+ 1 - 1
Jint/Native/Promise/PromiseOperations.cs

@@ -138,7 +138,7 @@ internal static class PromiseOperations
 
                 break;
             default:
-                ExceptionHelper.ThrowArgumentOutOfRangeException();
+                Throw.ArgumentOutOfRangeException();
                 break;
         }
 

+ 2 - 2
Jint/Native/Promise/PromisePrototype.cs

@@ -56,7 +56,7 @@ internal sealed class PromisePrototype : Prototype
         var promise = thisValue as JsPromise;
         if (promise is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method Promise.prototype.then called on incompatible receiver");
+            Throw.TypeError(_realm, "Method Promise.prototype.then called on incompatible receiver");
         }
 
         // 3. Let C be ? SpeciesConstructor(promise, %Promise%).
@@ -87,7 +87,7 @@ internal sealed class PromisePrototype : Prototype
         var promise = thisValue as ObjectInstance;
         if (promise is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "this passed to Promise.prototype.finally is not an object");
+            Throw.TypeError(_realm, "this passed to Promise.prototype.finally is not an object");
         }
 
         // 3. Let C be ? SpeciesConstructor(promise, %Promise%).

+ 3 - 3
Jint/Native/Proxy/ProxyConstructor.cs

@@ -37,7 +37,7 @@ internal sealed class ProxyConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return Construct(arguments.At(0), arguments.At(1));
@@ -83,13 +83,13 @@ internal sealed class ProxyConstructor : Constructor
     {
         if (target is not ObjectInstance targetObject)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Cannot create proxy with a non-object as target");
+            Throw.TypeError(_realm, "Cannot create proxy with a non-object as target");
             return null;
         }
 
         if (handler is not ObjectInstance targetHandler)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Cannot create proxy with a non-object as handler");
+            Throw.TypeError(_realm, "Cannot create proxy with a non-object as handler");
             return null;
         }
 

+ 13 - 13
Jint/Native/Reflect/ReflectInstance.cs

@@ -60,7 +60,7 @@ internal sealed class ReflectInstance : ObjectInstance
 
         if (!target.IsCallable)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var args = FunctionPrototype.CreateListFromArrayLike(_realm, argumentsList);
@@ -93,7 +93,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var target = arguments.At(0) as ObjectInstance;
         if (target is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.defineProperty called on non-object");
+            Throw.TypeError(_realm, "Reflect.defineProperty called on non-object");
         }
 
         var propertyKey = arguments.At(1);
@@ -110,7 +110,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = arguments.At(0) as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.deleteProperty called on non-object");
+            Throw.TypeError(_realm, "Reflect.deleteProperty called on non-object");
         }
 
         var property = TypeConverter.ToPropertyKey(arguments.At(1));
@@ -122,7 +122,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = arguments.At(0) as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.has called on non-object");
+            Throw.TypeError(_realm, "Reflect.has called on non-object");
         }
 
         var property = TypeConverter.ToPropertyKey(arguments.At(1));
@@ -139,7 +139,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = target as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.set called on non-object");
+            Throw.TypeError(_realm, "Reflect.set called on non-object");
         }
 
         return o.Set(property, value, receiver);
@@ -151,7 +151,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = target as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.get called on non-object");
+            Throw.TypeError(_realm, "Reflect.get called on non-object");
         }
 
         var receiver = arguments.At(2, target);
@@ -163,7 +163,7 @@ internal sealed class ReflectInstance : ObjectInstance
     {
         if (!arguments.At(0).IsObject())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.getOwnPropertyDescriptor called on non-object");
+            Throw.TypeError(_realm, "Reflect.getOwnPropertyDescriptor called on non-object");
         }
         return _realm.Intrinsics.Object.GetOwnPropertyDescriptor(Undefined, arguments);
     }
@@ -173,7 +173,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = arguments.At(0) as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.get called on non-object");
+            Throw.TypeError(_realm, "Reflect.get called on non-object");
         }
 
         var keys = o.GetOwnPropertyKeys();
@@ -185,7 +185,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = arguments.At(0) as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.isExtensible called on non-object");
+            Throw.TypeError(_realm, "Reflect.isExtensible called on non-object");
         }
 
         return o.Extensible;
@@ -196,7 +196,7 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = arguments.At(0) as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.preventExtensions called on non-object");
+            Throw.TypeError(_realm, "Reflect.preventExtensions called on non-object");
         }
 
         return o.PreventExtensions();
@@ -208,7 +208,7 @@ internal sealed class ReflectInstance : ObjectInstance
 
         if (!target.IsObject())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.getPrototypeOf called on non-object");
+            Throw.TypeError(_realm, "Reflect.getPrototypeOf called on non-object");
         }
 
         return _realm.Intrinsics.Object.GetPrototypeOf(Undefined, arguments);
@@ -221,13 +221,13 @@ internal sealed class ReflectInstance : ObjectInstance
         var o = target as ObjectInstance;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Reflect.setPrototypeOf called on non-object");
+            Throw.TypeError(_realm, "Reflect.setPrototypeOf called on non-object");
         }
 
         var prototype = arguments.At(1);
         if (!prototype.IsObject() && !prototype.IsNull())
         {
-            ExceptionHelper.ThrowTypeError(_realm, $"Object prototype may only be an Object or null: {prototype}");
+            Throw.TypeError(_realm, $"Object prototype may only be an Object or null: {prototype}");
         }
 
         return o.SetPrototypeOf(prototype);

+ 2 - 2
Jint/Native/RegExp/RegExpConstructor.cs

@@ -109,7 +109,7 @@ public sealed class RegExpConstructor : Constructor
 
             if (!regExpParseResult.Success)
             {
-                ExceptionHelper.ThrowSyntaxError(_realm, $"Unsupported regular expression. {regExpParseResult.ConversionError!.Description}");
+                Throw.SyntaxError(_realm, $"Unsupported regular expression. {regExpParseResult.ConversionError!.Description}");
             }
 
             r.Value = regExpParseResult.Regex!;
@@ -117,7 +117,7 @@ public sealed class RegExpConstructor : Constructor
         }
         catch (Exception ex)
         {
-            ExceptionHelper.ThrowSyntaxError(_realm, ex.Message);
+            Throw.SyntaxError(_realm, ex.Message);
         }
 
         r.Flags = f;

+ 5 - 5
Jint/Native/RegExp/RegExpPrototype.cs

@@ -60,7 +60,7 @@ internal sealed class RegExpPrototype : Prototype
                     var r = thisObj as JsRegExp;
                     if (r is null)
                     {
-                        ExceptionHelper.ThrowTypeError(_realm);
+                        Throw.TypeError(_realm);
                     }
 
                     return valueExtractor(r);
@@ -113,7 +113,7 @@ internal sealed class RegExpPrototype : Prototype
         var r = thisObject as JsRegExp;
         if (r is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (string.IsNullOrEmpty(r.Source))
@@ -825,7 +825,7 @@ internal sealed class RegExpPrototype : Prototype
             var result = callable.Call(r, s);
             if (!result.IsNull() && !result.IsObject())
             {
-                ExceptionHelper.ThrowTypeError(r.Engine.Realm);
+                Throw.TypeError(r.Engine.Realm);
             }
 
             return result;
@@ -833,7 +833,7 @@ internal sealed class RegExpPrototype : Prototype
 
         if (ri is null)
         {
-            ExceptionHelper.ThrowTypeError(r.Engine.Realm);
+            Throw.TypeError(r.Engine.Realm);
         }
 
         return RegExpBuiltinExec(ri, s);
@@ -1074,7 +1074,7 @@ internal sealed class RegExpPrototype : Prototype
         var r = thisObject as JsRegExp;
         if (r is null)
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         var s = TypeConverter.ToString(arguments.At(0));

+ 2 - 2
Jint/Native/Set/SetConstructor.cs

@@ -51,7 +51,7 @@ public sealed class SetConstructor : Constructor
             var adder = adderValue as ICallable;
             if (adder is null)
             {
-                ExceptionHelper.ThrowTypeError(_engine.Realm, "add must be callable");
+                Throw.TypeError(_engine.Realm, "add must be callable");
             }
 
             var iterable = arguments.At(0).GetIterator(_realm);
@@ -85,7 +85,7 @@ public sealed class SetConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_engine.Realm);
+            Throw.TypeError(_engine.Realm);
         }
 
         var set = OrdinaryCreateFromConstructor(

+ 6 - 6
Jint/Native/Set/SetPrototype.cs

@@ -461,32 +461,32 @@ internal sealed class SetPrototype : Prototype
     {
         if (obj is not ObjectInstance)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var rawSize = obj.Get(CommonProperties.Size);
         var numSize = TypeConverter.ToNumber(rawSize);
         if (double.IsNaN(numSize))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var intSize = TypeConverter.ToIntegerOrInfinity(numSize);
         if (intSize < 0)
         {
-            ExceptionHelper.ThrowRangeError(_realm);
+            Throw.RangeError(_realm);
         }
 
         var has = obj.Get(CommonProperties.Has);
         if (!has.IsCallable)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var keys = obj.Get(CommonProperties.Keys);
         if (!keys.IsCallable)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return new SetRecord(Set: obj, Size: intSize, Has: (ICallable) has, Keys: (ICallable) keys);
@@ -505,7 +505,7 @@ internal sealed class SetPrototype : Prototype
             return set;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "object must be a Set");
+        Throw.TypeError(_realm, "object must be a Set");
         return default;
     }
 }

+ 7 - 7
Jint/Native/ShadowRealm/ShadowRealm.cs

@@ -40,7 +40,7 @@ public sealed class ShadowRealm : ObjectInstance
     {
         if (!preparedScript.IsValid)
         {
-            ExceptionHelper.ThrowInvalidPreparedScriptArgumentException(nameof(preparedScript));
+            Throw.InvalidPreparedScriptArgumentException(nameof(preparedScript));
         }
 
         var callerRealm = _engine.Realm;
@@ -116,11 +116,11 @@ public sealed class ShadowRealm : ObjectInstance
         {
             if (string.Equals(e.Error.Code, "InvalidLhsInAssignment", StringComparison.Ordinal))
             {
-                ExceptionHelper.ThrowReferenceError(callerRealm, e.Description);
+                Throw.ReferenceError(callerRealm, e.Description);
             }
             else
             {
-                ExceptionHelper.ThrowSyntaxError(callerRealm, e.Message);
+                Throw.SyntaxError(callerRealm, e.Message);
             }
 
             return default;
@@ -319,7 +319,7 @@ public sealed class ShadowRealm : ObjectInstance
             var hasOwn = exports.HasOwnProperty(s);
             if (!hasOwn)
             {
-                ExceptionHelper.ThrowTypeError(_realm, $"export name {s} missing");
+                Throw.TypeError(_realm, $"export name {s} missing");
             }
 
             var value = exports.Get(s);
@@ -333,7 +333,7 @@ public sealed class ShadowRealm : ObjectInstance
         var instance = thisObj as ShadowRealm;
         if (instance is null)
         {
-            ExceptionHelper.ThrowTypeError(callerRealm, "object must be a ShadowRealm");
+            Throw.TypeError(callerRealm, "object must be a ShadowRealm");
         }
 
         return instance;
@@ -341,7 +341,7 @@ public sealed class ShadowRealm : ObjectInstance
 
     private static void ThrowCrossRealmError(Realm callerRealm, string message)
     {
-        ExceptionHelper.ThrowTypeError(callerRealm, "Cross-Realm Error: " + message);
+        Throw.TypeError(callerRealm, "Cross-Realm Error: " + message);
     }
 
     private sealed class WrappedFunction : Function.Function
@@ -405,7 +405,7 @@ public sealed class ShadowRealm : ObjectInstance
 
         protected override object? VisitSuper(Super super)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Shadow realm code cannot contain super");
+            Throw.TypeError(_realm, "Shadow realm code cannot contain super");
             return null;
         }
     }

+ 1 - 1
Jint/Native/ShadowRealm/ShadowRealmConstructor.cs

@@ -68,7 +68,7 @@ public sealed class ShadowRealmConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return Construct(newTarget);

+ 4 - 4
Jint/Native/ShadowRealm/ShadowRealmPrototype.cs

@@ -49,7 +49,7 @@ internal sealed class ShadowRealmPrototype : Prototype
 
         if (!sourceText.IsString())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid source text " + sourceText);
+            Throw.TypeError(_realm, "Invalid source text " + sourceText);
         }
 
         var parserOptions = _engine.GetActiveParserOptions();
@@ -74,12 +74,12 @@ internal sealed class ShadowRealmPrototype : Prototype
         var specifierString = TypeConverter.ToJsString(specifier);
         if (!specifier.IsString())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid specifier");
+            Throw.TypeError(_realm, "Invalid specifier");
         }
 
         if (!exportName.IsString())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Invalid exportName");
+            Throw.TypeError(_realm, "Invalid exportName");
         }
 
         var callerRealm = _realm;
@@ -93,7 +93,7 @@ internal sealed class ShadowRealmPrototype : Prototype
             return shadowRealm;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm, "object must be a ShadowRealm");
+        Throw.TypeError(_realm, "object must be a ShadowRealm");
         return default;
     }
 }

+ 3 - 3
Jint/Native/SharedArrayBuffer/SharedArrayBufferConstructor.cs

@@ -64,7 +64,7 @@ internal sealed class SharedArrayBufferConstructor : Constructor
 
     protected internal override JsValue Call(JsValue thisObject, JsCallArguments arguments)
     {
-        ExceptionHelper.ThrowTypeError(_realm, "Constructor SharedArrayBuffer requires 'new'");
+        Throw.TypeError(_realm, "Constructor SharedArrayBuffer requires 'new'");
         return Undefined;
     }
 
@@ -72,7 +72,7 @@ internal sealed class SharedArrayBufferConstructor : Constructor
     {
         if (newTarget.IsUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var length = arguments.At(0);
@@ -90,7 +90,7 @@ internal sealed class SharedArrayBufferConstructor : Constructor
 
         if (allocatingGrowableBuffer && byteLength > maxByteLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm);
+            Throw.RangeError(_realm);
         }
 
         var allocLength = maxByteLength.GetValueOrDefault(byteLength);

+ 11 - 11
Jint/Native/SharedArrayBuffer/SharedArrayBufferPrototype.cs

@@ -48,7 +48,7 @@ internal sealed class SharedArrayBufferPrototype : Prototype
         var o = thisObj as JsSharedArrayBuffer;
         if (o is null || !o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method prototype.byteLength called on incompatible receiver " + thisObj);
+            Throw.TypeError(_realm, "Method prototype.byteLength called on incompatible receiver " + thisObj);
         }
 
         return JsNumber.Create(o.ArrayBufferByteLength);
@@ -62,7 +62,7 @@ internal sealed class SharedArrayBufferPrototype : Prototype
         var o = thisObj as JsSharedArrayBuffer;
         if (o is null || !o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method prototype.slice called on incompatible receiver " + thisObj);
+            Throw.TypeError(_realm, "Method prototype.slice called on incompatible receiver " + thisObj);
         }
 
         o.AssertNotDetached();
@@ -102,34 +102,34 @@ internal sealed class SharedArrayBufferPrototype : Prototype
 
         if (bufferInstance is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (!bufferInstance.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (bufferInstance.IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (ReferenceEquals(bufferInstance, o))
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (bufferInstance.ArrayBufferByteLength < newLen)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         // NOTE: Side-effects of the above steps may have detached O.
 
         if (bufferInstance.IsDetachedBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var fromBuf = o.ArrayBufferData!;
@@ -146,7 +146,7 @@ internal sealed class SharedArrayBufferPrototype : Prototype
         var o = thisObject as JsSharedArrayBuffer;
         if (o is null || !o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method SharedArrayBuffer.prototype.growable called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method SharedArrayBuffer.prototype.growable called on incompatible receiver " + thisObject);
         }
 
         return !o.IsFixedLengthArrayBuffer;
@@ -160,7 +160,7 @@ internal sealed class SharedArrayBufferPrototype : Prototype
         var o = thisObject as JsSharedArrayBuffer;
         if (o is null || !o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method SharedArrayBuffer.prototype.grow called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method SharedArrayBuffer.prototype.grow called on incompatible receiver " + thisObject);
         }
 
         var newLength = arguments.At(0);
@@ -181,7 +181,7 @@ internal sealed class SharedArrayBufferPrototype : Prototype
         var o = thisObject as JsSharedArrayBuffer;
         if (o is null || !o.IsSharedArrayBuffer)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Method SharedArrayBuffer.prototype.maxByteLength called on incompatible receiver " + thisObject);
+            Throw.TypeError(_realm, "Method SharedArrayBuffer.prototype.maxByteLength called on incompatible receiver " + thisObject);
         }
 
         if (o.IsDetachedBuffer)

+ 1 - 1
Jint/Native/String/StringConstructor.cs

@@ -123,7 +123,7 @@ internal sealed class StringConstructor : Constructor
         return JsString.Create(result.ToString());
 
 rangeError:
-        _engine.SignalError(ExceptionHelper.CreateRangeError(_realm, "Invalid code point " + codePoint));
+        _engine.SignalError(Throw.CreateRangeError(_realm, "Invalid code point " + codePoint));
         return JsEmpty.Instance;
     }
 

+ 10 - 10
Jint/Native/String/StringPrototype.cs

@@ -114,7 +114,7 @@ internal sealed class StringPrototype : StringInstance
         var s = TypeConverter.ToObject(_realm, thisObject) as StringInstance;
         if (s is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return s.StringData;
@@ -245,7 +245,7 @@ internal sealed class StringPrototype : StringInstance
             }
             catch (CultureNotFoundException)
             {
-                ExceptionHelper.ThrowRangeError(_realm, "Incorrect culture information provided");
+                Throw.RangeError(_realm, "Incorrect culture information provided");
             }
         }
         if (string.Equals("lt", culture.Name, StringComparison.OrdinalIgnoreCase))
@@ -625,7 +625,7 @@ internal sealed class StringPrototype : StringInstance
                 TypeConverter.RequireObjectCoercible(_engine, flags);
                 if (!TypeConverter.ToString(flags).Contains('g'))
                 {
-                    ExceptionHelper.ThrowTypeError(_realm, "String.prototype.replaceAll called with a non-global RegExp argument");
+                    Throw.TypeError(_realm, "String.prototype.replaceAll called with a non-global RegExp argument");
                 }
             }
 
@@ -738,7 +738,7 @@ internal sealed class StringPrototype : StringInstance
                 TypeConverter.RequireObjectCoercible(_engine, flags);
                 if (!TypeConverter.ToString(flags).Contains('g'))
                 {
-                    ExceptionHelper.ThrowTypeError(_realm);
+                    Throw.TypeError(_realm);
                 }
             }
             var matcher = GetMethod(_realm, regex, GlobalSymbolRegistry.MatchAll);
@@ -963,7 +963,7 @@ internal sealed class StringPrototype : StringInstance
             return thisObject;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm);
+        Throw.TypeError(_realm);
         return Undefined;
     }
 
@@ -1032,7 +1032,7 @@ internal sealed class StringPrototype : StringInstance
         {
             if (searchString.IsRegExp())
             {
-                ExceptionHelper.ThrowTypeError(_realm);
+                Throw.TypeError(_realm);
             }
         }
 
@@ -1064,7 +1064,7 @@ internal sealed class StringPrototype : StringInstance
         {
             if (searchString.IsRegExp())
             {
-                ExceptionHelper.ThrowTypeError(_realm);
+                Throw.TypeError(_realm);
             }
         }
 
@@ -1089,7 +1089,7 @@ internal sealed class StringPrototype : StringInstance
 
         if (searchString.IsRegExp())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "First argument to String.prototype.includes must not be a regular expression");
+            Throw.TypeError(_realm, "First argument to String.prototype.includes must not be a regular expression");
         }
 
         var searchStr = TypeConverter.ToString(searchString);
@@ -1141,7 +1141,7 @@ internal sealed class StringPrototype : StringInstance
                 nf = NormalizationForm.FormKD;
                 break;
             default:
-                ExceptionHelper.ThrowRangeError(
+                Throw.RangeError(
                     _realm,
                     "The normalization form should be one of NFC, NFD, NFKC, NFKD.");
                 break;
@@ -1163,7 +1163,7 @@ internal sealed class StringPrototype : StringInstance
 
         if (n < 0 || double.IsPositiveInfinity(n))
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid count value");
+            Throw.RangeError(_realm, "Invalid count value");
         }
 
         if (n == 0 || s.Length == 0)

+ 2 - 2
Jint/Native/Symbol/SymbolConstructor.cs

@@ -99,7 +99,7 @@ internal sealed class SymbolConstructor : Constructor
         var symbol = arguments.At(0) as JsSymbol;
         if (symbol is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         if (_engine.GlobalSymbolRegistry.TryGetSymbol(symbol._value, out var e))
@@ -112,7 +112,7 @@ internal sealed class SymbolConstructor : Constructor
 
     public override ObjectInstance Construct(JsCallArguments arguments, JsValue newTarget)
     {
-        ExceptionHelper.ThrowTypeError(_realm, "Symbol is not a constructor");
+        Throw.TypeError(_realm, "Symbol is not a constructor");
         return null;
     }
 

+ 1 - 1
Jint/Native/Symbol/SymbolPrototype.cs

@@ -92,7 +92,7 @@ internal sealed class SymbolPrototype : Prototype
             return instance.SymbolData;
         }
 
-        ExceptionHelper.ThrowTypeError(_realm);
+        Throw.TypeError(_realm);
         return null;
     }
 }

+ 9 - 9
Jint/Native/TypedArray/IntrinsicTypedArrayConstructor.cs

@@ -52,7 +52,7 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
         var c = thisObject;
         if (!c.IsConstructor)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var source = arguments.At(0);
@@ -64,7 +64,7 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
         {
             if (!mapFunction.IsCallable)
             {
-                ExceptionHelper.ThrowTypeError(_realm);
+                Throw.TypeError(_realm);
             }
         }
 
@@ -88,7 +88,7 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
 
         if (source.IsNullOrUndefined())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Cannot convert undefined or null to object");
+            Throw.TypeError(_realm, "Cannot convert undefined or null to object");
         }
 
         var arrayLike = TypeConverter.ToObject(_realm, source);
@@ -129,7 +129,7 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
 
         if (!thisObject.IsConstructor)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var newObj = TypedArrayCreate(_realm, (IConstructor) thisObject, [len]);
@@ -155,7 +155,7 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
         var result = TypedArrayCreate(_realm, constructor, argumentList);
         if (result._contentType != exemplar._contentType)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return result;
@@ -173,11 +173,11 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
         {
             if (taRecord.IsTypedArrayOutOfBounds)
             {
-                ExceptionHelper.ThrowTypeError(realm, "TypedArray is out of bounds");
+                Throw.TypeError(realm, "TypedArray is out of bounds");
             }
             if (newTypedArray.GetLength() < number._value)
             {
-                ExceptionHelper.ThrowTypeError(realm);
+                Throw.TypeError(realm);
             }
         }
 
@@ -191,13 +191,13 @@ internal sealed class IntrinsicTypedArrayConstructor : Constructor
 
     protected internal override JsValue Call(JsValue thisObject, JsCallArguments arguments)
     {
-        ExceptionHelper.ThrowTypeError(_realm, "Abstract class TypedArray not directly callable");
+        Throw.TypeError(_realm, "Abstract class TypedArray not directly callable");
         return Undefined;
     }
 
     public override ObjectInstance Construct(JsCallArguments arguments, JsValue newTarget)
     {
-        ExceptionHelper.ThrowTypeError(_realm, "Abstract class TypedArray not directly constructable");
+        Throw.TypeError(_realm, "Abstract class TypedArray not directly constructable");
         return null;
     }
 }

+ 22 - 22
Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs

@@ -94,7 +94,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var o = thisObject as JsTypedArray;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         return o._viewedArrayBuffer;
@@ -108,7 +108,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var o = thisObject as JsTypedArray;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var taRecord = MakeTypedArrayWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
@@ -123,7 +123,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var o = thisObject as JsTypedArray;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var taRecord = MakeTypedArrayWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
@@ -143,7 +143,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var o = thisObject as JsTypedArray;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var taRecord = MakeTypedArrayWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
@@ -341,7 +341,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
             taRecord = MakeTypedArrayWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
             if (taRecord.IsTypedArrayOutOfBounds)
             {
-                ExceptionHelper.ThrowTypeError(_realm, "TypedArray is out of bounds");
+                Throw.TypeError(_realm, "TypedArray is out of bounds");
             }
 
             len = taRecord.TypedArrayLength;
@@ -484,7 +484,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         taRecord = MakeTypedArrayWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
         if (taRecord.IsTypedArrayOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "TypedArray is out of bounds");
+            Throw.TypeError(_realm, "TypedArray is out of bounds");
         }
 
         len = taRecord.TypedArrayLength;
@@ -897,7 +897,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
 
         if (len == 0 && arguments.Length < 2)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var k = 0;
@@ -943,7 +943,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
 
         if (len == 0 && arguments.Length < 2)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var k = (long) len - 1;
@@ -1007,7 +1007,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var target = thisObject as JsTypedArray;
         if (target is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var source = arguments.At(0);
@@ -1016,7 +1016,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var targetOffset = TypeConverter.ToIntegerOrInfinity(offset);
         if (targetOffset < 0)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid offset");
+            Throw.RangeError(_realm, "Invalid offset");
         }
 
         if (source is JsTypedArray typedArrayInstance)
@@ -1040,7 +1040,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var targetRecord = MakeTypedArrayWithBufferWitnessRecord(target, ArrayBufferOrder.SeqCst);
         if (targetRecord.IsTypedArrayOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var targetLength = targetRecord.TypedArrayLength;
@@ -1049,7 +1049,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var srcRecord = MakeTypedArrayWithBufferWitnessRecord(source, ArrayBufferOrder.SeqCst);
         if (srcRecord.IsTypedArrayOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var targetType = target._arrayElementType;
@@ -1063,17 +1063,17 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
 
         if (double.IsNegativeInfinity(targetOffset))
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid target offset");
+            Throw.RangeError(_realm, "Invalid target offset");
         }
 
         if (srcLength + targetOffset > targetLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid target offset");
+            Throw.RangeError(_realm, "Invalid target offset");
         }
 
         if (target._contentType != source._contentType)
         {
-            ExceptionHelper.ThrowTypeError(_realm, "Content type mismatch");
+            Throw.TypeError(_realm, "Content type mismatch");
         }
 
         var same = SameValue(srcBuffer, targetBuffer);
@@ -1127,7 +1127,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var targetRecord = MakeTypedArrayWithBufferWitnessRecord(target, ArrayBufferOrder.SeqCst);
         if (targetRecord.IsTypedArrayOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var targetLength = targetRecord.TypedArrayLength;
@@ -1136,12 +1136,12 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
 
         if (double.IsNegativeInfinity(targetOffset))
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid target offset");
+            Throw.RangeError(_realm, "Invalid target offset");
         }
 
         if (srcLength + targetOffset > targetLength)
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid target offset");
+            Throw.RangeError(_realm, "Invalid target offset");
         }
 
         var k = 0;
@@ -1237,7 +1237,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
             taRecord = MakeTypedArrayWithBufferWitnessRecord(o, ArrayBufferOrder.SeqCst);
             if (taRecord.IsTypedArrayOutOfBounds)
             {
-                ExceptionHelper.ThrowTypeError(_realm, "TypedArray is out of bounds");
+                Throw.TypeError(_realm, "TypedArray is out of bounds");
             }
 
             endIndex = System.Math.Min(endIndex, taRecord.TypedArrayLength);
@@ -1348,7 +1348,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         var o = thisObject as JsTypedArray;
         if (o is null)
         {
-            ExceptionHelper.ThrowTypeError(_realm);
+            Throw.TypeError(_realm);
         }
 
         var start = arguments.At(0);
@@ -1549,7 +1549,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
 
         if (!o.IsValidIntegerIndex(actualIndex))
         {
-            ExceptionHelper.ThrowRangeError(_realm, "Invalid start index");
+            Throw.RangeError(_realm, "Invalid start index");
         }
 
         var a = TypedArrayCreateSameType(o, [JsNumber.Create(len)]);
@@ -1578,7 +1578,7 @@ internal sealed class IntrinsicTypedArrayPrototype : Prototype
         {
             if (compareArg is not ICallable callable)
             {
-                ExceptionHelper.ThrowTypeError(_realm, "The comparison function must be either a function or undefined");
+                Throw.TypeError(_realm, "The comparison function must be either a function or undefined");
                 return null;
             }
             compareFn = callable;

+ 2 - 2
Jint/Native/TypedArray/TypeArrayHelper.cs

@@ -9,14 +9,14 @@ internal static class TypeArrayHelper
     {
         if (o is not JsTypedArray typedArray)
         {
-            ExceptionHelper.ThrowTypeError(realm);
+            Throw.TypeError(realm);
             return default;
         }
 
         var taRecord = IntrinsicTypedArrayPrototype.MakeTypedArrayWithBufferWitnessRecord(typedArray, order);
         if (taRecord.IsTypedArrayOutOfBounds)
         {
-            ExceptionHelper.ThrowTypeError(realm, "TypedArray is out of bounds");
+            Throw.TypeError(realm, "TypedArray is out of bounds");
         }
 
         return taRecord;

+ 17 - 17
Jint/Native/TypedArray/TypedArrayConstructor.Uint8Array.cs

@@ -43,7 +43,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
         if (!s.IsString())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "fromBase64 must be called with a string");
+            Throw.TypeError(_realm, "fromBase64 must be called with a string");
         }
 
         var opts = GetOptionsObject(_engine, arguments.At(1));
@@ -70,7 +70,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
         if (lastChunkHandling is not JsString s || (s != "loose" && s != "strict" && s != "stop-before-partial"))
         {
-            ExceptionHelper.ThrowTypeError(engine.Realm, "lastChunkHandling must be either 'loose', 'strict' or 'stop-before-partial'");
+            Throw.TypeError(engine.Realm, "lastChunkHandling must be either 'loose', 'strict' or 'stop-before-partial'");
             return default;
         }
 
@@ -87,7 +87,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
         if (alphabet is not JsString s || (s != "base64" && s != "base64url"))
         {
-            ExceptionHelper.ThrowTypeError(engine.Realm, "alphabet must be either 'base64' or 'base64url'");
+            Throw.TypeError(engine.Realm, "alphabet must be either 'base64' or 'base64url'");
             return default;
         }
 
@@ -133,14 +133,14 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
                     {
                         if (chunkLength == 1)
                         {
-                            return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid base64 chunk length."), read);
+                            return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid base64 chunk length."), read);
                         }
 
                         DecodeBase64Chunk(engine, bytes, chunk, chunkLength, throwOnExtraBits: false);
                     }
                     else // strict
                     {
-                        return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid base64 chunk length in strict mode."), read);
+                        return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid base64 chunk length in strict mode."), read);
                     }
                 }
 
@@ -154,7 +154,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
             {
                 if (chunkLength < 2)
                 {
-                    return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid '=' placement in base64 string."), read);
+                    return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid '=' placement in base64 string."), read);
                 }
 
                 index = SkipAsciiWhitespace(input, index);
@@ -167,13 +167,13 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
                             return new FromEncodingResult(bytes.ToArray(), Error: null, read);
                         }
 
-                        return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid base64 string termination."), read);
+                        return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid base64 string termination."), read);
                     }
 
                     currentChar = input[index];
                     if (currentChar != '=')
                     {
-                        return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Expected '=' in base64 string."), read);
+                        return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Expected '=' in base64 string."), read);
                     }
 
                     index = SkipAsciiWhitespace(input, index + 1);
@@ -181,7 +181,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
                 if (index < length)
                 {
-                    return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Extra characters after base64 string."), read);
+                    return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Extra characters after base64 string."), read);
                 }
 
                 DecodeBase64Chunk(engine, bytes, chunk, chunkLength, throwOnExtraBits);
@@ -192,7 +192,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
             {
                 if (currentChar is '+' or '/')
                 {
-                    return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid character in base64url string."), read);
+                    return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid character in base64url string."), read);
                 }
 
                 if (currentChar == '-')
@@ -208,7 +208,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
             if (!Base64Alphabet.Contains(currentChar))
             {
-                return new FromEncodingResult(bytes.ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid base64 character."), read);
+                return new FromEncodingResult(bytes.ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid base64 character."), read);
             }
 
             ulong remaining = maxLength - (ulong) bytes.Count;
@@ -272,7 +272,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
         {
             if (throwOnExtraBits && bytes[1] != 0)
             {
-                ExceptionHelper.ThrowSyntaxError(engine.Realm, "Invalid padding in base64 chunk.");
+                Throw.SyntaxError(engine.Realm, "Invalid padding in base64 chunk.");
             }
             into.Add(bytes[0]);
             return;
@@ -282,7 +282,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
         {
             if (throwOnExtraBits && bytes[2] != 0)
             {
-                ExceptionHelper.ThrowSyntaxError(engine.Realm, "Invalid padding in base64 chunk.");
+                Throw.SyntaxError(engine.Realm, "Invalid padding in base64 chunk.");
             }
             into.Add(bytes[0]);
             into.Add(bytes[1]);
@@ -298,7 +298,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
         if (!s.IsString())
         {
-            ExceptionHelper.ThrowTypeError(_realm, "fromHex must be called with a string");
+            Throw.TypeError(_realm, "fromHex must be called with a string");
         }
 
         var result = FromHex(_engine, s.ToString());
@@ -320,7 +320,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
 
         if (length % 2 != 0)
         {
-            return new FromEncodingResult([], ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid hex string"), read);
+            return new FromEncodingResult([], Throw.CreateSyntaxError(engine.Realm, "Invalid hex string"), read);
         }
 
         var byteIndex = 0;
@@ -329,7 +329,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
             var hexits = s.AsSpan(read, 2);
             if (!hexits[0].IsHexDigit() || !hexits[1].IsHexDigit())
             {
-                return new FromEncodingResult(bytes.AsSpan(0, byteIndex).ToArray(), ExceptionHelper.CreateSyntaxError(engine.Realm, "Invalid hex value"), read);
+                return new FromEncodingResult(bytes.AsSpan(0, byteIndex).ToArray(), Throw.CreateSyntaxError(engine.Realm, "Invalid hex value"), read);
             }
 
 #if SUPPORTS_SPAN_PARSE
@@ -356,7 +356,7 @@ public sealed class Uint8ArrayConstructor : TypedArrayConstructor
             return options.AsObject();
         }
 
-        ExceptionHelper.ThrowTypeError(engine.Realm, "Invalid options");
+        Throw.TypeError(engine.Realm, "Invalid options");
         return default;
     }
 }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini