Commit 22bee2c9 authored by Joyee Cheung's avatar Joyee Cheung Committed by V8 LUCI CQ

[serializer] print reference stack when external reference is unknown

Print the reference stack when V8 is unable to encode an external
reference in debug builds so that it's easier for the embedder
to track the external reference down.

Refs: https://github.com/nodejs/node/pull/38905
Change-Id: Ia86eeb87833d7de0eccc7bc040301c78ddb3240c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2988831Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/master@{#75546}
parent 103f5dbf
......@@ -318,6 +318,23 @@ void Serializer::ResolvePendingForwardReference(int forward_reference_id) {
}
}
ExternalReferenceEncoder::Value Serializer::EncodeExternalReference(
Address addr) {
Maybe<ExternalReferenceEncoder::Value> result =
external_reference_encoder_.TryEncode(addr);
if (result.IsNothing()) {
#ifdef DEBUG
PrintStack(std::cerr);
#endif
void* addr_ptr = reinterpret_cast<void*>(addr);
v8::base::OS::PrintError("Unknown external reference %p.\n", addr_ptr);
v8::base::OS::PrintError("%s\n",
ExternalReferenceTable::ResolveSymbol(addr_ptr));
v8::base::OS::Abort();
}
return result.FromJust();
}
void Serializer::RegisterObjectIsPending(Handle<HeapObject> obj) {
if (*obj == ReadOnlyRoots(isolate()).not_mapped_symbol()) return;
......
......@@ -244,9 +244,8 @@ class Serializer : public SerializerDeserializer {
// Returns true if the given heap object is a bytecode handler code object.
bool ObjectIsBytecodeHandler(Handle<HeapObject> obj) const;
ExternalReferenceEncoder::Value EncodeExternalReference(Address addr) {
return external_reference_encoder_.Encode(addr);
}
ExternalReferenceEncoder::Value EncodeExternalReference(Address addr);
Maybe<ExternalReferenceEncoder::Value> TryEncodeExternalReference(
Address addr) {
return external_reference_encoder_.TryEncode(addr);
......
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