| 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 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 | 2063 |
| 2064 // This is an example of using checking of JS allocations tracking in a test. | 2064 // This is an example of using checking of JS allocations tracking in a test. |
| 2065 TEST(HeapObjectsTracker) { | 2065 TEST(HeapObjectsTracker) { |
| 2066 const char* extensions[] = { HeapProfilerExtension::kName }; | 2066 const char* extensions[] = { HeapProfilerExtension::kName }; |
| 2067 v8::ExtensionConfiguration config(1, extensions); | 2067 v8::ExtensionConfiguration config(1, extensions); |
| 2068 LocalContext env(&config); | 2068 LocalContext env(&config); |
| 2069 v8::HandleScope scope(env->GetIsolate()); | 2069 v8::HandleScope scope(env->GetIsolate()); |
| 2070 HeapObjectsTracker tracker; | 2070 HeapObjectsTracker tracker; |
| 2071 CompileRun("var a = 1.2"); | 2071 CompileRun("var a = 1.2"); |
| 2072 CompileRun("var a = 1.2; var b = 1.0; var c = 1.0;"); | 2072 CompileRun("var a = 1.2; var b = 1.0; var c = 1.0;"); |
| 2073 // CompileRun("var a = new Array(3); findUntrackedObjects();"); |
| 2073 CompileRun( | 2074 CompileRun( |
| 2074 "var a = [];\n" | 2075 "var a = [];\n" |
| 2075 "for (var i = 0; i < 5; ++i)\n" | 2076 "for (var i = 0; i < 5; ++i)\n" |
| 2076 " a[i] = i;\n" | 2077 " a[i] = i;\n" |
| 2077 "findUntrackedObjects();\n" | 2078 "findUntrackedObjects();\n" |
| 2078 "for (var i = 0; i < 3; ++i)\n" | 2079 "for (var i = 0; i < 3; ++i)\n" |
| 2079 " a.shift();\n" | 2080 " a.shift();\n" |
| 2080 "findUntrackedObjects();\n"); | 2081 "findUntrackedObjects();\n"); |
| 2081 } | 2082 } |
| 2082 | 2083 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 | 2171 |
| 2171 const char* names[] = | 2172 const char* names[] = |
| 2172 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; | 2173 { "(anonymous function)", "start", "f_0_0", "f_0_1", "f_0_2" }; |
| 2173 AllocationTraceNode* node = | 2174 AllocationTraceNode* node = |
| 2174 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | 2175 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); |
| 2175 CHECK_NE(NULL, node); | 2176 CHECK_NE(NULL, node); |
| 2176 CHECK_GE(node->allocation_count(), 100); | 2177 CHECK_GE(node->allocation_count(), 100); |
| 2177 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); | 2178 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); |
| 2178 heap_profiler->StopRecordingHeapAllocations(); | 2179 heap_profiler->StopRecordingHeapAllocations(); |
| 2179 } | 2180 } |
| OLD | NEW |