[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/1494755 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#59952}
This commit is contained in:
parent
8d940b913a
commit
3ce662f4e6
@ -1241,8 +1241,6 @@ static void PrintFrames(Isolate* isolate,
|
||||
}
|
||||
|
||||
void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) {
|
||||
// The MentionedObjectCache is not GC-proof at the moment.
|
||||
DisallowHeapAllocation no_gc;
|
||||
HandleScope scope(this);
|
||||
DCHECK(accumulator->IsMentionedObjectCacheClear(this));
|
||||
|
||||
|
@ -357,7 +357,7 @@ V8_EXPORT_PRIVATE void FreeCurrentEmbeddedBlob();
|
||||
V(int, suffix_table, (kBMMaxShift + 1)) \
|
||||
ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
|
||||
|
||||
typedef std::vector<HeapObject> DebugObjectCache;
|
||||
using DebugObjectCache = std::vector<Handle<HeapObject>>;
|
||||
|
||||
#define ISOLATE_INIT_LIST(V) \
|
||||
/* Assembler state. */ \
|
||||
|
@ -190,17 +190,18 @@ void StringStream::PrintObject(Object o) {
|
||||
if (o->IsHeapObject() && object_print_mode_ == kPrintObjectVerbose) {
|
||||
// TODO(delphick): Consider whether we can get the isolate without using
|
||||
// TLS.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
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++) {
|
||||
if ((*debug_object_cache)[i] == o) {
|
||||
if (*(*debug_object_cache)[i] == o) {
|
||||
Add("#%d#", static_cast<int>(i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (debug_object_cache->size() < kMentionedObjectCacheMaxSize) {
|
||||
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 {
|
||||
Add("@%p", o);
|
||||
}
|
||||
@ -364,7 +365,7 @@ void StringStream::PrintMentionedObjectCache(Isolate* isolate) {
|
||||
isolate->string_stream_debug_object_cache();
|
||||
Add("==== Key ============================================\n\n");
|
||||
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),
|
||||
reinterpret_cast<void*>(printee->ptr()));
|
||||
printee->ShortPrint(this);
|
||||
|
Loading…
Reference in New Issue
Block a user