Skip to content

Commit

Permalink
Backed out changeset d3a026933bce (bug 1308039) for spidermonkey bust…
Browse files Browse the repository at this point in the history
…age. r=backout on a CLOSED TREE

UltraBlame original commit: 5fa834fe9b96d1b6b1cf99d14335b0beb1bd3811
  • Loading branch information
marco-c committed Sep 30, 2019
1 parent c7d94d7 commit 750be22
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
22 changes: 11 additions & 11 deletions js/public/GCAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,24 @@ GetGCNumber();

class JS_PUBLIC_API(AutoAssertOnGC)
{
#ifdef DEBUG
js::gc::GCRuntime* gc;
size_t gcNumber;

public:
AutoAssertOnGC();
explicit AutoAssertOnGC(JSContext* cx);
~AutoAssertOnGC();

static void VerifyIsSafeToGC(JSRuntime* rt);
#else
public:
AutoAssertOnGC() {}
explicit AutoAssertOnGC(JSContext* cx) {}
~AutoAssertOnGC() {}

static void VerifyIsSafeToGC(JSRuntime* rt) {}
#endif
};


Expand Down Expand Up @@ -565,23 +576,12 @@ class JS_PUBLIC_API(AutoAssertGCCallback) : public AutoSuppressGCAnalysis





#ifdef DEBUG
class JS_PUBLIC_API(AutoCheckCannotGC) : public AutoAssertOnGC
{
public:
AutoCheckCannotGC() : AutoAssertOnGC() {}
explicit AutoCheckCannotGC(JSContext* cx) : AutoAssertOnGC(cx) {}
} JS_HAZ_GC_INVALIDATED;
#else
class JS_PUBLIC_API(AutoCheckCannotGC)
{
public:
AutoCheckCannotGC() {}
explicit AutoCheckCannotGC(JSContext* cx) {}
} JS_HAZ_GC_INVALIDATED;
#endif



Expand Down
2 changes: 1 addition & 1 deletion js/src/gc/Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ GCRuntime::checkAllocatorState(JSContext* cx, AllocKind kind)


if (allowGC && !rt->mainThread.suppressGC)
rt->gc.verifyIsSafeToGC();
JS::AutoAssertOnGC::VerifyIsSafeToGC(rt);


if (js::oom::ShouldFailWithOOM()) {
Expand Down
19 changes: 7 additions & 12 deletions js/src/gc/GCRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,25 +721,20 @@ class GCRuntime
--noNurseryAllocationCheck;
}

bool isStrictProxyCheckingEnabled() { return disableStrictProxyCheckingCount == 0; }
void disableStrictProxyChecking() { ++disableStrictProxyCheckingCount; }
void enableStrictProxyChecking() {
MOZ_ASSERT(disableStrictProxyCheckingCount > 0);
--disableStrictProxyCheckingCount;
}
#endif

bool isInsideUnsafeRegion() { return inUnsafeRegion != 0; }
void enterUnsafeRegion() { ++inUnsafeRegion; }
void leaveUnsafeRegion() {
MOZ_ASSERT(inUnsafeRegion > 0);
--inUnsafeRegion;
}

void verifyIsSafeToGC() {
MOZ_DIAGNOSTIC_ASSERT(!isInsideUnsafeRegion(),
"[AutoAssertOnGC] possible GC in GC-unsafe region");
bool isStrictProxyCheckingEnabled() { return disableStrictProxyCheckingCount == 0; }
void disableStrictProxyChecking() { ++disableStrictProxyCheckingCount; }
void enableStrictProxyChecking() {
MOZ_ASSERT(disableStrictProxyCheckingCount > 0);
--disableStrictProxyCheckingCount;
}
#endif

void setAlwaysPreserveCode() { alwaysPreserveCode = true; }

Expand Down Expand Up @@ -1349,6 +1344,7 @@ class GCRuntime

bool alwaysPreserveCode;

#ifdef DEBUG



Expand All @@ -1357,7 +1353,6 @@ class GCRuntime

int inUnsafeRegion;

#ifdef DEBUG
size_t noGCOrAllocationCheck;
size_t noNurseryAllocationCheck;

Expand Down
12 changes: 10 additions & 2 deletions js/src/jsgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,8 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
mallocBytesUntilGC(0),
mallocGCTriggered(false),
alwaysPreserveCode(false),
inUnsafeRegion(0),
#ifdef DEBUG
inUnsafeRegion(0),
noGCOrAllocationCheck(0),
noNurseryAllocationCheck(0),
arenasEmptyAtShutdown(true),
Expand Down Expand Up @@ -6133,7 +6133,7 @@ GCRuntime::gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason::
MOZ_ASSERT(!rt->mainThread.suppressGC);


verifyIsSafeToGC();
JS::AutoAssertOnGC::VerifyIsSafeToGC(rt);

{
gcstats::AutoPhase ap(stats, gcstats::PHASE_WAIT_BACKGROUND_THREAD);
Expand Down Expand Up @@ -6974,6 +6974,7 @@ JS::GetGCNumber()
}
#endif

#ifdef DEBUG
JS::AutoAssertOnGC::AutoAssertOnGC()
: gc(nullptr), gcNumber(0)
{
Expand Down Expand Up @@ -7013,6 +7014,13 @@ JS::AutoAssertOnGC::~AutoAssertOnGC()
}
}

void
JS::AutoAssertOnGC::VerifyIsSafeToGC(JSRuntime* rt)
{
if (rt->gc.isInsideUnsafeRegion())
MOZ_CRASH("[AutoAssertOnGC] possible GC in GC-unsafe region");
}

JS::AutoAssertNoAlloc::AutoAssertNoAlloc(JSContext* cx)
: gc(nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion js/src/vm/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ js::RunScript(JSContext* cx, RunState& state)
JS_CHECK_RECURSION(cx, return false);


cx->runtime()->gc.verifyIsSafeToGC();
JS::AutoAssertOnGC::VerifyIsSafeToGC(cx->runtime());

if (!Debugger::checkNoExecute(cx, state.script()))
return false;
Expand Down

0 comments on commit 750be22

Please sign in to comment.