Skip to content
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

Bridging: call original constructor for subclasses of level larger than 1 #2546

Merged
merged 1 commit into from
Jun 8, 2023

Conversation

hmdne
Copy link
Member

@hmdne hmdne commented Jun 5, 2023

This commit introduces a function descends_from_bridged_class(klass) to check if a class or any of its ancestors is a bridged class. During the allocation of a new class, the descends_from_bridged_class() function is now used to determine if the new class is a descendant of a bridged class, and if so, it ensures the original JavaScript constructor is correctly called. This enables more accurate and robust handling of class hierarchies involving bridged classes.

This problem has manifested in Firefox which didn't capture stacktraces for RuntimeError, but did so for StandardError.

This fixes #2540

…an 1

This commit introduces a function `descends_from_bridged_class(klass)` to check
if a class or any of its ancestors is a bridged class. During the allocation of
a new class, the `descends_from_bridged_class()` function is now used to
determine if the new class is a descendant of a bridged class, and if so, it
ensures the original JavaScript constructor is correctly called. This enables
more accurate and robust handling of class hierarchies involving bridged classes.

This problem has manifested in Firefox which didn't capture stacktraces for
RuntimeError, but did so for StandardError.

This fixes #2540
Copy link
Member

@elia elia left a comment

Choose a reason for hiding this comment

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

Left one optional comment, feel free to ignore

Comment on lines +544 to +545
if (klass.$$super) return descends_from_bridged_class(klass.$$super);
return false;
Copy link
Member

Choose a reason for hiding this comment

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

if we invert these two lines we might get tail-call optimization in browsers supporting it (e.g. safari apparently https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit/)

@hmdne hmdne added this to the v1.8 milestone Jun 8, 2023
@hmdne hmdne merged commit d5fa3d7 into master Jun 8, 2023
18 of 21 checks passed
@hmdne hmdne deleted the hmdne/bridged-descendants branch June 8, 2023 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: No backtrace on exceptions under Firefox
2 participants