From 8d05893074eff07920f7ce64591e0f0764dcb870 Mon Sep 17 00:00:00 2001 From: Filipe Marques Date: Mon, 10 Feb 2025 11:42:39 +0000 Subject: [PATCH 1/3] Ensure `parse{Int|Float}` are the same as `Number.parse{Int|Float}` --- .../ecmaref6/section 20/section_20.1.esl | 10 ++++---- .../ecmaref6/section 6/section_6.1.esl | 24 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/JS-Interpreters/ecmaref6/section 20/section_20.1.esl b/JS-Interpreters/ecmaref6/section 20/section_20.1.esl index 59ae743c7..bf57ea368 100644 --- a/JS-Interpreters/ecmaref6/section 20/section_20.1.esl +++ b/JS-Interpreters/ecmaref6/section 20/section_20.1.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -189,13 +189,13 @@ function initNumberConstructor(prototype, global, strict) { createBuiltInPropertyWithFullDescriptor(NumberConstructor, "NEGATIVE_INFINITY", (-Infinity), false, false, false); /* 20.1.2.12 Number.parseFloat ( string ) */ - parseFloatObject := CreateBuiltInFunctionObject(["string"], "GlobalObjectParseFloat", global, strict, null); + parseFloatObject := |Intrinsics|["parseFloat"]; createBuiltInProperty(NumberConstructor, "parseFloat", parseFloatObject); descriptor := newDataPropertyDescriptorFull("parseFloat", false, false, true); setJSProperty(parseFloatObject, "name", descriptor); /* 20.1.2.13 Number.parseInt ( string, radix ) */ - parseIntObject := CreateBuiltInFunctionObject(["string", "radix"], "GlobalObjectParseInt", global, strict, null); + parseIntObject := |Intrinsics|["parseInt"]; createBuiltInProperty(NumberConstructor, "parseInt", parseIntObject); descriptor := newDataPropertyDescriptorFull("parseInt", false, false, true); setJSProperty(parseIntObject, "name", descriptor); diff --git a/JS-Interpreters/ecmaref6/section 6/section_6.1.esl b/JS-Interpreters/ecmaref6/section 6/section_6.1.esl index 4e25e1070..c84683127 100644 --- a/JS-Interpreters/ecmaref6/section 6/section_6.1.esl +++ b/JS-Interpreters/ecmaref6/section 6/section_6.1.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -262,6 +262,16 @@ function initIntrinsics(intrinsics, realm, strict) { /* Math */ intrinsics.Math := initMathObject(realm, objProto, strict); + /* parseFloat */ + /* IMPORTANT: This needs to be here before `initNumberObject`! */ + parseFloat := CreateBuiltInFunctionObject(["string"], "GlobalObjectParseFloat", realm, strict, null); + intrinsics.parseFloat := parseFloat; + + /* parseInt */ + /* IMPORTANT: This needs to be here before `initNumberObject`! */ + parseInt := CreateBuiltInFunctionObject(["string", "radix"], "GlobalObjectParseInt", realm, strict, null); + intrinsics.parseInt := parseInt; + /* Number */ NumberObject := initNumberObject(realm, objProto, strict); intrinsics.Number := NumberObject; @@ -272,14 +282,6 @@ function initIntrinsics(intrinsics, realm, strict) { intrinsics.ObjProto_toString := getJSProperty(objProto, "toString").Value; intrinsics.ObjectIteratorPrototype := initObjectIteratorPrototype(realm, objProto, strict); - /* parseFloat */ - parseFloat := CreateBuiltInFunctionObject(["string"], "GlobalObjectParseFloat", realm, strict, null); - intrinsics.parseFloat := parseFloat; - - /* parseInt */ - parseInt := CreateBuiltInFunctionObject(["string", "radix"], "GlobalObjectParseInt", realm, strict, null); - intrinsics.parseInt := parseInt; - /* Promise */ PromiseObject := initPromiseObject(realm, funcProto, objProto, strict); intrinsics.Promise := PromiseObject; From ad4c34d80a344353d694dec3767330fad6ea0d34 Mon Sep 17 00:00:00 2001 From: Filipe Marques Date: Mon, 10 Feb 2025 12:35:33 +0000 Subject: [PATCH 2/3] Try to fix some strict checks --- JS-Interpreters/ecmaref5/section 10/section_10.3.esl | 8 ++++---- JS-Interpreters/ecmaref5/section 8/section_8.7.esl | 6 +++--- JS-Interpreters/ecmaref6/esl_interpreter.esl | 4 ++-- JS-Interpreters/ecmaref6/section 10/section_10.2.esl | 10 +++++----- JS-Interpreters/ecmaref6/section 19/section_19.2.esl | 8 ++++---- JS-Interpreters/ecmaref6/section 6/section_6.2.esl | 6 +++--- JS-Interpreters/ecmaref6/section 8/section_8.3.esl | 11 ++++------- JS-Interpreters/ecmaref6/section 9/section_9.2.esl | 10 +++++----- JS-Interpreters/ecmaref6/section 9/section_9.3.esl | 10 +++++----- 9 files changed, 35 insertions(+), 38 deletions(-) diff --git a/JS-Interpreters/ecmaref5/section 10/section_10.3.esl b/JS-Interpreters/ecmaref5/section 10/section_10.3.esl index d425316a9..b8636f946 100644 --- a/JS-Interpreters/ecmaref5/section 10/section_10.3.esl +++ b/JS-Interpreters/ecmaref5/section 10/section_10.3.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -60,7 +60,7 @@ function IdentifierResolution(Identifier, runningExecCtx) { /* 2. If the syntactic production that is being evaluated is contained in a strict mode code, then let strict be true, else let strict be false. */ - if (isContainedInStrictCode(runningExecCtx)) strict := true; else strict := false; + strict := isContainedInStrictCode(runningExecCtx); /* 3. Return the result of calling GetIdentifierReference function passing env, Identifier, and strict as arguments. The result of evaluating an identifier is always a value of type Reference with its referenced name component equal to the Identifier String. */ diff --git a/JS-Interpreters/ecmaref5/section 8/section_8.7.esl b/JS-Interpreters/ecmaref5/section 8/section_8.7.esl index ce418c6c2..0a13f6457 100644 --- a/JS-Interpreters/ecmaref5/section 8/section_8.7.esl +++ b/JS-Interpreters/ecmaref5/section 8/section_8.7.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ diff --git a/JS-Interpreters/ecmaref6/esl_interpreter.esl b/JS-Interpreters/ecmaref6/esl_interpreter.esl index 5d6928b7f..9a0e92e68 100644 --- a/JS-Interpreters/ecmaref6/esl_interpreter.esl +++ b/JS-Interpreters/ecmaref6/esl_interpreter.esl @@ -78,7 +78,7 @@ function JS_Interpreter_Expr(e, scope) { /* 1. If the function code for this ArrowFunction is strict mode code (10.2.1), */ /* let strict be true. Otherwise let strict be false */ - if (isStrictModeCode(ConciseBody, scope)) strict := true; else strict := false; + strict := isStrictModeCode(ConciseBody, scope); /* 2. Let scope be the LexicalEnvironment of the running execution context. */ lexEnv := scope.LexicalEnvironment; /* 3. Let parameters be CoveredFormalsList of ArrowParameters. */ @@ -969,7 +969,7 @@ function JS_Interpreter_FunctionDeclaration(FunctionDeclaration, scope) { /* 1. If the function code for FunctionDeclaration is strict mode code, let strict be true. Otherwise let strict be false. */ - if (isStrictModeCode(FunctionBody, scope)) strict := true; else strict := false; + strict := isStrictModeCode(FunctionBody, scope); /* 2. Let name br StringValue of BindingIdentifier */ name := Identifier.name; lex := getLexicalEnvironment(scope); diff --git a/JS-Interpreters/ecmaref6/section 10/section_10.2.esl b/JS-Interpreters/ecmaref6/section 10/section_10.2.esl index ec1211850..7e59e6436 100644 --- a/JS-Interpreters/ecmaref6/section 10/section_10.2.esl +++ b/JS-Interpreters/ecmaref6/section 10/section_10.2.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -17,9 +17,9 @@ /* 10.2 Strict Code */ function isStrict(code) { - return (code != 'undefined &&& code.strict == true); + return (code != 'undefined &&& code.strict); } function isStrictModeCode(code, execCtx) { - return (code != 'undefined &&& code.strict == true) ||| isContainedInStrictCode(execCtx); + return (code != 'undefined &&& code.strict) ||| isContainedInStrictCode(execCtx); } diff --git a/JS-Interpreters/ecmaref6/section 19/section_19.2.esl b/JS-Interpreters/ecmaref6/section 19/section_19.2.esl index 5cbcdc058..be3dd679c 100644 --- a/JS-Interpreters/ecmaref6/section 19/section_19.2.esl +++ b/JS-Interpreters/ecmaref6/section 19/section_19.2.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -434,7 +434,7 @@ function isParsableAsFunctionBody(bodyObj) { } function isBuiltInFunctionBodyStrictModeCode(bodyObj) { - return ("strict" in_obj bodyObj) &&& (bodyObj.strict); + return ("strict" in_obj bodyObj) &&& bodyObj.strict; } function anyStrictModeRestrictionApplicable(bodyObj) { diff --git a/JS-Interpreters/ecmaref6/section 6/section_6.2.esl b/JS-Interpreters/ecmaref6/section 6/section_6.2.esl index 2b3dd72b1..0670d0329 100644 --- a/JS-Interpreters/ecmaref6/section 6/section_6.2.esl +++ b/JS-Interpreters/ecmaref6/section 6/section_6.2.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ diff --git a/JS-Interpreters/ecmaref6/section 8/section_8.3.esl b/JS-Interpreters/ecmaref6/section 8/section_8.3.esl index 56db205a8..7d2f6fc3e 100644 --- a/JS-Interpreters/ecmaref6/section 8/section_8.3.esl +++ b/JS-Interpreters/ecmaref6/section 8/section_8.3.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -25,10 +25,7 @@ function IdentifierResolution(Identifier, runningExecCtx) { env := getLexicalEnvironment(runningExecCtx); /* 2. If the syntactic production that is being evaluated is contained in a strict mode code, then let strict be true, else let strict be false. */ - if (isContainedInStrictCode(runningExecCtx)) - strict := true; - else - strict := false; + strict := isContainedInStrictCode(runningExecCtx); /* 3. Return the result of calling GetIdentifierReference function passing env, Identifier, and strict as arguments. The result of evaluating an identifier is always a value of type Reference with its referenced name component equal to the Identifier String. */ diff --git a/JS-Interpreters/ecmaref6/section 9/section_9.2.esl b/JS-Interpreters/ecmaref6/section 9/section_9.2.esl index 5de09cc20..129f21975 100644 --- a/JS-Interpreters/ecmaref6/section 9/section_9.2.esl +++ b/JS-Interpreters/ecmaref6/section 9/section_9.2.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -143,7 +143,7 @@ function OrdinaryCallBindThis (F, calleeContext, thisArgument) { /* 4. Let localEnv be the LexicalEnvironment of calleeContext. */ localEnv := calleeContext.LexicalEnvironment; /* 5. If thisMode is strict, let thisValue be thisArgument. */ - if (thisMode == "strict") { + if (thisMode == "Strict") { thisValue := thisArgument; /* 6. Else */ } else { @@ -367,7 +367,7 @@ function FunctionInitialize(F, kind, ParameterList, Body, Scope) { /* 10. Else if Strict is true, */ else if (Strict == true) /* set the [[ThisMode]] internal slot of F to strict */ - F.ThisMode := "strict"; + F.ThisMode := "Strict"; /* 11. Else set the [[ThisMode]] internal slot of F to global. */ else F.ThisMode := "global"; diff --git a/JS-Interpreters/ecmaref6/section 9/section_9.3.esl b/JS-Interpreters/ecmaref6/section 9/section_9.3.esl index 7a23b357f..8a311701e 100644 --- a/JS-Interpreters/ecmaref6/section 9/section_9.3.esl +++ b/JS-Interpreters/ecmaref6/section 9/section_9.3.esl @@ -1,15 +1,15 @@ /* Copyright (C) 2022-2025 formalsec programmers - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -62,11 +62,11 @@ function BuiltInCall(externalScope, ref, F, V, NewTarget, argumentsList) { if (("ECMAScriptCode" in_obj F) &&& (typeof F.ECMAScriptCode == "string") &&& ((F.ECMAScriptCode == "FunctionPrototypeCall") ||| (F.ECMAScriptCode == "TypedArraySubConstructor"))) { args := completeArgs(argumentsList, F); - result := {F.ECMAScriptCode}(externalScope, V, NewTarget, F.strict, args) catch BuiltInCall_Handler; + result := {F.ECMAScriptCode}(externalScope, V, NewTarget, F.Strict, args) catch BuiltInCall_Handler; } else if (("ECMAScriptCode" in_obj F) &&& ((typeof F.ECMAScriptCode == "string") ||| (typeof F.ECMAScriptCode == "curry"))) { args := completeArgs(argumentsList, F); - result := {F.ECMAScriptCode}(F.Environment, V, NewTarget, F.strict, args) catch BuiltInCall_Handler; + result := {F.ECMAScriptCode}(F.Environment, V, NewTarget, F.Strict, args) catch BuiltInCall_Handler; } /* 10. Remove calleeContext from the execution context stack and restore callerContext as the running execution context. */ From 4b5d4f7b680d10c53a95fd4933fbff0ef1197f3a Mon Sep 17 00:00:00 2001 From: Filipe Marques Date: Mon, 10 Feb 2025 12:36:57 +0000 Subject: [PATCH 3/3] Update `bench/test262` submodule --- bench/test262 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/test262 b/bench/test262 index c2050fe16..624cc17d6 160000 --- a/bench/test262 +++ b/bench/test262 @@ -1 +1 @@ -Subproject commit c2050fe161080f7dc0bb86b91ff3cee2f42f79e0 +Subproject commit 624cc17d6b5cb1ac34937dbce5aa77e7eef475e2