Backed out changeset 1437c48ae58d (bug 1030945) for introducing a new hazard, CLOSED TREE

This commit is contained in:
Wes Kocher 2014-06-27 15:52:38 -07:00
parent 5e6d3185c6
commit bcf16ff0d1
3 changed files with 22 additions and 71 deletions

View File

@ -1,40 +0,0 @@
function AsmModule(stdlib, foreign, heap) {
"use asm";
var ffi = foreign.t;
function doTest() {
ffi();
}
function test() {
doTest();
}
return { test: test };
}
let stack;
function tester() {
stack = saveStack();
}
const buf = ArrayBuffer(1024*8);
const module = AsmModule(this, { t: tester }, buf);
module.test();
print(stack);
assertEq(stack.functionDisplayName, "tester");
assertEq(stack.parent.functionDisplayName, "doTest");
assertEq(stack.parent.line, 6);
assertEq(stack.parent.column, 4);
assertEq(stack.parent.parent.functionDisplayName, "test");
assertEq(stack.parent.parent.line, 10);
assertEq(stack.parent.parent.column, 4);
assertEq(stack.parent.parent.parent.line, 24);
assertEq(stack.parent.parent.parent.column, 0);
assertEq(stack.parent.parent.parent.parent, null);

View File

@ -393,14 +393,17 @@ SavedStacks::init()
return frames.init();
}
bool
SavedStacks::saveCurrentStack(JSContext *cx, MutableHandleSavedFrame frame)
{
JS_ASSERT(initialized());
JS_ASSERT(&cx->compartment()->savedStacks() == this);
FrameIter iter(cx);
ScriptFrameIter iter(cx);
return insertFrames(cx, iter, frame);
}
void
SavedStacks::sweep(JSRuntime *rt)
{
@ -459,7 +462,7 @@ SavedStacks::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
}
bool
SavedStacks::insertFrames(JSContext *cx, FrameIter &iter, MutableHandleSavedFrame frame)
SavedStacks::insertFrames(JSContext *cx, ScriptFrameIter &iter, MutableHandleSavedFrame frame)
{
if (iter.done()) {
frame.set(nullptr);
@ -474,43 +477,26 @@ SavedStacks::insertFrames(JSContext *cx, FrameIter &iter, MutableHandleSavedFram
// in js/src/jit-test/tests/saved-stacks/bug-1006876-too-much-recursion.js).
JS_CHECK_RECURSION_DONT_REPORT(cx, return false);
JSPrincipals* principals = iter.compartment()->principals;
RootedAtom name(cx, iter.isNonEvalFunctionFrame() ? iter.functionDisplayAtom() : nullptr);
// When we have a |JSScript| for this frame, use |getLocation| to get a
// potentially memoized location result and copy it into |location|. When we
// do not have a |JSScript| for this frame (asm.js frames), we take a slow
// path that doesn't employ memoization, and update |location|'s slots
// directly.
LocationValue location;+ if (iter.hasScript()) {
JSScript *script = iter.script();
RootedScript script(cx, iter.script());
jsbytecode *pc = iter.pc();
if (!getLocation(cx, script, pc, &location))
return false;
} else {
const char *filename = iter.scriptFilename();
if (!filename)
filename = "";
location.source.set(Atomize(cx, filename, strlen(filename)));
if (!location.source)
return false;
uint32_t column;
location.line = iter.computeLine(&column);
location.column = column;
}
RootedFunction callee(cx, iter.maybeCallee());
// script and callee should keep compartment alive.
JSCompartment *compartment = iter.compartment();
RootedSavedFrame parentFrame(cx);
if (!insertFrames(cx, ++iter, &parentFrame))
return false;
LocationValue location;
if (!getLocation(cx, script, pc, &location))
return false;
SavedFrame::AutoLookupRooter lookup(cx,
location.source,
location.line,
location.column,
name,
callee ? callee->displayAtom() : nullptr,
parentFrame,
principals);
compartment->principals);
frame.set(getOrCreateSavedFrame(cx, lookup));
return frame.get() != nullptr;

View File

@ -108,17 +108,22 @@ class SavedStacks {
void sweep(JSRuntime *rt);
uint32_t count();
void clear();
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
private:
SavedFrame::Set frames;
JSObject *savedFrameProto;
bool insertFrames(JSContext *cx, FrameIter &iter, MutableHandleSavedFrame frame);
bool insertFrames(JSContext *cx, ScriptFrameIter &iter, MutableHandleSavedFrame frame);
SavedFrame *getOrCreateSavedFrame(JSContext *cx, const SavedFrame::Lookup &lookup);
// |SavedFrame.prototype| is created lazily and held weakly. It should only
// be accessed through this method.
JSObject *getOrCreateSavedFramePrototype(JSContext *cx);
SavedFrame *createFrameFromLookup(JSContext *cx, const SavedFrame::Lookup &lookup);
// Cache for memoizing PCToLineNumber lookups.
struct PCKey {
PCKey(JSScript *script, jsbytecode *pc) : script(script), pc(pc) { }