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 3022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3033 v8::base::SmartPointer<v8::AllocationProfile> profile( | 3033 v8::base::SmartPointer<v8::AllocationProfile> profile( |
3034 heap_profiler->GetAllocationProfile()); | 3034 heap_profiler->GetAllocationProfile()); |
3035 CHECK(!profile.is_empty()); | 3035 CHECK(!profile.is_empty()); |
3036 const char* names[] = {"(V8 API)"}; | 3036 const char* names[] = {"(V8 API)"}; |
3037 auto node = FindAllocationProfileNode( | 3037 auto node = FindAllocationProfileNode( |
3038 *profile, Vector<const char*>(names, arraysize(names))); | 3038 *profile, Vector<const char*>(names, arraysize(names))); |
3039 CHECK(node); | 3039 CHECK(node); |
3040 | 3040 |
3041 heap_profiler->StopSamplingHeapProfiler(); | 3041 heap_profiler->StopSamplingHeapProfiler(); |
3042 } | 3042 } |
3043 | |
3044 TEST(SamplingHeapProfilerLeftTrimming) { | |
3045 v8::HandleScope scope(v8::Isolate::GetCurrent()); | |
3046 LocalContext env; | |
3047 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | |
3048 | |
3049 // Suppress randomness to avoid flakiness in tests. | |
3050 v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; | |
3051 | |
3052 heap_profiler->StartSamplingHeapProfiler(64); | |
3053 | |
3054 CompileRun( | |
3055 "for (var j = 0; j < 30000; ++j) {\n" | |
3056 " var a = [];\n" | |
3057 " for (var i = 0; i < 5; ++i)\n" | |
3058 " a[i] = i;\n" | |
3059 " for (var i = 0; i < 3; ++i)\n" | |
3060 " a.shift();\n" | |
3061 "}\n"); | |
3062 // Should not crash. | |
Hannes Payer (out of office)
2016/04/13 13:32:29
Don't you need to call GC to crash? Why does it cr
| |
3063 | |
3064 heap_profiler->StopSamplingHeapProfiler(); | |
3065 } | |
OLD | NEW |