Skip to content

[JSC] Remove JSGlobalObject::hasVarDeclaration() #30121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

shvaikalesh
Copy link
Member

@shvaikalesh shvaikalesh commented Jun 24, 2024

775c66f

[JSC] Remove JSGlobalObject::hasVarDeclaration()
https://bugs.webkit.org/show_bug.cgi?id=275821
<rdar://problem/130438575>

Reviewed by Justin Michaud and Yijia Huang.

This change implements stage 3 proposal [1] to remove [[VarNames]] from global object,
which purpose was to prevent redeclaration of `var` and `function` bindings that were
declared via eval().

However, those bindings are configurable and thus still were redeclarable following `delete`.
The proposal simplified both mental model of redeclaration constraints and its implementation.

This patch effectively reverts [2] and aligns JSC with V8.

[1]: https://github.com/tc39/proposal-redeclarable-global-eval-vars
[2]: #17662

* JSTests/stress/global-add-function-should-not-be-shadowed-by-lexical-bindings.js:
* JSTests/stress/global-add-var-should-not-be-shadowed-by-lexical-bindings.js:
* JSTests/stress/has-var-declaration.js:
* JSTests/test262/expectations.yaml: Mark 1 test as passing.
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::createGlobalFunctionBinding):
(JSC::JSGlobalObject::addStaticGlobals):
(JSC::JSGlobalObject::deleteProperty): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h:
(JSC::JSGlobalObject::createGlobalVarBinding):
(JSC::JSGlobalObject::hasVarDeclaration): Deleted.
* Source/JavaScriptCore/runtime/ProgramExecutable.cpp:
(JSC::ProgramExecutable::initializeGlobalProperties):

Canonical link: https://commits.webkit.org/280316@main

881534f

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 🧪 unsafe-merge ✅ 🛠 tv ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@shvaikalesh shvaikalesh requested a review from a team as a code owner June 24, 2024 20:07
@shvaikalesh shvaikalesh self-assigned this Jun 24, 2024
@shvaikalesh shvaikalesh added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Jun 24, 2024
Copy link
Contributor

@hyjorc1 hyjorc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

Copy link
Contributor

@justinmichaud justinmichaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me too

@shvaikalesh shvaikalesh added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 24, 2024
https://bugs.webkit.org/show_bug.cgi?id=275821
<rdar://problem/130438575>

Reviewed by Justin Michaud and Yijia Huang.

This change implements stage 3 proposal [1] to remove [[VarNames]] from global object,
which purpose was to prevent redeclaration of `var` and `function` bindings that were
declared via eval().

However, those bindings are configurable and thus still were redeclarable following `delete`.
The proposal simplified both mental model of redeclaration constraints and its implementation.

This patch effectively reverts [2] and aligns JSC with V8.

[1]: https://github.com/tc39/proposal-redeclarable-global-eval-vars
[2]: WebKit#17662

* JSTests/stress/global-add-function-should-not-be-shadowed-by-lexical-bindings.js:
* JSTests/stress/global-add-var-should-not-be-shadowed-by-lexical-bindings.js:
* JSTests/stress/has-var-declaration.js:
* JSTests/test262/expectations.yaml: Mark 1 test as passing.
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::createGlobalFunctionBinding):
(JSC::JSGlobalObject::addStaticGlobals):
(JSC::JSGlobalObject::deleteProperty): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h:
(JSC::JSGlobalObject::createGlobalVarBinding):
(JSC::JSGlobalObject::hasVarDeclaration): Deleted.
* Source/JavaScriptCore/runtime/ProgramExecutable.cpp:
(JSC::ProgramExecutable::initializeGlobalProperties):

Canonical link: https://commits.webkit.org/280316@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/JSC-Remove-JSGlobalObjecthasVarDeclaration branch from 881534f to 775c66f Compare June 24, 2024 23:18
@webkit-commit-queue
Copy link
Collaborator

Committed 280316@main (775c66f): https://commits.webkit.org/280316@main

Reviewed commits have been landed. Closing PR #30121 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 775c66f into WebKit:main Jun 24, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants