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

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

Issue 1475953002: [stubs] A new approach to TF stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 build Created 5 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
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-object-observe.cc » ('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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool has_A2; 89 bool has_A2;
90 bool has_B2; 90 bool has_B2;
91 bool has_C2; 91 bool has_C2;
92 }; 92 };
93 93
94 } // namespace 94 } // namespace
95 95
96 96
97 static const v8::HeapGraphNode* GetGlobalObject( 97 static const v8::HeapGraphNode* GetGlobalObject(
98 const v8::HeapSnapshot* snapshot) { 98 const v8::HeapSnapshot* snapshot) {
99 CHECK_EQ(3, snapshot->GetRoot()->GetChildrenCount()); 99 CHECK_EQ(2, snapshot->GetRoot()->GetChildrenCount());
100 // The 0th-child is (GC Roots), 1st is code stubs context, 2nd is the user 100 // The 0th-child is (GC Roots), 1st is the user root.
101 // root.
102 const v8::HeapGraphNode* global_obj = 101 const v8::HeapGraphNode* global_obj =
103 snapshot->GetRoot()->GetChild(2)->GetToNode(); 102 snapshot->GetRoot()->GetChild(1)->GetToNode();
104 CHECK_EQ(0, strncmp("Object", const_cast<i::HeapEntry*>( 103 CHECK_EQ(0, strncmp("Object", const_cast<i::HeapEntry*>(
105 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6)); 104 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6));
106 return global_obj; 105 return global_obj;
107 } 106 }
108 107
109 108
110 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, 109 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node,
111 v8::HeapGraphEdge::Type type, 110 v8::HeapGraphEdge::Type type,
112 const char* name) { 111 const char* name) {
113 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { 112 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 int string_index = static_cast<int>( 985 int string_index = static_cast<int>(
987 nodes_array->Get(string_obj_pos + 1)->ToNumber(isolate)->Value()); 986 nodes_array->Get(string_obj_pos + 1)->ToNumber(isolate)->Value());
988 CHECK_GT(string_index, 0); 987 CHECK_GT(string_index, 0);
989 v8::Local<v8::Object> strings_array = 988 v8::Local<v8::Object> strings_array =
990 parsed_snapshot->Get(v8_str("strings"))->ToObject(isolate); 989 parsed_snapshot->Get(v8_str("strings"))->ToObject(isolate);
991 v8::Local<v8::String> string = 990 v8::Local<v8::String> string =
992 strings_array->Get(string_index)->ToString(isolate); 991 strings_array->Get(string_index)->ToString(isolate);
993 v8::Local<v8::String> ref_string = 992 v8::Local<v8::String> ref_string =
994 CompileRun(STRING_LITERAL_FOR_TEST)->ToString(isolate); 993 CompileRun(STRING_LITERAL_FOR_TEST)->ToString(isolate);
995 #undef STRING_LITERAL_FOR_TEST 994 #undef STRING_LITERAL_FOR_TEST
996 CHECK_LT(0, strcmp(*v8::String::Utf8Value(ref_string), 995 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(ref_string),
997 *v8::String::Utf8Value(string))); 996 *v8::String::Utf8Value(string)));
998 } 997 }
999 998
1000 999
1001 TEST(HeapSnapshotJSONSerializationAborting) { 1000 TEST(HeapSnapshotJSONSerializationAborting) {
1002 LocalContext env; 1001 LocalContext env;
1003 v8::HandleScope scope(env->GetIsolate()); 1002 v8::HandleScope scope(env->GetIsolate());
1004 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1003 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1005 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 1004 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
1006 CHECK(ValidateSnapshot(snapshot)); 1005 CHECK(ValidateSnapshot(snapshot));
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 LocalContext env; 2113 LocalContext env;
2115 v8::HandleScope scope(env->GetIsolate()); 2114 v8::HandleScope scope(env->GetIsolate());
2116 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 2115 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2117 2116
2118 CHECK(CcTest::i_isolate()->debug()->Load()); 2117 CHECK(CcTest::i_isolate()->debug()->Load());
2119 CompileRun("foo = {};"); 2118 CompileRun("foo = {};");
2120 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 2119 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
2121 CHECK(ValidateSnapshot(snapshot)); 2120 CHECK(ValidateSnapshot(snapshot));
2122 const v8::HeapGraphNode* root = snapshot->GetRoot(); 2121 const v8::HeapGraphNode* root = snapshot->GetRoot();
2123 int globals_count = 0; 2122 int globals_count = 0;
2124 bool found = false;
2125 for (int i = 0; i < root->GetChildrenCount(); ++i) { 2123 for (int i = 0; i < root->GetChildrenCount(); ++i) {
2126 const v8::HeapGraphEdge* edge = root->GetChild(i); 2124 const v8::HeapGraphEdge* edge = root->GetChild(i);
2127 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) { 2125 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) {
2128 ++globals_count; 2126 ++globals_count;
2129 const v8::HeapGraphNode* global = edge->GetToNode(); 2127 const v8::HeapGraphNode* global = edge->GetToNode();
2130 const v8::HeapGraphNode* foo = 2128 const v8::HeapGraphNode* foo =
2131 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); 2129 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo");
2132 if (foo != nullptr) { 2130 CHECK(foo);
2133 found = true;
2134 }
2135 } 2131 }
2136 } 2132 }
2137 CHECK_EQ(2, globals_count); 2133 CHECK_EQ(1, globals_count);
2138 CHECK(found);
2139 } 2134 }
2140 2135
2141 2136
2142 TEST(AllStrongGcRootsHaveNames) { 2137 TEST(AllStrongGcRootsHaveNames) {
2143 LocalContext env; 2138 LocalContext env;
2144 v8::HandleScope scope(env->GetIsolate()); 2139 v8::HandleScope scope(env->GetIsolate());
2145 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 2140 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2146 2141
2147 CompileRun("foo = {};"); 2142 CompileRun("foo = {};");
2148 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 2143 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 map.AddRange(ToAddress(0x180), 0x80, 6U); 2795 map.AddRange(ToAddress(0x180), 0x80, 6U);
2801 map.AddRange(ToAddress(0x180), 0x80, 7U); 2796 map.AddRange(ToAddress(0x180), 0x80, 7U);
2802 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); 2797 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180)));
2803 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); 2798 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200)));
2804 CHECK_EQ(3u, map.size()); 2799 CHECK_EQ(3u, map.size());
2805 2800
2806 map.Clear(); 2801 map.Clear();
2807 CHECK_EQ(0u, map.size()); 2802 CHECK_EQ(0u, map.size());
2808 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); 2803 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400)));
2809 } 2804 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698