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

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

Issue 18584007: Bugfix: AllocationSite objects need to be walkable by the heap snapshot (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Nit fixin' Created 7 years, 5 months 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 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 // Check all the objects have got their names. 1825 // Check all the objects have got their names.
1826 // ... well check just every 8th because otherwise it's too slow in debug. 1826 // ... well check just every 8th because otherwise it's too slow in debug.
1827 for (int i = 0; i < num_objects - 1; i += 8) { 1827 for (int i = 0; i < num_objects - 1; i += 8) {
1828 i::EmbeddedVector<char, 100> var_name; 1828 i::EmbeddedVector<char, 100> var_name;
1829 i::OS::SNPrintF(var_name, "f_%d", i); 1829 i::OS::SNPrintF(var_name, "f_%d", i);
1830 const v8::HeapGraphNode* f_object = GetProperty( 1830 const v8::HeapGraphNode* f_object = GetProperty(
1831 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1831 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1832 CHECK_NE(NULL, f_object); 1832 CHECK_NE(NULL, f_object);
1833 } 1833 }
1834 } 1834 }
1835
1836
1837 TEST(AllocationSitesAreVisible) {
1838 LocalContext env;
1839 v8::HandleScope scope(env->GetIsolate());
1840 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1841 CompileRun(
1842 "fun = function () { var a = [3, 2, 1]; return a; }\n"
1843 "fun();");
1844 const v8::HeapSnapshot* snapshot =
1845 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1846
1847 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1848 CHECK_NE(NULL, global);
1849 const v8::HeapGraphNode* fun_code =
1850 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun");
1851 CHECK_NE(NULL, fun_code);
1852 const v8::HeapGraphNode* literals =
1853 GetProperty(fun_code, v8::HeapGraphEdge::kInternal, "literals");
1854 CHECK_NE(NULL, literals);
1855 CHECK_EQ(v8::HeapGraphNode::kArray, literals->GetType());
1856 CHECK_EQ(2, literals->GetChildrenCount());
1857
1858 // The second value in the literals array should be the boilerplate,
1859 // after an AllocationSite.
1860 const v8::HeapGraphEdge* prop = literals->GetChild(1);
1861 const v8::HeapGraphNode* allocation_site = prop->GetToNode();
1862 v8::String::Utf8Value name(allocation_site->GetName());
1863 CHECK_EQ("system / AllocationSite", *name);
1864 const v8::HeapGraphNode* transition_info =
1865 GetProperty(allocation_site, v8::HeapGraphEdge::kInternal,
1866 "transition_info");
1867 CHECK_NE(NULL, transition_info);
1868
1869 const v8::HeapGraphNode* elements =
1870 GetProperty(transition_info, v8::HeapGraphEdge::kInternal,
1871 "elements");
1872 CHECK_NE(NULL, elements);
1873 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType());
1874 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize());
1875
1876 CHECK(transition_info->GetHeapValue()->IsArray());
1877 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(
1878 transition_info->GetHeapValue());
1879 // Verify the array is "a" in the code above.
1880 CHECK_EQ(3, array->Length());
1881 CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0)));
1882 CHECK_EQ(v8::Integer::New(2), array->Get(v8::Integer::New(1)));
1883 CHECK_EQ(v8::Integer::New(1), array->Get(v8::Integer::New(2)));
1884 }
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