| 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 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2550 // Print for better diagnostics in case of failure. | 2550 // Print for better diagnostics in case of failure. |
| 2551 tracker->trace_tree()->Print(tracker); | 2551 tracker->trace_tree()->Print(tracker); |
| 2552 | 2552 |
| 2553 AllocationTraceNode* node = FindNode(tracker, ArrayVector(names)); | 2553 AllocationTraceNode* node = FindNode(tracker, ArrayVector(names)); |
| 2554 CHECK(node); | 2554 CHECK(node); |
| 2555 CHECK_GE(node->allocation_count(), 2u); | 2555 CHECK_GE(node->allocation_count(), 2u); |
| 2556 CHECK_GE(node->allocation_size(), 4u * 5u); | 2556 CHECK_GE(node->allocation_size(), 4u * 5u); |
| 2557 heap_profiler->StopTrackingHeapObjects(); | 2557 heap_profiler->StopTrackingHeapObjects(); |
| 2558 } | 2558 } |
| 2559 | 2559 |
| 2560 | 2560 TEST(TrackHeapAllocationsWithInlining) { |
| 2561 TEST(TrackHeapAllocations) { | |
| 2562 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2561 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2563 LocalContext env; | 2562 LocalContext env; |
| 2564 | 2563 |
| 2564 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 2565 heap_profiler->StartTrackingHeapObjects(true); |
| 2566 |
| 2567 CompileRun(record_trace_tree_source); |
| 2568 |
| 2569 AllocationTracker* tracker = |
| 2570 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); |
| 2571 CHECK(tracker); |
| 2572 // Resolve all function locations. |
| 2573 tracker->PrepareForSerialization(); |
| 2574 // Print for better diagnostics in case of failure. |
| 2575 tracker->trace_tree()->Print(tracker); |
| 2576 |
| 2577 const char* names[] = {"", "start", "f_0_0"}; |
| 2578 AllocationTraceNode* node = FindNode(tracker, ArrayVector(names)); |
| 2579 CHECK(node); |
| 2580 CHECK_GE(node->allocation_count(), 12u); |
| 2581 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); |
| 2582 heap_profiler->StopTrackingHeapObjects(); |
| 2583 } |
| 2584 |
| 2585 TEST(TrackHeapAllocationsWithoutInlining) { |
| 2586 i::FLAG_max_inlined_source_size = 0; // Disable inlining |
| 2587 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2588 LocalContext env; |
| 2589 |
| 2565 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 2590 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 2566 heap_profiler->StartTrackingHeapObjects(true); | 2591 heap_profiler->StartTrackingHeapObjects(true); |
| 2567 | 2592 |
| 2568 CompileRun(record_trace_tree_source); | 2593 CompileRun(record_trace_tree_source); |
| 2569 | 2594 |
| 2570 AllocationTracker* tracker = | 2595 AllocationTracker* tracker = |
| 2571 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); | 2596 reinterpret_cast<i::HeapProfiler*>(heap_profiler)->allocation_tracker(); |
| 2572 CHECK(tracker); | 2597 CHECK(tracker); |
| 2573 // Resolve all function locations. | 2598 // Resolve all function locations. |
| 2574 tracker->PrepareForSerialization(); | 2599 tracker->PrepareForSerialization(); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3085 " a[i] = i;\n" | 3110 " a[i] = i;\n" |
| 3086 " for (var i = 0; i < 3; ++i)\n" | 3111 " for (var i = 0; i < 3; ++i)\n" |
| 3087 " a.shift();\n" | 3112 " a.shift();\n" |
| 3088 "}\n"); | 3113 "}\n"); |
| 3089 | 3114 |
| 3090 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 3115 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); |
| 3091 // Should not crash. | 3116 // Should not crash. |
| 3092 | 3117 |
| 3093 heap_profiler->StopSamplingHeapProfiler(); | 3118 heap_profiler->StopSamplingHeapProfiler(); |
| 3094 } | 3119 } |
| OLD | NEW |