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

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

Issue 15129002: stop using AsciiValue (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: adding deprecation notice Created 7 years, 7 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-deoptimization.cc ('k') | test/cctest/test-lockers.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6)); 101 reinterpret_cast<const i::HeapEntry*>(global_obj))->name(), 6));
102 return global_obj; 102 return global_obj;
103 } 103 }
104 104
105 105
106 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, 106 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node,
107 v8::HeapGraphEdge::Type type, 107 v8::HeapGraphEdge::Type type,
108 const char* name) { 108 const char* name) {
109 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { 109 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
110 const v8::HeapGraphEdge* prop = node->GetChild(i); 110 const v8::HeapGraphEdge* prop = node->GetChild(i);
111 v8::String::AsciiValue prop_name(prop->GetName()); 111 v8::String::Utf8Value prop_name(prop->GetName());
112 if (prop->GetType() == type && strcmp(name, *prop_name) == 0) 112 if (prop->GetType() == type && strcmp(name, *prop_name) == 0)
113 return prop->GetToNode(); 113 return prop->GetToNode();
114 } 114 }
115 return NULL; 115 return NULL;
116 } 116 }
117 117
118 118
119 static bool HasString(const v8::HeapGraphNode* node, const char* contents) { 119 static bool HasString(const v8::HeapGraphNode* node, const char* contents) {
120 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { 120 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
121 const v8::HeapGraphEdge* prop = node->GetChild(i); 121 const v8::HeapGraphEdge* prop = node->GetChild(i);
122 const v8::HeapGraphNode* node = prop->GetToNode(); 122 const v8::HeapGraphNode* node = prop->GetToNode();
123 if (node->GetType() == v8::HeapGraphNode::kString) { 123 if (node->GetType() == v8::HeapGraphNode::kString) {
124 v8::String::AsciiValue node_name(node->GetName()); 124 v8::String::Utf8Value node_name(node->GetName());
125 if (strcmp(contents, *node_name) == 0) return true; 125 if (strcmp(contents, *node_name) == 0) return true;
126 } 126 }
127 } 127 }
128 return false; 128 return false;
129 } 129 }
130 130
131 131
132 TEST(HeapSnapshot) { 132 TEST(HeapSnapshot) {
133 LocalContext env2; 133 LocalContext env2;
134 v8::HandleScope scope(env2->GetIsolate()); 134 v8::HandleScope scope(env2->GetIsolate());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 CHECK_NE(NULL, compiled); 278 CHECK_NE(NULL, compiled);
279 CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType()); 279 CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType());
280 const v8::HeapGraphNode* lazy = 280 const v8::HeapGraphNode* lazy =
281 GetProperty(global, v8::HeapGraphEdge::kProperty, "lazy"); 281 GetProperty(global, v8::HeapGraphEdge::kProperty, "lazy");
282 CHECK_NE(NULL, lazy); 282 CHECK_NE(NULL, lazy);
283 CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType()); 283 CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType());
284 const v8::HeapGraphNode* anonymous = 284 const v8::HeapGraphNode* anonymous =
285 GetProperty(global, v8::HeapGraphEdge::kProperty, "anonymous"); 285 GetProperty(global, v8::HeapGraphEdge::kProperty, "anonymous");
286 CHECK_NE(NULL, anonymous); 286 CHECK_NE(NULL, anonymous);
287 CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType()); 287 CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType());
288 v8::String::AsciiValue anonymous_name(anonymous->GetName()); 288 v8::String::Utf8Value anonymous_name(anonymous->GetName());
289 CHECK_EQ("", *anonymous_name); 289 CHECK_EQ("", *anonymous_name);
290 290
291 // Find references to code. 291 // Find references to code.
292 const v8::HeapGraphNode* compiled_code = 292 const v8::HeapGraphNode* compiled_code =
293 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared"); 293 GetProperty(compiled, v8::HeapGraphEdge::kInternal, "shared");
294 CHECK_NE(NULL, compiled_code); 294 CHECK_NE(NULL, compiled_code);
295 const v8::HeapGraphNode* lazy_code = 295 const v8::HeapGraphNode* lazy_code =
296 GetProperty(lazy, v8::HeapGraphEdge::kInternal, "shared"); 296 GetProperty(lazy, v8::HeapGraphEdge::kInternal, "shared");
297 CHECK_NE(NULL, lazy_code); 297 CHECK_NE(NULL, lazy_code);
298 298
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 virtual const char* GetGroupLabel() { return group_label_; } 1072 virtual const char* GetGroupLabel() { return group_label_; }
1073 virtual const char* GetLabel() { return label_; } 1073 virtual const char* GetLabel() { return label_; }
1074 virtual intptr_t GetElementCount() { return element_count_; } 1074 virtual intptr_t GetElementCount() { return element_count_; }
1075 virtual intptr_t GetSizeInBytes() { return size_; } 1075 virtual intptr_t GetSizeInBytes() { return size_; }
1076 bool disposed() { return disposed_; } 1076 bool disposed() { return disposed_; }
1077 1077
1078 static v8::RetainedObjectInfo* WrapperInfoCallback( 1078 static v8::RetainedObjectInfo* WrapperInfoCallback(
1079 uint16_t class_id, v8::Handle<v8::Value> wrapper) { 1079 uint16_t class_id, v8::Handle<v8::Value> wrapper) {
1080 if (class_id == 1) { 1080 if (class_id == 1) {
1081 if (wrapper->IsString()) { 1081 if (wrapper->IsString()) {
1082 v8::String::AsciiValue ascii(wrapper); 1082 v8::String::Utf8Value utf8(wrapper);
1083 if (strcmp(*ascii, "AAA") == 0) 1083 if (strcmp(*utf8, "AAA") == 0)
1084 return new TestRetainedObjectInfo(1, "aaa-group", "aaa", 100); 1084 return new TestRetainedObjectInfo(1, "aaa-group", "aaa", 100);
1085 else if (strcmp(*ascii, "BBB") == 0) 1085 else if (strcmp(*utf8, "BBB") == 0)
1086 return new TestRetainedObjectInfo(1, "aaa-group", "aaa", 100); 1086 return new TestRetainedObjectInfo(1, "aaa-group", "aaa", 100);
1087 } 1087 }
1088 } else if (class_id == 2) { 1088 } else if (class_id == 2) {
1089 if (wrapper->IsString()) { 1089 if (wrapper->IsString()) {
1090 v8::String::AsciiValue ascii(wrapper); 1090 v8::String::Utf8Value utf8(wrapper);
1091 if (strcmp(*ascii, "CCC") == 0) 1091 if (strcmp(*utf8, "CCC") == 0)
1092 return new TestRetainedObjectInfo(2, "ccc-group", "ccc"); 1092 return new TestRetainedObjectInfo(2, "ccc-group", "ccc");
1093 } 1093 }
1094 } 1094 }
1095 CHECK(false); 1095 CHECK(false);
1096 return NULL; 1096 return NULL;
1097 } 1097 }
1098 1098
1099 static i::List<TestRetainedObjectInfo*> instances; 1099 static i::List<TestRetainedObjectInfo*> instances;
1100 1100
1101 private: 1101 private:
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 const v8::HeapGraphNode* obj0 = GetProperty( 1247 const v8::HeapGraphNode* obj0 = GetProperty(
1248 global_object, v8::HeapGraphEdge::kProperty, "root_object"); 1248 global_object, v8::HeapGraphEdge::kProperty, "root_object");
1249 CHECK(obj0); 1249 CHECK(obj0);
1250 CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType()); 1250 CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType());
1251 const v8::HeapGraphNode* obj1 = GetProperty( 1251 const v8::HeapGraphNode* obj1 = GetProperty(
1252 obj0, v8::HeapGraphEdge::kInternal, "native"); 1252 obj0, v8::HeapGraphEdge::kInternal, "native");
1253 CHECK(obj1); 1253 CHECK(obj1);
1254 int implicit_targets_count = 0; 1254 int implicit_targets_count = 0;
1255 for (int i = 0, count = obj1->GetChildrenCount(); i < count; ++i) { 1255 for (int i = 0, count = obj1->GetChildrenCount(); i < count; ++i) {
1256 const v8::HeapGraphEdge* prop = obj1->GetChild(i); 1256 const v8::HeapGraphEdge* prop = obj1->GetChild(i);
1257 v8::String::AsciiValue prop_name(prop->GetName()); 1257 v8::String::Utf8Value prop_name(prop->GetName());
1258 if (prop->GetType() == v8::HeapGraphEdge::kInternal && 1258 if (prop->GetType() == v8::HeapGraphEdge::kInternal &&
1259 strcmp("native", *prop_name) == 0) { 1259 strcmp("native", *prop_name) == 0) {
1260 ++implicit_targets_count; 1260 ++implicit_targets_count;
1261 } 1261 }
1262 } 1262 }
1263 CHECK_EQ(2, implicit_targets_count); 1263 CHECK_EQ(2, implicit_targets_count);
1264 v8::V8::RemoveGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue); 1264 v8::V8::RemoveGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
1265 } 1265 }
1266 1266
1267 1267
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 1685 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1686 const v8::HeapGraphNode* gc_roots = GetNode( 1686 const v8::HeapGraphNode* gc_roots = GetNode(
1687 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); 1687 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)");
1688 CHECK_NE(NULL, gc_roots); 1688 CHECK_NE(NULL, gc_roots);
1689 const v8::HeapGraphNode* strong_roots = GetNode( 1689 const v8::HeapGraphNode* strong_roots = GetNode(
1690 gc_roots, v8::HeapGraphNode::kObject, "(Strong roots)"); 1690 gc_roots, v8::HeapGraphNode::kObject, "(Strong roots)");
1691 CHECK_NE(NULL, strong_roots); 1691 CHECK_NE(NULL, strong_roots);
1692 for (int i = 0; i < strong_roots->GetChildrenCount(); ++i) { 1692 for (int i = 0; i < strong_roots->GetChildrenCount(); ++i) {
1693 const v8::HeapGraphEdge* edge = strong_roots->GetChild(i); 1693 const v8::HeapGraphEdge* edge = strong_roots->GetChild(i);
1694 CHECK_EQ(v8::HeapGraphEdge::kInternal, edge->GetType()); 1694 CHECK_EQ(v8::HeapGraphEdge::kInternal, edge->GetType());
1695 v8::String::AsciiValue name(edge->GetName()); 1695 v8::String::Utf8Value name(edge->GetName());
1696 CHECK(isalpha(**name)); 1696 CHECK(isalpha(**name));
1697 } 1697 }
1698 } 1698 }
1699 1699
1700 1700
1701 TEST(NoRefsToNonEssentialEntries) { 1701 TEST(NoRefsToNonEssentialEntries) {
1702 LocalContext env; 1702 LocalContext env;
1703 v8::HandleScope scope(env->GetIsolate()); 1703 v8::HandleScope scope(env->GetIsolate());
1704 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1704 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1705 CompileRun("global_object = {};\n"); 1705 CompileRun("global_object = {};\n");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 // Check all the objects have got their names. 1777 // Check all the objects have got their names.
1778 // ... well check just every 8th because otherwise it's too slow in debug. 1778 // ... well check just every 8th because otherwise it's too slow in debug.
1779 for (int i = 0; i < num_objects - 1; i += 8) { 1779 for (int i = 0; i < num_objects - 1; i += 8) {
1780 i::EmbeddedVector<char, 100> var_name; 1780 i::EmbeddedVector<char, 100> var_name;
1781 i::OS::SNPrintF(var_name, "f_%d", i); 1781 i::OS::SNPrintF(var_name, "f_%d", i);
1782 const v8::HeapGraphNode* f_object = GetProperty( 1782 const v8::HeapGraphNode* f_object = GetProperty(
1783 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1783 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1784 CHECK_NE(NULL, f_object); 1784 CHECK_NE(NULL, f_object);
1785 } 1785 }
1786 } 1786 }
OLDNEW
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-lockers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698