Skip to content

Commit

Permalink
Backed out 4 changesets (bug 1545582) for causing build bustages in S…
Browse files Browse the repository at this point in the history
…avedStacks.cpp CLOSED TREE

Backed out changeset a47c4a44bae0 (bug 1545582)
Backed out changeset c05a5d68d9a8 (bug 1545582)
Backed out changeset 699de45940b1 (bug 1545582)
Backed out changeset 285673afaa99 (bug 1545582)
  • Loading branch information
Mihai Alexandru Michis committed Jun 14, 2019
1 parent 4a505cf commit cff1990
Show file tree
Hide file tree
Showing 28 changed files with 69 additions and 558 deletions.
1 change: 0 additions & 1 deletion devtools/client/performance-new/popup/background.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ function intializeState() {
tasktracer: false,
trackopts: false,
jstracer: false,
jsallocations: false,
};

if (AppConstants.platform === "android") {
Expand Down
4 changes: 0 additions & 4 deletions devtools/client/performance-new/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ <h1 class="settings-setting-label">Buffer size:</h1>
id="perf-settings-feature-checkbox-jstracer" type="checkbox" value="jstracer" />
<div class="perf-settings-feature-name">JSTracer</div>
<div class="perf-settings-feature-title">Trace JS engine (Experimental, requires custom build.)</div>
</label><label class="perf-settings-checkbox-label perf-settings-feature-label"><input class="perf-settings-checkbox"
id="perf-settings-feature-checkbox-jsallocations" type="checkbox" value="jsallocations" />
<div class="perf-settings-feature-name">JS Allocations</div>
<div class="perf-settings-feature-title">Track JavaScript allocations (Experimental.)</div>
</label>
</div>
</div>
Expand Down
5 changes: 1 addition & 4 deletions devtools/client/performance-new/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const features = [
"stackwalk",
"tasktracer",
"jstracer",
"jsallocations",
"trackopts",
];
const threadPrefix = "perf-settings-thread-checkbox-";
Expand Down Expand Up @@ -258,7 +257,6 @@ function calculateOverhead(state) {
const overheadFromSeqStyle = state.seqstyle ? 0.05 : 0;
const overheadFromTaskTracer = state.tasktracer ? 0.05 : 0;
const overheadFromJSTracer = state.jstracer ? 0.05 : 0;
const overheadFromJSAllocations = state.jsallocations ? 0.05 : 0;
return clamp(
overheadFromSampling +
overheadFromBuffersize +
Expand All @@ -267,8 +265,7 @@ function calculateOverhead(state) {
overheadFromJavaScrpt +
overheadFromSeqStyle +
overheadFromTaskTracer +
overheadFromJSTracer +
overheadFromJSAllocations,
overheadFromJSTracer,
0,
1
);
Expand Down
75 changes: 0 additions & 75 deletions js/public/AllocationRecording.h

This file was deleted.

5 changes: 0 additions & 5 deletions js/public/UbiNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,6 @@ enum class CoarseType : uint32_t {
LAST = DOMNode
};

/**
* Convert a CoarseType enum into a string. The string is statically allocated.
*/
JS_PUBLIC_API const char* CoarseTypeToString(CoarseType type);

inline uint32_t CoarseTypeToUint32(CoarseType type) {
return static_cast<uint32_t>(type);
}
Expand Down
1 change: 0 additions & 1 deletion js/src/jsapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,6 @@ JS_PUBLIC_API void JS_FireOnNewGlobalObject(JSContext* cx,
cx->check(global);
Rooted<js::GlobalObject*> globalObject(cx, &global->as<GlobalObject>());
Debugger::onNewGlobalObject(cx, globalObject);
cx->runtime()->ensureRealmIsRecordingAllocations(globalObject);
}

JS_PUBLIC_API JSObject* JS_NewObject(JSContext* cx, const JSClass* jsclasp) {
Expand Down
1 change: 0 additions & 1 deletion js/src/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ EXPORTS += [
]

EXPORTS.js += [
'../public/AllocationRecording.h',
'../public/AllocPolicy.h',
'../public/ArrayBuffer.h',
'../public/BuildId.h',
Expand Down
7 changes: 1 addition & 6 deletions js/src/vm/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3327,12 +3327,7 @@ void Debugger::removeAllocationsTracking(GlobalObject& global) {
return;
}

if (!global.realm()->runtimeFromMainThread()->recordAllocationCallback) {
// Something like the Gecko Profiler could request from the the JS runtime
// to record allocations. If it is recording allocations, then do not
// destroy the allocation metadata builder at this time.
global.realm()->forgetAllocationMetadataBuilder();
}
global.realm()->forgetAllocationMetadataBuilder();
}

bool Debugger::addAllocationsTrackingForAllDebuggees(JSContext* cx) {
Expand Down
13 changes: 7 additions & 6 deletions js/src/vm/Debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
#ifdef DEBUG
static void assertThingIsNotGray(Debugger* dbg) { return; }
#endif
/*
* Return true if the given global is being observed by at least one
* Debugger that is tracking allocations.
*/
static bool isObservedByDebuggerTrackingAllocations(
const GlobalObject& debuggee);

private:
GCPtrNativeObject object; /* The Debugger object. Strong reference. */
Expand Down Expand Up @@ -455,6 +449,13 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
*/
static bool cannotTrackAllocations(const GlobalObject& global);

/*
* Return true if the given global is being observed by at least one
* Debugger that is tracking allocations.
*/
static bool isObservedByDebuggerTrackingAllocations(
const GlobalObject& global);

/*
* Add allocations tracking for objects allocated within the given
* debuggee's compartment. The given debuggee global must be observed by at
Expand Down
7 changes: 0 additions & 7 deletions js/src/vm/Realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,6 @@ void Realm::clearTables() {
varNames_.clear();
}

// Check to see if this individual realm is recording allocations. Debuggers or
// runtimes can try and record allocations, so this method can check to see if
// any initialization is needed.
bool Realm::isRecordingAllocations() { return !!allocationMetadataBuilder_; }

void Realm::setAllocationMetadataBuilder(
const js::AllocationMetadataBuilder* builder) {
// Clear any jitcode in the runtime, which behaves differently depending on
Expand All @@ -628,8 +623,6 @@ void Realm::setAllocationMetadataBuilder(
}

void Realm::forgetAllocationMetadataBuilder() {
MOZ_ASSERT(allocationMetadataBuilder_);

// Unlike setAllocationMetadataBuilder, we don't have to discard all JIT
// code here (code is still valid, just a bit slower because it doesn't do
// inline GC allocations when a metadata builder is present), but we do want
Expand Down
6 changes: 2 additions & 4 deletions js/src/vm/Realm.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ class JS::Realm : public JS::shadow::Realm {
const void* addressOfMetadataBuilder() const {
return &allocationMetadataBuilder_;
}
bool isRecordingAllocations();
void setAllocationMetadataBuilder(
const js::AllocationMetadataBuilder* builder);
void forgetAllocationMetadataBuilder();
Expand Down Expand Up @@ -798,9 +797,8 @@ class JS::Realm : public JS::shadow::Realm {

// Recompute the probability with which this realm should record
// profiling data (stack traces, allocations log, etc.) about each
// allocation. We first consult the JS runtime to see if it is recording
// allocations, and if not then check the probabilities requested by the
// Debugger instances observing us, if any.
// allocation. We consult the probabilities requested by the Debugger
// instances observing us, if any.
void chooseAllocationSamplingProbability() {
savedStacks_.chooseSamplingProbability(this);
}
Expand Down
55 changes: 0 additions & 55 deletions js/src/vm/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,62 +847,7 @@ JS_FRIEND_API bool JS::IsProfilingEnabledForContext(JSContext* cx) {
return cx->runtime()->geckoProfiler().enabled();
}

JS_FRIEND_API void JS::EnableRecordingAllocations(
JSContext* cx, JS::RecordAllocationsCallback callback, double probability) {
MOZ_ASSERT(cx);
MOZ_ASSERT(cx->isMainThreadContext());
cx->runtime()->startRecordingAllocations(probability, callback);
}

JS_FRIEND_API void JS::DisableRecordingAllocations(JSContext* cx) {
MOZ_ASSERT(cx);
MOZ_ASSERT(cx->isMainThreadContext());
cx->runtime()->stopRecordingAllocations();
}

JS_PUBLIC_API void JS::shadow::RegisterWeakCache(
JSRuntime* rt, detail::WeakCacheBase* cachep) {
rt->registerWeakCache(cachep);
}

void JSRuntime::startRecordingAllocations(
double probability, JS::RecordAllocationsCallback callback) {
allocationSamplingProbability = probability;
recordAllocationCallback = callback;

// Go through all of the existing realms, and turn on allocation tracking.
for (RealmsIter realm(this); !realm.done(); realm.next()) {
realm->setAllocationMetadataBuilder(&SavedStacks::metadataBuilder);
realm->chooseAllocationSamplingProbability();
}
}

void JSRuntime::stopRecordingAllocations() {
recordAllocationCallback = nullptr;
// Go through all of the existing realms, and turn on allocation tracking.
for (RealmsIter realm(this); !realm.done(); realm.next()) {
js::GlobalObject* global = realm->maybeGlobal();
if (!realm->isDebuggee() || !global ||
!Debugger::isObservedByDebuggerTrackingAllocations(*global)) {
// Only remove the allocation metadata builder if no Debuggers are
// tracking allocations.
realm->forgetAllocationMetadataBuilder();
}
}
}

// This function can run to ensure that when new realms are created
// they have allocation logging turned on.
void JSRuntime::ensureRealmIsRecordingAllocations(
Handle<GlobalObject*> global) {
if (recordAllocationCallback) {
if (!global->realm()->isRecordingAllocations()) {
// This is a new realm, turn on allocations for it.
global->realm()->setAllocationMetadataBuilder(
&SavedStacks::metadataBuilder);
}
// Ensure the probability is up to date with the current combination of
// debuggers and runtime profiling.
global->realm()->chooseAllocationSamplingProbability();
}
}
11 changes: 0 additions & 11 deletions js/src/vm/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "gc/GCRuntime.h"
#include "gc/Tracer.h"
#include "irregexp/RegExpStack.h"
#include "js/AllocationRecording.h"
#include "js/BuildId.h" // JS::BuildIdOp
#include "js/Debug.h"
#include "js/experimental/SourceHook.h" // js::SourceHook
Expand Down Expand Up @@ -525,11 +524,6 @@ struct JSRuntime : public js::MallocProvider<JSRuntime> {
// number of realms visited by RealmsIter.
js::MainThreadData<size_t> numRealms;

// The Gecko Profiler may want to sample the allocations happening across the
// browser. This callback can be registered to record the allocation.
js::MainThreadData<JS::RecordAllocationsCallback> recordAllocationCallback;
js::MainThreadData<double> allocationSamplingProbability;

private:
// Number of debuggee realms in the runtime.
js::MainThreadData<size_t> numDebuggeeRealms_;
Expand All @@ -546,11 +540,6 @@ struct JSRuntime : public js::MallocProvider<JSRuntime> {
void incrementNumDebuggeeRealmsObservingCoverage();
void decrementNumDebuggeeRealmsObservingCoverage();

void startRecordingAllocations(double probability,
JS::RecordAllocationsCallback callback);
void stopRecordingAllocations();
void ensureRealmIsRecordingAllocations(JS::Handle<js::GlobalObject*> global);

/* Locale-specific callbacks for string conversion. */
js::MainThreadData<const JSLocaleCallbacks*> localeCallbacks;

Expand Down
37 changes: 0 additions & 37 deletions js/src/vm/SavedStacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,16 +1798,6 @@ bool SavedStacks::getLocation(JSContext* cx, const FrameIter& iter,
}

void SavedStacks::chooseSamplingProbability(Realm* realm) {
{
JSRuntime* runtime = realm->runtimeFromMainThread();
if (runtime->recordAllocationCallback) {
// The runtime is tracking allocations across all realms, in this case
// ignore all of the debugger values, and use the runtime's probability.
this->setSamplingProbability(runtime->allocationSamplingProbability);
return;
}
}

// Use unbarriered version to prevent triggering read barrier while
// collecting, this is safe as long as global does not escape.
GlobalObject* global = realm->unsafeUnbarrieredMaybeGlobal();
Expand Down Expand Up @@ -1839,10 +1829,6 @@ void SavedStacks::chooseSamplingProbability(Realm* realm) {
}
MOZ_ASSERT(foundAnyDebuggers);

this->setSamplingProbability(probability);
}

void SavedStacks::setSamplingProbability(double probability) {
if (!bernoulliSeeded) {
mozilla::Array<uint64_t, 2> seed;
GenerateXorShift128PlusSeed(seed);
Expand Down Expand Up @@ -1873,29 +1859,6 @@ JSObject* SavedStacks::MetadataBuilder::build(
oomUnsafe.crash("SavedStacksMetadataBuilder");
}

auto recordAllocationCallback =
cx->realm()->runtimeFromMainThread()->recordAllocationCallback;
if (recordAllocationCallback) {
// The following code translates the JS-specific information, into an
// RecordAllocationInfo object that can be consumed outside of SpiderMonkey.

// Do not GC during this operation, strings are being copied out of the JS
// engine.
AutoCheckCannotGC nogc;

auto node = JS::ubi::Node(obj.get());

// Pass the non-SpiderMonkey specific information back to the
// callback to get it out of the JS engine. Strings will need to be
// copied by the callback. After it is done we release the
// AutoCheckCannotGC.
recordAllocationCallback(JS::RecordAllocationInfo{
node.typeName(), node.jsObjectClassName(), node.descriptiveTypeName(),
node.scriptFilename(), JS::ubi::CoarseTypeToString(node.coarseType()),
node.size(cx->runtime()->debuggerMallocSizeOf),
gc::IsInsideNursery(obj)});
}

MOZ_ASSERT_IF(frame, !frame->is<WrapperObject>());
return frame;
}
Expand Down
1 change: 0 additions & 1 deletion js/src/vm/SavedStacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ class SavedStacks {
Handle<SavedFrame::Lookup> lookup);
SavedFrame* createFrameFromLookup(JSContext* cx,
Handle<SavedFrame::Lookup> lookup);
void setSamplingProbability(double probability);

// Cache for memoizing PCToLineNumber lookups.

Expand Down
Loading

0 comments on commit cff1990

Please sign in to comment.