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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 CHECK_NE(NULL, child_string); | 406 CHECK_NE(NULL, child_string); |
407 CHECK_EQ(v8::HeapGraphNode::kSlicedString, child_string->GetType()); | 407 CHECK_EQ(v8::HeapGraphNode::kSlicedString, child_string->GetType()); |
408 const v8::HeapGraphNode* parent = | 408 const v8::HeapGraphNode* parent = |
409 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent"); | 409 GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent"); |
410 CHECK_EQ(parent_string, parent); | 410 CHECK_EQ(parent_string, parent); |
411 heap_profiler->DeleteAllHeapSnapshots(); | 411 heap_profiler->DeleteAllHeapSnapshots(); |
412 } | 412 } |
413 | 413 |
414 | 414 |
415 TEST(HeapSnapshotConsString) { | 415 TEST(HeapSnapshotConsString) { |
416 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 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 = i::Isolate::Current()->factory(); |
426 i::Handle<i::String> first = | 426 i::Handle<i::String> first = |
(...skipping 22 matching lines...) Expand all Loading... |
449 const v8::HeapGraphNode* second_node = | 449 const v8::HeapGraphNode* second_node = |
450 GetProperty(string_node, v8::HeapGraphEdge::kInternal, "second"); | 450 GetProperty(string_node, v8::HeapGraphEdge::kInternal, "second"); |
451 CHECK_EQ(v8::HeapGraphNode::kString, second_node->GetType()); | 451 CHECK_EQ(v8::HeapGraphNode::kString, second_node->GetType()); |
452 | 452 |
453 heap_profiler->DeleteAllHeapSnapshots(); | 453 heap_profiler->DeleteAllHeapSnapshots(); |
454 } | 454 } |
455 | 455 |
456 | 456 |
457 | 457 |
458 TEST(HeapSnapshotInternalReferences) { | 458 TEST(HeapSnapshotInternalReferences) { |
459 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 459 v8::Isolate* isolate = CcTest::isolate(); |
460 v8::HandleScope scope(isolate); | 460 v8::HandleScope scope(isolate); |
461 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 461 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
462 global_template->SetInternalFieldCount(2); | 462 global_template->SetInternalFieldCount(2); |
463 LocalContext env(NULL, global_template); | 463 LocalContext env(NULL, global_template); |
464 v8::Handle<v8::Object> global_proxy = env->Global(); | 464 v8::Handle<v8::Object> global_proxy = env->Global(); |
465 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 465 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
466 CHECK_EQ(2, global->InternalFieldCount()); | 466 CHECK_EQ(2, global->InternalFieldCount()); |
467 v8::Local<v8::Object> obj = v8::Object::New(); | 467 v8::Local<v8::Object> obj = v8::Object::New(); |
468 global->SetInternalField(0, v8_num(17)); | 468 global->SetInternalField(0, v8_num(17)); |
469 global->SetInternalField(1, obj); | 469 global->SetInternalField(1, obj); |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 bool HasWeakEdge(const v8::HeapGraphNode* node) { | 1731 bool HasWeakEdge(const v8::HeapGraphNode* node) { |
1732 for (int i = 0; i < node->GetChildrenCount(); ++i) { | 1732 for (int i = 0; i < node->GetChildrenCount(); ++i) { |
1733 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); | 1733 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); |
1734 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; | 1734 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; |
1735 } | 1735 } |
1736 return false; | 1736 return false; |
1737 } | 1737 } |
1738 | 1738 |
1739 | 1739 |
1740 bool HasWeakGlobalHandle() { | 1740 bool HasWeakGlobalHandle() { |
1741 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1741 v8::Isolate* isolate = CcTest::isolate(); |
1742 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); | 1742 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); |
1743 const v8::HeapSnapshot* snapshot = | 1743 const v8::HeapSnapshot* snapshot = |
1744 heap_profiler->TakeHeapSnapshot(v8_str("weaks")); | 1744 heap_profiler->TakeHeapSnapshot(v8_str("weaks")); |
1745 CHECK(ValidateSnapshot(snapshot)); | 1745 CHECK(ValidateSnapshot(snapshot)); |
1746 const v8::HeapGraphNode* gc_roots = GetNode( | 1746 const v8::HeapGraphNode* gc_roots = GetNode( |
1747 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); | 1747 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); |
1748 CHECK_NE(NULL, gc_roots); | 1748 CHECK_NE(NULL, gc_roots); |
1749 const v8::HeapGraphNode* global_handles = GetNode( | 1749 const v8::HeapGraphNode* global_handles = GetNode( |
1750 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); | 1750 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); |
1751 CHECK_NE(NULL, global_handles); | 1751 CHECK_NE(NULL, global_handles); |
(...skipping 246 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 |