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

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

Issue 119323006: Revert r18449 "Reland r18383: More API cleanup." and r18450 "Unbreak build." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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/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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 465
466 TEST(HeapSnapshotInternalReferences) { 466 TEST(HeapSnapshotInternalReferences) {
467 v8::Isolate* isolate = CcTest::isolate(); 467 v8::Isolate* isolate = CcTest::isolate();
468 v8::HandleScope scope(isolate); 468 v8::HandleScope scope(isolate);
469 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 469 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
470 global_template->SetInternalFieldCount(2); 470 global_template->SetInternalFieldCount(2);
471 LocalContext env(NULL, global_template); 471 LocalContext env(NULL, global_template);
472 v8::Handle<v8::Object> global_proxy = env->Global(); 472 v8::Handle<v8::Object> global_proxy = env->Global();
473 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 473 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
474 CHECK_EQ(2, global->InternalFieldCount()); 474 CHECK_EQ(2, global->InternalFieldCount());
475 v8::Local<v8::Object> obj = v8::Object::New(isolate); 475 v8::Local<v8::Object> obj = v8::Object::New();
476 global->SetInternalField(0, v8_num(17)); 476 global->SetInternalField(0, v8_num(17));
477 global->SetInternalField(1, obj); 477 global->SetInternalField(1, obj);
478 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); 478 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
479 const v8::HeapSnapshot* snapshot = 479 const v8::HeapSnapshot* snapshot =
480 heap_profiler->TakeHeapSnapshot(v8_str("internals")); 480 heap_profiler->TakeHeapSnapshot(v8_str("internals"));
481 CHECK(ValidateSnapshot(snapshot)); 481 CHECK(ValidateSnapshot(snapshot));
482 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); 482 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
483 // The first reference will not present, because it's a Smi. 483 // The first reference will not present, because it's a Smi.
484 CHECK_EQ(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0")); 484 CHECK_EQ(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0"));
485 // The second reference is to an object. 485 // The second reference is to an object.
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1347
1348 1348
1349 class GraphWithImplicitRefs { 1349 class GraphWithImplicitRefs {
1350 public: 1350 public:
1351 static const int kObjectsCount = 4; 1351 static const int kObjectsCount = 4;
1352 explicit GraphWithImplicitRefs(LocalContext* env) { 1352 explicit GraphWithImplicitRefs(LocalContext* env) {
1353 CHECK_EQ(NULL, instance_); 1353 CHECK_EQ(NULL, instance_);
1354 instance_ = this; 1354 instance_ = this;
1355 isolate_ = (*env)->GetIsolate(); 1355 isolate_ = (*env)->GetIsolate();
1356 for (int i = 0; i < kObjectsCount; i++) { 1356 for (int i = 0; i < kObjectsCount; i++) {
1357 objects_[i].Reset(isolate_, v8::Object::New(isolate_)); 1357 objects_[i].Reset(isolate_, v8::Object::New());
1358 } 1358 }
1359 (*env)->Global()->Set(v8_str("root_object"), 1359 (*env)->Global()->Set(v8_str("root_object"),
1360 v8::Local<v8::Value>::New(isolate_, objects_[0])); 1360 v8::Local<v8::Value>::New(isolate_, objects_[0]));
1361 } 1361 }
1362 ~GraphWithImplicitRefs() { 1362 ~GraphWithImplicitRefs() {
1363 instance_ = NULL; 1363 instance_ = NULL;
1364 } 1364 }
1365 1365
1366 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { 1366 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) {
1367 instance_->AddImplicitReferences(); 1367 instance_->AddImplicitReferences();
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 } 1814 }
1815 1815
1816 1816
1817 TEST(WeakGlobalHandle) { 1817 TEST(WeakGlobalHandle) {
1818 LocalContext env; 1818 LocalContext env;
1819 v8::HandleScope scope(env->GetIsolate()); 1819 v8::HandleScope scope(env->GetIsolate());
1820 1820
1821 CHECK(!HasWeakGlobalHandle()); 1821 CHECK(!HasWeakGlobalHandle());
1822 1822
1823 v8::Persistent<v8::Object>* handle = 1823 v8::Persistent<v8::Object>* handle =
1824 new v8::Persistent<v8::Object>(env->GetIsolate(), 1824 new v8::Persistent<v8::Object>(env->GetIsolate(), v8::Object::New());
1825 v8::Object::New(env->GetIsolate()));
1826 handle->SetWeak(handle, PersistentHandleCallback); 1825 handle->SetWeak(handle, PersistentHandleCallback);
1827 1826
1828 CHECK(HasWeakGlobalHandle()); 1827 CHECK(HasWeakGlobalHandle());
1829 } 1828 }
1830 1829
1831 1830
1832 TEST(SfiAndJsFunctionWeakRefs) { 1831 TEST(SfiAndJsFunctionWeakRefs) {
1833 LocalContext env; 1832 LocalContext env;
1834 v8::HandleScope scope(env->GetIsolate()); 1833 v8::HandleScope scope(env->GetIsolate());
1835 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1834 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 i::OS::SNPrintF(var_name, "f_%d", i); 1988 i::OS::SNPrintF(var_name, "f_%d", i);
1990 const v8::HeapGraphNode* f_object = GetProperty( 1989 const v8::HeapGraphNode* f_object = GetProperty(
1991 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1990 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1992 CHECK_NE(NULL, f_object); 1991 CHECK_NE(NULL, f_object);
1993 } 1992 }
1994 } 1993 }
1995 1994
1996 1995
1997 TEST(AllocationSitesAreVisible) { 1996 TEST(AllocationSitesAreVisible) {
1998 LocalContext env; 1997 LocalContext env;
1999 v8::Isolate* isolate = env->GetIsolate(); 1998 v8::HandleScope scope(env->GetIsolate());
2000 v8::HandleScope scope(isolate); 1999 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2001 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
2002 CompileRun( 2000 CompileRun(
2003 "fun = function () { var a = [3, 2, 1]; return a; }\n" 2001 "fun = function () { var a = [3, 2, 1]; return a; }\n"
2004 "fun();"); 2002 "fun();");
2005 const v8::HeapSnapshot* snapshot = 2003 const v8::HeapSnapshot* snapshot =
2006 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 2004 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
2007 CHECK(ValidateSnapshot(snapshot)); 2005 CHECK(ValidateSnapshot(snapshot));
2008 2006
2009 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 2007 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
2010 CHECK_NE(NULL, global); 2008 CHECK_NE(NULL, global);
2011 const v8::HeapGraphNode* fun_code = 2009 const v8::HeapGraphNode* fun_code =
(...skipping 22 matching lines...) Expand all
2034 CHECK_NE(NULL, elements); 2032 CHECK_NE(NULL, elements);
2035 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType()); 2033 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType());
2036 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize()); 2034 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize());
2037 2035
2038 v8::Handle<v8::Value> array_val = 2036 v8::Handle<v8::Value> array_val =
2039 heap_profiler->FindObjectById(transition_info->GetId()); 2037 heap_profiler->FindObjectById(transition_info->GetId());
2040 CHECK(array_val->IsArray()); 2038 CHECK(array_val->IsArray());
2041 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(array_val); 2039 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(array_val);
2042 // Verify the array is "a" in the code above. 2040 // Verify the array is "a" in the code above.
2043 CHECK_EQ(3, array->Length()); 2041 CHECK_EQ(3, array->Length());
2044 CHECK_EQ(v8::Integer::New(isolate, 3), 2042 CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0)));
2045 array->Get(v8::Integer::New(isolate, 0))); 2043 CHECK_EQ(v8::Integer::New(2), array->Get(v8::Integer::New(1)));
2046 CHECK_EQ(v8::Integer::New(isolate, 2), 2044 CHECK_EQ(v8::Integer::New(1), array->Get(v8::Integer::New(2)));
2047 array->Get(v8::Integer::New(isolate, 1)));
2048 CHECK_EQ(v8::Integer::New(isolate, 1),
2049 array->Get(v8::Integer::New(isolate, 2)));
2050 } 2045 }
2051 2046
2052 2047
2053 TEST(JSFunctionHasCodeLink) { 2048 TEST(JSFunctionHasCodeLink) {
2054 LocalContext env; 2049 LocalContext env;
2055 v8::HandleScope scope(env->GetIsolate()); 2050 v8::HandleScope scope(env->GetIsolate());
2056 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 2051 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2057 CompileRun("function foo(x, y) { return x + y; }\n"); 2052 CompileRun("function foo(x, y) { return x + y; }\n");
2058 const v8::HeapSnapshot* snapshot = 2053 const v8::HeapSnapshot* snapshot =
2059 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 2054 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2361 2356
2362 AllocationTraceNode* node = 2357 AllocationTraceNode* node =
2363 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); 2358 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
2364 CHECK_NE(NULL, node); 2359 CHECK_NE(NULL, node);
2365 CHECK_LT(node->allocation_count(), 100); 2360 CHECK_LT(node->allocation_count(), 100);
2366 2361
2367 CcTest::heap()->DisableInlineAllocation(); 2362 CcTest::heap()->DisableInlineAllocation();
2368 heap_profiler->StopTrackingHeapObjects(); 2363 heap_profiler->StopTrackingHeapObjects();
2369 } 2364 }
2370 } 2365 }
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