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 8300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8311 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { | 8311 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { |
8312 HandleScope scope(isolate); | 8312 HandleScope scope(isolate); |
8313 ASSERT(args.length() == 1); | 8313 ASSERT(args.length() == 1); |
8314 Handle<JSFunction> function = args.at<JSFunction>(0); | 8314 Handle<JSFunction> function = args.at<JSFunction>(0); |
8315 | 8315 |
8316 if (!AllowOptimization(isolate, function)) { | 8316 if (!AllowOptimization(isolate, function)) { |
8317 function->ReplaceCode(function->shared()->code()); | 8317 function->ReplaceCode(function->shared()->code()); |
8318 return function->code(); | 8318 return function->code(); |
8319 } | 8319 } |
8320 function->shared()->code()->set_profiler_ticks(0); | 8320 function->shared()->code()->set_profiler_ticks(0); |
8321 if (JSFunction::CompileOptimized(function, | 8321 if (JSFunction::CompileOptimized(function, CLEAR_EXCEPTION)) { |
8322 BailoutId::None(), | |
8323 CLEAR_EXCEPTION)) { | |
8324 return function->code(); | 8322 return function->code(); |
8325 } | 8323 } |
8326 if (FLAG_trace_opt) { | 8324 if (FLAG_trace_opt) { |
8327 PrintF("[failed to optimize "); | 8325 PrintF("[failed to optimize "); |
8328 function->PrintName(); | 8326 function->PrintName(); |
8329 PrintF(": optimized compilation failed]\n"); | 8327 PrintF(": optimized compilation failed]\n"); |
8330 } | 8328 } |
8331 function->ReplaceCode(function->shared()->code()); | 8329 function->ReplaceCode(function->shared()->code()); |
8332 return function->code(); | 8330 return function->code(); |
8333 } | 8331 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8409 ASSERT(type == deoptimizer->bailout_type()); | 8407 ASSERT(type == deoptimizer->bailout_type()); |
8410 | 8408 |
8411 // Make sure to materialize objects before causing any allocation. | 8409 // Make sure to materialize objects before causing any allocation. |
8412 JavaScriptFrameIterator it(isolate); | 8410 JavaScriptFrameIterator it(isolate); |
8413 deoptimizer->MaterializeHeapObjects(&it); | 8411 deoptimizer->MaterializeHeapObjects(&it); |
8414 delete deoptimizer; | 8412 delete deoptimizer; |
8415 | 8413 |
8416 JavaScriptFrame* frame = it.frame(); | 8414 JavaScriptFrame* frame = it.frame(); |
8417 RUNTIME_ASSERT(frame->function()->IsJSFunction()); | 8415 RUNTIME_ASSERT(frame->function()->IsJSFunction()); |
8418 | 8416 |
8417 ASSERT(frame->function() == *function); | |
Michael Starzinger
2013/09/09 15:34:44
nit: Move up one line.
| |
8419 // Avoid doing too much work when running with --always-opt and keep | 8418 // Avoid doing too much work when running with --always-opt and keep |
8420 // the optimized code around. | 8419 // the optimized code around. |
8421 if (FLAG_always_opt || type == Deoptimizer::LAZY) { | 8420 if (FLAG_always_opt || type == Deoptimizer::LAZY) { |
8422 return isolate->heap()->undefined_value(); | 8421 return isolate->heap()->undefined_value(); |
8423 } | 8422 } |
8424 | 8423 |
8425 // Search for other activations of the same function and code. | 8424 // Search for other activations of the same function and code. |
8426 ActivationsFinder activations_finder(*optimized_code); | 8425 ActivationsFinder activations_finder(*optimized_code); |
8427 activations_finder.VisitFrames(&it); | 8426 activations_finder.VisitFrames(&it); |
8428 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); | 8427 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8585 | 8584 |
8586 | 8585 |
8587 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { | 8586 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
8588 HandleScope scope(isolate); | 8587 HandleScope scope(isolate); |
8589 ASSERT(args.length() == 1); | 8588 ASSERT(args.length() == 1); |
8590 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8589 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8591 | 8590 |
8592 // We're not prepared to handle a function with arguments object. | 8591 // We're not prepared to handle a function with arguments object. |
8593 ASSERT(!function->shared()->uses_arguments()); | 8592 ASSERT(!function->shared()->uses_arguments()); |
8594 | 8593 |
8595 // If the optimization attempt succeeded, return the AST id tagged as a | 8594 // If the optimization attempt succeeds, return the code object, which, |
8596 // smi. This tells the builtin that we need to translate the unoptimized | 8595 // which the unoptimized code can jump into. |
Michael Starzinger
2013/09/09 15:34:44
nit: Drop one of the "which".
| |
8597 // frame to an optimized one. | 8596 Handle<Code> code = |
8598 BailoutId ast_id = | |
8599 (FLAG_concurrent_recompilation && FLAG_concurrent_osr) | 8597 (FLAG_concurrent_recompilation && FLAG_concurrent_osr) |
8600 ? Compiler::CompileForConcurrentOSR(function) | 8598 ? Compiler::CompileForConcurrentOSR(function) |
8601 : Compiler::CompileForOnStackReplacement(function); | 8599 : Compiler::CompileForOnStackReplacement(function); |
8602 if (!ast_id.IsNone()) { | 8600 if (!code.is_null()) { |
8603 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); | 8601 #if DEBUG |
8604 return Smi::FromInt(ast_id.ToInt()); | 8602 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
8603 DeoptimizationInputData* data = | |
8604 DeoptimizationInputData::cast(code->deoptimization_data()); | |
8605 ASSERT(!BailoutId(data->OsrAstId()->value()).IsNone()); | |
8606 #endif | |
8607 // TODO(titzer): this is a massive hack to make the deopt counts | |
8608 // match. Fix heuristics for reenabling optimizations! | |
8609 function->shared()->increment_deopt_count(); | |
8610 return *code; | |
8605 } else { | 8611 } else { |
8606 if (function->IsMarkedForLazyRecompilation() || | 8612 if (function->IsMarkedForLazyRecompilation() || |
8607 function->IsMarkedForConcurrentRecompilation()) { | 8613 function->IsMarkedForConcurrentRecompilation()) { |
8608 function->ReplaceCode(function->shared()->code()); | 8614 function->ReplaceCode(function->shared()->code()); |
8609 } | 8615 } |
8610 return Smi::FromInt(-1); | 8616 return NULL; |
8611 } | 8617 } |
8612 } | 8618 } |
8613 | 8619 |
8614 | 8620 |
8615 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) { | 8621 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) { |
8616 SealHandleScope shs(isolate); | 8622 SealHandleScope shs(isolate); |
8617 ASSERT(args.length() == 2); | 8623 ASSERT(args.length() == 2); |
8618 #ifdef DEBUG | 8624 #ifdef DEBUG |
8619 CONVERT_SMI_ARG_CHECKED(interval, 0); | 8625 CONVERT_SMI_ARG_CHECKED(interval, 0); |
8620 CONVERT_SMI_ARG_CHECKED(timeout, 1); | 8626 CONVERT_SMI_ARG_CHECKED(timeout, 1); |
(...skipping 6053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14674 // Handle last resort GC and make sure to allow future allocations | 14680 // Handle last resort GC and make sure to allow future allocations |
14675 // to grow the heap without causing GCs (if possible). | 14681 // to grow the heap without causing GCs (if possible). |
14676 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14682 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14677 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14683 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14678 "Runtime::PerformGC"); | 14684 "Runtime::PerformGC"); |
14679 } | 14685 } |
14680 } | 14686 } |
14681 | 14687 |
14682 | 14688 |
14683 } } // namespace v8::internal | 14689 } } // namespace v8::internal |
OLD | NEW |