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 8479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8490 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); | 8490 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); |
8491 function->MarkForLazyRecompilation(); | 8491 function->MarkForLazyRecompilation(); |
8492 | 8492 |
8493 Code* unoptimized = function->shared()->code(); | 8493 Code* unoptimized = function->shared()->code(); |
8494 if (args.length() == 2 && | 8494 if (args.length() == 2 && |
8495 unoptimized->kind() == Code::FUNCTION) { | 8495 unoptimized->kind() == Code::FUNCTION) { |
8496 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 8496 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
8497 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { | 8497 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { |
8498 // Start patching from the currently patched loop nesting level. | 8498 // Start patching from the currently patched loop nesting level. |
8499 int current_level = unoptimized->allow_osr_at_loop_nesting_level(); | 8499 int current_level = unoptimized->allow_osr_at_loop_nesting_level(); |
8500 ASSERT(Deoptimizer::VerifyInterruptCode( | 8500 ASSERT(BackEdgeTable::Verify(isolate, unoptimized, current_level)); |
8501 isolate, unoptimized, current_level)); | |
8502 for (int i = current_level + 1; i <= Code::kMaxLoopNestingMarker; i++) { | 8501 for (int i = current_level + 1; i <= Code::kMaxLoopNestingMarker; i++) { |
8503 unoptimized->set_allow_osr_at_loop_nesting_level(i); | 8502 unoptimized->set_allow_osr_at_loop_nesting_level(i); |
8504 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); | 8503 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); |
8505 } | 8504 } |
8506 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) { | 8505 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) { |
8507 function->MarkForConcurrentRecompilation(); | 8506 function->MarkForConcurrentRecompilation(); |
8508 } | 8507 } |
8509 } | 8508 } |
8510 | 8509 |
8511 return isolate->heap()->undefined_value(); | 8510 return isolate->heap()->undefined_value(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8644 ASSERT(!ast_id.IsNone()); | 8643 ASSERT(!ast_id.IsNone()); |
8645 if (FLAG_trace_osr) { | 8644 if (FLAG_trace_osr) { |
8646 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); | 8645 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); |
8647 function->PrintName(); | 8646 function->PrintName(); |
8648 PrintF("]\n"); | 8647 PrintF("]\n"); |
8649 } | 8648 } |
8650 // Attempt OSR compilation. | 8649 // Attempt OSR compilation. |
8651 result = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION); | 8650 result = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION); |
8652 } | 8651 } |
8653 | 8652 |
8654 // Revert the patched interrupt now, regardless of whether OSR succeeds. | 8653 // Revert the patched back edge table, regardless of whether OSR succeeds. |
8655 Deoptimizer::RevertInterruptCode(isolate, *unoptimized); | 8654 BackEdgeTable::Revert(isolate, *unoptimized); |
8656 | 8655 |
8657 // Check whether we ended up with usable optimized code. | 8656 // Check whether we ended up with usable optimized code. |
8658 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { | 8657 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { |
8659 DeoptimizationInputData* data = | 8658 DeoptimizationInputData* data = |
8660 DeoptimizationInputData::cast(result->deoptimization_data()); | 8659 DeoptimizationInputData::cast(result->deoptimization_data()); |
8661 | 8660 |
8662 if (data->OsrPcOffset()->value() >= 0) { | 8661 if (data->OsrPcOffset()->value() >= 0) { |
8663 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); | 8662 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); |
8664 if (FLAG_trace_osr) { | 8663 if (FLAG_trace_osr) { |
8665 PrintF("[OSR - entry at AST id %d, offset %d in optimized code]\n", | 8664 PrintF("[OSR - entry at AST id %d, offset %d in optimized code]\n", |
(...skipping 6132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14798 // Handle last resort GC and make sure to allow future allocations | 14797 // Handle last resort GC and make sure to allow future allocations |
14799 // to grow the heap without causing GCs (if possible). | 14798 // to grow the heap without causing GCs (if possible). |
14800 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14799 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14801 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14800 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14802 "Runtime::PerformGC"); | 14801 "Runtime::PerformGC"); |
14803 } | 14802 } |
14804 } | 14803 } |
14805 | 14804 |
14806 | 14805 |
14807 } } // namespace v8::internal | 14806 } } // namespace v8::internal |
OLD | NEW |