Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 98633009: Delete v8::HeapGraphNode::GetHeapValue (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Deleted the method instead of deprecating it. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 const int nodes_count = snapshot->GetNodesCount(); 1555 const int nodes_count = snapshot->GetNodesCount();
1556 int count = 0; 1556 int count = 0;
1557 for (int i = 0; i < nodes_count; ++i) { 1557 for (int i = 0; i < nodes_count; ++i) {
1558 if (snapshot->GetNode(i) == global) 1558 if (snapshot->GetNode(i) == global)
1559 ++count; 1559 ++count;
1560 } 1560 }
1561 CHECK_EQ(1, count); 1561 CHECK_EQ(1, count);
1562 } 1562 }
1563 1563
1564 1564
1565 TEST(GetHeapValue) { 1565 TEST(GetHeapValueForNode) {
1566 LocalContext env; 1566 LocalContext env;
1567 v8::HandleScope scope(env->GetIsolate()); 1567 v8::HandleScope scope(env->GetIsolate());
1568 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1568 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1569 1569
1570 CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };"); 1570 CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };");
1571 const v8::HeapSnapshot* snapshot = 1571 const v8::HeapSnapshot* snapshot =
1572 heap_profiler->TakeHeapSnapshot(v8_str("value")); 1572 heap_profiler->TakeHeapSnapshot(v8_str("value"));
1573 CHECK(ValidateSnapshot(snapshot)); 1573 CHECK(ValidateSnapshot(snapshot));
1574 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1574 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1575 CHECK(global->GetHeapValue()->IsObject()); 1575 CHECK(heap_profiler->FindObjectById(global->GetId())->IsObject());
1576 v8::Local<v8::Object> js_global = 1576 v8::Local<v8::Object> js_global =
1577 env->Global()->GetPrototype().As<v8::Object>(); 1577 env->Global()->GetPrototype().As<v8::Object>();
1578 CHECK(js_global == global->GetHeapValue()); 1578 CHECK(js_global == heap_profiler->FindObjectById(global->GetId()));
1579 const v8::HeapGraphNode* obj = GetProperty( 1579 const v8::HeapGraphNode* obj = GetProperty(
1580 global, v8::HeapGraphEdge::kProperty, "a"); 1580 global, v8::HeapGraphEdge::kProperty, "a");
1581 CHECK(obj->GetHeapValue()->IsObject()); 1581 CHECK(heap_profiler->FindObjectById(obj->GetId())->IsObject());
1582 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); 1582 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>();
1583 CHECK(js_obj == obj->GetHeapValue()); 1583 CHECK(js_obj == heap_profiler->FindObjectById(obj->GetId()));
1584 const v8::HeapGraphNode* s_prop = 1584 const v8::HeapGraphNode* s_prop =
1585 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); 1585 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop");
1586 v8::Local<v8::String> js_s_prop = 1586 v8::Local<v8::String> js_s_prop =
1587 js_obj->Get(v8_str("s_prop")).As<v8::String>(); 1587 js_obj->Get(v8_str("s_prop")).As<v8::String>();
1588 CHECK(js_s_prop == s_prop->GetHeapValue()); 1588 CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->GetId()));
1589 const v8::HeapGraphNode* n_prop = 1589 const v8::HeapGraphNode* n_prop =
1590 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); 1590 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop");
1591 v8::Local<v8::Number> js_n_prop = 1591 v8::Local<v8::Number> js_n_prop =
1592 js_obj->Get(v8_str("n_prop")).As<v8::Number>(); 1592 js_obj->Get(v8_str("n_prop")).As<v8::Number>();
1593 CHECK(js_n_prop->NumberValue() == n_prop->GetHeapValue()->NumberValue()); 1593 CHECK(js_n_prop->NumberValue() ==
1594 heap_profiler->FindObjectById(n_prop->GetId())->NumberValue());
1594 } 1595 }
1595 1596
1596 1597
1597 TEST(GetHeapValueForDeletedObject) { 1598 TEST(GetHeapValueForDeletedObject) {
1598 LocalContext env; 1599 LocalContext env;
1599 v8::HandleScope scope(env->GetIsolate()); 1600 v8::HandleScope scope(env->GetIsolate());
1600 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1601 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1601 1602
1602 // It is impossible to delete a global property, so we are about to delete a 1603 // It is impossible to delete a global property, so we are about to delete a
1603 // property of the "a" object. Also, the "p" object can't be an empty one 1604 // property of the "a" object. Also, the "p" object can't be an empty one
1604 // because the empty object is static and isn't actually deleted. 1605 // because the empty object is static and isn't actually deleted.
1605 CompileRun("a = { p: { r: {} } };"); 1606 CompileRun("a = { p: { r: {} } };");
1606 const v8::HeapSnapshot* snapshot = 1607 const v8::HeapSnapshot* snapshot =
1607 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 1608 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1608 CHECK(ValidateSnapshot(snapshot)); 1609 CHECK(ValidateSnapshot(snapshot));
1609 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1610 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1610 const v8::HeapGraphNode* obj = GetProperty( 1611 const v8::HeapGraphNode* obj = GetProperty(
1611 global, v8::HeapGraphEdge::kProperty, "a"); 1612 global, v8::HeapGraphEdge::kProperty, "a");
1612 const v8::HeapGraphNode* prop = GetProperty( 1613 const v8::HeapGraphNode* prop = GetProperty(
1613 obj, v8::HeapGraphEdge::kProperty, "p"); 1614 obj, v8::HeapGraphEdge::kProperty, "p");
1614 { 1615 {
1615 // Perform the check inside a nested local scope to avoid creating a 1616 // Perform the check inside a nested local scope to avoid creating a
1616 // reference to the object we are deleting. 1617 // reference to the object we are deleting.
1617 v8::HandleScope scope(env->GetIsolate()); 1618 v8::HandleScope scope(env->GetIsolate());
1618 CHECK(prop->GetHeapValue()->IsObject()); 1619 CHECK(heap_profiler->FindObjectById(prop->GetId())->IsObject());
1619 } 1620 }
1620 CompileRun("delete a.p;"); 1621 CompileRun("delete a.p;");
1621 CHECK(prop->GetHeapValue()->IsUndefined()); 1622 CHECK(heap_profiler->FindObjectById(prop->GetId()).IsEmpty());
1622 } 1623 }
1623 1624
1624 1625
1625 static int StringCmp(const char* ref, i::String* act) { 1626 static int StringCmp(const char* ref, i::String* act) {
1626 i::SmartArrayPointer<char> s_act = act->ToCString(); 1627 i::SmartArrayPointer<char> s_act = act->ToCString();
1627 int result = strcmp(ref, s_act.get()); 1628 int result = strcmp(ref, s_act.get());
1628 if (result != 0) 1629 if (result != 0)
1629 fprintf(stderr, "Expected: \"%s\", Actual: \"%s\"\n", ref, s_act.get()); 1630 fprintf(stderr, "Expected: \"%s\", Actual: \"%s\"\n", ref, s_act.get());
1630 return result; 1631 return result;
1631 } 1632 }
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 "transition_info"); 2026 "transition_info");
2026 CHECK_NE(NULL, transition_info); 2027 CHECK_NE(NULL, transition_info);
2027 2028
2028 const v8::HeapGraphNode* elements = 2029 const v8::HeapGraphNode* elements =
2029 GetProperty(transition_info, v8::HeapGraphEdge::kInternal, 2030 GetProperty(transition_info, v8::HeapGraphEdge::kInternal,
2030 "elements"); 2031 "elements");
2031 CHECK_NE(NULL, elements); 2032 CHECK_NE(NULL, elements);
2032 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType()); 2033 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType());
2033 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize()); 2034 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize());
2034 2035
2035 CHECK(transition_info->GetHeapValue()->IsArray()); 2036 v8::Handle<v8::Value> array_val =
2036 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast( 2037 heap_profiler->FindObjectById(transition_info->GetId());
2037 transition_info->GetHeapValue()); 2038 CHECK(array_val->IsArray());
2039 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(array_val);
2038 // Verify the array is "a" in the code above. 2040 // Verify the array is "a" in the code above.
2039 CHECK_EQ(3, array->Length()); 2041 CHECK_EQ(3, array->Length());
2040 CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0))); 2042 CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0)));
2041 CHECK_EQ(v8::Integer::New(2), array->Get(v8::Integer::New(1))); 2043 CHECK_EQ(v8::Integer::New(2), array->Get(v8::Integer::New(1)));
2042 CHECK_EQ(v8::Integer::New(1), array->Get(v8::Integer::New(2))); 2044 CHECK_EQ(v8::Integer::New(1), array->Get(v8::Integer::New(2)));
2043 } 2045 }
2044 2046
2045 2047
2046 TEST(JSFunctionHasCodeLink) { 2048 TEST(JSFunctionHasCodeLink) {
2047 LocalContext env; 2049 LocalContext env;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 2356
2355 AllocationTraceNode* node = 2357 AllocationTraceNode* node =
2356 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); 2358 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
2357 CHECK_NE(NULL, node); 2359 CHECK_NE(NULL, node);
2358 CHECK_LT(node->allocation_count(), 100); 2360 CHECK_LT(node->allocation_count(), 100);
2359 2361
2360 CcTest::heap()->DisableInlineAllocation(); 2362 CcTest::heap()->DisableInlineAllocation();
2361 heap_profiler->StopTrackingHeapObjects(); 2363 heap_profiler->StopTrackingHeapObjects();
2362 } 2364 }
2363 } 2365 }
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698