Backed out changeset 8cbc5f3bf065 (bug 935809)

This commit is contained in:
Sebastian Hengst 2017-05-03 00:20:58 +02:00
Родитель 864c74ce82
Коммит 35b152a5a6
2 изменённых файлов: 35 добавлений и 64 удалений

Просмотреть файл

@ -524,6 +524,7 @@ RequireGlobalObject(JSContext* cx, HandleValue dbgobj, HandleObject referent)
BreakpointSite::BreakpointSite(Type type) BreakpointSite::BreakpointSite(Type type)
: type_(type), enabledCount(0) : type_(type), enabledCount(0)
{ {
JS_INIT_CLIST(&breakpoints);
} }
void void
@ -546,22 +547,21 @@ BreakpointSite::dec(FreeOp* fop)
bool bool
BreakpointSite::isEmpty() const BreakpointSite::isEmpty() const
{ {
return breakpoints.isEmpty(); return JS_CLIST_IS_EMPTY(&breakpoints);
} }
Breakpoint* Breakpoint*
BreakpointSite::firstBreakpoint() const BreakpointSite::firstBreakpoint() const
{ {
if (isEmpty()) if (JS_CLIST_IS_EMPTY(&breakpoints))
return nullptr; return nullptr;
return &(*breakpoints.begin()); return Breakpoint::fromSiteLinks(JS_NEXT_LINK(&breakpoints));
} }
bool bool
BreakpointSite::hasBreakpoint(Breakpoint* toFind) BreakpointSite::hasBreakpoint(Breakpoint* bp)
{ {
const BreakpointList::Iterator bp(toFind); for (Breakpoint* p = firstBreakpoint(); p; p = p->nextInSite())
for (auto p = breakpoints.begin(); p; p++)
if (p == bp) if (p == bp)
return true; return true;
return false; return false;
@ -571,8 +571,20 @@ Breakpoint::Breakpoint(Debugger* debugger, BreakpointSite* site, JSObject* handl
: debugger(debugger), site(site), handler(handler) : debugger(debugger), site(site), handler(handler)
{ {
MOZ_ASSERT(handler->compartment() == debugger->object->compartment()); MOZ_ASSERT(handler->compartment() == debugger->object->compartment());
debugger->breakpoints.pushBack(this); JS_APPEND_LINK(&debuggerLinks, &debugger->breakpoints);
site->breakpoints.pushBack(this); 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 void
@ -580,8 +592,8 @@ Breakpoint::destroy(FreeOp* fop)
{ {
if (debugger->enabled) if (debugger->enabled)
site->dec(fop); site->dec(fop);
debugger->breakpoints.remove(this); JS_REMOVE_LINK(&debuggerLinks);
site->breakpoints.remove(this); JS_REMOVE_LINK(&siteLinks);
site->destroyIfEmpty(fop); site->destroyIfEmpty(fop);
fop->delete_(this); fop->delete_(this);
} }
@ -589,13 +601,15 @@ Breakpoint::destroy(FreeOp* fop)
Breakpoint* Breakpoint*
Breakpoint::nextInDebugger() Breakpoint::nextInDebugger()
{ {
return debuggerLink.mNext; JSCList* link = JS_NEXT_LINK(&debuggerLinks);
return (link == &debugger->breakpoints) ? nullptr : fromDebuggerLinks(link);
} }
Breakpoint* Breakpoint*
Breakpoint::nextInSite() Breakpoint::nextInSite()
{ {
return siteLink.mNext; JSCList* link = JS_NEXT_LINK(&siteLinks);
return (link == &site->breakpoints) ? nullptr : fromSiteLinks(link);
} }
JSBreakpointSite::JSBreakpointSite(JSScript* script, jsbytecode* pc) JSBreakpointSite::JSBreakpointSite(JSScript* script, jsbytecode* pc)
@ -670,6 +684,7 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg)
{ {
assertSameCompartment(cx, dbg); assertSameCompartment(cx, dbg);
JS_INIT_CLIST(&breakpoints);
JS_INIT_CLIST(&onNewGlobalObjectWatchersLink); JS_INIT_CLIST(&onNewGlobalObjectWatchersLink);
#ifdef JS_TRACE_LOGGING #ifdef JS_TRACE_LOGGING

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef vm_Debugger_h #ifndef vm_Debugger_h
#define vm_Debugger_h #define vm_Debugger_h
#include "mozilla/DoublyLinkedList.h"
#include "mozilla/GuardObjects.h" #include "mozilla/GuardObjects.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
#include "mozilla/Range.h" #include "mozilla/Range.h"
@ -386,27 +385,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
// Whether to enable code coverage on the Debuggee. // Whether to enable code coverage on the Debuggee.
bool collectCoverageInfo; bool collectCoverageInfo;
template<typename T> JSCList breakpoints; /* Circular list of all js::Breakpoints in this debugger */
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;
// The set of GC numbers for which one or more of this Debugger's observed // The set of GC numbers for which one or more of this Debugger's observed
// debuggees participated in. // debuggees participated in.
@ -1583,27 +1562,7 @@ class BreakpointSite {
private: private:
Type type_; Type type_;
template<typename T> JSCList breakpoints; /* cyclic list of all js::Breakpoints at this instruction */
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;
size_t enabledCount; /* number of breakpoints in the list that are enabled */ size_t enabledCount; /* number of breakpoints in the list that are enabled */
protected: protected:
@ -1647,7 +1606,6 @@ class BreakpointSite {
class Breakpoint { class Breakpoint {
friend struct ::JSCompartment; friend struct ::JSCompartment;
friend class Debugger; friend class Debugger;
friend class BreakpointSite;
public: public:
Debugger * const debugger; Debugger * const debugger;
@ -1655,14 +1613,12 @@ class Breakpoint {
private: private:
/* |handler| is marked unconditionally during minor GC. */ /* |handler| is marked unconditionally during minor GC. */
js::PreBarrieredObject handler; js::PreBarrieredObject handler;
JSCList debuggerLinks;
/** JSCList siteLinks;
* Link elements for each list this breakpoint can be in.
*/
mozilla::DoublyLinkedListElement<Breakpoint> debuggerLink;
mozilla::DoublyLinkedListElement<Breakpoint> siteLink;
public: public:
static Breakpoint* fromDebuggerLinks(JSCList* links);
static Breakpoint* fromSiteLinks(JSCList* links);
Breakpoint(Debugger* debugger, BreakpointSite* site, JSObject* handler); Breakpoint(Debugger* debugger, BreakpointSite* site, JSObject* handler);
void destroy(FreeOp* fop); void destroy(FreeOp* fop);
Breakpoint* nextInDebugger(); Breakpoint* nextInDebugger();
@ -1740,9 +1696,9 @@ Breakpoint::asWasm()
Breakpoint* Breakpoint*
Debugger::firstBreakpoint() const Debugger::firstBreakpoint() const
{ {
if (breakpoints.isEmpty()) if (JS_CLIST_IS_EMPTY(&breakpoints))
return nullptr; return nullptr;
return &(*breakpoints.begin()); return Breakpoint::fromDebuggerLinks(JS_NEXT_LINK(&breakpoints));
} }
/* static */ Debugger* /* static */ Debugger*