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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 ++entries; | 681 ++entries; |
682 } | 682 } |
683 } | 683 } |
684 CHECK_EQ(2, entries); | 684 CHECK_EQ(2, entries); |
685 const v8::HeapGraphNode* map_s = | 685 const v8::HeapGraphNode* map_s = |
686 GetProperty(map, v8::HeapGraphEdge::kProperty, "str"); | 686 GetProperty(map, v8::HeapGraphEdge::kProperty, "str"); |
687 CHECK(map_s); | 687 CHECK(map_s); |
688 CHECK_EQ(s->GetId(), map_s->GetId()); | 688 CHECK_EQ(s->GetId(), map_s->GetId()); |
689 } | 689 } |
690 | 690 |
| 691 TEST(HeapSnapshotMap) { |
| 692 LocalContext env; |
| 693 v8::HandleScope scope(env->GetIsolate()); |
| 694 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 695 |
| 696 CompileRun( |
| 697 "function Z() { this.foo = {}; }\n" |
| 698 "z = new Z();\n"); |
| 699 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); |
| 700 CHECK(ValidateSnapshot(snapshot)); |
| 701 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
| 702 const v8::HeapGraphNode* z = |
| 703 GetProperty(global, v8::HeapGraphEdge::kProperty, "z"); |
| 704 CHECK(z); |
| 705 const v8::HeapGraphNode* map = |
| 706 GetProperty(z, v8::HeapGraphEdge::kInternal, "map"); |
| 707 CHECK(map); |
| 708 CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "map")); |
| 709 CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "prototype")); |
| 710 CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "back_pointer")); |
| 711 CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors")); |
| 712 CHECK(GetProperty(map, v8::HeapGraphEdge::kInternal, "weak_cell_cache")); |
| 713 } |
691 | 714 |
692 TEST(HeapSnapshotInternalReferences) { | 715 TEST(HeapSnapshotInternalReferences) { |
693 v8::Isolate* isolate = CcTest::isolate(); | 716 v8::Isolate* isolate = CcTest::isolate(); |
694 v8::HandleScope scope(isolate); | 717 v8::HandleScope scope(isolate); |
695 v8::Local<v8::ObjectTemplate> global_template = | 718 v8::Local<v8::ObjectTemplate> global_template = |
696 v8::ObjectTemplate::New(isolate); | 719 v8::ObjectTemplate::New(isolate); |
697 global_template->SetInternalFieldCount(2); | 720 global_template->SetInternalFieldCount(2); |
698 LocalContext env(NULL, global_template); | 721 LocalContext env(NULL, global_template); |
699 v8::Local<v8::Object> global_proxy = env->Global(); | 722 v8::Local<v8::Object> global_proxy = env->Global(); |
700 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 723 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
(...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3077 " a[i] = i;\n" | 3100 " a[i] = i;\n" |
3078 " for (var i = 0; i < 3; ++i)\n" | 3101 " for (var i = 0; i < 3; ++i)\n" |
3079 " a.shift();\n" | 3102 " a.shift();\n" |
3080 "}\n"); | 3103 "}\n"); |
3081 | 3104 |
3082 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 3105 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); |
3083 // Should not crash. | 3106 // Should not crash. |
3084 | 3107 |
3085 heap_profiler->StopSamplingHeapProfiler(); | 3108 heap_profiler->StopSamplingHeapProfiler(); |
3086 } | 3109 } |
OLD | NEW |