Skip to content

Commit

Permalink
Bug 1412202 - Part 5: Update DebugEnvironments for generator frames. …
Browse files Browse the repository at this point in the history
…r=jandem

No effect yet, since there are no stack locals to copy. Without this change,
storing generator locals in the stack would cause several debugger tests to
fail.

Differential Revision: https://phabricator.services.mozilla.com/D93387
  • Loading branch information
jorendorff committed Oct 15, 2020
1 parent 250ff7f commit ecd6a30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
22 changes: 4 additions & 18 deletions js/src/vm/EnvironmentObject.cpp
Expand Up @@ -2457,7 +2457,10 @@ ArrayObject* DebugEnvironmentProxy::maybeSnapshot() const {
}

void DebugEnvironmentProxy::initSnapshot(ArrayObject& o) {
MOZ_ASSERT(maybeSnapshot() == nullptr);
MOZ_ASSERT_IF(
maybeSnapshot() != nullptr,
environment().is<CallObject>() &&
environment().as<CallObject>().callee().isGeneratorOrAsync());
setReservedSlot(SNAPSHOT_SLOT, ObjectValue(o));
}

Expand Down Expand Up @@ -2665,11 +2668,6 @@ bool DebugEnvironments::addDebugEnvironment(
Handle<DebugEnvironmentProxy*> debugEnv) {
MOZ_ASSERT(!ei.hasSyntacticEnvironment());
MOZ_ASSERT(cx->realm() == debugEnv->nonCCWRealm());
// Generators should always have environments.
MOZ_ASSERT_IF(
ei.scope().is<FunctionScope>(),
!ei.scope().as<FunctionScope>().canonicalFunction()->isGenerator() &&
!ei.scope().as<FunctionScope>().canonicalFunction()->isAsync());

if (!CanUseDebugEnvironmentMaps(cx)) {
return true;
Expand Down Expand Up @@ -2835,10 +2833,6 @@ void DebugEnvironments::onPopCall(JSContext* cx, AbstractFramePtr frame) {
return;
}

if (frame.callee()->isGenerator() || frame.callee()->isAsync()) {
return;
}

CallObject& callobj = frame.environmentChain()->as<CallObject>();
envs->liveEnvs.remove(&callobj);
if (JSObject* obj = envs->proxiedEnvs.lookup(&callobj)) {
Expand Down Expand Up @@ -2960,12 +2954,6 @@ bool DebugEnvironments::updateLiveEnvironments(JSContext* cx) {
continue;
}

if (frame.isFunctionFrame()) {
if (frame.callee()->isGenerator() || frame.callee()->isAsync()) {
continue;
}
}

if (!frame.isDebuggee()) {
continue;
}
Expand Down Expand Up @@ -3143,8 +3131,6 @@ static DebugEnvironmentProxy* GetDebugEnvironmentForMissing(
if (ei.scope().is<FunctionScope>()) {
RootedFunction callee(cx,
ei.scope().as<FunctionScope>().canonicalFunction());
// Generators should always reify their scopes.
MOZ_ASSERT(!callee->isGenerator() && !callee->isAsync());

JS::ExposeObjectToActiveJS(callee);
Rooted<CallObject*> callobj(cx,
Expand Down
4 changes: 4 additions & 0 deletions js/src/vm/JSFunction.h
Expand Up @@ -514,6 +514,10 @@ class JSFunction : public js::NativeObject {
return asyncKind() == js::FunctionAsyncKind::AsyncFunction;
}

bool isGeneratorOrAsync() const {
return isGenerator() || isAsync();
}

void initScript(js::BaseScript* script) {
MOZ_ASSERT_IF(script, realm() == script->realm());
MOZ_ASSERT(isInterpreted());
Expand Down

0 comments on commit ecd6a30

Please sign in to comment.