mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Bug 1800724 - Use DecoratorEmitter::emitCallExtraInitializers in BytecodeEmitter; r=arai
Differential Revision: https://phabricator.services.mozilla.com/D195924
This commit is contained in:
parent
6c8d7b3a1a
commit
cbc0f9fd97
@ -10755,6 +10755,11 @@ bool BytecodeEmitter::emitInitializeInstanceMembers(
|
||||
return false;
|
||||
}
|
||||
// 5. Return unused.
|
||||
|
||||
if (!de.emitCallExtraInitializers(TaggedParserAtomIndex::WellKnown::
|
||||
dot_instanceExtraInitializers_())) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
|
@ -812,8 +812,14 @@ bool DecoratorEmitter::emitInitializeFieldOrAccessor() {
|
||||
|
||||
bool DecoratorEmitter::emitCallExtraInitializers(
|
||||
TaggedParserAtomIndex extraInitializers) {
|
||||
// Support for static and class extra initializers will be added in
|
||||
// bug 1868220 and bug 1868221.
|
||||
MOZ_ASSERT(
|
||||
extraInitializers ==
|
||||
TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_());
|
||||
|
||||
if (!bce_->emitGetName(extraInitializers)) {
|
||||
// [stack] ARRAY
|
||||
// [stack] ARRAY
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -834,9 +840,6 @@ bool DecoratorEmitter::emitCallExtraInitializers(
|
||||
}
|
||||
|
||||
InternalWhileEmitter wh(bce_);
|
||||
// At this point, we have no context to determine offsets in the
|
||||
// code for this while statement. Ideally, it would correspond to
|
||||
// the field we're initializing.
|
||||
if (!wh.emitCond()) {
|
||||
// [stack] ARRAY LENGTH INDEX
|
||||
return false;
|
||||
@ -886,7 +889,7 @@ bool DecoratorEmitter::emitCallExtraInitializers(
|
||||
|
||||
// Callee is always internal function.
|
||||
if (!bce_->emitCall(JSOp::CallIgnoresRv, 0)) {
|
||||
// [stack] ARRAY LENGTH INDEX INITIALIZER THIS RVAL
|
||||
// [stack] ARRAY LENGTH INDEX RVAL
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
// |jit-test| skip-if: !getBuildConfiguration("decorators")
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
let extraInitializerCalled = {};
|
||||
|
||||
function checkDecoratorContext(kind, isPrivate, isStatic, name) {
|
||||
return function (value, context) {
|
||||
if (kind == "field") {
|
||||
@ -16,7 +18,7 @@ function checkDecoratorContext(kind, isPrivate, isStatic, name) {
|
||||
assertEq(context.static, isStatic);
|
||||
assertEq(context.name, name);
|
||||
assertEq(typeof context.addInitializer, "function");
|
||||
context.addInitializer(() => {});
|
||||
context.addInitializer(() => {extraInitializerCalled[context.name] = true;});
|
||||
// return undefined
|
||||
}
|
||||
}
|
||||
@ -27,3 +29,5 @@ class C {
|
||||
}
|
||||
|
||||
let c = new C();
|
||||
assertEq(extraInitializerCalled["x"], true);
|
||||
assertEq(extraInitializerCalled["y accessor storage"], true);
|
||||
|
Loading…
Reference in New Issue
Block a user