OLD | NEW |
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 TEST(HeapSnapshotConsString) { | 415 TEST(HeapSnapshotConsString) { |
416 v8::Isolate* isolate = CcTest::isolate(); | 416 v8::Isolate* isolate = CcTest::isolate(); |
417 v8::HandleScope scope(isolate); | 417 v8::HandleScope scope(isolate); |
418 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 418 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
419 global_template->SetInternalFieldCount(1); | 419 global_template->SetInternalFieldCount(1); |
420 LocalContext env(NULL, global_template); | 420 LocalContext env(NULL, global_template); |
421 v8::Handle<v8::Object> global_proxy = env->Global(); | 421 v8::Handle<v8::Object> global_proxy = env->Global(); |
422 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 422 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
423 CHECK_EQ(1, global->InternalFieldCount()); | 423 CHECK_EQ(1, global->InternalFieldCount()); |
424 | 424 |
425 i::Factory* factory = i::Isolate::Current()->factory(); | 425 i::Factory* factory = CcTest::i_isolate()->factory(); |
426 i::Handle<i::String> first = | 426 i::Handle<i::String> first = |
427 factory->NewStringFromAscii(i::CStrVector("0123456789")); | 427 factory->NewStringFromAscii(i::CStrVector("0123456789")); |
428 i::Handle<i::String> second = | 428 i::Handle<i::String> second = |
429 factory->NewStringFromAscii(i::CStrVector("0123456789")); | 429 factory->NewStringFromAscii(i::CStrVector("0123456789")); |
430 i::Handle<i::String> cons_string = factory->NewConsString(first, second); | 430 i::Handle<i::String> cons_string = factory->NewConsString(first, second); |
431 | 431 |
432 global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); | 432 global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); |
433 | 433 |
434 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); | 434 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); |
435 const v8::HeapSnapshot* snapshot = | 435 const v8::HeapSnapshot* snapshot = |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 | 1475 |
1476 | 1476 |
1477 TEST(NoHandleLeaks) { | 1477 TEST(NoHandleLeaks) { |
1478 LocalContext env; | 1478 LocalContext env; |
1479 v8::HandleScope scope(env->GetIsolate()); | 1479 v8::HandleScope scope(env->GetIsolate()); |
1480 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1480 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
1481 | 1481 |
1482 CompileRun("document = { URL:\"abcdefgh\" };"); | 1482 CompileRun("document = { URL:\"abcdefgh\" };"); |
1483 | 1483 |
1484 v8::Handle<v8::String> name(v8_str("leakz")); | 1484 v8::Handle<v8::String> name(v8_str("leakz")); |
1485 i::Isolate* isolate = i::Isolate::Current(); | 1485 i::Isolate* isolate = CcTest::i_isolate(); |
1486 int count_before = i::HandleScope::NumberOfHandles(isolate); | 1486 int count_before = i::HandleScope::NumberOfHandles(isolate); |
1487 heap_profiler->TakeHeapSnapshot(name); | 1487 heap_profiler->TakeHeapSnapshot(name); |
1488 int count_after = i::HandleScope::NumberOfHandles(isolate); | 1488 int count_after = i::HandleScope::NumberOfHandles(isolate); |
1489 CHECK_EQ(count_before, count_after); | 1489 CHECK_EQ(count_before, count_after); |
1490 } | 1490 } |
1491 | 1491 |
1492 | 1492 |
1493 TEST(NodesIteration) { | 1493 TEST(NodesIteration) { |
1494 LocalContext env; | 1494 LocalContext env; |
1495 v8::HandleScope scope(env->GetIsolate()); | 1495 v8::HandleScope scope(env->GetIsolate()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 CHECK(!HasWeakEdge(shared)); | 1793 CHECK(!HasWeakEdge(shared)); |
1794 } | 1794 } |
1795 | 1795 |
1796 | 1796 |
1797 #ifdef ENABLE_DEBUGGER_SUPPORT | 1797 #ifdef ENABLE_DEBUGGER_SUPPORT |
1798 TEST(NoDebugObjectInSnapshot) { | 1798 TEST(NoDebugObjectInSnapshot) { |
1799 LocalContext env; | 1799 LocalContext env; |
1800 v8::HandleScope scope(env->GetIsolate()); | 1800 v8::HandleScope scope(env->GetIsolate()); |
1801 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1801 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
1802 | 1802 |
1803 v8::internal::Isolate::Current()->debug()->Load(); | 1803 CcTest::i_isolate()->debug()->Load(); |
1804 CompileRun("foo = {};"); | 1804 CompileRun("foo = {};"); |
1805 const v8::HeapSnapshot* snapshot = | 1805 const v8::HeapSnapshot* snapshot = |
1806 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); | 1806 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
1807 CHECK(ValidateSnapshot(snapshot)); | 1807 CHECK(ValidateSnapshot(snapshot)); |
1808 const v8::HeapGraphNode* root = snapshot->GetRoot(); | 1808 const v8::HeapGraphNode* root = snapshot->GetRoot(); |
1809 int globals_count = 0; | 1809 int globals_count = 0; |
1810 for (int i = 0; i < root->GetChildrenCount(); ++i) { | 1810 for (int i = 0; i < root->GetChildrenCount(); ++i) { |
1811 const v8::HeapGraphEdge* edge = root->GetChild(i); | 1811 const v8::HeapGraphEdge* edge = root->GetChild(i); |
1812 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) { | 1812 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) { |
1813 ++globals_count; | 1813 ++globals_count; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); | 1998 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
1999 CHECK(ValidateSnapshot(snapshot)); | 1999 CHECK(ValidateSnapshot(snapshot)); |
2000 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 2000 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
2001 const v8::HeapGraphNode* foo_func = | 2001 const v8::HeapGraphNode* foo_func = |
2002 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); | 2002 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); |
2003 CHECK_NE(NULL, foo_func); | 2003 CHECK_NE(NULL, foo_func); |
2004 const v8::HeapGraphNode* code = | 2004 const v8::HeapGraphNode* code = |
2005 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code"); | 2005 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code"); |
2006 CHECK_NE(NULL, code); | 2006 CHECK_NE(NULL, code); |
2007 } | 2007 } |
OLD | NEW |