Skip to content

Commit

Permalink
Merge commit '7f52e4f92d3d3ded9a1701ee2f93966075ae5004' into 9.0-abi-…
Browse files Browse the repository at this point in the history
…stable
  • Loading branch information
targos committed Apr 17, 2021
2 parents ed7f09b + 7f52e4f commit 69aa92d
Show file tree
Hide file tree
Showing 30 changed files with 332 additions and 263 deletions.
4 changes: 4 additions & 0 deletions include/js_protocol.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,17 @@ experimental domain HeapProfiler
# when the tracking is stopped.
optional boolean reportProgress
optional boolean treatGlobalObjectsAsRoots
# If true, numerical values are included in the snapshot
optional boolean captureNumericValue

command takeHeapSnapshot
parameters
# If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
optional boolean reportProgress
# If true, a raw snapshot without artifical roots will be generated
optional boolean treatGlobalObjectsAsRoots
# If true, numerical values are included in the snapshot
optional boolean captureNumericValue

event addHeapSnapshotChunk
parameters
Expand Down
3 changes: 2 additions & 1 deletion include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ class V8_EXPORT HeapProfiler {
const HeapSnapshot* TakeHeapSnapshot(
ActivityControl* control = nullptr,
ObjectNameResolver* global_object_name_resolver = nullptr,
bool treat_global_objects_as_roots = true);
bool treat_global_objects_as_roots = true,
bool capture_numeric_value = false);

/**
* Starts tracking of heap objects population statistics. After calling
Expand Down
5 changes: 3 additions & 2 deletions src/api/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10043,10 +10043,11 @@ void HeapProfiler::ClearObjectIds() {

const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
ActivityControl* control, ObjectNameResolver* resolver,
bool treat_global_objects_as_roots) {
bool treat_global_objects_as_roots, bool capture_numeric_value) {
return reinterpret_cast<const HeapSnapshot*>(
reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot(
control, resolver, treat_global_objects_as_roots));
control, resolver, treat_global_objects_as_roots,
capture_numeric_value));
}

void HeapProfiler::StartTrackingHeapObjects(bool track_allocations) {
Expand Down
5 changes: 5 additions & 0 deletions src/builtins/ppc/builtins-ppc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,11 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}

void Builtins::Generate_WasmOnStackReplace(MacroAssembler* masm) {
// Only needed on x64.
__ Trap();
}
#endif // V8_ENABLE_WEBASSEMBLY

void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
Expand Down
5 changes: 5 additions & 0 deletions src/builtins/s390/builtins-s390.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2550,6 +2550,11 @@ void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) {
// TODO(v8:10701): Implement for this platform.
__ Trap();
}

void Builtins::Generate_WasmOnStackReplace(MacroAssembler* masm) {
// Only needed on x64.
__ Trap();
}
#endif // V8_ENABLE_WEBASSEMBLY

void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
Expand Down
18 changes: 18 additions & 0 deletions src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ void SharedTurboAssembler::Movapd(XMMRegister dst, XMMRegister src) {
}
}

void SharedTurboAssembler::F64x2ExtractLane(DoubleRegister dst, XMMRegister src,
uint8_t lane) {
if (lane == 0) {
if (dst != src) {
Movaps(dst, src);
}
} else {
DCHECK_EQ(1, lane);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(this, AVX);
// Pass src as operand to avoid false-dependency on dst.
vmovhlps(dst, src, src);
} else {
movhlps(dst, src);
}
}
}

void SharedTurboAssembler::S128Store32Lane(Operand dst, XMMRegister src,
uint8_t laneidx) {
if (laneidx == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class V8_EXPORT_PRIVATE SharedTurboAssembler : public TurboAssemblerBase {
AVX_OP_SSE4_1(Roundpd, roundpd)
AVX_OP_SSE4_1(Roundps, roundps)

void F64x2ExtractLane(DoubleRegister dst, XMMRegister src, uint8_t lane);
void S128Store32Lane(Operand dst, XMMRegister src, uint8_t laneidx);
void I16x8ExtMulLow(XMMRegister dst, XMMRegister src1, XMMRegister src2,
XMMRegister scrat, bool is_signed);
Expand Down
34 changes: 4 additions & 30 deletions src/compiler/backend/ia32/code-generator-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1866,38 +1866,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
case kIA32F64x2Splat: {
XMMRegister dst = i.OutputDoubleRegister();
XMMRegister src = i.InputDoubleRegister(0);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(tasm(), AVX);
__ vshufpd(i.OutputSimd128Register(), src, src, 0x0);
} else {
DCHECK_EQ(dst, src);
__ shufpd(dst, src, 0x0);
}
__ Movddup(i.OutputSimd128Register(), i.InputDoubleRegister(0));
break;
}
case kSSEF64x2ExtractLane: {
DCHECK_EQ(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
XMMRegister dst = i.OutputDoubleRegister();
int8_t lane = i.InputInt8(1);
if (lane != 0) {
DCHECK_EQ(lane, 1);
__ shufpd(dst, dst, lane);
}
break;
}
case kAVXF64x2ExtractLane: {
CpuFeatureScope avx_scope(tasm(), AVX);
XMMRegister dst = i.OutputDoubleRegister();
XMMRegister src = i.InputSimd128Register(0);
int8_t lane = i.InputInt8(1);
if (lane == 0) {
if (dst != src) __ vmovapd(dst, src);
} else {
DCHECK_EQ(lane, 1);
__ vshufpd(dst, src, src, lane);
}
case kF64x2ExtractLane: {
__ F64x2ExtractLane(i.OutputDoubleRegister(), i.InputDoubleRegister(0),
i.InputUint8(1));
break;
}
case kSSEF64x2ReplaceLane: {
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/backend/ia32/instruction-codes-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ namespace compiler {
V(IA32Poke) \
V(IA32Peek) \
V(IA32F64x2Splat) \
V(SSEF64x2ExtractLane) \
V(AVXF64x2ExtractLane) \
V(F64x2ExtractLane) \
V(SSEF64x2ReplaceLane) \
V(AVXF64x2ReplaceLane) \
V(IA32F64x2Sqrt) \
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/backend/ia32/instruction-scheduler-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kIA32BitcastFI:
case kIA32BitcastIF:
case kIA32F64x2Splat:
case kSSEF64x2ExtractLane:
case kAVXF64x2ExtractLane:
case kF64x2ExtractLane:
case kSSEF64x2ReplaceLane:
case kAVXF64x2ReplaceLane:
case kIA32F64x2Sqrt:
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/backend/ia32/instruction-selector-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ void InstructionSelector::VisitF64x2Splat(Node* node) {
}

void InstructionSelector::VisitF64x2ExtractLane(Node* node) {
VisitRRISimd(this, node, kAVXF64x2ExtractLane, kSSEF64x2ExtractLane);
VisitRRISimd(this, node, kF64x2ExtractLane, kF64x2ExtractLane);
}

void InstructionSelector::VisitI64x2SplatI32Pair(Node* node) {
Expand Down
17 changes: 2 additions & 15 deletions src/compiler/backend/x64/code-generator-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2390,21 +2390,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
case kX64F64x2ExtractLane: {
DoubleRegister dst = i.OutputDoubleRegister();
XMMRegister src = i.InputSimd128Register(0);
uint8_t lane = i.InputUint8(1);
if (lane == 0) {
__ Move(dst, src);
} else {
DCHECK_EQ(1, lane);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(tasm(), AVX);
// Pass src as operand to avoid false-dependency on dst.
__ vmovhlps(dst, src, src);
} else {
__ movhlps(dst, src);
}
}
__ F64x2ExtractLane(i.OutputDoubleRegister(), i.InputDoubleRegister(0),
i.InputUint8(1));
break;
}
case kX64F64x2Sqrt: {
Expand Down
12 changes: 8 additions & 4 deletions src/inspector/v8-heap-profiler-agent-impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ Response V8HeapProfilerAgentImpl::startTrackingHeapObjects(
}

Response V8HeapProfilerAgentImpl::stopTrackingHeapObjects(
Maybe<bool> reportProgress, Maybe<bool> treatGlobalObjectsAsRoots) {
Maybe<bool> reportProgress, Maybe<bool> treatGlobalObjectsAsRoots,
Maybe<bool> captureNumericValue) {
requestHeapStatsUpdate();
takeHeapSnapshot(std::move(reportProgress),
std::move(treatGlobalObjectsAsRoots));
std::move(treatGlobalObjectsAsRoots),
std::move(captureNumericValue));
stopTrackingHeapObjectsInternal();
return Response::Success();
}
Expand All @@ -258,7 +260,8 @@ Response V8HeapProfilerAgentImpl::disable() {
}

Response V8HeapProfilerAgentImpl::takeHeapSnapshot(
Maybe<bool> reportProgress, Maybe<bool> treatGlobalObjectsAsRoots) {
Maybe<bool> reportProgress, Maybe<bool> treatGlobalObjectsAsRoots,
Maybe<bool> captureNumericValue) {
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) return Response::ServerError("Cannot access v8 heap profiler");
std::unique_ptr<HeapSnapshotProgress> progress;
Expand All @@ -267,7 +270,8 @@ Response V8HeapProfilerAgentImpl::takeHeapSnapshot(

GlobalObjectNameResolver resolver(m_session);
const v8::HeapSnapshot* snapshot = profiler->TakeHeapSnapshot(
progress.get(), &resolver, treatGlobalObjectsAsRoots.fromMaybe(true));
progress.get(), &resolver, treatGlobalObjectsAsRoots.fromMaybe(true),
captureNumericValue.fromMaybe(false));
if (!snapshot) return Response::ServerError("Failed to take heap snapshot");
HeapSnapshotOutputStream stream(&m_frontend);
snapshot->Serialize(&stream);
Expand Down
9 changes: 5 additions & 4 deletions src/inspector/v8-heap-profiler-agent-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ class V8HeapProfilerAgentImpl : public protocol::HeapProfiler::Backend {

Response enable() override;
Response startTrackingHeapObjects(Maybe<bool> trackAllocations) override;
Response stopTrackingHeapObjects(
Maybe<bool> reportProgress,
Maybe<bool> treatGlobalObjectsAsRoots) override;
Response stopTrackingHeapObjects(Maybe<bool> reportProgress,
Maybe<bool> treatGlobalObjectsAsRoots,
Maybe<bool> captureNumericValue) override;

Response disable() override;

Response takeHeapSnapshot(Maybe<bool> reportProgress,
Maybe<bool> treatGlobalObjectsAsRoots) override;
Maybe<bool> treatGlobalObjectsAsRoots,
Maybe<bool> captureNumericValue) override;

Response getObjectByHeapObjectId(
const String16& heapSnapshotObjectId, Maybe<String16> objectGroup,
Expand Down
5 changes: 3 additions & 2 deletions src/profiler/heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ v8::EmbedderGraph::Node::Detachedness HeapProfiler::GetDetachedness(
HeapSnapshot* HeapProfiler::TakeSnapshot(
v8::ActivityControl* control,
v8::HeapProfiler::ObjectNameResolver* resolver,
bool treat_global_objects_as_roots) {
bool treat_global_objects_as_roots, bool capture_numeric_value) {
is_taking_snapshot_ = true;
HeapSnapshot* result = new HeapSnapshot(this, treat_global_objects_as_roots);
HeapSnapshot* result = new HeapSnapshot(this, treat_global_objects_as_roots,
capture_numeric_value);
{
HeapSnapshotGenerator generator(result, control, resolver, heap());
if (!generator.GenerateSnapshot()) {
Expand Down
3 changes: 2 additions & 1 deletion src/profiler/heap-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class HeapProfiler : public HeapObjectAllocationTracker {

HeapSnapshot* TakeSnapshot(v8::ActivityControl* control,
v8::HeapProfiler::ObjectNameResolver* resolver,
bool treat_global_objects_as_roots);
bool treat_global_objects_as_roots,
bool capture_numeric_value);

bool StartSamplingHeapProfiler(uint64_t sample_interval, int stack_depth,
v8::HeapProfiler::SamplingFlags);
Expand Down
Loading

0 comments on commit 69aa92d

Please sign in to comment.