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

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

Issue 155723005: A64: Synchronize with r19001. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « test/cctest/test-heap.cc ('k') | test/intl/string/normalization.js » ('j') | 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 CHECK_EQ("", *anonymous_name); 337 CHECK_EQ("", *anonymous_name);
338 338
339 // Find references to code. 339 // Find references to code.
340 const v8::HeapGraphNode* compiled_code = 340 const v8::HeapGraphNode* compiled_code =
341 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared"); 341 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared");
342 CHECK_NE(NULL, compiled_code); 342 CHECK_NE(NULL, compiled_code);
343 const v8::HeapGraphNode* lazy_code = 343 const v8::HeapGraphNode* lazy_code =
344 GetProperty(lazy, v8::HeapGraphEdge::kInternal, "shared"); 344 GetProperty(lazy, v8::HeapGraphEdge::kInternal, "shared");
345 CHECK_NE(NULL, lazy_code); 345 CHECK_NE(NULL, lazy_code);
346 346
347 // Check that there's no strong next_code_link. There might be a weak one
348 // but might be not, so we can't check that fact.
349 const v8::HeapGraphNode* code =
350 GetProperty(compiled_code, v8::HeapGraphEdge::kInternal, "code");
351 CHECK_NE(NULL, code);
352 const v8::HeapGraphNode* next_code_link =
353 GetProperty(code, v8::HeapGraphEdge::kInternal, "code");
354 CHECK_EQ(NULL, next_code_link);
355
347 // Verify that non-compiled code doesn't contain references to "x" 356 // Verify that non-compiled code doesn't contain references to "x"
348 // literal, while compiled code does. The scope info is stored in FixedArray 357 // literal, while compiled code does. The scope info is stored in FixedArray
349 // objects attached to the SharedFunctionInfo. 358 // objects attached to the SharedFunctionInfo.
350 bool compiled_references_x = false, lazy_references_x = false; 359 bool compiled_references_x = false, lazy_references_x = false;
351 for (int i = 0, count = compiled_code->GetChildrenCount(); i < count; ++i) { 360 for (int i = 0, count = compiled_code->GetChildrenCount(); i < count; ++i) {
352 const v8::HeapGraphEdge* prop = compiled_code->GetChild(i); 361 const v8::HeapGraphEdge* prop = compiled_code->GetChild(i);
353 const v8::HeapGraphNode* node = prop->GetToNode(); 362 const v8::HeapGraphNode* node = prop->GetToNode();
354 if (node->GetType() == v8::HeapGraphNode::kArray) { 363 if (node->GetType() == v8::HeapGraphNode::kArray) {
355 if (HasString(node, "x")) { 364 if (HasString(node, "x")) {
356 compiled_references_x = true; 365 compiled_references_x = true;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 CHECK(ValidateSnapshot(snapshot)); 739 CHECK(ValidateSnapshot(snapshot));
731 740
732 TestJSONStream stream; 741 TestJSONStream stream;
733 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); 742 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON);
734 CHECK_GT(stream.size(), 0); 743 CHECK_GT(stream.size(), 0);
735 CHECK_EQ(1, stream.eos_signaled()); 744 CHECK_EQ(1, stream.eos_signaled());
736 i::ScopedVector<char> json(stream.size()); 745 i::ScopedVector<char> json(stream.size());
737 stream.WriteTo(json); 746 stream.WriteTo(json);
738 747
739 // Verify that snapshot string is valid JSON. 748 // Verify that snapshot string is valid JSON.
740 AsciiResource json_res(json); 749 AsciiResource* json_res = new AsciiResource(json);
741 v8::Local<v8::String> json_string = 750 v8::Local<v8::String> json_string =
742 v8::String::NewExternal(env->GetIsolate(), &json_res); 751 v8::String::NewExternal(env->GetIsolate(), json_res);
743 env->Global()->Set(v8_str("json_snapshot"), json_string); 752 env->Global()->Set(v8_str("json_snapshot"), json_string);
744 v8::Local<v8::Value> snapshot_parse_result = CompileRun( 753 v8::Local<v8::Value> snapshot_parse_result = CompileRun(
745 "var parsed = JSON.parse(json_snapshot); true;"); 754 "var parsed = JSON.parse(json_snapshot); true;");
746 CHECK(!snapshot_parse_result.IsEmpty()); 755 CHECK(!snapshot_parse_result.IsEmpty());
747 756
748 // Verify that snapshot object has required fields. 757 // Verify that snapshot object has required fields.
749 v8::Local<v8::Object> parsed_snapshot = 758 v8::Local<v8::Object> parsed_snapshot =
750 env->Global()->Get(v8_str("parsed"))->ToObject(); 759 env->Global()->Get(v8_str("parsed"))->ToObject();
751 CHECK(parsed_snapshot->Has(v8_str("snapshot"))); 760 CHECK(parsed_snapshot->Has(v8_str("snapshot")));
752 CHECK(parsed_snapshot->Has(v8_str("nodes"))); 761 CHECK(parsed_snapshot->Has(v8_str("nodes")));
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 &name_resolver); 1530 &name_resolver);
1522 CHECK(ValidateSnapshot(snapshot)); 1531 CHECK(ValidateSnapshot(snapshot));
1523 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1532 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1524 CHECK_NE(NULL, global); 1533 CHECK_NE(NULL, global);
1525 CHECK_EQ("Object / Global object name" , 1534 CHECK_EQ("Object / Global object name" ,
1526 const_cast<i::HeapEntry*>( 1535 const_cast<i::HeapEntry*>(
1527 reinterpret_cast<const i::HeapEntry*>(global))->name()); 1536 reinterpret_cast<const i::HeapEntry*>(global))->name());
1528 } 1537 }
1529 1538
1530 1539
1540 TEST(GlobalObjectFields) {
1541 LocalContext env;
1542 v8::HandleScope scope(env->GetIsolate());
1543 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1544 CompileRun("obj = {};");
1545 const v8::HeapSnapshot* snapshot =
1546 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1547 CHECK(ValidateSnapshot(snapshot));
1548 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1549 const v8::HeapGraphNode* builtins =
1550 GetProperty(global, v8::HeapGraphEdge::kInternal, "builtins");
1551 CHECK_NE(NULL, builtins);
1552 const v8::HeapGraphNode* native_context =
1553 GetProperty(global, v8::HeapGraphEdge::kInternal, "native_context");
1554 CHECK_NE(NULL, native_context);
1555 const v8::HeapGraphNode* global_context =
1556 GetProperty(global, v8::HeapGraphEdge::kInternal, "global_context");
1557 CHECK_NE(NULL, global_context);
1558 const v8::HeapGraphNode* global_receiver =
1559 GetProperty(global, v8::HeapGraphEdge::kInternal, "global_receiver");
1560 CHECK_NE(NULL, global_receiver);
1561 }
1562
1563
1531 TEST(NoHandleLeaks) { 1564 TEST(NoHandleLeaks) {
1532 LocalContext env; 1565 LocalContext env;
1533 v8::HandleScope scope(env->GetIsolate()); 1566 v8::HandleScope scope(env->GetIsolate());
1534 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1567 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1535 1568
1536 CompileRun("document = { URL:\"abcdefgh\" };"); 1569 CompileRun("document = { URL:\"abcdefgh\" };");
1537 1570
1538 v8::Handle<v8::String> name(v8_str("leakz")); 1571 v8::Handle<v8::String> name(v8_str("leakz"));
1539 i::Isolate* isolate = CcTest::i_isolate(); 1572 i::Isolate* isolate = CcTest::i_isolate();
1540 int count_before = i::HandleScope::NumberOfHandles(isolate); 1573 int count_before = i::HandleScope::NumberOfHandles(isolate);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 const char* stub_path[] = { 2139 const char* stub_path[] = {
2107 "::(GC roots)", 2140 "::(GC roots)",
2108 "::(Strong roots)", 2141 "::(Strong roots)",
2109 "code_stubs::", 2142 "code_stubs::",
2110 "::(ArraySingleArgumentConstructorStub code)" 2143 "::(ArraySingleArgumentConstructorStub code)"
2111 }; 2144 };
2112 const v8::HeapGraphNode* node = GetNodeByPath(snapshot, 2145 const v8::HeapGraphNode* node = GetNodeByPath(snapshot,
2113 stub_path, ARRAY_SIZE(stub_path)); 2146 stub_path, ARRAY_SIZE(stub_path));
2114 CHECK_NE(NULL, node); 2147 CHECK_NE(NULL, node);
2115 2148
2116 const char* builtin_path[] = { 2149 const char* builtin_path1[] = {
2117 "::(GC roots)", 2150 "::(GC roots)",
2118 "::(Builtins)", 2151 "::(Builtins)",
2119 "::(KeyedLoadIC_Generic code)" 2152 "::(KeyedLoadIC_Generic builtin)"
2120 }; 2153 };
2121 node = GetNodeByPath(snapshot, builtin_path, ARRAY_SIZE(builtin_path)); 2154 node = GetNodeByPath(snapshot, builtin_path1, ARRAY_SIZE(builtin_path1));
2122 CHECK_NE(NULL, node); 2155 CHECK_NE(NULL, node);
2156
2157 const char* builtin_path2[] = {
2158 "::(GC roots)",
2159 "::(Builtins)",
2160 "::(CompileUnoptimized builtin)"
2161 };
2162 node = GetNodeByPath(snapshot, builtin_path2, ARRAY_SIZE(builtin_path2));
2163 CHECK_NE(NULL, node);
2164 v8::String::Utf8Value node_name(node->GetName());
2165 CHECK_EQ("(CompileUnoptimized builtin)", *node_name);
2123 } 2166 }
2124 2167
2125 2168
2126 static const char* record_trace_tree_source = 2169 static const char* record_trace_tree_source =
2127 "var topFunctions = [];\n" 2170 "var topFunctions = [];\n"
2128 "var global = this;\n" 2171 "var global = this;\n"
2129 "function generateFunctions(width, depth) {\n" 2172 "function generateFunctions(width, depth) {\n"
2130 " var script = [];\n" 2173 " var script = [];\n"
2131 " for (var i = 0; i < width; i++) {\n" 2174 " for (var i = 0; i < width; i++) {\n"
2132 " for (var j = 0; j < depth; j++) {\n" 2175 " for (var j = 0; j < depth; j++) {\n"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 const v8::HeapGraphNode* arr1_obj = 2376 const v8::HeapGraphNode* arr1_obj =
2334 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1"); 2377 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1");
2335 CHECK_NE(NULL, arr1_obj); 2378 CHECK_NE(NULL, arr1_obj);
2336 const v8::HeapGraphNode* arr1_buffer = 2379 const v8::HeapGraphNode* arr1_buffer =
2337 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); 2380 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer");
2338 CHECK_NE(NULL, arr1_buffer); 2381 CHECK_NE(NULL, arr1_buffer);
2339 const v8::HeapGraphNode* first_view = 2382 const v8::HeapGraphNode* first_view =
2340 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); 2383 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view");
2341 CHECK_NE(NULL, first_view); 2384 CHECK_NE(NULL, first_view);
2342 } 2385 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/intl/string/normalization.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698