Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1954ffc
Move `call` and `construct` to `VarScope`.
aardvark179 Dec 10, 2025
3b94326
Move `JSCode` signatures to use `VarScope` for scopes.
aardvark179 Jan 8, 2026
8a4e397
First round of conversion of `Scriptable` to `VarScope`.
aardvark179 Dec 11, 2025
7f56410
Second round of conversion of `Scriptable` to `VarScope`.
aardvark179 Dec 11, 2025
9034bff
Third round of conversion of `Scriptable` to `VarScope`.
aardvark179 Dec 26, 2025
53b5b59
Fourth round of conversions of `Scriptable` to `VarScope`.
aardvark179 Dec 26, 2025
cd288d5
Make parameter type of `setParentScope` be `VarScope`.
aardvark179 Dec 31, 2025
ae7860c
Change `ScriptRuntime` in preparation for full separation.
aardvark179 Mar 9, 2026
8a76c34
Final round of conversion of `Scriptable` to `VarScope`.
aardvark179 Mar 9, 2026
c542819
Make `Scriptable` and `VarScope` separate descendants of `PropHolder`.
aardvark179 Dec 31, 2025
6d72b27
Remove old `NativeWith` implementation.
aardvark179 Jan 16, 2026
35c6c1b
Convert `BaseFunction` to descriptor.
aardvark179 Feb 2, 2026
23b2463
Convert `NativeString` to descriptors.
aardvark179 Jan 15, 2026
5a01c9c
Convert `NativeNumber` to descriptors.
aardvark179 Jan 15, 2026
4c8f389
Move `NativeMath` to descriptors.
aardvark179 Jan 16, 2026
ae1f7d8
Convert `NativeJSON` to descriptors.
aardvark179 Jan 16, 2026
be634a7
Convert `NativeScript` to descriptors.
aardvark179 Jan 16, 2026
39fdda0
Move `NativeIterator` to be based on descriptors.
aardvark179 Jan 19, 2026
5077054
Convert `NativeGlobal` to descriptor.
aardvark179 Jan 21, 2026
2144e03
Convert error initialisation to descriptors.
aardvark179 Jan 21, 2026
4f5bf3b
Global fixup.
aardvark179 Feb 6, 2026
87daf96
Convert `ArrayBuffer` to descriptors.
aardvark179 Jan 27, 2026
0382e04
Move typed array to descriptor.
aardvark179 Jan 28, 2026
2b45912
Update test 262 properties.
aardvark179 Feb 3, 2026
5d13581
Move `NativeDataView` to descriptors.
aardvark179 Jan 28, 2026
b892e2f
Removing unused methods
aardvark179 Jan 29, 2026
e01beb8
Convert `NativeMap` to descriptor.
aardvark179 Jan 29, 2026
c80a47c
Move `NativeSet` to descriptors.
aardvark179 Jan 29, 2026
2387e03
Move `NativePromise` to descriptors.
aardvark179 Jan 29, 2026
bf5b7bc
Move `NativeWeakMap` to descriptor.
aardvark179 Jan 29, 2026
aa8d43f
Move `NativeWeakSet` to descriptors.
aardvark179 Jan 29, 2026
d6749e7
Convert `NativeBigInt` to descriptor.
aardvark179 Jan 30, 2026
1e506d6
Convert `NativeProxy` to descriptor.
aardvark179 Jan 30, 2026
0724b9a
Convert `NativeReflect` to descriptors.
aardvark179 Jan 30, 2026
b449560
Convert `NativeContinuation` to descriptor.
aardvark179 Feb 4, 2026
96203bf
Convert `NativeGenerator` to descriptor.
aardvark179 Feb 4, 2026
6cbf272
Spotless.
aardvark179 Feb 18, 2026
7958b97
Convert `NativeCallSite` to descriptors.
aardvark179 Feb 26, 2026
2dbf349
Convert `ES6Iteratorz` to descriptors.
aardvark179 Feb 4, 2026
a8b1147
Update 262 properties.
aardvark179 Mar 19, 2026
f1f5c21
Convert `thisObj` to be `Object` not `Scriptable`.
aardvark179 Feb 12, 2026
0fcbe1e
Update test 262 properties.
aardvark179 Mar 11, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.VarScope;
import org.mozilla.javascript.annotations.*;
import org.openjdk.jmh.annotations.*;

Expand Down Expand Up @@ -56,7 +58,7 @@ public void close() {
}

Context cx;
Scriptable scope;
TopLevel scope;
Script testScript;
}

Expand All @@ -74,7 +76,7 @@ public void init()

@Benchmark
public Object annotatedClassMethods(AnnotatedClassState state) {
return state.testScript.exec(state.cx, state.scope, state.scope);
return state.testScript.exec(state.cx, state.scope, state.scope.getGlobalThis());
}

public static class AnnotatedClass extends ScriptableObject {
Expand Down Expand Up @@ -138,14 +140,14 @@ public void init()

@Benchmark
public Object idClassMethods(IdClassState state) {
return state.testScript.exec(state.cx, state.scope, state.scope);
return state.testScript.exec(state.cx, state.scope, state.scope.getGlobalThis());
}

public static class IdClass extends IdScriptableObject {

private static final String TAG = "IdClass";

public static void init(Scriptable scope) {
public static void init(TopLevel scope) {
IdClass idc = new IdClass();
idc.exportAsJSClass(MAX_ID, scope, false);
}
Expand Down Expand Up @@ -217,11 +219,7 @@ protected void initPrototypeId(int id) {

@Override
public Object execIdCall(
IdFunctionObject f,
Context cx,
Scriptable scope,
Scriptable thisObj,
Object[] args) {
IdFunctionObject f, Context cx, VarScope scope, Scriptable thisObj, Object[] args) {
if (!f.hasTag(TAG)) {
return super.execIdCall(f, cx, scope, thisObj, args);
}
Expand Down Expand Up @@ -331,18 +329,16 @@ public void init()

@Benchmark
public Object dumbLambdaClassMethods(DumbLambdaState state) {
return state.testScript.exec(state.cx, state.scope, state.scope);
return state.testScript.exec(state.cx, state.scope, state.scope.getGlobalThis());
}

private static class DumbLambdaClass extends ScriptableObject {

private static Object noop(
Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
private static Object noop(Context cx, VarScope scope, Object thisObj, Object[] args) {
return Undefined.instance;
}

private static Object setValue(
Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
private static Object setValue(Context cx, VarScope scope, Object thisObj, Object[] args) {
if (args.length < 1) {
throw ScriptRuntime.throwError(cx, scope, "Not enough args");
}
Expand All @@ -352,20 +348,19 @@ private static Object setValue(
return Undefined.instance;
}

private static Object getValue(
Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
private static Object getValue(Context cx, VarScope scope, Object thisObj, Object[] args) {
DumbLambdaClass self =
LambdaConstructor.convertThisObject(thisObj, DumbLambdaClass.class);
return self.value;
}

public static void init(Scriptable scope) {
public static void init(VarScope scope) {
LambdaConstructor cons =
new LambdaConstructor(
scope,
"DumbLambdaClass",
0,
(Context cx, Scriptable s, Object[] args) -> new DumbLambdaClass());
(Context cx, VarScope s, Object[] args) -> new DumbLambdaClass());
cons.definePrototypeMethod(scope, "one", 0, DumbLambdaClass::noop);
cons.definePrototypeMethod(scope, "two", 0, DumbLambdaClass::noop);
cons.definePrototypeMethod(scope, "three", 0, DumbLambdaClass::noop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.openjdk.jmh.annotations.*;

@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class GeneratorBenchmark {
@State(Scope.Thread)
public static class GeneratorState {
Context cx;
Scriptable scope;
TopLevel scope;

Function nativeGenerator;
Function transpiledGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.openjdk.jmh.annotations.*;

@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class MathBenchmark {
@State(Scope.Thread)
public static class MathState {
Context cx;
Scriptable scope;
TopLevel scope;

Function addConstantInts;
Function addIntAndConstant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.mozilla.javascript.VarScope;
import org.mozilla.javascript.tools.shell.Global;
import org.openjdk.jmh.annotations.*;

Expand All @@ -20,7 +22,7 @@ public class ObjectBenchmark {
// "count" should match "@OperationsPerInvocation" annotations
static final int count = 1000;

static void runCode(Context cx, Scriptable scope, String fileName) throws IOException {
static void runCode(Context cx, VarScope scope, String fileName) throws IOException {
try (FileReader rdr = new FileReader(fileName)) {
cx.evaluateReader(scope, rdr, "test.js", 1, null);
}
Expand All @@ -29,7 +31,7 @@ static void runCode(Context cx, Scriptable scope, String fileName) throws IOExce
@State(Scope.Thread)
public static class FieldTestState {
Context cx;
Scriptable scope;
TopLevel scope;
Scriptable strings;
Scriptable ints;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.openjdk.jmh.annotations.*;

@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class PropertyBenchmark {
@State(Scope.Thread)
public static class PropertyState {
Context cx;
Scriptable scope;
TopLevel scope;

Function create;
Function createFieldByField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Callable;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.openjdk.jmh.annotations.*;

@OutputTimeUnit(TimeUnit.MICROSECONDS)
Expand All @@ -16,7 +16,7 @@ public class RegexpAtomicQuantifierBenchmark {
@State(Scope.Thread)
public static class RegExpState {
Context cx;
Scriptable scope;
TopLevel scope;
Callable testFunc;

@Setup(Level.Trial)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.EmbeddedSlotMap;
import org.mozilla.javascript.HashSlotMap;
import org.mozilla.javascript.PropHolder;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Slot;
import org.mozilla.javascript.SlotMap;
import org.openjdk.jmh.annotations.*;
Expand All @@ -15,9 +17,9 @@ public class SlotMapBenchmark {

@State(Scope.Thread)
public static class EmbeddedState {
final EmbeddedSlotMap emptyMap = new EmbeddedSlotMap();
final EmbeddedSlotMap size10Map = new EmbeddedSlotMap();
final EmbeddedSlotMap size100Map = new EmbeddedSlotMap();
final EmbeddedSlotMap<Scriptable> emptyMap = new EmbeddedSlotMap<>();
final EmbeddedSlotMap<Scriptable> size10Map = new EmbeddedSlotMap<>();
final EmbeddedSlotMap<Scriptable> size100Map = new EmbeddedSlotMap<>();
final String[] randomKeys = new String[100];
String size100LastKey;
String size10LastKey;
Expand All @@ -42,7 +44,7 @@ public void create() {
@Benchmark
@OperationsPerInvocation(100)
public Object embeddedInsert1Key(EmbeddedState state) {
Slot newSlot = null;
Slot<Scriptable> newSlot = null;
for (int i = 0; i < 100; i++) {
newSlot = state.emptyMap.modify(null, state.randomKeys[i], 0, 0);
}
Expand All @@ -55,7 +57,7 @@ public Object embeddedInsert1Key(EmbeddedState state) {
@Benchmark
@OperationsPerInvocation(100)
public Object embeddedQueryKey10Entries(EmbeddedState state) {
Slot slot = null;
Slot<Scriptable> slot = null;
for (int i = 0; i < 100; i++) {
slot = state.size10Map.query(state.size10LastKey, 0);
}
Expand All @@ -68,7 +70,7 @@ public Object embeddedQueryKey10Entries(EmbeddedState state) {
@Benchmark
@OperationsPerInvocation(100)
public Object embeddedQueryKey100Entries(EmbeddedState state) {
Slot slot = null;
Slot<Scriptable> slot = null;
for (int i = 0; i < 100; i++) {
slot = state.size100Map.query(state.size100LastKey, 0);
}
Expand All @@ -80,9 +82,9 @@ public Object embeddedQueryKey100Entries(EmbeddedState state) {

@State(Scope.Thread)
public static class HashState {
final HashSlotMap emptyMap = new HashSlotMap();
final HashSlotMap size10Map = new HashSlotMap();
final HashSlotMap size100Map = new HashSlotMap();
final HashSlotMap<Scriptable> emptyMap = new HashSlotMap<>();
final HashSlotMap<Scriptable> size10Map = new HashSlotMap<>();
final HashSlotMap<Scriptable> size100Map = new HashSlotMap<>();
final String[] randomKeys = new String[100];
String size100LastKey;
String size10LastKey;
Expand All @@ -107,7 +109,7 @@ public void create() {
@Benchmark
@OperationsPerInvocation(100)
public Object hashInsert1Key(HashState state) {
Slot newSlot = null;
Slot<Scriptable> newSlot = null;
for (int i = 0; i < 100; i++) {
newSlot = state.emptyMap.modify(null, state.randomKeys[i], 0, 0);
}
Expand All @@ -120,7 +122,7 @@ public Object hashInsert1Key(HashState state) {
@Benchmark
@OperationsPerInvocation(100)
public Object hashQueryKey10Entries(HashState state) {
Slot slot = null;
Slot<Scriptable> slot = null;
for (int i = 0; i < 100; i++) {
slot = state.size10Map.query(state.size10LastKey, 0);
}
Expand All @@ -133,7 +135,7 @@ public Object hashQueryKey10Entries(HashState state) {
@Benchmark
@OperationsPerInvocation(100)
public Object hashQueryKey100Entries(HashState state) {
Slot slot = null;
Slot<Scriptable> slot = null;
for (int i = 0; i < 100; i++) {
slot = state.size100Map.query(state.size100LastKey, 0);
}
Expand All @@ -154,9 +156,9 @@ private static String makeRandomString() {
}

/** Insert a random key and value into the map */
private static String insertRandomEntry(SlotMap map) {
private static <T extends PropHolder<T>> String insertRandomEntry(SlotMap<T> map) {
String key = makeRandomString();
Slot slot = map.modify(null, key, 0, 0);
Slot<T> slot = map.modify(null, key, 0, 0);
slot.setValue(key, null, null);
return key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.concurrent.TimeUnit;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.TopLevel;
import org.openjdk.jmh.annotations.*;

public class SunSpiderBenchmark {
Expand All @@ -14,7 +14,7 @@ public class SunSpiderBenchmark {
@OutputTimeUnit(TimeUnit.MICROSECONDS)
abstract static class AbstractState {
Context cx;
Scriptable scope;
TopLevel scope;
Script script;
String fileName;

Expand Down Expand Up @@ -44,7 +44,7 @@ public void tearDown() {
}

Object run() {
return script.exec(cx, scope, scope);
return script.exec(cx, scope, scope.getGlobalThis());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.TopLevel;
import org.openjdk.jmh.annotations.*;

@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class ThrowBenchmark {
@State(Scope.Thread)
public static class GeneratorState {
Context cx;
Scriptable scope;
TopLevel scope;

Function shallowThrow;
Function mediumThrow;
Expand Down
Loading
Loading