Report "hidden properties" in heap profiler for properties case

BUG=v8:2212
TEST=cctest/test-heap-profiler/HiddenPropertiesFastCase
Review URL: https://chromiumcodereview.appspot.com/10692058

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11966 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yurys@chromium.org 2012-07-02 12:46:31 +00:00
parent 3f1ea190fc
commit 771ba7ae99
2 changed files with 54 additions and 9 deletions

View File

@ -2182,16 +2182,31 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
switch (descs->GetType(i)) {
case FIELD: {
int index = descs->GetFieldIndex(i);
String* k = descs->GetKey(i);
if (index < js_obj->map()->inobject_properties()) {
SetPropertyReference(
js_obj, entry,
descs->GetKey(i), js_obj->InObjectPropertyAt(index),
NULL,
js_obj->GetInObjectPropertyOffset(index));
Object* value = js_obj->InObjectPropertyAt(index);
if (k != heap_->hidden_symbol()) {
SetPropertyReference(
js_obj, entry,
k, value,
NULL,
js_obj->GetInObjectPropertyOffset(index));
} else {
TagObject(value, "(hidden properties)");
SetInternalReference(
js_obj, entry,
"hidden_properties", value,
js_obj->GetInObjectPropertyOffset(index));
}
} else {
SetPropertyReference(
js_obj, entry,
descs->GetKey(i), js_obj->FastPropertyAt(index));
Object* value = js_obj->FastPropertyAt(index);
if (k != heap_->hidden_symbol()) {
SetPropertyReference(js_obj, entry, k, value);
} else {
TagObject(value, "(hidden properties)");
SetInternalReference(js_obj, entry, "hidden_properties", value);
}
}
break;
}
@ -2237,7 +2252,7 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
Object* value = target->IsJSGlobalPropertyCell()
? JSGlobalPropertyCell::cast(target)->value()
: target;
if (String::cast(k)->length() > 0) {
if (k != heap_->hidden_symbol()) {
SetPropertyReference(js_obj, entry, String::cast(k), value);
} else {
TagObject(value, "(hidden properties)");

View File

@ -1449,6 +1449,36 @@ TEST(FastCaseGetter) {
CHECK_NE(NULL, setterFunction);
}
TEST(HiddenPropertiesFastCase) {
v8::HandleScope scope;
LocalContext env;
CompileRun(
"function C(x) { this.a = this; this.b = x; }\n"
"c = new C(2012);\n");
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8_str("HiddenPropertiesFastCase1"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* c =
GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
CHECK_NE(NULL, c);
const v8::HeapGraphNode* hidden_props =
GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties");
CHECK_EQ(NULL, hidden_props);
v8::Handle<v8::Value> cHandle = env->Global()->Get(v8::String::New("c"));
CHECK(!cHandle.IsEmpty() && cHandle->IsObject());
cHandle->ToObject()->GetIdentityHash();
snapshot = v8::HeapProfiler::TakeSnapshot(
v8_str("HiddenPropertiesFastCase2"));
global = GetGlobalObject(snapshot);
c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
CHECK_NE(NULL, c);
hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal,
"hidden_properties");
CHECK_NE(NULL, hidden_props);
}
bool HasWeakEdge(const v8::HeapGraphNode* node) {
for (int i = 0; i < node->GetChildrenCount(); ++i) {