OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 // Bump the code age so that flushing is triggered. | 1233 // Bump the code age so that flushing is triggered. |
1234 const int kAgingThreshold = 6; | 1234 const int kAgingThreshold = 6; |
1235 for (int i = 0; i < kAgingThreshold; i++) { | 1235 for (int i = 0; i < kAgingThreshold; i++) { |
1236 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); | 1236 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
1237 } | 1237 } |
1238 | 1238 |
1239 // Simulate incremental marking so that the function is enqueued as | 1239 // Simulate incremental marking so that the function is enqueued as |
1240 // code flushing candidate. | 1240 // code flushing candidate. |
1241 SimulateIncrementalMarking(); | 1241 SimulateIncrementalMarking(); |
1242 | 1242 |
| 1243 #ifdef ENABLE_DEBUGGER_SUPPORT |
1243 // Enable the debugger and add a breakpoint while incremental marking | 1244 // Enable the debugger and add a breakpoint while incremental marking |
1244 // is running so that incremental marking aborts and code flushing is | 1245 // is running so that incremental marking aborts and code flushing is |
1245 // disabled. | 1246 // disabled. |
1246 int position = 0; | 1247 int position = 0; |
1247 Handle<Object> breakpoint_object(Smi::FromInt(0), isolate); | 1248 Handle<Object> breakpoint_object(Smi::FromInt(0), isolate); |
1248 isolate->debug()->SetBreakPoint(function, breakpoint_object, &position); | 1249 isolate->debug()->SetBreakPoint(function, breakpoint_object, &position); |
1249 isolate->debug()->ClearAllBreakPoints(); | 1250 isolate->debug()->ClearAllBreakPoints(); |
| 1251 #endif // ENABLE_DEBUGGER_SUPPORT |
1250 | 1252 |
1251 // Force optimization now that code flushing is disabled. | 1253 // Force optimization now that code flushing is disabled. |
1252 { v8::HandleScope scope(env->GetIsolate()); | 1254 { v8::HandleScope scope(env->GetIsolate()); |
1253 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); | 1255 CompileRun("%OptimizeFunctionOnNextCall(foo); foo();"); |
1254 } | 1256 } |
1255 | 1257 |
1256 // Simulate one final GC to make sure the candidate queue is sane. | 1258 // Simulate one final GC to make sure the candidate queue is sane. |
1257 heap->CollectAllGarbage(Heap::kNoGCFlags); | 1259 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1258 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); | 1260 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); |
1259 CHECK(function->is_compiled() || !function->IsOptimized()); | 1261 CHECK(function->is_compiled() || !function->IsOptimized()); |
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 } | 3005 } |
3004 | 3006 |
3005 function = inner_scope.CloseAndEscape(handle(*f, isolate)); | 3007 function = inner_scope.CloseAndEscape(handle(*f, isolate)); |
3006 } | 3008 } |
3007 | 3009 |
3008 // Simulate incremental marking so that unoptimized function is enqueued as a | 3010 // Simulate incremental marking so that unoptimized function is enqueued as a |
3009 // candidate for code flushing. The shared function info however will not be | 3011 // candidate for code flushing. The shared function info however will not be |
3010 // explicitly enqueued. | 3012 // explicitly enqueued. |
3011 SimulateIncrementalMarking(); | 3013 SimulateIncrementalMarking(); |
3012 | 3014 |
| 3015 #ifdef ENABLE_DEBUGGER_SUPPORT |
3013 // Now enable the debugger which in turn will disable code flushing. | 3016 // Now enable the debugger which in turn will disable code flushing. |
3014 CHECK(isolate->debug()->Load()); | 3017 CHECK(isolate->debug()->Load()); |
| 3018 #endif // ENABLE_DEBUGGER_SUPPORT |
3015 | 3019 |
3016 // This cycle will bust the heap and subsequent cycles will go ballistic. | 3020 // This cycle will bust the heap and subsequent cycles will go ballistic. |
3017 heap->CollectAllGarbage(Heap::kNoGCFlags); | 3021 heap->CollectAllGarbage(Heap::kNoGCFlags); |
3018 heap->CollectAllGarbage(Heap::kNoGCFlags); | 3022 heap->CollectAllGarbage(Heap::kNoGCFlags); |
3019 } | 3023 } |
3020 | 3024 |
3021 | 3025 |
3022 class DummyVisitor : public ObjectVisitor { | 3026 class DummyVisitor : public ObjectVisitor { |
3023 public: | 3027 public: |
3024 void VisitPointers(Object** start, Object** end) { } | 3028 void VisitPointers(Object** start, Object** end) { } |
(...skipping 13 matching lines...) Expand all Loading... |
3038 } | 3042 } |
3039 // An entire block of handles has been filled. | 3043 // An entire block of handles has been filled. |
3040 // Next handle would require a new block. | 3044 // Next handle would require a new block. |
3041 ASSERT(data->next == data->limit); | 3045 ASSERT(data->next == data->limit); |
3042 | 3046 |
3043 DeferredHandleScope deferred(isolate); | 3047 DeferredHandleScope deferred(isolate); |
3044 DummyVisitor visitor; | 3048 DummyVisitor visitor; |
3045 isolate->handle_scope_implementer()->Iterate(&visitor); | 3049 isolate->handle_scope_implementer()->Iterate(&visitor); |
3046 deferred.Detach(); | 3050 deferred.Detach(); |
3047 } | 3051 } |
OLD | NEW |