Revert "Bug 1161332 - Don't save the JSContext when saving FrameIter::Data. (r=jimb)"

This reverts commit 0e314030329b4d3291127ee211a1484ebfb8c7c9.
This commit is contained in:
Shu-yu Guo 2015-09-03 16:55:05 -07:00
parent 7670e8c54f
commit 185faceac4
4 changed files with 12 additions and 34 deletions

View File

@ -1,16 +0,0 @@
// |jit-test| error: Error
var g = newGlobal();
g.eval('function f(a) { if (a == 1) debugger; evaluate("f(" + a + " - 1);", {newContext: true}); }');
var N = 9;
var dbg = new Debugger(g);
var frames = [];
dbg.onEnterFrame = function (frame) {
frames.push(frame);
frame.onPop = function () { assertEq(frame.onPop, frame.onPop); };
};
dbg.onDebuggerStatement = function (frame) {
for (var f of frames)
f.eval('a').return;
};
evaluate("g.f(N);");

View File

@ -5909,7 +5909,7 @@ CheckThisFrame(JSContext* cx, const CallArgs& args, const char* fnname, bool che
THIS_FRAME_THISOBJ(cx, argc, vp, fnname, args, thisobj); \
AbstractFramePtr frame = AbstractFramePtr::FromRaw(thisobj->getPrivate()); \
if (frame.isScriptFrameIterData()) { \
ScriptFrameIter iter(cx, *(ScriptFrameIter::Data*)(frame.raw())); \
ScriptFrameIter iter(*(ScriptFrameIter::Data*)(frame.raw())); \
frame = iter.abstractFramePtr(); \
}
@ -5919,7 +5919,7 @@ CheckThisFrame(JSContext* cx, const CallArgs& args, const char* fnname, bool che
{ \
AbstractFramePtr f = AbstractFramePtr::FromRaw(thisobj->getPrivate()); \
if (f.isScriptFrameIterData()) { \
maybeIter.emplace(cx, *(ScriptFrameIter::Data*)(f.raw())); \
maybeIter.emplace(*(ScriptFrameIter::Data*)(f.raw())); \
} else { \
maybeIter.emplace(cx, ScriptFrameIter::ALL_CONTEXTS, \
ScriptFrameIter::GO_THROUGH_SAVED, \

View File

@ -595,7 +595,7 @@ FrameIter::Data::Data(JSContext* cx, SavedOption savedOption,
}
FrameIter::Data::Data(const FrameIter::Data& other)
: cx_(nullptr),
: cx_(other.cx_),
savedOption_(other.savedOption_),
contextOption_(other.contextOption_),
debuggerEvalOption_(other.debuggerEvalOption_),
@ -645,12 +645,11 @@ FrameIter::FrameIter(const FrameIter& other)
{
}
FrameIter::FrameIter(JSContext* cx, const Data& data)
FrameIter::FrameIter(const Data& data)
: data_(data),
ionInlineFrames_(cx, data_.jitFrames_.isIonScripted() ? &data_.jitFrames_ : nullptr)
ionInlineFrames_(data.cx_, data_.jitFrames_.isIonScripted() ? &data_.jitFrames_ : nullptr)
{
MOZ_ASSERT(!data.cx_);
data_.cx_ = cx;
MOZ_ASSERT(data.cx_);
if (data_.jitFrames_.isIonScripted()) {
while (ionInlineFrames_.frameNo() != data.ionInlineFrameNo_)

View File

@ -1906,7 +1906,7 @@ class FrameIter
DebuggerEvalOption = FOLLOW_DEBUGGER_EVAL_PREV_LINK);
FrameIter(JSContext* cx, ContextOption, SavedOption, DebuggerEvalOption, JSPrincipals*);
FrameIter(const FrameIter& iter);
FrameIter(JSContext* cx, const Data& data);
MOZ_IMPLICIT FrameIter(const Data& data);
MOZ_IMPLICIT FrameIter(AbstractFramePtr frame);
bool done() const { return data_.state_ == DONE; }
@ -2018,11 +2018,6 @@ class FrameIter
// -----------------------------------------------------------
AbstractFramePtr abstractFramePtr() const;
// N.B. Copying the internal data nulls out the saved cx_, as the
// JSContext's lifetime is not tied to the Data lifetime. When
// re-instantiating a new FrameIter with a saved data, a new cx must be
// provided.
AbstractFramePtr copyDataAsAbstractFramePtr() const;
Data* copyData() const;
@ -2078,7 +2073,7 @@ class ScriptFrameIter : public FrameIter
}
ScriptFrameIter(const ScriptFrameIter& iter) : FrameIter(iter) { settle(); }
ScriptFrameIter(JSContext* cx, const FrameIter::Data& data) : FrameIter(cx, data) { settle(); }
explicit ScriptFrameIter(const FrameIter::Data& data) : FrameIter(data) { settle(); }
explicit ScriptFrameIter(AbstractFramePtr frame) : FrameIter(frame) { settle(); }
ScriptFrameIter& operator++() {
@ -2138,8 +2133,8 @@ class NonBuiltinFrameIter : public FrameIter
settle();
}
explicit NonBuiltinFrameIter(JSContext* cx, const FrameIter::Data& data)
: FrameIter(cx, data)
explicit NonBuiltinFrameIter(const FrameIter::Data& data)
: FrameIter(data)
{}
NonBuiltinFrameIter& operator++() {
@ -2183,8 +2178,8 @@ class NonBuiltinScriptFrameIter : public ScriptFrameIter
settle();
}
explicit NonBuiltinScriptFrameIter(JSContext* cx, const ScriptFrameIter::Data& data)
: ScriptFrameIter(cx, data)
explicit NonBuiltinScriptFrameIter(const ScriptFrameIter::Data& data)
: ScriptFrameIter(data)
{}
NonBuiltinScriptFrameIter& operator++() {