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

[BUGFIX beta] Move __nextSuper onto meta #5430

Closed
wants to merge 1 commit into from

Conversation

mixonic
Copy link
Member

@mixonic mixonic commented Aug 19, 2014

Properties cannot be modified on a frozen object, which means even if the functions to not alter the context, the super implementation itself will raise an exception when a wrapped method calls (and changes __nextSuper).

Part of the challenge here is that Ember wraps functions defensively- it has no insight into if super will be called by a function and no tools for hinting about non-super-calling functions. Ember also follows a pattern of using hooks, so many methods are intended to be overridden even if the override will never call super. Unfortunately this pattern costs us. With either hinting or a new internals-only super syntax, we can improve the performance regardless.

But putting super on the meta we kill two birds with one stone. The property does not need to use slow defineProperty (it is already not enumerable on the object) and it can still be set regardless of an object being frozen.

This is not expected to have an impact on performance. The number of meta objects created during a run of the tests remains steady at about 22000 objects, and the number of requests for meta triples from 30k to 90k.

Fixes #4970, Fixes #5324, Fixes #5374

test("contains on a froze array does not raise", function() {
var testArray = EmberArray.apply([]);
var throws = false;
Object.freeze(testArray);
Copy link
Member

Choose a reason for hiding this comment

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

need to detect if Object.freeze is supported by the runtime here, otherwise will fail in ie8

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I just skip the test if Object.free is not present?

Thanks, was thinking of this but was unsure.

Copy link
Member

Choose a reason for hiding this comment

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

yeah i would just skip

Properties cannot be modified on a frozen object, which means even if
the functions to not alter the context, the super implementation itself
will raise an exception when a wrapped method calls (and __nextSuper is
set).

Part of the challenge here is that Ember wraps functions defensively- it
has no insight into if super will be called by a function and no tools
for hinting about non-super-calling functions. Ember also follows a
pattern of using hooks, so many methods are intended to be overridden
even if the override will never call super. Unfortunately this patterns
costs us.

But putting super on the meta we kill two birds with one stone. The
property does not need to use slow defineProperty (it is already not
enumerable on the object) and it can still be set regardless of an
object being frozen.

This is not expected to have an impact on performance. The number of
meta objects created during a run of the tests remains steady at about
22000 objects, and the number of requests for meta triples from 30k to
90k.

Fixes emberjs#4970, Fixes emberjs#5324, Fixes emberjs#5374
@rwjblue
Copy link
Member

rwjblue commented Aug 19, 2014

I am definitely in favor of this change, but I am unsure that we should pull it into the current beta channel. It is slated for release as 1.7.0 (todayish), we have already completed the standard beta releases, and vetting process. The current situation has existed since 1.5.0 (released on 2014-03-30), and we have not had major backlash about this problem.

In short: this is definitely a valuable fix (please do not read that I am discounting the effort of validity of this), but I think we should wait and make it part of 1.8 (which will release into beta in the next day or two) so that we can get some folks banging on it to make sure there are no new quirks to be ironed out.

@mixonic
Copy link
Member Author

mixonic commented Aug 19, 2014

Agreed, 100%. Please do not rush it through. @twokul was looking at performance this morning, and I would like to sync with Stef on it. I've not pushed anything new onto meta before.

@twokul
Copy link
Member

twokul commented Aug 19, 2014

I haven't found radical perf regressions. Although, it's a known issue that meta deopts. Likely a subject for a different PR.

@mixonic
Copy link
Member Author

mixonic commented Aug 19, 2014

@stefanpenner 👍 👎 ? IMO this is a good solution knowing that we want to have either an incremental or big improvement to super in 2.0.


ok(!throws, "No exception thrown calling contains");
});
}

Choose a reason for hiding this comment

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

You might want to test against Object.seal as well.

@stefanpenner
Copy link
Member

honestly the meta call there is extremely scary re: perf

Did you isolate how this worked before the recent super chain?

@twokul
Copy link
Member

twokul commented Aug 19, 2014

@stefanpenner maybe quick chat tonight? I'll share what I have

@stefanpenner
Copy link
Member

In afew hours I should be free

@stefanpenner
Copy link
Member

@mixonic got time to join us?

@stefanpenner
Copy link
Member

@mixonic i think #5444 fixed james's problem and might supercede this?

@rwjblue
Copy link
Member

rwjblue commented Aug 23, 2014

@mixonic - Was this superceded by #5444?

@mixonic
Copy link
Member Author

mixonic commented Aug 27, 2014

#5444 does not actually supersede this, it only makes the problem happen less often.

However this approach is un-popular and I agree we have some better options. Closing it in favor of a pass at resurrecting oldSuper.

@mixonic mixonic closed this Aug 27, 2014
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.

Cannot call contains on frozen Array Array#contains creates an enumerable "__nextSuper" property.
6 participants