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 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2223 | 2223 |
2224 const char* names[] = | 2224 const char* names[] = |
2225 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; | 2225 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; |
2226 AllocationTraceNode* node = | 2226 AllocationTraceNode* node = |
2227 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | 2227 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); |
2228 CHECK_NE(NULL, node); | 2228 CHECK_NE(NULL, node); |
2229 CHECK_GE(node->allocation_count(), 100); | 2229 CHECK_GE(node->allocation_count(), 100); |
2230 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); | 2230 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); |
2231 heap_profiler->StopRecordingHeapAllocations(); | 2231 heap_profiler->StopRecordingHeapAllocations(); |
2232 } | 2232 } |
2233 | |
2234 | |
2235 static const char* inline_heap_allocation_source = | |
loislo
2013/11/15 13:44:15
I see no reason to think that it was an inline all
yurys
2013/11/15 14:32:26
Done. Added additional step which checks that the
| |
2236 "function f_0(x) {\n" | |
2237 " try {\n" | |
2238 " return f_1(x+1);\n" | |
2239 " } catch (e) {}\n" | |
2240 "}\n" | |
2241 "function f_1(x) {\n" | |
2242 " try {\n" | |
Michael Starzinger
2013/11/15 13:38:39
I guess the try-catch is used to prevent optimizat
yurys
2013/11/15 13:48:06
You are right, try-catch is here just to prevent o
| |
2243 " return new f_2(x+1);\n" | |
2244 " } catch (e) {}\n" | |
2245 "}\n" | |
2246 "function f_2(x) {\n" | |
2247 " this.foo = x;\n" | |
2248 "}\n" | |
2249 "var instances = [];\n" | |
2250 "function start() {\n" | |
2251 " instances.push(f_0(0));\n" | |
2252 "}\n" | |
2253 "\n" | |
2254 "for (var i = 0; i < 100; i++) start();\n"; | |
2255 | |
2256 | |
2257 TEST(TrackBumpPointerAllocations) { | |
2258 v8::HandleScope scope(v8::Isolate::GetCurrent()); | |
2259 LocalContext env; | |
2260 | |
2261 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | |
2262 heap_profiler->StartRecordingHeapAllocations(); | |
2263 | |
2264 CompileRun(inline_heap_allocation_source); | |
2265 | |
2266 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot( | |
2267 v8::String::New("Test")); | |
2268 i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection(); | |
2269 AllocationTracker* tracker = collection->allocation_tracker(); | |
2270 CHECK_NE(NULL, tracker); | |
2271 // Resolve all function locations. | |
2272 tracker->PrepareForSerialization(); | |
2273 // Print for better diagnostics in case of failure. | |
2274 tracker->trace_tree()->Print(tracker); | |
2275 | |
2276 const char* names[] = | |
2277 { "(anonymous function)", "start", "f_0", "f_1" }; | |
2278 AllocationTraceNode* node = | |
2279 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | |
2280 CHECK_NE(NULL, node); | |
2281 CHECK_GE(node->allocation_count(), 100); | |
2282 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); | |
2283 heap_profiler->StopRecordingHeapAllocations(); | |
2284 } | |
OLD | NEW |