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 8416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8427 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 8427 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
8428 PrintF("[unoptimized: "); | 8428 PrintF("[unoptimized: "); |
8429 function->PrintName(); | 8429 function->PrintName(); |
8430 PrintF("]\n"); | 8430 PrintF("]\n"); |
8431 } | 8431 } |
8432 #endif | 8432 #endif |
8433 | 8433 |
8434 // Compile the target function. | 8434 // Compile the target function. |
8435 ASSERT(function->shared()->allows_lazy_compilation()); | 8435 ASSERT(function->shared()->allows_lazy_compilation()); |
8436 | 8436 |
8437 Handle<Code> code = Compiler::GetUnoptimizedCode(function); | 8437 Handle<Code> code; |
8438 RETURN_IF_EMPTY_HANDLE(isolate, code); | 8438 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, |
| 8439 Compiler::GetUnoptimizedCode(function)); |
8439 function->ReplaceCode(*code); | 8440 function->ReplaceCode(*code); |
8440 | 8441 |
8441 // All done. Return the compiled code. | 8442 // All done. Return the compiled code. |
8442 ASSERT(function->is_compiled()); | 8443 ASSERT(function->is_compiled()); |
8443 ASSERT(function->code()->kind() == Code::FUNCTION || | 8444 ASSERT(function->code()->kind() == Code::FUNCTION || |
8444 (FLAG_always_opt && | 8445 (FLAG_always_opt && |
8445 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); | 8446 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); |
8446 return *code; | 8447 return *code; |
8447 } | 8448 } |
8448 | 8449 |
(...skipping 20 matching lines...) Expand all Loading... |
8469 PrintF("[failed to optimize "); | 8470 PrintF("[failed to optimize "); |
8470 function->PrintName(); | 8471 function->PrintName(); |
8471 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", | 8472 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", |
8472 function->shared()->optimization_disabled() ? "F" : "T", | 8473 function->shared()->optimization_disabled() ? "F" : "T", |
8473 isolate->DebuggerHasBreakPoints() ? "T" : "F"); | 8474 isolate->DebuggerHasBreakPoints() ? "T" : "F"); |
8474 } | 8475 } |
8475 function->ReplaceCode(*unoptimized); | 8476 function->ReplaceCode(*unoptimized); |
8476 } else { | 8477 } else { |
8477 Compiler::ConcurrencyMode mode = concurrent ? Compiler::CONCURRENT | 8478 Compiler::ConcurrencyMode mode = concurrent ? Compiler::CONCURRENT |
8478 : Compiler::NOT_CONCURRENT; | 8479 : Compiler::NOT_CONCURRENT; |
8479 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized, mode); | 8480 Handle<Code> code; |
8480 function->ReplaceCode(code.is_null() ? *unoptimized : *code); | 8481 if (Compiler::GetOptimizedCode( |
| 8482 function, unoptimized, mode).ToHandle(&code)) { |
| 8483 function->ReplaceCode(*code); |
| 8484 } else { |
| 8485 function->ReplaceCode(*unoptimized); |
| 8486 } |
8481 } | 8487 } |
8482 | 8488 |
8483 ASSERT(function->code()->kind() == Code::FUNCTION || | 8489 ASSERT(function->code()->kind() == Code::FUNCTION || |
8484 function->code()->kind() == Code::OPTIMIZED_FUNCTION || | 8490 function->code()->kind() == Code::OPTIMIZED_FUNCTION || |
8485 function->IsInOptimizationQueue()); | 8491 function->IsInOptimizationQueue()); |
8486 return function->code(); | 8492 return function->code(); |
8487 } | 8493 } |
8488 | 8494 |
8489 | 8495 |
8490 class ActivationsFinder : public ThreadVisitor { | 8496 class ActivationsFinder : public ThreadVisitor { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8791 job = thread->FindReadyOSRCandidate(function, ast_id); | 8797 job = thread->FindReadyOSRCandidate(function, ast_id); |
8792 } | 8798 } |
8793 | 8799 |
8794 if (job != NULL) { | 8800 if (job != NULL) { |
8795 if (FLAG_trace_osr) { | 8801 if (FLAG_trace_osr) { |
8796 PrintF("[OSR - Found ready: "); | 8802 PrintF("[OSR - Found ready: "); |
8797 function->PrintName(); | 8803 function->PrintName(); |
8798 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 8804 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
8799 } | 8805 } |
8800 result = Compiler::GetConcurrentlyOptimizedCode(job); | 8806 result = Compiler::GetConcurrentlyOptimizedCode(job); |
8801 } else if (result.is_null() && | 8807 } else if (IsSuitableForOnStackReplacement(isolate, function, caller_code)) { |
8802 IsSuitableForOnStackReplacement(isolate, function, caller_code)) { | |
8803 if (FLAG_trace_osr) { | 8808 if (FLAG_trace_osr) { |
8804 PrintF("[OSR - Compiling: "); | 8809 PrintF("[OSR - Compiling: "); |
8805 function->PrintName(); | 8810 function->PrintName(); |
8806 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 8811 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
8807 } | 8812 } |
8808 result = Compiler::GetOptimizedCode(function, caller_code, mode, ast_id); | 8813 MaybeHandle<Code> maybe_result = Compiler::GetOptimizedCode( |
8809 if (result.is_identical_to(isolate->builtins()->InOptimizationQueue())) { | 8814 function, caller_code, mode, ast_id); |
| 8815 if (maybe_result.ToHandle(&result) && |
| 8816 result.is_identical_to(isolate->builtins()->InOptimizationQueue())) { |
8810 // Optimization is queued. Return to check later. | 8817 // Optimization is queued. Return to check later. |
8811 return NULL; | 8818 return NULL; |
8812 } | 8819 } |
8813 } | 8820 } |
8814 | 8821 |
8815 // Revert the patched back edge table, regardless of whether OSR succeeds. | 8822 // Revert the patched back edge table, regardless of whether OSR succeeds. |
8816 BackEdgeTable::Revert(isolate, *caller_code); | 8823 BackEdgeTable::Revert(isolate, *caller_code); |
8817 | 8824 |
8818 // Check whether we ended up with usable optimized code. | 8825 // Check whether we ended up with usable optimized code. |
8819 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { | 8826 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { |
(...skipping 6311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15131 } | 15138 } |
15132 } | 15139 } |
15133 | 15140 |
15134 | 15141 |
15135 void Runtime::OutOfMemory() { | 15142 void Runtime::OutOfMemory() { |
15136 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15143 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15137 UNREACHABLE(); | 15144 UNREACHABLE(); |
15138 } | 15145 } |
15139 | 15146 |
15140 } } // namespace v8::internal | 15147 } } // namespace v8::internal |
OLD | NEW |