Backed out 4 changesets (bug 935809) for build bustage. a=backout

CLOSED TREE

Backed out changeset 8a48682a5150 (bug 935809)
Backed out changeset 8260fdc2c008 (bug 935809)
Backed out changeset f53c07293e1f (bug 935809)
Backed out changeset 4176ccbd4970 (bug 935809)

--HG--
extra : amend_source : cb83d78b0bed2e4b41dc5937a2b01008aa8a84bb
This commit is contained in:
Iris Hsiao 2017-04-27 10:13:45 +08:00
parent d5698ea13d
commit 15d2d6ea30
7 changed files with 192 additions and 108 deletions

107
js/src/jsclist.h Normal file
View File

@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef jsclist_h
#define jsclist_h
#include "jstypes.h"
/*
** Circular linked list
*/
typedef struct JSCListStr {
struct JSCListStr* next;
struct JSCListStr* prev;
} JSCList;
/*
** Insert element "_e" into the list, before "_l".
*/
#define JS_INSERT_BEFORE(_e,_l) \
JS_BEGIN_MACRO \
(_e)->next = (_l); \
(_e)->prev = (_l)->prev; \
(_l)->prev->next = (_e); \
(_l)->prev = (_e); \
JS_END_MACRO
/*
** Insert element "_e" into the list, after "_l".
*/
#define JS_INSERT_AFTER(_e,_l) \
JS_BEGIN_MACRO \
(_e)->next = (_l)->next; \
(_e)->prev = (_l); \
(_l)->next->prev = (_e); \
(_l)->next = (_e); \
JS_END_MACRO
/*
** Return the element following element "_e"
*/
#define JS_NEXT_LINK(_e) \
((_e)->next)
/*
** Return the element preceding element "_e"
*/
#define JS_PREV_LINK(_e) \
((_e)->prev)
/*
** Append an element "_e" to the end of the list "_l"
*/
#define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l)
/*
** Insert an element "_e" at the head of the list "_l"
*/
#define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l)
/* Return the head/tail of the list */
#define JS_LIST_HEAD(_l) (_l)->next
#define JS_LIST_TAIL(_l) (_l)->prev
/*
** Remove the element "_e" from it's circular list.
*/
#define JS_REMOVE_LINK(_e) \
JS_BEGIN_MACRO \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
JS_END_MACRO
/*
** Remove the element "_e" from it's circular list. Also initializes the
** linkage.
*/
#define JS_REMOVE_AND_INIT_LINK(_e) \
JS_BEGIN_MACRO \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
(_e)->next = (_e); \
(_e)->prev = (_e); \
JS_END_MACRO
/*
** Return non-zero if the given circular list "_l" is empty, zero if the
** circular list is not empty
*/
#define JS_CLIST_IS_EMPTY(_l) \
bool((_l)->next == (_l))
/*
** Initialize a circular list
*/
#define JS_INIT_CLIST(_l) \
JS_BEGIN_MACRO \
(_l)->next = (_l); \
(_l)->prev = (_l); \
JS_END_MACRO
#define JS_INIT_STATIC_CLIST(_l) \
{(_l), (_l)}
#endif /* jsclist_h */

View File

@ -81,6 +81,7 @@ EXPORTS += [
'jsalloc.h',
'jsapi.h',
'jsbytecode.h',
'jsclist.h',
'jscpucfg.h',
'jsfriendapi.h',
'jsprf.h',

View File

@ -524,6 +524,7 @@ RequireGlobalObject(JSContext* cx, HandleValue dbgobj, HandleObject referent)
BreakpointSite::BreakpointSite(Type type)
: type_(type), enabledCount(0)
{
JS_INIT_CLIST(&breakpoints);
}
void
@ -546,22 +547,21 @@ BreakpointSite::dec(FreeOp* fop)
bool
BreakpointSite::isEmpty() const
{
return breakpoints.isEmpty();
return JS_CLIST_IS_EMPTY(&breakpoints);
}
Breakpoint*
BreakpointSite::firstBreakpoint() const
{
if (isEmpty())
if (JS_CLIST_IS_EMPTY(&breakpoints))
return nullptr;
return &(*breakpoints.begin());
return Breakpoint::fromSiteLinks(JS_NEXT_LINK(&breakpoints));
}
bool
BreakpointSite::hasBreakpoint(Breakpoint* toFind)
BreakpointSite::hasBreakpoint(Breakpoint* bp)
{
const BreakpointList::Iterator bp(toFind);
for (auto p = breakpoints.begin(); p; p++)
for (Breakpoint* p = firstBreakpoint(); p; p = p->nextInSite())
if (p == bp)
return true;
return false;
@ -571,8 +571,20 @@ Breakpoint::Breakpoint(Debugger* debugger, BreakpointSite* site, JSObject* handl
: debugger(debugger), site(site), handler(handler)
{
MOZ_ASSERT(handler->compartment() == debugger->object->compartment());
debugger->breakpoints.pushBack(this);
site->breakpoints.pushBack(this);
JS_APPEND_LINK(&debuggerLinks, &debugger->breakpoints);
JS_APPEND_LINK(&siteLinks, &site->breakpoints);
}
Breakpoint*
Breakpoint::fromDebuggerLinks(JSCList* links)
{
return (Breakpoint*) ((unsigned char*) links - offsetof(Breakpoint, debuggerLinks));
}
Breakpoint*
Breakpoint::fromSiteLinks(JSCList* links)
{
return (Breakpoint*) ((unsigned char*) links - offsetof(Breakpoint, siteLinks));
}
void
@ -580,8 +592,8 @@ Breakpoint::destroy(FreeOp* fop)
{
if (debugger->enabled)
site->dec(fop);
debugger->breakpoints.remove(this);
site->breakpoints.remove(this);
JS_REMOVE_LINK(&debuggerLinks);
JS_REMOVE_LINK(&siteLinks);
site->destroyIfEmpty(fop);
fop->delete_(this);
}
@ -589,13 +601,15 @@ Breakpoint::destroy(FreeOp* fop)
Breakpoint*
Breakpoint::nextInDebugger()
{
return debuggerLink.mNext;
JSCList* link = JS_NEXT_LINK(&debuggerLinks);
return (link == &debugger->breakpoints) ? nullptr : fromDebuggerLinks(link);
}
Breakpoint*
Breakpoint::nextInSite()
{
return siteLink.mNext;
JSCList* link = JS_NEXT_LINK(&siteLinks);
return (link == &site->breakpoints) ? nullptr : fromSiteLinks(link);
}
JSBreakpointSite::JSBreakpointSite(JSScript* script, jsbytecode* pc)
@ -670,6 +684,9 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg)
{
assertSameCompartment(cx, dbg);
JS_INIT_CLIST(&breakpoints);
JS_INIT_CLIST(&onNewGlobalObjectWatchersLink);
#ifdef JS_TRACE_LOGGING
TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
if (logger) {
@ -688,14 +705,15 @@ Debugger::~Debugger()
allocationsLog.clear();
/*
* Since the inactive state for this link is a singleton cycle, it's always
* safe to apply JS_REMOVE_LINK to it, regardless of whether we're in the list or not.
*
* We don't have to worry about locking here since Debugger is not
* background finalized.
*/
JSContext* cx = TlsContext.get();
if (onNewGlobalObjectWatchersLink.mPrev ||
onNewGlobalObjectWatchersLink.mNext)
cx->runtime()->onNewGlobalObjectWatchers().remove(this);
JS_REMOVE_LINK(&onNewGlobalObjectWatchersLink);
JSContext* cx = TlsContext.get();
cx->runtime()->endSingleThreadedExecution(cx);
}
@ -2160,7 +2178,7 @@ Debugger::fireNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global, Mutab
void
Debugger::slowPathOnNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global)
{
MOZ_ASSERT(!cx->runtime()->onNewGlobalObjectWatchers().isEmpty());
MOZ_ASSERT(!JS_CLIST_IS_EMPTY(&cx->runtime()->onNewGlobalObjectWatchers()));
if (global->compartment()->creationOptions().invisibleToDebugger())
return;
@ -2170,9 +2188,13 @@ Debugger::slowPathOnNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global)
* can be mutated while we're walking it.
*/
AutoObjectVector watchers(cx);
for (auto& dbg : cx->runtime()->onNewGlobalObjectWatchers()) {
MOZ_ASSERT(dbg.observesNewGlobalObject());
JSObject* obj = dbg.object;
for (JSCList* link = JS_LIST_HEAD(&cx->runtime()->onNewGlobalObjectWatchers());
link != &cx->runtime()->onNewGlobalObjectWatchers();
link = JS_NEXT_LINK(link))
{
Debugger* dbg = fromOnNewGlobalObjectWatchersLink(link);
MOZ_ASSERT(dbg->observesNewGlobalObject());
JSObject* obj = dbg->object;
JS::ExposeObjectToActiveJS(obj);
if (!watchers.append(obj)) {
if (cx->isExceptionPending())
@ -3349,9 +3371,14 @@ Debugger::setEnabled(JSContext* cx, unsigned argc, Value* vp)
*/
if (dbg->getHook(OnNewGlobalObject)) {
if (!wasEnabled) {
cx->runtime()->onNewGlobalObjectWatchers().pushBack(dbg);
/* If we were not enabled, the link should be a singleton list. */
MOZ_ASSERT(JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
JS_APPEND_LINK(&dbg->onNewGlobalObjectWatchersLink,
&cx->runtime()->onNewGlobalObjectWatchers());
} else {
cx->runtime()->onNewGlobalObjectWatchers().remove(dbg);
/* If we were enabled, the link should be inserted in the list. */
MOZ_ASSERT(!JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
JS_REMOVE_AND_INIT_LINK(&dbg->onNewGlobalObjectWatchersLink);
}
}
@ -3511,9 +3538,14 @@ Debugger::setOnNewGlobalObject(JSContext* cx, unsigned argc, Value* vp)
if (dbg->enabled) {
JSObject* newHook = dbg->getHook(OnNewGlobalObject);
if (!oldHook && newHook) {
cx->runtime()->onNewGlobalObjectWatchers().pushBack(dbg);
/* If we didn't have a hook, the link should be a singleton list. */
MOZ_ASSERT(JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
JS_APPEND_LINK(&dbg->onNewGlobalObjectWatchersLink,
&cx->runtime()->onNewGlobalObjectWatchers());
} else if (oldHook && !newHook) {
cx->runtime()->onNewGlobalObjectWatchers().remove(dbg);
/* If we did have a hook, the link should be inserted in the list. */
MOZ_ASSERT(!JS_CLIST_IS_EMPTY(&dbg->onNewGlobalObjectWatchersLink));
JS_REMOVE_AND_INIT_LINK(&dbg->onNewGlobalObjectWatchersLink);
}
}

View File

@ -7,13 +7,13 @@
#ifndef vm_Debugger_h
#define vm_Debugger_h
#include "mozilla/DoublyLinkedList.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/LinkedList.h"
#include "mozilla/Range.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Vector.h"
#include "jsclist.h"
#include "jscntxt.h"
#include "jscompartment.h"
#include "jsweakmap.h"
@ -258,7 +258,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
{
friend class Breakpoint;
friend class DebuggerMemory;
friend class JSRuntime::GlobalObjectWatchersSiblingAccess<Debugger>;
friend class SavedStacks;
friend class ScriptedOnStepHandler;
friend class ScriptedOnPopHandler;
@ -386,27 +385,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
// Whether to enable code coverage on the Debuggee.
bool collectCoverageInfo;
template<typename T>
struct DebuggerSiblingAccess {
static T* GetNext(T* elm) {
return elm->debuggerLink.mNext;
}
static void SetNext(T* elm, T* next) {
elm->debuggerLink.mNext = next;
}
static T* GetPrev(T* elm) {
return elm->debuggerLink.mPrev;
}
static void SetPrev(T* elm, T* prev) {
elm->debuggerLink.mPrev = prev;
}
};
// List of all js::Breakpoints in this debugger.
using BreakpointList =
mozilla::DoublyLinkedList<js::Breakpoint,
DebuggerSiblingAccess<js::Breakpoint>>;
BreakpointList breakpoints;
JSCList breakpoints; /* Circular list of all js::Breakpoints in this debugger */
// The set of GC numbers for which one or more of this Debugger's observed
// debuggees participated in.
@ -466,10 +445,11 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
/*
* If this Debugger is enabled, and has a onNewGlobalObject handler, then
* this link is inserted into the list headed by
* JSRuntime::onNewGlobalObjectWatchers.
* this link is inserted into the circular list headed by
* JSRuntime::onNewGlobalObjectWatchers. Otherwise, this is set to a
* singleton cycle.
*/
mozilla::DoublyLinkedListElement<Debugger> onNewGlobalObjectWatchersLink;
JSCList onNewGlobalObjectWatchersLink;
/*
* Map from stack frames that are currently on the stack to Debugger.Frame
@ -809,6 +789,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
inline Breakpoint* firstBreakpoint() const;
static inline Debugger* fromOnNewGlobalObjectWatchersLink(JSCList* link);
static MOZ_MUST_USE bool replaceFrameGuts(JSContext* cx, AbstractFramePtr from,
AbstractFramePtr to,
ScriptFrameIter& iter);
@ -1580,27 +1562,7 @@ class BreakpointSite {
private:
Type type_;
template<typename T>
struct SiteSiblingAccess {
static T* GetNext(T* elm) {
return elm->siteLink.mNext;
}
static void SetNext(T* elm, T* next) {
elm->siteLink.mNext = next;
}
static T* GetPrev(T* elm) {
return elm->siteLink.mPrev;
}
static void SetPrev(T* elm, T* prev) {
elm->siteLink.mPrev = prev;
}
};
// List of all js::Breakpoints at this instruction.
using BreakpointList =
mozilla::DoublyLinkedList<js::Breakpoint,
SiteSiblingAccess<js::Breakpoint>>;
BreakpointList breakpoints;
JSCList breakpoints; /* cyclic list of all js::Breakpoints at this instruction */
size_t enabledCount; /* number of breakpoints in the list that are enabled */
protected:
@ -1644,7 +1606,6 @@ class BreakpointSite {
class Breakpoint {
friend struct ::JSCompartment;
friend class Debugger;
friend class BreakpointSite;
public:
Debugger * const debugger;
@ -1652,14 +1613,12 @@ class Breakpoint {
private:
/* |handler| is marked unconditionally during minor GC. */
js::PreBarrieredObject handler;
/**
* Link elements for each list this breakpoint can be in.
*/
mozilla::DoublyLinkedListElement<Breakpoint> debuggerLink;
mozilla::DoublyLinkedListElement<Breakpoint> siteLink;
JSCList debuggerLinks;
JSCList siteLinks;
public:
static Breakpoint* fromDebuggerLinks(JSCList* links);
static Breakpoint* fromSiteLinks(JSCList* links);
Breakpoint(Debugger* debugger, BreakpointSite* site, JSObject* handler);
void destroy(FreeOp* fop);
Breakpoint* nextInDebugger();
@ -1737,9 +1696,15 @@ Breakpoint::asWasm()
Breakpoint*
Debugger::firstBreakpoint() const
{
if (breakpoints.isEmpty())
if (JS_CLIST_IS_EMPTY(&breakpoints))
return nullptr;
return &(*breakpoints.begin());
return Breakpoint::fromDebuggerLinks(JS_NEXT_LINK(&breakpoints));
}
/* static */ Debugger*
Debugger::fromOnNewGlobalObjectWatchersLink(JSCList* link) {
char* p = reinterpret_cast<char*>(link);
return reinterpret_cast<Debugger*>(p - offsetof(Debugger, onNewGlobalObjectWatchersLink));
}
const js::GCPtrNativeObject&
@ -1800,7 +1765,7 @@ Debugger::onNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global)
#ifdef DEBUG
global->compartment()->firedOnNewGlobalObject = true;
#endif
if (!cx->runtime()->onNewGlobalObjectWatchers().isEmpty())
if (!JS_CLIST_IS_EMPTY(&cx->runtime()->onNewGlobalObjectWatchers()))
Debugger::slowPathOnNewGlobalObject(cx, global);
}

View File

@ -182,6 +182,7 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
liveRuntimesCount++;
/* Initialize infallibly first, so we can goto bad and JS_DestroyRuntime. */
JS_INIT_CLIST(&onNewGlobalObjectWatchers());
PodZero(&asmJSCacheOps);
lcovOutput().init();

View File

@ -9,7 +9,6 @@
#include "mozilla/Atomics.h"
#include "mozilla/Attributes.h"
#include "mozilla/DoublyLinkedList.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/PodOperations.h"
@ -20,6 +19,7 @@
#include <setjmp.h>
#include "jsatom.h"
#include "jsclist.h"
#include "jsscript.h"
#ifdef XP_DARWIN
@ -567,34 +567,14 @@ struct JSRuntime : public js::MallocProvider<JSRuntime>
weakCaches().insertBack(cachep);
}
template <typename T>
struct GlobalObjectWatchersSiblingAccess {
static T* GetNext(T* elm) {
return elm->onNewGlobalObjectWatchersLink.mNext;
}
static void SetNext(T* elm, T* next) {
elm->onNewGlobalObjectWatchersLink.mNext = next;
}
static T* GetPrev(T* elm) {
return elm->onNewGlobalObjectWatchersLink.mPrev;
}
static void SetPrev(T* elm, T* prev) {
elm->onNewGlobalObjectWatchersLink.mPrev = prev;
}
};
using WatchersList =
mozilla::DoublyLinkedList<js::Debugger,
GlobalObjectWatchersSiblingAccess<js::Debugger>>;
private:
/*
* List of all enabled Debuggers that have onNewGlobalObject handler
* methods established.
* Head of circular list of all enabled Debuggers that have
* onNewGlobalObject handler methods established.
*/
js::ActiveThreadData<WatchersList> onNewGlobalObjectWatchers_;
js::ActiveThreadData<JSCList> onNewGlobalObjectWatchers_;
public:
WatchersList& onNewGlobalObjectWatchers() { return onNewGlobalObjectWatchers_.ref(); }
JSCList& onNewGlobalObjectWatchers() { return onNewGlobalObjectWatchers_.ref(); }
private:
/*

View File

@ -12,8 +12,6 @@
#include <algorithm>
#include <iterator>
#include "mozilla/Assertions.h"
/**
* Where mozilla::LinkedList strives for ease of use above all other
* considerations, mozilla::DoublyLinkedList strives for flexibility. The