mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 10:40:12 +00:00
Bug 1297360 - Copy strings returned by ProfilingFrameIterator API r=djvj
This commit is contained in:
parent
d27c885d1e
commit
c5e590d3e6
@ -116,7 +116,7 @@ class JS_PUBLIC_API(ProfilingFrameIterator)
|
||||
void* stackAddress;
|
||||
void* returnAddress;
|
||||
void* activation;
|
||||
const char* label;
|
||||
UniqueChars label;
|
||||
};
|
||||
|
||||
bool isAsmJS() const;
|
||||
|
@ -1662,7 +1662,8 @@ ReadSPSProfilingStack(JSContext* cx, unsigned argc, Value* vp)
|
||||
if (!JS_DefineProperty(cx, inlineFrameInfo, "kind", frameKind, propAttrs))
|
||||
return false;
|
||||
|
||||
frameLabel = NewStringCopyZ<CanGC>(cx, frames[inlineFrameNo].label);
|
||||
auto chars = frames[inlineFrameNo].label.release();
|
||||
frameLabel = NewString<CanGC>(cx, reinterpret_cast<Latin1Char*>(chars), strlen(chars));
|
||||
if (!frameLabel)
|
||||
return false;
|
||||
|
||||
|
@ -4685,7 +4685,8 @@ SingleStepCallback(void* arg, jit::Simulator* sim, void* pc)
|
||||
if (!stack.append(",", 1))
|
||||
oomUnsafe.crash("stack.append");
|
||||
}
|
||||
if (!stack.append(frames[i].label, strlen(frames[i].label)))
|
||||
auto chars = frames[i].label.get();
|
||||
if (!stack.append(chars, strlen(chars)))
|
||||
oomUnsafe.crash("stack.append");
|
||||
frameNo++;
|
||||
}
|
||||
|
@ -1872,8 +1872,7 @@ JS::ProfilingFrameIterator::getPhysicalFrameAndEntry(jit::JitcodeGlobalEntry* en
|
||||
frame.stackAddress = stackAddr;
|
||||
frame.returnAddress = nullptr;
|
||||
frame.activation = activation_;
|
||||
frame.label = nullptr;
|
||||
return mozilla::Some(frame);
|
||||
return mozilla::Some(mozilla::Move(frame));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(isJit());
|
||||
@ -1897,8 +1896,7 @@ JS::ProfilingFrameIterator::getPhysicalFrameAndEntry(jit::JitcodeGlobalEntry* en
|
||||
frame.stackAddress = stackAddr;
|
||||
frame.returnAddress = returnAddr;
|
||||
frame.activation = activation_;
|
||||
frame.label = nullptr;
|
||||
return mozilla::Some(frame);
|
||||
return mozilla::Some(mozilla::Move(frame));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@ -1915,8 +1913,10 @@ JS::ProfilingFrameIterator::extractStack(Frame* frames, uint32_t offset, uint32_
|
||||
return 0;
|
||||
|
||||
if (isAsmJS()) {
|
||||
frames[offset] = physicalFrame.value();
|
||||
frames[offset].label = asmJSIter().label();
|
||||
frames[offset] = mozilla::Move(physicalFrame.ref());
|
||||
frames[offset].label = DuplicateString(asmJSIter().label());
|
||||
if (!frames[offset].label)
|
||||
return 0; // Drop stack frames silently on OOM.
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1927,8 +1927,11 @@ JS::ProfilingFrameIterator::extractStack(Frame* frames, uint32_t offset, uint32_
|
||||
for (uint32_t i = 0; i < depth; i++) {
|
||||
if (offset + i >= end)
|
||||
return i;
|
||||
frames[offset + i] = physicalFrame.value();
|
||||
frames[offset + i].label = labels[i];
|
||||
Frame& frame = frames[offset + i];
|
||||
frame = mozilla::Move(physicalFrame.ref());
|
||||
frame.label = DuplicateString(labels[i]);
|
||||
if (!frame.label)
|
||||
return i; // Drop stack frames silently on OOM.
|
||||
}
|
||||
|
||||
return depth;
|
||||
|
@ -781,7 +781,7 @@ void mergeStacksIntoProfile(ThreadProfile& aProfile, TickSample* aSample, Native
|
||||
mozilla::Maybe<JS::ProfilingFrameIterator::Frame> frame =
|
||||
jsIter.getPhysicalFrameWithoutLabel();
|
||||
if (frame.isSome())
|
||||
jsFrames[jsCount++] = frame.value();
|
||||
jsFrames[jsCount++] = mozilla::Move(frame.ref());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -891,7 +891,7 @@ void mergeStacksIntoProfile(ThreadProfile& aProfile, TickSample* aSample, Native
|
||||
// with stale JIT code return addresses.
|
||||
if (aSample->isSamplingCurrentThread ||
|
||||
jsFrame.kind == JS::ProfilingFrameIterator::Frame_AsmJS) {
|
||||
addDynamicTag(aProfile, 'c', jsFrame.label);
|
||||
addDynamicTag(aProfile, 'c', jsFrame.label.get());
|
||||
} else {
|
||||
MOZ_ASSERT(jsFrame.kind == JS::ProfilingFrameIterator::Frame_Ion ||
|
||||
jsFrame.kind == JS::ProfilingFrameIterator::Frame_Baseline);
|
||||
|
Loading…
x
Reference in New Issue
Block a user