Commit 3ce662f4 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Make MentionedObjectCache GC-safe

This changes DebugObjectCache to be a vector of Handles rather than
tagged pointers, meaning it's not GC-safe.

This will allow PrintStack to allocate memory if required (if for
instance source positions must be regenerated).

Bug: v8:8834, v8:8510
Change-Id: Ieec9a827af9abbcb9b5b237d79984eedf0cdcc57
Reviewed-on: https://chromium-review.googlesource.com/c/1494755Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59952}
parent 8d940b91
...@@ -1241,8 +1241,6 @@ static void PrintFrames(Isolate* isolate, ...@@ -1241,8 +1241,6 @@ static void PrintFrames(Isolate* isolate,
} }
void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) { void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) {
// The MentionedObjectCache is not GC-proof at the moment.
DisallowHeapAllocation no_gc;
HandleScope scope(this); HandleScope scope(this);
DCHECK(accumulator->IsMentionedObjectCacheClear(this)); DCHECK(accumulator->IsMentionedObjectCacheClear(this));
......
...@@ -357,7 +357,7 @@ V8_EXPORT_PRIVATE void FreeCurrentEmbeddedBlob(); ...@@ -357,7 +357,7 @@ V8_EXPORT_PRIVATE void FreeCurrentEmbeddedBlob();
V(int, suffix_table, (kBMMaxShift + 1)) \ V(int, suffix_table, (kBMMaxShift + 1)) \
ISOLATE_INIT_DEBUG_ARRAY_LIST(V) ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
typedef std::vector<HeapObject> DebugObjectCache; using DebugObjectCache = std::vector<Handle<HeapObject>>;
#define ISOLATE_INIT_LIST(V) \ #define ISOLATE_INIT_LIST(V) \
/* Assembler state. */ \ /* Assembler state. */ \
......
...@@ -190,17 +190,18 @@ void StringStream::PrintObject(Object o) { ...@@ -190,17 +190,18 @@ void StringStream::PrintObject(Object o) {
if (o->IsHeapObject() && object_print_mode_ == kPrintObjectVerbose) { if (o->IsHeapObject() && object_print_mode_ == kPrintObjectVerbose) {
// TODO(delphick): Consider whether we can get the isolate without using // TODO(delphick): Consider whether we can get the isolate without using
// TLS. // TLS.
Isolate* isolate = Isolate::Current();
DebugObjectCache* debug_object_cache = DebugObjectCache* debug_object_cache =
Isolate::Current()->string_stream_debug_object_cache(); isolate->string_stream_debug_object_cache();
for (size_t i = 0; i < debug_object_cache->size(); i++) { for (size_t i = 0; i < debug_object_cache->size(); i++) {
if ((*debug_object_cache)[i] == o) { if (*(*debug_object_cache)[i] == o) {
Add("#%d#", static_cast<int>(i)); Add("#%d#", static_cast<int>(i));
return; return;
} }
} }
if (debug_object_cache->size() < kMentionedObjectCacheMaxSize) { if (debug_object_cache->size() < kMentionedObjectCacheMaxSize) {
Add("#%d#", static_cast<int>(debug_object_cache->size())); Add("#%d#", static_cast<int>(debug_object_cache->size()));
debug_object_cache->push_back(HeapObject::cast(o)); debug_object_cache->push_back(handle(HeapObject::cast(o), isolate));
} else { } else {
Add("@%p", o); Add("@%p", o);
} }
...@@ -364,7 +365,7 @@ void StringStream::PrintMentionedObjectCache(Isolate* isolate) { ...@@ -364,7 +365,7 @@ void StringStream::PrintMentionedObjectCache(Isolate* isolate) {
isolate->string_stream_debug_object_cache(); isolate->string_stream_debug_object_cache();
Add("==== Key ============================================\n\n"); Add("==== Key ============================================\n\n");
for (size_t i = 0; i < debug_object_cache->size(); i++) { for (size_t i = 0; i < debug_object_cache->size(); i++) {
HeapObject printee = (*debug_object_cache)[i]; HeapObject printee = *(*debug_object_cache)[i];
Add(" #%d# %p: ", static_cast<int>(i), Add(" #%d# %p: ", static_cast<int>(i),
reinterpret_cast<void*>(printee->ptr())); reinterpret_cast<void*>(printee->ptr()));
printee->ShortPrint(this); printee->ShortPrint(this);
......
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