Commit 0d3e5872 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

Add %DebugPrintPtr(0x...) for exploring metadata

Often at the d8 prompt, you'd like to explore some pointer found
from calls to %DebugPrint(). %DebugPrintPtr() takes a pointer and
attempts to print it as an object.

Change-Id: Ibc3368136a2ed92f400b52dbf2855f3c7d80d887
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2276046Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68617}
parent 2b236e33
...@@ -740,12 +740,7 @@ RUNTIME_FUNCTION(Runtime_SimulateNewspaceFull) { ...@@ -740,12 +740,7 @@ RUNTIME_FUNCTION(Runtime_SimulateNewspaceFull) {
return ReadOnlyRoots(isolate).undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugPrint) { static void DebugPrintImpl(MaybeObject maybe_object) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
MaybeObject maybe_object(*args.address_of_arg_at(0));
StdoutStream os; StdoutStream os;
if (maybe_object->IsCleared()) { if (maybe_object->IsCleared()) {
os << "[weak cleared]"; os << "[weak cleared]";
...@@ -767,7 +762,32 @@ RUNTIME_FUNCTION(Runtime_DebugPrint) { ...@@ -767,7 +762,32 @@ RUNTIME_FUNCTION(Runtime_DebugPrint) {
#endif #endif
} }
os << std::endl; os << std::endl;
}
RUNTIME_FUNCTION(Runtime_DebugPrint) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
MaybeObject maybe_object(*args.address_of_arg_at(0));
DebugPrintImpl(maybe_object);
return args[0];
}
RUNTIME_FUNCTION(Runtime_DebugPrintPtr) {
SealHandleScope shs(isolate);
StdoutStream os;
DCHECK_EQ(1, args.length());
MaybeObject maybe_object(*args.address_of_arg_at(0));
if (!maybe_object.IsCleared()) {
Object object = maybe_object.GetHeapObjectOrSmi();
size_t pointer;
if (object.ToIntegerIndex(&pointer)) {
MaybeObject from_pointer(static_cast<Address>(pointer));
DebugPrintImpl(from_pointer);
}
}
// We don't allow the converted pointer to leak out to JavaScript.
return args[0]; return args[0];
} }
......
...@@ -460,6 +460,7 @@ namespace internal { ...@@ -460,6 +460,7 @@ namespace internal {
F(ConstructDouble, 2, 1) \ F(ConstructDouble, 2, 1) \
F(ConstructSlicedString, 2, 1) \ F(ConstructSlicedString, 2, 1) \
F(DebugPrint, 1, 1) \ F(DebugPrint, 1, 1) \
F(DebugPrintPtr, 1, 1) \
F(DebugTrace, 0, 1) \ F(DebugTrace, 0, 1) \
F(DebugTrackRetainingPath, -1, 1) \ F(DebugTrackRetainingPath, -1, 1) \
F(DeoptimizeFunction, 1, 1) \ F(DeoptimizeFunction, 1, 1) \
......
Markdown is supported
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