Commit b4503bfe authored by Jan de Mooij's avatar Jan de Mooij
Browse files

Bug 1083482 part 1 - Remove SpiderMonkey support for legacy generators. r=arai

parent 54b6236e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -851,7 +851,7 @@ static const uint32_t JSCLASS_FOREGROUND_FINALIZE = 1 << (JSCLASS_HIGH_FLAGS
// application.
static const uint32_t JSCLASS_GLOBAL_APPLICATION_SLOTS = 5;
static const uint32_t JSCLASS_GLOBAL_SLOT_COUNT =
    JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 2 + 38;
    JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 2 + 37;

#define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n)                              \
    (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n)))
+0 −63
Original line number Diff line number Diff line
@@ -70,69 +70,6 @@ function StarGeneratorReturn(val) {
    }
}

function LegacyGeneratorNext(val) {
    if (!IsObject(this) || !IsLegacyGeneratorObject(this))
        return callFunction(CallLegacyGeneratorMethodIfWrapped, this, val, "LegacyGeneratorNext");

    if (LegacyGeneratorObjectIsClosed(this))
        ThrowStopIteration();

    if (GeneratorIsRunning(this))
        ThrowTypeError(JSMSG_NESTING_GENERATOR);

    try {
        return resumeGenerator(this, val, "next");
    } catch (e) {
        if (!LegacyGeneratorObjectIsClosed(this))
            GeneratorSetClosed(this);
        throw e;
    }
}
_SetCanonicalName(LegacyGeneratorNext, "next");

function LegacyGeneratorThrow(val) {
    if (!IsObject(this) || !IsLegacyGeneratorObject(this))
        return callFunction(CallLegacyGeneratorMethodIfWrapped, this, val, "LegacyGeneratorThrow");

    if (LegacyGeneratorObjectIsClosed(this))
        throw val;

    if (GeneratorIsRunning(this))
        ThrowTypeError(JSMSG_NESTING_GENERATOR);

    try {
        return resumeGenerator(this, val, "throw");
    } catch (e) {
        if (!LegacyGeneratorObjectIsClosed(this))
            GeneratorSetClosed(this);
        throw e;
    }
}

// Called by js::CloseIterator.
function LegacyGeneratorCloseInternal() {
    assert(IsObject(this), "Not an object: " + ToString(this));
    assert(IsLegacyGeneratorObject(this), "Not a legacy generator object: " + ToString(this));
    assert(!LegacyGeneratorObjectIsClosed(this), "Already closed: " + ToString(this));

    if (GeneratorIsRunning(this))
        ThrowTypeError(JSMSG_NESTING_GENERATOR);

    resumeGenerator(this, undefined, "close");
    if (!LegacyGeneratorObjectIsClosed(this))
        CloseClosingLegacyGeneratorObject(this);
}

function LegacyGeneratorClose() {
    if (!IsObject(this) || !IsLegacyGeneratorObject(this))
        return callFunction(CallLegacyGeneratorMethodIfWrapped, this, "LegacyGeneratorClose");

    if (LegacyGeneratorObjectIsClosed(this))
        return undefined;

    callFunction(LegacyGeneratorCloseInternal, this);
}

function InterpretGeneratorResume(gen, val, kind) {
    // If we want to resume a generator in the interpreter, the script containing
    // the resumeGenerator/JSOP_RESUME also has to run in the interpreter. The
+3 −9
Original line number Diff line number Diff line
@@ -228,7 +228,6 @@ GetPropertyDefault(JSContext* cx, HandleObject obj, HandleId id, HandleValue def
enum class GeneratorStyle
{
    None,
    Legacy,
    ES6
};

@@ -1613,14 +1612,11 @@ NodeBuilder::function(ASTType type, TokenPos* pos,
    }

    if (isGenerator) {
        // Distinguish ES6 generators from legacy generators.
        RootedValue styleVal(cx);
        JSAtom* styleStr = generatorStyle == GeneratorStyle::ES6
                           ? Atomize(cx, "es6", 3)
                           : Atomize(cx, "legacy", 6);
        MOZ_ASSERT(generatorStyle == GeneratorStyle::ES6);
        JSAtom* styleStr = Atomize(cx, "es6", 3);
        if (!styleStr)
            return false;
        styleVal.setString(styleStr);
        RootedValue styleVal(cx, StringValue(styleStr));
        return newNode(type, pos,
                       "id", id,
                       "params", array,
@@ -3433,8 +3429,6 @@ ASTSerializer::function(ParseNode* pn, ASTType type, MutableHandleValue dst)
    GeneratorStyle generatorStyle =
        pn->pn_funbox->isStarGenerator()
        ? GeneratorStyle::ES6
        : pn->pn_funbox->isLegacyGenerator()
        ? GeneratorStyle::Legacy
        : GeneratorStyle::None;

    bool isAsync = pn->pn_funbox->isAsync();
+0 −1
Original line number Diff line number Diff line
@@ -684,7 +684,6 @@ frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const cha
        return false;

    Rooted<JSFunction*> fun(cx, lazy->functionNonDelazifying());
    MOZ_ASSERT(!lazy->isLegacyGenerator());
    ParseNode* pn = parser.standaloneLazyFunction(fun, lazy->toStringStart(),
                                                  lazy->strict(), lazy->generatorKind(),
                                                  lazy->asyncKind());
+0 −2
Original line number Diff line number Diff line
@@ -401,7 +401,6 @@ class BytecodeEmitter::EmitterScope : public Nestable<BytecodeEmitter::EmitterSc
            bce->maxFixedSlots = nextFrameSlot_;
        MOZ_ASSERT_IF(bce->sc->isFunctionBox() &&
                      (bce->sc->asFunctionBox()->isStarGenerator() ||
                       bce->sc->asFunctionBox()->isLegacyGenerator() ||
                       bce->sc->asFunctionBox()->isAsync()),
                      bce->maxFixedSlots == 0);
    }
@@ -4834,7 +4833,6 @@ BytecodeEmitter::isRunOnceLambda()
    FunctionBox* funbox = sc->asFunctionBox();
    return !funbox->argumentsHasLocalBinding() &&
           !funbox->isStarGenerator() &&
           !funbox->isLegacyGenerator() &&
           !funbox->isAsync() &&
           !funbox->function()->explicitName();
}
Loading