Backed out changeset 0dca237df7e2 (bug 1160307) for causing bug 1184752.

This commit is contained in:
Ryan VanderMeulen 2015-07-16 20:38:13 -04:00
parent 9c9d6ad942
commit 84f80b7f6f
15 changed files with 21 additions and 196 deletions

View File

@ -13937,9 +13937,7 @@ public:
const char* aReason,
const char16_t* aFunctionName,
const char16_t* aFileName,
uint32_t aLineNumber,
JS::Handle<JS::Value> aAsyncStack,
JS::Handle<JS::Value> aAsyncCause)
uint32_t aLineNumber)
: TimelineMarker(aDocShell, aName, TRACING_INTERVAL_START,
NS_ConvertUTF8toUTF16(aReason),
NO_STACK)
@ -13947,11 +13945,6 @@ public:
, mFileName(aFileName)
, mLineNumber(aLineNumber)
{
JSContext* ctx = nsContentUtils::GetCurrentJSContext();
if (ctx) {
mAsyncStack.init(ctx, aAsyncStack);
mAsyncCause.init(ctx, aAsyncCause);
}
}
void AddDetails(JSContext* aCx, mozilla::dom::ProfileTimelineMarker& aMarker)
@ -13964,17 +13957,6 @@ public:
stackFrame.mLine.Construct(mLineNumber);
stackFrame.mSource.Construct(mFileName);
stackFrame.mFunctionDisplayName.Construct(mFunctionName);
if (mAsyncStack.isObject() && !mAsyncStack.isNullOrUndefined() &&
mAsyncCause.isString()) {
JS::Rooted<JSObject*> asyncStack(aCx, mAsyncStack.toObjectOrNull());
JS::Rooted<JSString*> asyncCause(aCx, mAsyncCause.toString());
JS::Rooted<JSObject*> parentFrame(aCx);
if (!JS::CopyAsyncStack(aCx, asyncStack, asyncCause, &parentFrame, 0)) {
JS_ClearPendingException(aCx);
} else {
stackFrame.mAsyncParent = parentFrame;
}
}
JS::Rooted<JS::Value> newStack(aCx);
if (ToJSValue(aCx, stackFrame, &newStack)) {
@ -13991,17 +13973,13 @@ private:
nsString mFunctionName;
nsString mFileName;
uint32_t mLineNumber;
JS::PersistentRooted<JS::Value> mAsyncStack;
JS::PersistentRooted<JS::Value> mAsyncCause;
};
void
nsDocShell::NotifyJSRunToCompletionStart(const char* aReason,
const char16_t* aFunctionName,
const char16_t* aFilename,
const uint32_t aLineNumber,
JS::Handle<JS::Value> aAsyncStack,
JS::Handle<JS::Value> aAsyncCause)
const uint32_t aLineNumber)
{
bool timelineOn = nsIDocShell::GetRecordProfileTimelineMarkers();
@ -14010,8 +13988,7 @@ nsDocShell::NotifyJSRunToCompletionStart(const char* aReason,
mozilla::UniquePtr<TimelineMarker> marker =
MakeUnique<JavascriptTimelineMarker>(this, "Javascript", aReason,
aFunctionName, aFilename,
aLineNumber, aAsyncStack,
aAsyncCause);
aLineNumber);
AddProfileTimelineMarker(Move(marker));
}
mJSRunToCompletionDepth++;

View File

@ -46,7 +46,7 @@ interface nsITabParent;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(9f2babc4-4c2a-4cf7-929f-a1efc325b0df)]
[scriptable, builtinclass, uuid(97471054-0BC8-4A57-BBFE-6C255BCBBB67)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@ -1034,9 +1034,7 @@ interface nsIDocShell : nsIDocShellTreeItem
[noscript,notxpcom,nostdcall] void notifyJSRunToCompletionStart(in string aReason,
in wstring functionName,
in wstring fileName,
in unsigned long lineNumber,
in jsval asyncStack,
in jsval asyncCause);
in unsigned long lineNumber);
[noscript,notxpcom,nostdcall] void notifyJSRunToCompletionStop();
/**

View File

@ -31,50 +31,4 @@ let TESTS = [{
}
}];
if (Services.prefs.getBoolPref("javascript.options.asyncstack")) {
TESTS.push({
desc: "Async stack trace on Javascript marker",
searchFor: (markers) => {
return markers.some(m => (m.name == "Javascript" &&
m.causeName == "promise callback"));
},
setup: function(docShell) {
content.dispatchEvent(new content.Event("promisetest"));
},
check: function(markers) {
markers = markers.filter(m => (m.name == "Javascript" &&
m.causeName == "promise callback"));
ok(markers.length > 0, "Found a Javascript marker");
let frame = markers[0].stack;
ok(frame.asyncParent !== null, "Parent frame has async parent");
is(frame.asyncParent.asyncCause, "Promise",
"Async parent has correct cause");
is(frame.asyncParent.functionDisplayName, "do_promise",
"Async parent has correct function name");
}
}, {
desc: "Async stack trace on Javascript marker with script",
searchFor: (markers) => {
return markers.some(m => (m.name == "Javascript" &&
m.causeName == "promise callback"));
},
setup: function(docShell) {
content.dispatchEvent(new content.Event("promisescript"));
},
check: function(markers) {
markers = markers.filter(m => (m.name == "Javascript" &&
m.causeName == "promise callback"));
ok(markers.length > 0, "Found a Javascript marker");
let frame = markers[0].stack;
ok(frame.asyncParent !== null, "Parent frame has async parent");
is(frame.asyncParent.asyncCause, "Promise",
"Async parent has correct cause");
is(frame.asyncParent.functionDisplayName, "do_promise_script",
"Async parent has correct function name");
}
});
}
timelineContentTest(TESTS);

View File

@ -21,33 +21,6 @@
}
window.addEventListener("dog", do_xhr, true);
function do_promise() {
new Promise(function(resolve, reject) {
console.time("Bob");
window.setTimeout(function() {
resolve(23);
}, 10);
}).then(function (val) {
console.timeEnd("Bob");
});
}
window.addEventListener("promisetest", do_promise, true);
var globalResolver;
function do_promise_script() {
new Promise(function(resolve, reject) {
console.time("Bob");
globalResolver = resolve;
window.setTimeout("globalResolver(23);", 10);
}).then(function (val) {
console.timeEnd("Bob");
});
}
window.addEventListener("promisescript", do_promise_script, true);
</script>
</body>

View File

@ -564,8 +564,7 @@ AutoEntryScript::DocshellEntryMonitor::DocshellEntryMonitor(JSContext* aCx,
void
AutoEntryScript::DocshellEntryMonitor::Entry(JSContext* aCx, JSFunction* aFunction,
JSScript* aScript, JS::Handle<JS::Value> aAsyncStack,
JS::Handle<JSString*> aAsyncCause)
JSScript* aScript)
{
JS::Rooted<JSFunction*> rootedFunction(aCx);
if (aFunction) {
@ -610,13 +609,10 @@ AutoEntryScript::DocshellEntryMonitor::Entry(JSContext* aCx, JSFunction* aFuncti
const char16_t* functionNameChars = functionName.isTwoByte() ?
functionName.twoByteChars() : nullptr;
JS::Rooted<JS::Value> asyncCauseValue(aCx, aAsyncCause ? StringValue(aAsyncCause) :
JS::NullValue());
docShellForJSRunToCompletion->NotifyJSRunToCompletionStart(mReason,
functionNameChars,
filename.BeginReading(),
lineNumber, aAsyncStack,
asyncCauseValue);
lineNumber);
}
}

View File

@ -349,26 +349,20 @@ private:
public:
DocshellEntryMonitor(JSContext* aCx, const char* aReason);
void Entry(JSContext* aCx, JSFunction* aFunction,
JS::Handle<JS::Value> aAsyncStack,
JS::Handle<JSString*> aAsyncCause) override
void Entry(JSContext* aCx, JSFunction* aFunction) override
{
Entry(aCx, aFunction, nullptr, aAsyncStack, aAsyncCause);
Entry(aCx, aFunction, nullptr);
}
void Entry(JSContext* aCx, JSScript* aScript,
JS::Handle<JS::Value> aAsyncStack,
JS::Handle<JSString*> aAsyncCause) override
void Entry(JSContext* aCx, JSScript* aScript) override
{
Entry(aCx, nullptr, aScript, aAsyncStack, aAsyncCause);
Entry(aCx, nullptr, aScript);
}
void Exit(JSContext* aCx) override;
private:
void Entry(JSContext* aCx, JSFunction* aFunction, JSScript* aScript,
JS::Handle<JS::Value> aAsyncStack,
JS::Handle<JSString*> aAsyncCause);
void Entry(JSContext* aCx, JSFunction* aFunction, JSScript* aScript);
const char* mReason;
};

View File

@ -15,7 +15,7 @@ dictionary ProfileTimelineStackFrame {
DOMString functionDisplayName;
object? parent = null;
object? asyncParent = null;
DOMString asyncCause;
object? asyncCause = null;
};
dictionary ProfileTimelineLayerRect {

View File

@ -359,16 +359,12 @@ class MOZ_STACK_CLASS AutoEntryMonitor {
// We have begun executing |function|. Note that |function| may not be the
// actual closure we are running, but only the canonical function object to
// which the script refers.
virtual void Entry(JSContext* cx, JSFunction* function,
HandleValue asyncStack,
HandleString asyncCause) = 0;
virtual void Entry(JSContext* cx, JSFunction* function) = 0;
// Execution has begun at the entry point of |script|, which is not a
// function body. (This is probably being executed by 'eval' or some
// JSAPI equivalent.)
virtual void Entry(JSContext* cx, JSScript* script,
HandleValue asyncStack,
HandleString asyncCause) = 0;
virtual void Entry(JSContext* cx, JSScript* script) = 0;
// Execution of the function or script has ended.
virtual void Exit(JSContext* cx) { }

View File

@ -93,7 +93,6 @@
#include "vm/Interpreter-inl.h"
#include "vm/NativeObject-inl.h"
#include "vm/SavedStacks-inl.h"
#include "vm/String-inl.h"
using namespace js;
@ -6237,22 +6236,6 @@ JS::CaptureCurrentStack(JSContext* cx, JS::MutableHandleObject stackp, unsigned
return true;
}
JS_PUBLIC_API(bool)
JS::CopyAsyncStack(JSContext* cx, JS::HandleObject asyncStack,
JS::HandleString asyncCause, JS::MutableHandleObject stackp,
unsigned maxFrameCount)
{
js::AssertObjectIsSavedFrameOrWrapper(cx, asyncStack);
JSCompartment* compartment = cx->compartment();
MOZ_ASSERT(compartment);
Rooted<SavedFrame*> frame(cx);
if (!compartment->savedStacks().copyAsyncStack(cx, asyncStack, asyncCause,
&frame, maxFrameCount))
return false;
stackp.set(frame.get());
return true;
}
JS_PUBLIC_API(Zone*)
JS::GetObjectZone(JSObject* obj)
{

View File

@ -5316,25 +5316,6 @@ SetOutOfMemoryCallback(JSRuntime* rt, OutOfMemoryCallback cb, void* data);
extern JS_PUBLIC_API(bool)
CaptureCurrentStack(JSContext* cx, MutableHandleObject stackp, unsigned maxFrameCount = 0);
/*
* This is a utility function for preparing an async stack to be used
* by some other object. This may be used when you need to treat a
* given stack trace as an async parent. If you just need to capture
* the current stack, async parents and all, use CaptureCurrentStack
* instead.
*
* Here |asyncStack| is the async stack to prepare. It is copied into
* |cx|'s current compartment, and the newest frame is given
* |asyncCause| as its asynchronous cause. If |maxFrameCount| is
* non-zero, capture at most the youngest |maxFrameCount| frames. The
* new stack object is written to |stackp|. Returns true on success,
* or sets an exception and returns |false| on error.
*/
extern JS_PUBLIC_API(bool)
CopyAsyncStack(JSContext* cx, HandleObject asyncStack,
HandleString asyncCause, MutableHandleObject stackp,
unsigned maxFrameCount);
/*
* Accessors for working with SavedFrame JSObjects
*

View File

@ -4379,8 +4379,7 @@ class ShellAutoEntryMonitor : JS::dbg::AutoEntryMonitor {
MOZ_ASSERT(!enteredWithoutExit);
}
void Entry(JSContext* cx, JSFunction* function, JS::HandleValue asyncStack,
JS::HandleString asyncCause) override {
void Entry(JSContext* cx, JSFunction* function) override {
MOZ_ASSERT(!enteredWithoutExit);
enteredWithoutExit = true;
@ -4394,8 +4393,7 @@ class ShellAutoEntryMonitor : JS::dbg::AutoEntryMonitor {
oom = !log.append(make_string_copy("anonymous"));
}
void Entry(JSContext* cx, JSScript* script, JS::HandleValue asyncStack,
JS::HandleString asyncCause) override {
void Entry(JSContext* cx, JSScript* script) override {
MOZ_ASSERT(!enteredWithoutExit);
enteredWithoutExit = true;

View File

@ -823,21 +823,6 @@ SavedStacks::saveCurrentStack(JSContext* cx, MutableHandleSavedFrame frame, unsi
return insertFrames(cx, iter, frame, maxFrameCount);
}
bool
SavedStacks::copyAsyncStack(JSContext* cx, HandleObject asyncStack, HandleString asyncCause,
MutableHandleSavedFrame adoptedStack, unsigned maxFrameCount)
{
MOZ_ASSERT(initialized());
assertSameCompartment(cx, this);
RootedObject asyncStackObj(cx, CheckedUnwrap(asyncStack));
MOZ_ASSERT(asyncStackObj);
MOZ_ASSERT(js::SavedFrame::isSavedFrameAndNotProto(*asyncStackObj));
RootedSavedFrame frame(cx, &asyncStackObj->as<js::SavedFrame>());
return adoptAsyncStack(cx, frame, asyncCause, adoptedStack, maxFrameCount);
}
void
SavedStacks::sweep(JSRuntime* rt)
{

View File

@ -274,8 +274,6 @@ class SavedStacks {
bool init();
bool initialized() const { return frames.initialized(); }
bool saveCurrentStack(JSContext* cx, MutableHandleSavedFrame frame, unsigned maxFrameCount = 0);
bool copyAsyncStack(JSContext* cx, HandleObject asyncStack, HandleString asyncCause,
MutableHandleSavedFrame adoptedStack, unsigned maxFrameCount = 0);
void sweep(JSRuntime* rt);
void trace(JSTracer* trc);
uint32_t count();

View File

@ -923,14 +923,10 @@ InterpreterActivation::InterpreterActivation(RunState& state, JSContext* cx,
MOZ_ASSERT_IF(entryFrame_->isEvalFrame(), state.script()->isActiveEval());
if (entryMonitor_) {
RootedValue stack(cx_);
stack.setObjectOrNull(asyncStack_.get());
if (!cx_->compartment()->wrap(cx_, &stack))
stack.setUndefined();
if (entryFrame->isFunctionFrame())
entryMonitor_->Entry(cx_, entryFrame->fun(), stack, asyncCause_);
entryMonitor_->Entry(cx_, entryFrame->fun());
else
entryMonitor_->Entry(cx_, entryFrame->script(), stack, asyncCause_);
entryMonitor_->Entry(cx_, entryFrame->script());
}
}

View File

@ -1404,14 +1404,10 @@ jit::JitActivation::JitActivation(JSContext* cx, CalleeToken entryPoint, bool ac
if (entryMonitor_) {
MOZ_ASSERT(entryPoint);
RootedValue stack(cx_);
stack.setObjectOrNull(asyncStack_.get());
if (!cx_->compartment()->wrap(cx_, &stack))
stack.setUndefined();
if (CalleeTokenIsFunction(entryPoint))
entryMonitor_->Entry(cx_, CalleeTokenToFunction(entryPoint), stack, asyncCause_);
entryMonitor_->Entry(cx_, CalleeTokenToFunction(entryPoint));
else
entryMonitor_->Entry(cx_, CalleeTokenToScript(entryPoint), stack, asyncCause_);
entryMonitor_->Entry(cx_, CalleeTokenToScript(entryPoint));
}
}