Skip to content

Instantly share code, notes, and snippets.

@syg
Created October 7, 2014 22:03
Show Gist options
  • Save syg/5de0db4466314059f7fb to your computer and use it in GitHub Desktop.
Save syg/5de0db4466314059f7fb to your computer and use it in GitHub Desktop.
commit 4f2d29eaa915925d91b022fe6774047ef2259345
Author: Shu-yu Guo <[email protected]>
Date: Tue Oct 7 14:25:57 2014 -0700
synthesizables
diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
index c6126fe..a615aaa 100644
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -873,7 +873,7 @@ PopScope(JSContext *cx, ScopeIter &si)
si.initialFrame().popWith(cx);
break;
case ScopeIter::Call:
- case ScopeIter::StrictEval:
+ case ScopeIter::Eval:
break;
}
}
diff --git a/js/src/vm/ScopeObject.cpp b/js/src/vm/ScopeObject.cpp
index 215e664..a229cc4 100644
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -1201,12 +1201,6 @@ ScopeIter::settle()
if (frame_ && (ssi_.done() || maybeStaticScope() == frame_.script()->enclosingStaticScope()))
frame_ = NullFramePtr();
- // Don't settle on non-strict eval scopes, as there is no dynamic
- // counterpart to synthesize, and the static scope is a fiction inside
- // StaticScopeIter for iteration purposes.
- while (!ssi_.done() && ssi_.type() == StaticScopeIter<CanGC>::Eval && !ssi_.eval().isStrict())
- ssi_++;
-
#ifdef DEBUG
if (!ssi_.done() && hasScopeObject()) {
switch (ssi_.type()) {
@@ -1257,8 +1251,7 @@ ScopeIter::type() const
case StaticScopeIter<CanGC>::With:
return With;
case StaticScopeIter<CanGC>::Eval:
- MOZ_ASSERT(ssi_.eval().isStrict());
- return StrictEval;
+ return Eval;
case StaticScopeIter<CanGC>::NamedLambda:
MOZ_CRASH("named lambda static scopes should have been skipped");
}
@@ -2502,7 +2495,7 @@ GetDebugScopeForMissing(JSContext *cx, const ScopeIter &si)
break;
}
case ScopeIter::With:
- case ScopeIter::StrictEval:
+ case ScopeIter::Eval:
MOZ_CRASH("should already have a scope");
}
if (!debugScope)
@@ -2535,10 +2528,14 @@ GetDebugScope(JSContext *cx, const ScopeIter &si)
if (si.done())
return GetDebugScopeForNonScopeObject(si);
- if (!si.hasScopeObject())
+ if (si.hasScopeObject())
+ return GetDebugScopeForScope(cx, si);
+
+ if (si.canHaveScopeObject())
return GetDebugScopeForMissing(cx, si);
- return GetDebugScopeForScope(cx, si);
+ ScopeIter copy(cx, si);
+ return GetDebugScope(cx, ++copy);
}
JSObject *
diff --git a/js/src/vm/ScopeObject.h b/js/src/vm/ScopeObject.h
index 7d14e33..2fe5be5 100644
--- a/js/src/vm/ScopeObject.h
+++ b/js/src/vm/ScopeObject.h
@@ -718,10 +718,11 @@ class ScopeIter
inline JSObject &enclosingScope() const;
// If !done():
- enum Type { Call, Block, With, StrictEval };
+ enum Type { Call, Block, With, Eval };
Type type() const;
inline bool hasScopeObject() const;
+ inline bool canHaveScopeObject() const;
ScopeObject &scope() const;
JSObject *maybeStaticScope() const;
@@ -1022,6 +1023,14 @@ ScopeIter::hasScopeObject() const
return ssi_.hasDynamicScopeObject();
}
+inline bool
+ScopeIter::canHaveScopeObject() const
+{
+ // Non-strict eval scopes cannot have dynamic scope objects and thus are
+ // not synthesizable.
+ return !ssi_.done() && (type() != Eval || staticEval().isStrict());
+}
+
inline JSObject &
ScopeIter::enclosingScope() const
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment