[heap-profiler] Names for JSGeneratorObject-fields

Add names for fields in JSGeneratorObjects in Heap Snapshot
Generator.

Bug: chromium:854097
Change-Id: I075acf0821c9d002535b4fdc4ce4ddbb2fc9627c
Reviewed-on: https://chromium-review.googlesource.com/1148387
Commit-Queue: Dominik Inführ <dinfuehr@google.com>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54652}
This commit is contained in:
Dominik Inführ 2018-07-24 16:05:02 +02:00 committed by Commit Bot
parent 743de156fb
commit 956ac1bd15
4 changed files with 48 additions and 0 deletions

View File

@ -692,6 +692,7 @@ class FixedArrayBase;
class PropertyArray;
class FunctionLiteral;
class FunctionTemplateInfo;
class JSGeneratorObject;
class JSAsyncGeneratorObject;
class JSGlobalObject;
class JSGlobalProxy;

View File

@ -17,6 +17,7 @@
#include "src/objects/api-callbacks.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-generator-inl.h"
#include "src/objects/js-promise-inl.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/literal-objects-inl.h"
@ -854,6 +855,8 @@ void V8HeapExplorer::ExtractReferences(int entry, HeapObject* obj) {
ExtractJSCollectionReferences(entry, JSMap::cast(obj));
} else if (obj->IsJSPromise()) {
ExtractJSPromiseReferences(entry, JSPromise::cast(obj));
} else if (obj->IsJSGeneratorObject()) {
ExtractJSGeneratorObjectReferences(entry, JSGeneratorObject::cast(obj));
}
ExtractJSObjectReferences(entry, JSObject::cast(obj));
} else if (obj->IsString()) {
@ -1356,6 +1359,19 @@ void V8HeapExplorer::ExtractJSPromiseReferences(int entry, JSPromise* promise) {
JSPromise::kReactionsOrResultOffset);
}
void V8HeapExplorer::ExtractJSGeneratorObjectReferences(
int entry, JSGeneratorObject* generator) {
SetInternalReference(generator, entry, "function", generator->function(),
JSGeneratorObject::kFunctionOffset);
SetInternalReference(generator, entry, "context", generator->context(),
JSGeneratorObject::kContextOffset);
SetInternalReference(generator, entry, "receiver", generator->receiver(),
JSGeneratorObject::kReceiverOffset);
SetInternalReference(generator, entry, "parameters_and_registers",
generator->parameters_and_registers(),
JSGeneratorObject::kParametersAndRegistersOffset);
}
void V8HeapExplorer::ExtractFixedArrayReferences(int entry, FixedArray* array) {
for (int i = 0, l = array->length(); i < l; ++i) {
DCHECK(!HasWeakHeapObjectTag(array->get(i)));

View File

@ -392,6 +392,8 @@ class V8HeapExplorer : public HeapEntriesAllocator {
int entry, ArrayBoilerplateDescription* value);
void ExtractJSArrayBufferReferences(int entry, JSArrayBuffer* buffer);
void ExtractJSPromiseReferences(int entry, JSPromise* promise);
void ExtractJSGeneratorObjectReferences(int entry,
JSGeneratorObject* generator);
void ExtractFixedArrayReferences(int entry, FixedArray* array);
void ExtractFeedbackVectorReferences(int entry,
FeedbackVector* feedback_vector);

View File

@ -2134,6 +2134,35 @@ TEST(AccessorInfo) {
CHECK(setter);
}
TEST(JSGeneratorObject) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext env;
v8::HandleScope scope(isolate);
v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
CompileRun(
"function* foo() { yield 1; }\n"
"g = foo();\n");
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* g =
GetProperty(isolate, global, v8::HeapGraphEdge::kProperty, "g");
CHECK(g);
const v8::HeapGraphNode* function = GetProperty(
env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, "function");
CHECK(function);
const v8::HeapGraphNode* context = GetProperty(
env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, "context");
CHECK(context);
const v8::HeapGraphNode* receiver = GetProperty(
env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, "receiver");
CHECK(receiver);
const v8::HeapGraphNode* parameters_and_registers =
GetProperty(env->GetIsolate(), g, v8::HeapGraphEdge::kInternal,
"parameters_and_registers");
CHECK(parameters_and_registers);
}
bool HasWeakEdge(const v8::HeapGraphNode* node) {
for (int i = 0; i < node->GetChildrenCount(); ++i) {