| 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 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 AllocationTraceNode* node = | 2491 AllocationTraceNode* node = |
| 2492 FindNode(tracker, Vector<const char*>(names, arraysize(names))); | 2492 FindNode(tracker, Vector<const char*>(names, arraysize(names))); |
| 2493 CHECK(node); | 2493 CHECK(node); |
| 2494 CHECK_GE(node->allocation_count(), 100u); | 2494 CHECK_GE(node->allocation_count(), 100u); |
| 2495 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); | 2495 CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); |
| 2496 heap_profiler->StopTrackingHeapObjects(); | 2496 heap_profiler->StopTrackingHeapObjects(); |
| 2497 } | 2497 } |
| 2498 | 2498 |
| 2499 | 2499 |
| 2500 static const char* inline_heap_allocation_source = | 2500 static const char* inline_heap_allocation_source = |
| 2501 "function f_0(x) {\n" | 2501 "function f_0(x) {\n" |
| 2502 " return f_1(x+1);\n" | 2502 " return f_1(x+1);\n" |
| 2503 "}\n" | 2503 "}\n" |
| 2504 "%NeverOptimizeFunction(f_0);\n" | 2504 "%NeverOptimizeFunction(f_0);\n" |
| 2505 "function f_1(x) {\n" | 2505 "function f_1(x) {\n" |
| 2506 " return new f_2(x+1);\n" | 2506 " return new f_2(x+1);\n" |
| 2507 "}\n" | 2507 "}\n" |
| 2508 "function f_2(x) {\n" | 2508 "%NeverOptimizeFunction(f_1);\n" |
| 2509 " this.foo = x;\n" | 2509 "function f_2(x) {\n" |
| 2510 "}\n" | 2510 " this.foo = x;\n" |
| 2511 "var instances = [];\n" | 2511 "}\n" |
| 2512 "function start() {\n" | 2512 "var instances = [];\n" |
| 2513 " instances.push(f_0(0));\n" | 2513 "function start() {\n" |
| 2514 "}\n" | 2514 " instances.push(f_0(0));\n" |
| 2515 "\n" | 2515 "}\n" |
| 2516 "for (var i = 0; i < 100; i++) start();\n"; | 2516 "\n" |
| 2517 "for (var i = 0; i < 100; i++) start();\n"; |
| 2517 | 2518 |
| 2518 | 2519 |
| 2519 TEST(TrackBumpPointerAllocations) { | 2520 TEST(TrackBumpPointerAllocations) { |
| 2520 i::FLAG_allow_natives_syntax = true; | 2521 i::FLAG_allow_natives_syntax = true; |
| 2521 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2522 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 2522 LocalContext env; | 2523 LocalContext env; |
| 2523 | 2524 |
| 2524 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 2525 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 2525 const char* names[] = {"", "start", "f_0", "f_1"}; | 2526 const char* names[] = {"", "start", "f_0", "f_1"}; |
| 2526 // First check that normally all allocations are recorded. | 2527 // First check that normally all allocations are recorded. |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2796 map.AddRange(ToAddress(0x180), 0x80, 6U); |
| 2796 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2797 map.AddRange(ToAddress(0x180), 0x80, 7U); |
| 2797 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); | 2798 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); |
| 2798 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); | 2799 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); |
| 2799 CHECK_EQ(3u, map.size()); | 2800 CHECK_EQ(3u, map.size()); |
| 2800 | 2801 |
| 2801 map.Clear(); | 2802 map.Clear(); |
| 2802 CHECK_EQ(0u, map.size()); | 2803 CHECK_EQ(0u, map.size()); |
| 2803 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); | 2804 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); |
| 2804 } | 2805 } |
| OLD | NEW |