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 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 v8::base::SmartPointer<v8::AllocationProfile> profile( | 3003 v8::base::SmartPointer<v8::AllocationProfile> profile( |
3004 heap_profiler->GetAllocationProfile()); | 3004 heap_profiler->GetAllocationProfile()); |
3005 CHECK(!profile.is_empty()); | 3005 CHECK(!profile.is_empty()); |
3006 const char* names[] = {"(V8 API)"}; | 3006 const char* names[] = {"(V8 API)"}; |
3007 auto node = FindAllocationProfileNode( | 3007 auto node = FindAllocationProfileNode( |
3008 *profile, Vector<const char*>(names, arraysize(names))); | 3008 *profile, Vector<const char*>(names, arraysize(names))); |
3009 CHECK(node); | 3009 CHECK(node); |
3010 | 3010 |
3011 heap_profiler->StopSamplingHeapProfiler(); | 3011 heap_profiler->StopSamplingHeapProfiler(); |
3012 } | 3012 } |
| 3013 |
| 3014 TEST(SamplingHeapProfilerLeftTrimming) { |
| 3015 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 3016 LocalContext env; |
| 3017 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 3018 |
| 3019 // Suppress randomness to avoid flakiness in tests. |
| 3020 v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; |
| 3021 |
| 3022 heap_profiler->StartSamplingHeapProfiler(64); |
| 3023 |
| 3024 CompileRun( |
| 3025 "for (var j = 0; j < 500; ++j) {\n" |
| 3026 " var a = [];\n" |
| 3027 " for (var i = 0; i < 5; ++i)\n" |
| 3028 " a[i] = i;\n" |
| 3029 " for (var i = 0; i < 3; ++i)\n" |
| 3030 " a.shift();\n" |
| 3031 "}\n"); |
| 3032 |
| 3033 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); |
| 3034 // Should not crash. |
| 3035 |
| 3036 heap_profiler->StopSamplingHeapProfiler(); |
| 3037 } |
OLD | NEW |