Commit 771ba7ae authored by yurys@chromium.org's avatar yurys@chromium.org

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
parent 3f1ea190
...@@ -2182,16 +2182,31 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { ...@@ -2182,16 +2182,31 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
switch (descs->GetType(i)) { switch (descs->GetType(i)) {
case FIELD: { case FIELD: {
int index = descs->GetFieldIndex(i); int index = descs->GetFieldIndex(i);
String* k = descs->GetKey(i);
if (index < js_obj->map()->inobject_properties()) { if (index < js_obj->map()->inobject_properties()) {
SetPropertyReference( Object* value = js_obj->InObjectPropertyAt(index);
js_obj, entry, if (k != heap_->hidden_symbol()) {
descs->GetKey(i), js_obj->InObjectPropertyAt(index), SetPropertyReference(
NULL, js_obj, entry,
js_obj->GetInObjectPropertyOffset(index)); k, value,
NULL,
js_obj->GetInObjectPropertyOffset(index));
} else {
TagObject(value, "(hidden properties)");
SetInternalReference(
js_obj, entry,
"hidden_properties", value,
js_obj->GetInObjectPropertyOffset(index));
}
} else { } else {
SetPropertyReference( Object* value = js_obj->FastPropertyAt(index);
js_obj, entry, if (k != heap_->hidden_symbol()) {
descs->GetKey(i), js_obj->FastPropertyAt(index)); SetPropertyReference(js_obj, entry, k, value);
} else {
TagObject(value, "(hidden properties)");
SetInternalReference(js_obj, entry, "hidden_properties", value);
}
} }
break; break;
} }
...@@ -2237,7 +2252,7 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { ...@@ -2237,7 +2252,7 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
Object* value = target->IsJSGlobalPropertyCell() Object* value = target->IsJSGlobalPropertyCell()
? JSGlobalPropertyCell::cast(target)->value() ? JSGlobalPropertyCell::cast(target)->value()
: target; : target;
if (String::cast(k)->length() > 0) { if (k != heap_->hidden_symbol()) {
SetPropertyReference(js_obj, entry, String::cast(k), value); SetPropertyReference(js_obj, entry, String::cast(k), value);
} else { } else {
TagObject(value, "(hidden properties)"); TagObject(value, "(hidden properties)");
......
...@@ -1449,6 +1449,36 @@ TEST(FastCaseGetter) { ...@@ -1449,6 +1449,36 @@ TEST(FastCaseGetter) {
CHECK_NE(NULL, setterFunction); 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) { bool HasWeakEdge(const v8::HeapGraphNode* node) {
for (int i = 0; i < node->GetChildrenCount(); ++i) { for (int i = 0; i < node->GetChildrenCount(); ++i) {
......
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