Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions source/app/GocciaTestRunner.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ program GocciaTestRunner;

{$I Goccia.inc}

// Run the full JavaScript test suite with access to the entire 4 GB user
// address space available to a 32-bit process on 64-bit Windows. The runner
// builds a fresh engine per file and, on worker threads, keeps automatic GC
// disabled and retains each engine's object graph until the thread finishes
// the batch (the deliberate "bulk reclaim at shutdown" strategy). The full
// suite therefore peaks near ~2 GB on i386-win32 — already at the default
// 2 GB per-process limit on main, and over it once the suite grows — which
// surfaces as "Out of memory"/"Access violation" failures. Marking the
// binary large-address-aware lifts that ceiling to 4 GB. 64-bit Windows is
// already large-address-aware, so this only applies to the 32-bit build.
{$IF DEFINED(MSWINDOWS) AND DEFINED(CPU32)}
{$SETPEFLAGS $20} // IMAGE_FILE_LARGE_ADDRESS_AWARE
{$ENDIF}

uses
{$IFDEF UNIX}cthreads,{$ENDIF}
Classes,
Expand Down
9 changes: 6 additions & 3 deletions source/units/Goccia.Builtins.Atomics.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ procedure ShutdownAtomicsWaitersForCurrentThread;
TGocciaAtomics = class(TGocciaBuiltin)
public
constructor Create(const AName: string; AScope: TGocciaScope;
AThrowError: TGocciaThrowErrorCallback);
AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
destructor Destroy; override;
published
function AtomicsAdd(const AArgs: TGocciaArgumentsCollection;
Expand Down Expand Up @@ -942,7 +943,8 @@ procedure ShutdownAtomicsWaitersForCurrentThread;
end;

constructor TGocciaAtomics.Create(const AName: string; AScope: TGocciaScope;
AThrowError: TGocciaThrowErrorCallback);
AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
var
Members: TGocciaMemberCollection;
StaticMembers: TArray<TGocciaMemberDefinition>;
Expand Down Expand Up @@ -989,7 +991,8 @@ constructor TGocciaAtomics.Create(const AName: string; AScope: TGocciaScope;
end;

RegisterMemberDefinitions(FBuiltinObject, StaticMembers);
AScope.DefineLexicalBinding(AName, FBuiltinObject, dtLet, True);
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(AName, FBuiltinObject, dtLet, True);
end;

destructor TGocciaAtomics.Destroy;
Expand Down
19 changes: 15 additions & 4 deletions source/units/Goccia.Builtins.DisposableStack.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ TGocciaBuiltinDisposableStack = class(TGocciaBuiltin)
private
FDisposableStackPrototype: TGocciaValue;
FAsyncDisposableStackPrototype: TGocciaValue;
FDisposableStackConstructorValue: TGocciaValue;
FAsyncDisposableStackConstructorValue: TGocciaValue;
published
function DisposableStackConstructor(const AArgs: TGocciaArgumentsCollection;
const AThisValue: TGocciaValue): TGocciaValue;
Expand Down Expand Up @@ -51,7 +53,11 @@ TGocciaBuiltinDisposableStack = class(TGocciaBuiltin)
const AThisValue: TGocciaValue): TGocciaValue;
public
constructor Create(const AName: string; const AScope: TGocciaScope;
const AThrowError: TGocciaThrowErrorCallback);
const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);

property DisposableStackConstructorValue: TGocciaValue read FDisposableStackConstructorValue;
property AsyncDisposableStackConstructorValue: TGocciaValue read FAsyncDisposableStackConstructorValue;
end;

procedure ClearDisposableStackSlotMap;
Expand Down Expand Up @@ -455,7 +461,8 @@ function CreateDisposableStackInstance(const AIsAsync: Boolean;
{ TGocciaBuiltinDisposableStack }

constructor TGocciaBuiltinDisposableStack.Create(const AName: string;
const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback);
const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
var
DisposableStackFunc: TGocciaNativeFunctionValue;
AsyncDisposableStackFunc: TGocciaNativeFunctionValue;
Expand All @@ -474,15 +481,19 @@ constructor TGocciaBuiltinDisposableStack.Create(const AName: string;
TGocciaPropertyDescriptorData.Create(DisposableStackFunc, [pfWritable, pfConfigurable]));
DisposableStackFunc.DefineProperty(PROP_PROTOTYPE,
TGocciaPropertyDescriptorData.Create(FDisposableStackPrototype, []));
AScope.DefineLexicalBinding(CONSTRUCTOR_DISPOSABLE_STACK, DisposableStackFunc, dtConst, True);
FDisposableStackConstructorValue := DisposableStackFunc;
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(CONSTRUCTOR_DISPOSABLE_STACK, DisposableStackFunc, dtConst, True);

AsyncDisposableStackFunc := TGocciaNativeFunctionValue.Create(
AsyncDisposableStackConstructor, CONSTRUCTOR_ASYNC_DISPOSABLE_STACK, 0);
TGocciaObjectValue(FAsyncDisposableStackPrototype).DefineProperty(PROP_CONSTRUCTOR,
TGocciaPropertyDescriptorData.Create(AsyncDisposableStackFunc, [pfWritable, pfConfigurable]));
AsyncDisposableStackFunc.DefineProperty(PROP_PROTOTYPE,
TGocciaPropertyDescriptorData.Create(FAsyncDisposableStackPrototype, []));
AScope.DefineLexicalBinding(CONSTRUCTOR_ASYNC_DISPOSABLE_STACK, AsyncDisposableStackFunc, dtConst, True);
FAsyncDisposableStackConstructorValue := AsyncDisposableStackFunc;
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(CONSTRUCTOR_ASYNC_DISPOSABLE_STACK, AsyncDisposableStackFunc, dtConst, True);

UseFunc := TGocciaNativeFunctionValue.CreateWithoutPrototype(StackUse, PROP_USE, 1);
AdoptFunc := TGocciaNativeFunctionValue.CreateWithoutPrototype(StackAdopt, PROP_ADOPT, 2);
Expand Down
9 changes: 6 additions & 3 deletions source/units/Goccia.Builtins.GlobalProxy.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ TGocciaGlobalProxy = class
function ProxyRevocable(const AArgs: TGocciaArgumentsCollection;
const AThisValue: TGocciaValue): TGocciaValue;
public
constructor Create(const AScope: TGocciaScope);
constructor Create(const AScope: TGocciaScope;
const ADefineGlobalBinding: Boolean = True);

property ConstructorValue: TGocciaValue read FConstructorValue;
end;
Expand All @@ -37,7 +38,8 @@ implementation
Goccia.Values.ObjectValue,
Goccia.Values.ProxyValue;

constructor TGocciaGlobalProxy.Create(const AScope: TGocciaScope);
constructor TGocciaGlobalProxy.Create(const AScope: TGocciaScope;
const ADefineGlobalBinding: Boolean = True);
var
ConstructorFn: TGocciaNativeFunctionValue;
begin
Expand All @@ -48,7 +50,8 @@ constructor TGocciaGlobalProxy.Create(const AScope: TGocciaScope);
PROP_REVOCABLE, 2));
FConstructorValue := ConstructorFn;

AScope.DefineLexicalBinding(CONSTRUCTOR_PROXY, FConstructorValue, dtConst, True);
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(CONSTRUCTOR_PROXY, FConstructorValue, dtConst, True);
end;

// ES2026 §28.2.1 Proxy(target, handler)
Expand Down
11 changes: 8 additions & 3 deletions source/units/Goccia.Builtins.GlobalReflect.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ TGocciaGlobalReflect = class(TGocciaBuiltin)
function ReflectSet(const AArgs: TGocciaArgumentsCollection; const AThisValue: TGocciaValue): TGocciaValue;
function ReflectSetPrototypeOf(const AArgs: TGocciaArgumentsCollection; const AThisValue: TGocciaValue): TGocciaValue;
public
constructor Create(const AName: string; const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback);
constructor Create(const AName: string; const AScope: TGocciaScope;
const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
end;

implementation
Expand Down Expand Up @@ -66,7 +68,9 @@ procedure RequireObjectTarget(const ATarget: TGocciaValue; const AMethodName: st

{ TGocciaGlobalReflect }

constructor TGocciaGlobalReflect.Create(const AName: string; const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback);
constructor TGocciaGlobalReflect.Create(const AName: string;
const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
var
Members: TGocciaMemberCollection;
begin
Expand Down Expand Up @@ -97,7 +101,8 @@ constructor TGocciaGlobalReflect.Create(const AName: string; const AScope: TGocc
end;
RegisterMemberDefinitions(FBuiltinObject, FStaticMembers);

AScope.DefineLexicalBinding(AName, FBuiltinObject, dtConst, True);
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(AName, FBuiltinObject, dtConst, True);
end;

// ES2026 §28.1.1 Reflect.apply(target, thisArgument, argumentsList)
Expand Down
14 changes: 10 additions & 4 deletions source/units/Goccia.Builtins.Intl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ TGocciaIntlBuiltin = class(TGocciaBuiltin)
procedure RegisterSegmenter;
procedure RegisterDurationFormat;
public
constructor Create(const AName: string; const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback);
constructor Create(const AName: string; const AScope: TGocciaScope;
const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);

property IntlNamespace: TGocciaObjectValue read FIntlNamespace;
end;

function CanonicalizeLocaleListFromValue(const ALocales: TGocciaValue): IntlTypes.TStringArray;
Expand Down Expand Up @@ -100,8 +104,9 @@ implementation

{ TGocciaIntlBuiltin }

constructor TGocciaIntlBuiltin.Create(const AName: string; const AScope: TGocciaScope;
const AThrowError: TGocciaThrowErrorCallback);
constructor TGocciaIntlBuiltin.Create(const AName: string;
const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
var
IntlMembers: array[0..2] of TGocciaMemberDefinition;
begin
Expand Down Expand Up @@ -133,7 +138,8 @@ constructor TGocciaIntlBuiltin.Create(const AName: string; const AScope: TGoccia
[pfConfigurable]);
RegisterMemberDefinitions(FIntlNamespace, IntlMembers);

AScope.DefineLexicalBinding(AName, FIntlNamespace, dtLet, True);
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(AName, FIntlNamespace, dtLet, True);
finally
TGarbageCollector.Instance.RemoveTempRoot(FIntlNamespace);
end;
Expand Down
14 changes: 10 additions & 4 deletions source/units/Goccia.Builtins.Temporal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ TGocciaTemporalBuiltin = class(TGocciaBuiltin)
procedure RegisterZonedDateTime;
procedure RegisterNow;
public
constructor Create(const AName: string; const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback);
constructor Create(const AName: string; const AScope: TGocciaScope;
const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);

property TemporalNamespace: TGocciaObjectValue read FTemporalNamespace;
end;

implementation
Expand Down Expand Up @@ -121,8 +125,9 @@ implementation

{ TGocciaTemporalBuiltin }

constructor TGocciaTemporalBuiltin.Create(const AName: string; const AScope: TGocciaScope;
const AThrowError: TGocciaThrowErrorCallback);
constructor TGocciaTemporalBuiltin.Create(const AName: string;
const AScope: TGocciaScope; const AThrowError: TGocciaThrowErrorCallback;
const ADefineGlobalBinding: Boolean = True);
var
TemporalMembers: array[0..0] of TGocciaMemberDefinition;
begin
Expand All @@ -147,7 +152,8 @@ constructor TGocciaTemporalBuiltin.Create(const AName: string; const AScope: TGo
[pfConfigurable]);
RegisterMemberDefinitions(FTemporalNamespace, TemporalMembers);

AScope.DefineLexicalBinding(AName, FTemporalNamespace, dtLet, True);
if ADefineGlobalBinding then
AScope.DefineLexicalBinding(AName, FTemporalNamespace, dtLet, True);
finally
TGarbageCollector.Instance.RemoveTempRoot(FTemporalNamespace);
end;
Expand Down
Loading
Loading