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 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 2403 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
2404 heap_profiler->StartTrackingHeapObjects(true); | 2404 heap_profiler->StartTrackingHeapObjects(true); |
2405 | 2405 |
2406 CompileRun( | 2406 CompileRun( |
2407 "var a = [];\n" | 2407 "var a = [];\n" |
2408 "for (var i = 0; i < 5; ++i)\n" | 2408 "for (var i = 0; i < 5; ++i)\n" |
2409 " a[i] = i;\n" | 2409 " a[i] = i;\n" |
2410 "for (var i = 0; i < 3; ++i)\n" | 2410 "for (var i = 0; i < 3; ++i)\n" |
2411 " a.shift();\n"); | 2411 " a.shift();\n"); |
2412 | 2412 |
2413 const char* names[] = { "(anonymous function)" }; | 2413 const char* names[] = {""}; |
2414 AllocationTracker* tracker = | 2414 AllocationTracker* tracker = |
2415 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); | 2415 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); |
2416 CHECK_NE(NULL, tracker); | 2416 CHECK_NE(NULL, tracker); |
2417 // Resolve all function locations. | 2417 // Resolve all function locations. |
2418 tracker->PrepareForSerialization(); | 2418 tracker->PrepareForSerialization(); |
2419 // Print for better diagnostics in case of failure. | 2419 // Print for better diagnostics in case of failure. |
2420 tracker->trace_tree()->Print(tracker); | 2420 tracker->trace_tree()->Print(tracker); |
2421 | 2421 |
2422 AllocationTraceNode* node = | 2422 AllocationTraceNode* node = |
2423 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | 2423 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); |
(...skipping 14 matching lines...) Expand all Loading... |
2438 CompileRun(record_trace_tree_source); | 2438 CompileRun(record_trace_tree_source); |
2439 | 2439 |
2440 AllocationTracker* tracker = | 2440 AllocationTracker* tracker = |
2441 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); | 2441 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); |
2442 CHECK_NE(NULL, tracker); | 2442 CHECK_NE(NULL, tracker); |
2443 // Resolve all function locations. | 2443 // Resolve all function locations. |
2444 tracker->PrepareForSerialization(); | 2444 tracker->PrepareForSerialization(); |
2445 // Print for better diagnostics in case of failure. | 2445 // Print for better diagnostics in case of failure. |
2446 tracker->trace_tree()->Print(tracker); | 2446 tracker->trace_tree()->Print(tracker); |
2447 | 2447 |
2448 const char* names[] = | 2448 const char* names[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"}; |
2449 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; | |
2450 AllocationTraceNode* node = | 2449 AllocationTraceNode* node = |
2451 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | 2450 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); |
2452 CHECK_NE(NULL, node); | 2451 CHECK_NE(NULL, node); |
2453 CHECK_GE(node->allocation_count(), 100); | 2452 CHECK_GE(node->allocation_count(), 100); |
2454 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); | 2453 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); |
2455 heap_profiler->StopTrackingHeapObjects(); | 2454 heap_profiler->StopTrackingHeapObjects(); |
2456 } | 2455 } |
2457 | 2456 |
2458 | 2457 |
2459 static const char* inline_heap_allocation_source = | 2458 static const char* inline_heap_allocation_source = |
(...skipping 14 matching lines...) Expand all Loading... |
2474 "\n" | 2473 "\n" |
2475 "for (var i = 0; i < 100; i++) start();\n"; | 2474 "for (var i = 0; i < 100; i++) start();\n"; |
2476 | 2475 |
2477 | 2476 |
2478 TEST(TrackBumpPointerAllocations) { | 2477 TEST(TrackBumpPointerAllocations) { |
2479 i::FLAG_allow_natives_syntax = true; | 2478 i::FLAG_allow_natives_syntax = true; |
2480 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2479 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
2481 LocalContext env; | 2480 LocalContext env; |
2482 | 2481 |
2483 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 2482 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
2484 const char* names[] = { "(anonymous function)", "start", "f_0", "f_1" }; | 2483 const char* names[] = {"", "start", "f_0", "f_1"}; |
2485 // First check that normally all allocations are recorded. | 2484 // First check that normally all allocations are recorded. |
2486 { | 2485 { |
2487 heap_profiler->StartTrackingHeapObjects(true); | 2486 heap_profiler->StartTrackingHeapObjects(true); |
2488 | 2487 |
2489 CompileRun(inline_heap_allocation_source); | 2488 CompileRun(inline_heap_allocation_source); |
2490 | 2489 |
2491 AllocationTracker* tracker = | 2490 AllocationTracker* tracker = |
2492 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); | 2491 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); |
2493 CHECK_NE(NULL, tracker); | 2492 CHECK_NE(NULL, tracker); |
2494 // Resolve all function locations. | 2493 // Resolve all function locations. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2761 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2760 map.AddRange(ToAddress(0x180), 0x80, 6U); |
2762 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2761 map.AddRange(ToAddress(0x180), 0x80, 7U); |
2763 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 2762 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); |
2764 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 2763 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
2765 CHECK_EQ(3, static_cast<int>(map.size())); | 2764 CHECK_EQ(3, static_cast<int>(map.size())); |
2766 | 2765 |
2767 map.Clear(); | 2766 map.Clear(); |
2768 CHECK_EQ(0, static_cast<int>(map.size())); | 2767 CHECK_EQ(0, static_cast<int>(map.size())); |
2769 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 2768 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); |
2770 } | 2769 } |
OLD | NEW |