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 119013004: Revert "More API cleanup." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 } 1813 }
1814 1814
1815 1815
1816 TEST(WeakGlobalHandle) { 1816 TEST(WeakGlobalHandle) {
1817 LocalContext env; 1817 LocalContext env;
1818 v8::HandleScope scope(env->GetIsolate()); 1818 v8::HandleScope scope(env->GetIsolate());
1819 1819
1820 CHECK(!HasWeakGlobalHandle()); 1820 CHECK(!HasWeakGlobalHandle());
1821 1821
1822 v8::Persistent<v8::Object>* handle = 1822 v8::Persistent<v8::Object>* handle =
1823 new v8::Persistent<v8::Object>(env->GetIsolate(), 1823 new v8::Persistent<v8::Object>(env->GetIsolate(), v8::Object::New());
1824 v8::Object::New(env->GetIsolate()));
1825 handle->SetWeak(handle, PersistentHandleCallback); 1824 handle->SetWeak(handle, PersistentHandleCallback);
1826 1825
1827 CHECK(HasWeakGlobalHandle()); 1826 CHECK(HasWeakGlobalHandle());
1828 } 1827 }
1829 1828
1830 1829
1831 TEST(SfiAndJsFunctionWeakRefs) { 1830 TEST(SfiAndJsFunctionWeakRefs) {
1832 LocalContext env; 1831 LocalContext env;
1833 v8::HandleScope scope(env->GetIsolate()); 1832 v8::HandleScope scope(env->GetIsolate());
1834 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1833 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 i::OS::SNPrintF(var_name, "f_%d", i); 1987 i::OS::SNPrintF(var_name, "f_%d", i);
1989 const v8::HeapGraphNode* f_object = GetProperty( 1988 const v8::HeapGraphNode* f_object = GetProperty(
1990 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1989 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1991 CHECK_NE(NULL, f_object); 1990 CHECK_NE(NULL, f_object);
1992 } 1991 }
1993 } 1992 }
1994 1993
1995 1994
1996 TEST(AllocationSitesAreVisible) { 1995 TEST(AllocationSitesAreVisible) {
1997 LocalContext env; 1996 LocalContext env;
1998 v8::Isolate* isolate = env->GetIsolate(); 1997 v8::HandleScope scope(env->GetIsolate());
1999 v8::HandleScope scope(isolate); 1998 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2000 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
2001 CompileRun( 1999 CompileRun(
2002 "fun = function () { var a = [3, 2, 1]; return a; }\n" 2000 "fun = function () { var a = [3, 2, 1]; return a; }\n"
2003 "fun();"); 2001 "fun();");
2004 const v8::HeapSnapshot* snapshot = 2002 const v8::HeapSnapshot* snapshot =
2005 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 2003 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
2006 CHECK(ValidateSnapshot(snapshot)); 2004 CHECK(ValidateSnapshot(snapshot));
2007 2005
2008 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 2006 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
2009 CHECK_NE(NULL, global); 2007 CHECK_NE(NULL, global);
2010 const v8::HeapGraphNode* fun_code = 2008 const v8::HeapGraphNode* fun_code =
(...skipping 21 matching lines...) Expand all
2032 "elements"); 2030 "elements");
2033 CHECK_NE(NULL, elements); 2031 CHECK_NE(NULL, elements);
2034 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType()); 2032 CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType());
2035 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize()); 2033 CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize());
2036 2034
2037 CHECK(transition_info->GetHeapValue()->IsArray()); 2035 CHECK(transition_info->GetHeapValue()->IsArray());
2038 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast( 2036 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(
2039 transition_info->GetHeapValue()); 2037 transition_info->GetHeapValue());
2040 // Verify the array is "a" in the code above. 2038 // Verify the array is "a" in the code above.
2041 CHECK_EQ(3, array->Length()); 2039 CHECK_EQ(3, array->Length());
2042 CHECK_EQ(v8::Integer::New(isolate, 3), 2040 CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0)));
2043 array->Get(v8::Integer::New(isolate, 0))); 2041 CHECK_EQ(v8::Integer::New(2), array->Get(v8::Integer::New(1)));
2044 CHECK_EQ(v8::Integer::New(isolate, 2), 2042 CHECK_EQ(v8::Integer::New(1), array->Get(v8::Integer::New(2)));
2045 array->Get(v8::Integer::New(isolate, 1)));
2046 CHECK_EQ(v8::Integer::New(isolate, 1),
2047 array->Get(v8::Integer::New(isolate, 2)));
2048 } 2043 }
2049 2044
2050 2045
2051 TEST(JSFunctionHasCodeLink) { 2046 TEST(JSFunctionHasCodeLink) {
2052 LocalContext env; 2047 LocalContext env;
2053 v8::HandleScope scope(env->GetIsolate()); 2048 v8::HandleScope scope(env->GetIsolate());
2054 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 2049 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2055 CompileRun("function foo(x, y) { return x + y; }\n"); 2050 CompileRun("function foo(x, y) { return x + y; }\n");
2056 const v8::HeapSnapshot* snapshot = 2051 const v8::HeapSnapshot* snapshot =
2057 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 2052 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2354
2360 AllocationTraceNode* node = 2355 AllocationTraceNode* node =
2361 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); 2356 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
2362 CHECK_NE(NULL, node); 2357 CHECK_NE(NULL, node);
2363 CHECK_LT(node->allocation_count(), 100); 2358 CHECK_LT(node->allocation_count(), 100);
2364 2359
2365 CcTest::heap()->DisableInlineAllocation(); 2360 CcTest::heap()->DisableInlineAllocation();
2366 heap_profiler->StopTrackingHeapObjects(); 2361 heap_profiler->StopTrackingHeapObjects();
2367 } 2362 }
2368 } 2363 }
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