OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "compilation-cache.h" | 7 #include "compilation-cache.h" |
8 #include "execution.h" | 8 #include "execution.h" |
9 #include "factory.h" | 9 #include "factory.h" |
10 #include "macro-assembler.h" | 10 #include "macro-assembler.h" |
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2830 // Now optimize the function so that it is taken off the candidate list. | 2830 // Now optimize the function so that it is taken off the candidate list. |
2831 { | 2831 { |
2832 HandleScope inner_scope; | 2832 HandleScope inner_scope; |
2833 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); | 2833 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); |
2834 } | 2834 } |
2835 | 2835 |
2836 // This cycle will bust the heap and subsequent cycles will go ballistic. | 2836 // This cycle will bust the heap and subsequent cycles will go ballistic. |
2837 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2837 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
2838 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2838 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
2839 } | 2839 } |
2840 | |
2841 | |
2842 TEST(Regress173458) { | |
2843 i::FLAG_always_compact = true; | |
2844 i::FLAG_cache_optimized_code = false; | |
2845 i::FLAG_allow_natives_syntax = true; | |
2846 i::FLAG_flush_code_incrementally = true; | |
2847 InitializeVM(); | |
2848 v8::HandleScope scope; | |
2849 | |
2850 // Perform one initial GC to enable code flushing. | |
2851 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | |
2852 | |
2853 // Ensure the code ends up on an evacuation candidate. | |
2854 SimulateFullSpace(HEAP->code_space()); | |
2855 | |
2856 // Prepare an unoptimized function that is eligible for code flushing. | |
2857 Handle<JSFunction> function; | |
2858 { | |
2859 HandleScope inner_scope; | |
2860 CompileRun("function mkClosure() {" | |
2861 " return function(x) { return x + 1; };" | |
2862 "}" | |
2863 "var f = mkClosure();" | |
2864 "f(1); f(2);"); | |
2865 | |
2866 Handle<JSFunction> f = | |
2867 v8::Utils::OpenHandle( | |
2868 *v8::Handle<v8::Function>::Cast( | |
2869 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); | |
2870 CHECK(f->is_compiled()); | |
2871 const int kAgingThreshold = 6; | |
2872 for (int i = 0; i < kAgingThreshold; i++) { | |
2873 f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | |
2874 } | |
2875 | |
2876 function = inner_scope.CloseAndEscape(handle(*f, ISOLATE)); | |
2877 } | |
Hannes Payer (out of office)
2013/02/11 14:48:58
In the future, we may wanna have that code in a fu
Michael Starzinger
2013/02/11 15:01:33
Agreed, I'll clean that up in a follow-up CL. But
| |
2878 | |
2879 // Simulate incremental marking so that unoptimized function is enqueued as a | |
2880 // candidate for code flushing. The shared function info however will not be | |
2881 // explicitly enqueued. | |
2882 SimulateIncrementalMarking(); | |
2883 | |
2884 // Now enable the debugger which in turn will disable code flushing. | |
2885 CHECK(ISOLATE->debug()->Load()); | |
2886 | |
2887 // This cycle will bust the heap and subsequent cycles will go ballistic. | |
2888 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | |
2889 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | |
2890 } | |
OLD | NEW |