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

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

Issue 14294009: Revert the commits adding new GC-related APIs. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: remove test Created 7 years, 8 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
« no previous file with comments | « test/cctest/test-global-handles.cc ('k') | test/cctest/test-mark-compact.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 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "native")); 1184 CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "native"));
1185 } 1185 }
1186 1186
1187 1187
1188 class GraphWithImplicitRefs { 1188 class GraphWithImplicitRefs {
1189 public: 1189 public:
1190 static const int kObjectsCount = 4; 1190 static const int kObjectsCount = 4;
1191 explicit GraphWithImplicitRefs(LocalContext* env) { 1191 explicit GraphWithImplicitRefs(LocalContext* env) {
1192 CHECK_EQ(NULL, instance_); 1192 CHECK_EQ(NULL, instance_);
1193 instance_ = this; 1193 instance_ = this;
1194 isolate_ = (*env)->GetIsolate(); 1194 v8::Isolate* isolate = (*env)->GetIsolate();
1195 for (int i = 0; i < kObjectsCount; i++) { 1195 for (int i = 0; i < kObjectsCount; i++) {
1196 objects_[i] = 1196 objects_[i] = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
1197 v8::Persistent<v8::Object>::New(isolate_, v8::Object::New());
1198 } 1197 }
1199 (*env)->Global()->Set(v8_str("root_object"), objects_[0]); 1198 (*env)->Global()->Set(v8_str("root_object"), objects_[0]);
1200 } 1199 }
1201 ~GraphWithImplicitRefs() { 1200 ~GraphWithImplicitRefs() {
1202 instance_ = NULL; 1201 instance_ = NULL;
1203 } 1202 }
1204 1203
1205 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { 1204 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) {
1206 instance_->AddImplicitReferences(); 1205 instance_->AddImplicitReferences();
1207 } 1206 }
1208 1207
1209 private: 1208 private:
1210 void AddImplicitReferences() { 1209 void AddImplicitReferences() {
1211 // 0 -> 1 1210 // 0 -> 1
1212 v8::V8::SetObjectGroupId(isolate_, 1211 v8::V8::AddImplicitReferences(
1213 v8::Persistent<v8::Object>::Cast(objects_[0]), 1212 v8::Persistent<v8::Object>::Cast(objects_[0]), &objects_[1], 1);
1214 v8::UniqueId(1));
1215 v8::V8::SetObjectGroupRepresentative(
1216 isolate_,
1217 v8::UniqueId(1),
1218 v8::Persistent<v8::Object>::Cast(objects_[0]));
1219 v8::V8::AddImplicitReference(isolate_,
1220 v8::UniqueId(1),
1221 v8::Persistent<v8::Object>::Cast(objects_[1]));
1222 // Adding two more references(note length=2 in params): 1 -> 2, 1 -> 3 1213 // Adding two more references(note length=2 in params): 1 -> 2, 1 -> 3
1223 v8::V8::SetObjectGroupId(isolate_, 1214 v8::V8::AddImplicitReferences(
1224 v8::Persistent<v8::Object>::Cast(objects_[1]), 1215 v8::Persistent<v8::Object>::Cast(objects_[1]), &objects_[2], 2);
1225 v8::UniqueId(2));
1226 v8::V8::SetObjectGroupRepresentative(
1227 isolate_,
1228 v8::UniqueId(2),
1229 v8::Persistent<v8::Object>::Cast(objects_[1]));
1230 v8::V8::AddImplicitReference(isolate_,
1231 v8::UniqueId(2),
1232 v8::Persistent<v8::Object>::Cast(objects_[2]));
1233 v8::V8::AddImplicitReference(isolate_,
1234 v8::UniqueId(2),
1235 v8::Persistent<v8::Object>::Cast(objects_[3]));
1236 } 1216 }
1237 1217
1238 v8::Persistent<v8::Value> objects_[kObjectsCount]; 1218 v8::Persistent<v8::Value> objects_[kObjectsCount];
1239 static GraphWithImplicitRefs* instance_; 1219 static GraphWithImplicitRefs* instance_;
1240 v8::Isolate* isolate_;
1241 }; 1220 };
1242 1221
1243 GraphWithImplicitRefs* GraphWithImplicitRefs::instance_ = NULL; 1222 GraphWithImplicitRefs* GraphWithImplicitRefs::instance_ = NULL;
1244 1223
1245 1224
1246 TEST(HeapSnapshotImplicitReferences) { 1225 TEST(HeapSnapshotImplicitReferences) {
1247 LocalContext env; 1226 LocalContext env;
1248 v8::HandleScope scope(env->GetIsolate()); 1227 v8::HandleScope scope(env->GetIsolate());
1249 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1228 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1250 1229
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 // Check all the objects have got their names. 1765 // Check all the objects have got their names.
1787 // ... well check just every 8th because otherwise it's too slow in debug. 1766 // ... well check just every 8th because otherwise it's too slow in debug.
1788 for (int i = 0; i < num_objects - 1; i += 8) { 1767 for (int i = 0; i < num_objects - 1; i += 8) {
1789 i::EmbeddedVector<char, 100> var_name; 1768 i::EmbeddedVector<char, 100> var_name;
1790 i::OS::SNPrintF(var_name, "f_%d", i); 1769 i::OS::SNPrintF(var_name, "f_%d", i);
1791 const v8::HeapGraphNode* f_object = GetProperty( 1770 const v8::HeapGraphNode* f_object = GetProperty(
1792 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1771 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1793 CHECK_NE(NULL, f_object); 1772 CHECK_NE(NULL, f_object);
1794 } 1773 }
1795 } 1774 }
OLDNEW
« no previous file with comments | « test/cctest/test-global-handles.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698