| 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 const v8::HeapGraphNode* second_node = | 466 const v8::HeapGraphNode* second_node = |
| 467 GetProperty(string_node, v8::HeapGraphEdge::kInternal, "second"); | 467 GetProperty(string_node, v8::HeapGraphEdge::kInternal, "second"); |
| 468 CHECK_EQ(v8::HeapGraphNode::kString, second_node->GetType()); | 468 CHECK_EQ(v8::HeapGraphNode::kString, second_node->GetType()); |
| 469 | 469 |
| 470 heap_profiler->DeleteAllHeapSnapshots(); | 470 heap_profiler->DeleteAllHeapSnapshots(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 | 473 |
| 474 TEST(HeapSnapshotSymbol) { | 474 TEST(HeapSnapshotSymbol) { |
| 475 i::FLAG_harmony_symbols = true; | |
| 476 | |
| 477 LocalContext env; | 475 LocalContext env; |
| 478 v8::HandleScope scope(env->GetIsolate()); | 476 v8::HandleScope scope(env->GetIsolate()); |
| 479 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 477 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 480 | 478 |
| 481 CompileRun("a = Symbol('mySymbol');\n"); | 479 CompileRun("a = Symbol('mySymbol');\n"); |
| 482 const v8::HeapSnapshot* snapshot = | 480 const v8::HeapSnapshot* snapshot = |
| 483 heap_profiler->TakeHeapSnapshot(v8_str("Symbol")); | 481 heap_profiler->TakeHeapSnapshot(v8_str("Symbol")); |
| 484 CHECK(ValidateSnapshot(snapshot)); | 482 CHECK(ValidateSnapshot(snapshot)); |
| 485 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 483 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
| 486 const v8::HeapGraphNode* a = | 484 const v8::HeapGraphNode* a = |
| 487 GetProperty(global, v8::HeapGraphEdge::kProperty, "a"); | 485 GetProperty(global, v8::HeapGraphEdge::kProperty, "a"); |
| 488 CHECK_NE(NULL, a); | 486 CHECK_NE(NULL, a); |
| 489 CHECK_EQ(a->GetType(), v8::HeapGraphNode::kSymbol); | 487 CHECK_EQ(a->GetType(), v8::HeapGraphNode::kSymbol); |
| 490 CHECK_EQ(v8_str("symbol"), a->GetName()); | 488 CHECK_EQ(v8_str("symbol"), a->GetName()); |
| 491 const v8::HeapGraphNode* name = | 489 const v8::HeapGraphNode* name = |
| 492 GetProperty(a, v8::HeapGraphEdge::kInternal, "name"); | 490 GetProperty(a, v8::HeapGraphEdge::kInternal, "name"); |
| 493 CHECK_NE(NULL, name); | 491 CHECK_NE(NULL, name); |
| 494 CHECK_EQ(v8_str("mySymbol"), name->GetName()); | 492 CHECK_EQ(v8_str("mySymbol"), name->GetName()); |
| 495 } | 493 } |
| 496 | 494 |
| 497 | 495 |
| 498 TEST(HeapSnapshotWeakCollection) { | 496 TEST(HeapSnapshotWeakCollection) { |
| 499 i::FLAG_harmony_collections = true; | |
| 500 | |
| 501 LocalContext env; | 497 LocalContext env; |
| 502 v8::HandleScope scope(env->GetIsolate()); | 498 v8::HandleScope scope(env->GetIsolate()); |
| 503 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 499 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 504 | 500 |
| 505 CompileRun( | 501 CompileRun( |
| 506 "k = {}; v = {}; s = 'str';\n" | 502 "k = {}; v = {}; s = 'str';\n" |
| 507 "ws = new WeakSet(); ws.add(k); ws.add(v); ws[s] = s;\n" | 503 "ws = new WeakSet(); ws.add(k); ws.add(v); ws[s] = s;\n" |
| 508 "wm = new WeakMap(); wm.set(k, v); wm[s] = s;\n"); | 504 "wm = new WeakMap(); wm.set(k, v); wm[s] = s;\n"); |
| 509 const v8::HeapSnapshot* snapshot = | 505 const v8::HeapSnapshot* snapshot = |
| 510 heap_profiler->TakeHeapSnapshot(v8_str("WeakCollections")); | 506 heap_profiler->TakeHeapSnapshot(v8_str("WeakCollections")); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 561 } |
| 566 CHECK_EQ(2, weak_entries); | 562 CHECK_EQ(2, weak_entries); |
| 567 const v8::HeapGraphNode* wm_s = | 563 const v8::HeapGraphNode* wm_s = |
| 568 GetProperty(wm, v8::HeapGraphEdge::kProperty, "str"); | 564 GetProperty(wm, v8::HeapGraphEdge::kProperty, "str"); |
| 569 CHECK_NE(NULL, wm_s); | 565 CHECK_NE(NULL, wm_s); |
| 570 CHECK_EQ(static_cast<int>(s->GetId()), static_cast<int>(wm_s->GetId())); | 566 CHECK_EQ(static_cast<int>(s->GetId()), static_cast<int>(wm_s->GetId())); |
| 571 } | 567 } |
| 572 | 568 |
| 573 | 569 |
| 574 TEST(HeapSnapshotCollection) { | 570 TEST(HeapSnapshotCollection) { |
| 575 i::FLAG_harmony_collections = true; | |
| 576 | |
| 577 LocalContext env; | 571 LocalContext env; |
| 578 v8::HandleScope scope(env->GetIsolate()); | 572 v8::HandleScope scope(env->GetIsolate()); |
| 579 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 573 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 580 | 574 |
| 581 CompileRun( | 575 CompileRun( |
| 582 "k = {}; v = {}; s = 'str';\n" | 576 "k = {}; v = {}; s = 'str';\n" |
| 583 "set = new Set(); set.add(k); set.add(v); set[s] = s;\n" | 577 "set = new Set(); set.add(k); set.add(v); set[s] = s;\n" |
| 584 "map = new Map(); map.set(k, v); map[s] = s;\n"); | 578 "map = new Map(); map.set(k, v); map[s] = s;\n"); |
| 585 const v8::HeapSnapshot* snapshot = | 579 const v8::HeapSnapshot* snapshot = |
| 586 heap_profiler->TakeHeapSnapshot(v8_str("Collections")); | 580 heap_profiler->TakeHeapSnapshot(v8_str("Collections")); |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2757 map.AddRange(ToAddress(0x180), 0x80, 6U); |
| 2764 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2758 map.AddRange(ToAddress(0x180), 0x80, 7U); |
| 2765 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 2759 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); |
| 2766 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 2760 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
| 2767 CHECK_EQ(3, static_cast<int>(map.size())); | 2761 CHECK_EQ(3, static_cast<int>(map.size())); |
| 2768 | 2762 |
| 2769 map.Clear(); | 2763 map.Clear(); |
| 2770 CHECK_EQ(0, static_cast<int>(map.size())); | 2764 CHECK_EQ(0, static_cast<int>(map.size())); |
| 2771 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 2765 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); |
| 2772 } | 2766 } |
| OLD | NEW |