Commit 0a9705f2 authored by Mihai Alexandru Michis's avatar Mihai Alexandru Michis
Browse files

Backed out changeset 2921275a761f (bug 1599659) for causing bustages in...

Backed out changeset 2921275a761f (bug 1599659) for causing bustages in testSABAccounting.cpp CLOSED TREE
parent ecf3387c
......@@ -92,7 +92,6 @@ UNIFIED_SOURCES += [
'testRegExp.cpp',
'testResolveRecursion.cpp',
'tests.cpp',
'testSABAccounting.cpp',
'testSameValue.cpp',
'testSavedStacks.cpp',
'testScriptInfo.cpp',
......
#include "jsapi.h"
#include "jsfriendapi.h"
#include "builtin/TestingFunctions.h"
#include "js/SharedArrayBuffer.h"
#include "jsapi-tests/tests.h"
BEGIN_TEST(testSABAccounting) {
// Purge what we can
JS::PrepareForFullGC(cx);
NonIncrementalGC(cx, GC_SHRINK, GCReason::API);
// Self-hosting and chrome code should not use SABs, or the point of this
// predicate is completely lost.
CHECK(!JS_ContainsSharedArrayBuffer(cx));
JS::RootedObject obj(cx), obj2(cx);
CHECK(obj = JS::NewSharedArrayBuffer(cx, 4096));
CHECK(JS_ContainsSharedArrayBuffer(cx));
CHECK(obj2 = JS::NewSharedArrayBuffer(cx, 4096));
CHECK(JS_ContainsSharedArrayBuffer(cx));
// Discard those objects again.
obj = nullptr;
obj2 = nullptr;
JS::PrepareForFullGC(cx);
NonIncrementalGC(cx, GC_SHRINK, GCReason::API);
// Should be back to base state.
CHECK(!JS_ContainsSharedArrayBuffer(cx));
return true;
}
END_TEST(testSABAccounting)
......@@ -92,8 +92,7 @@ JSObject* JSAPITest::createGlobal(JSPrincipals* principals) {
.setStreamsEnabled(true)
.setFieldsEnabled(true)
.setAwaitFixEnabled(true)
.setWeakRefsEnabled(true)
.setSharedMemoryAndAtomicsEnabled(true);
.setWeakRefsEnabled(true);
newGlobal = JS_NewGlobalObject(cx, getGlobalClass(), principals,
JS::FireOnNewGlobalHook, options);
if (!newGlobal) {
......
......@@ -390,10 +390,6 @@ JS_PUBLIC_API void JS_SetFutexCanWait(JSContext* cx) {
cx->fx.setCanWait(true);
}
JS_PUBLIC_API bool JS_ContainsSharedArrayBuffer(JSContext* cx) {
return cx->runtime()->hasLiveSABs();
}
JS_PUBLIC_API JSRuntime* JS_GetParentRuntime(JSContext* cx) {
return cx->runtime()->parentRuntime ? cx->runtime()->parentRuntime
: cx->runtime();
......
......@@ -344,12 +344,6 @@ extern JS_PUBLIC_API JSRuntime* JS_GetRuntime(JSContext* cx);
extern JS_PUBLIC_API void JS_SetFutexCanWait(JSContext* cx);
// Returns true if there are any live SharedArrayBuffer objects, including those
// for wasm memories, associated with the context. This is conservative,
// because it does not run GC. Some dead objects may not have been collected
// yet and thus will be thought live.
extern JS_PUBLIC_API bool JS_ContainsSharedArrayBuffer(JSContext* cx);
namespace js {
void AssertHeapIsIdle();
......
......@@ -149,7 +149,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
staticStrings(nullptr),
commonNames(nullptr),
wellKnownSymbols(nullptr),
liveSABs(0),
offthreadIonCompilationEnabled_(true),
parallelParsingEnabled_(true),
#ifdef DEBUG
......
......@@ -840,24 +840,6 @@ struct JSRuntime {
JSRuntime* thisFromCtor() { return this; }
private:
// Number of live SharedArrayBuffer objects, including those in Wasm shared
// memories. uint64_t to avoid any risk of overflow.
js::MainThreadData<uint64_t> liveSABs;
public:
void incSABCount() {
MOZ_RELEASE_ASSERT(liveSABs != UINT64_MAX);
liveSABs++;
}
void decSABCount() {
MOZ_RELEASE_ASSERT(liveSABs > 0);
liveSABs--;
}
bool hasLiveSABs() const { return liveSABs > 0; }
public:
void reportAllocationOverflow() { js::ReportAllocationOverflow(nullptr); }
......
......@@ -251,7 +251,6 @@ SharedArrayBufferObject* SharedArrayBufferObject::New(
MOZ_ASSERT(obj->getClass() == &class_);
cx->runtime()->incSABCount();
obj->acceptRawBuffer(buffer, length);
return obj;
......@@ -274,9 +273,7 @@ SharedArrayRawBuffer* SharedArrayBufferObject::rawBufferObject() const {
}
void SharedArrayBufferObject::Finalize(JSFreeOp* fop, JSObject* obj) {
// Must be foreground finalizable so that we can account for the object.
MOZ_ASSERT(fop->onMainThread());
fop->runtime()->decSABCount();
MOZ_ASSERT(fop->maybeOnHelperThread());
SharedArrayBufferObject& buf = obj->as<SharedArrayBufferObject>();
......@@ -330,7 +327,6 @@ SharedArrayBufferObject* SharedArrayBufferObject::createFromNewRawBuffer(
return nullptr;
}
cx->runtime()->incSABCount();
obj->acceptRawBuffer(buffer, initialSize);
return obj;
......@@ -377,7 +373,7 @@ const JSClass SharedArrayBufferObject::class_ = {
JSCLASS_DELAY_METADATA_BUILDER |
JSCLASS_HAS_RESERVED_SLOTS(SharedArrayBufferObject::RESERVED_SLOTS) |
JSCLASS_HAS_CACHED_PROTO(JSProto_SharedArrayBuffer) |
JSCLASS_FOREGROUND_FINALIZE,
JSCLASS_BACKGROUND_FINALIZE,
&SharedArrayBufferObjectClassOps, &SharedArrayBufferObjectClassSpec,
JS_NULL_CLASS_EXT};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment