Add Box object to heap profiler.

LOG=Y
R=ulan@chromium.org, yurys@chromium.org

Review URL: https://codereview.chromium.org/143343006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19063 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
alph@chromium.org 2014-02-04 11:43:19 +00:00
parent 2794955852
commit efee3b8608
3 changed files with 37 additions and 0 deletions

View File

@ -1047,6 +1047,8 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
ExtractCodeCacheReferences(entry, CodeCache::cast(obj));
} else if (obj->IsCode()) {
ExtractCodeReferences(entry, Code::cast(obj));
} else if (obj->IsBox()) {
ExtractBoxReferences(entry, Box::cast(obj));
} else if (obj->IsCell()) {
ExtractCellReferences(entry, Cell::cast(obj));
} else if (obj->IsPropertyCell()) {
@ -1417,6 +1419,11 @@ void V8HeapExplorer::ExtractCodeReferences(int entry, Code* code) {
}
void V8HeapExplorer::ExtractBoxReferences(int entry, Box* box) {
SetInternalReference(box, entry, "value", box->value(), Box::kValueOffset);
}
void V8HeapExplorer::ExtractCellReferences(int entry, Cell* cell) {
SetInternalReference(cell, entry, "value", cell->value(), Cell::kValueOffset);
}

View File

@ -410,6 +410,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void ExtractAccessorPairReferences(int entry, AccessorPair* accessors);
void ExtractCodeCacheReferences(int entry, CodeCache* code_cache);
void ExtractCodeReferences(int entry, Code* code);
void ExtractBoxReferences(int entry, Box* box);
void ExtractCellReferences(int entry, Cell* cell);
void ExtractPropertyCellReferences(int entry, PropertyCell* cell);
void ExtractAllocationSiteReferences(int entry, AllocationSite* site);

View File

@ -2383,3 +2383,32 @@ TEST(ArrayBufferAndArrayBufferView) {
GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view");
CHECK_NE(NULL, first_view);
}
TEST(BoxObject) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
v8::Handle<v8::Object> global_proxy = env->Global();
v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
i::Factory* factory = CcTest::i_isolate()->factory();
i::Handle<i::String> string =
factory->NewStringFromAscii(i::CStrVector("string"));
i::Handle<i::Object> box = factory->NewBox(string);
global->Set(0, v8::ToApiHandle<v8::Object>(box));
v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
const v8::HeapSnapshot* snapshot =
heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
CHECK(ValidateSnapshot(snapshot));
const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
const v8::HeapGraphNode* box_node =
GetProperty(global_node, v8::HeapGraphEdge::kElement, "0");
CHECK_NE(NULL, box_node);
v8::String::Utf8Value box_node_name(box_node->GetName());
CHECK_EQ("system / Box", *box_node_name);
const v8::HeapGraphNode* box_value =
GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value");
CHECK_NE(NULL, box_value);
}