| 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 8446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8457 has_other_activations = activations_finder.has_activations(); | 8457 has_other_activations = activations_finder.has_activations(); |
| 8458 } | 8458 } |
| 8459 | 8459 |
| 8460 if (!has_other_activations) { | 8460 if (!has_other_activations) { |
| 8461 if (FLAG_trace_deopt) { | 8461 if (FLAG_trace_deopt) { |
| 8462 PrintF("[removing optimized code for: "); | 8462 PrintF("[removing optimized code for: "); |
| 8463 function->PrintName(); | 8463 function->PrintName(); |
| 8464 PrintF("]\n"); | 8464 PrintF("]\n"); |
| 8465 } | 8465 } |
| 8466 function->ReplaceCode(function->shared()->code()); | 8466 function->ReplaceCode(function->shared()->code()); |
| 8467 |
| 8468 // Limit the number of times we re-compile a functions after deoptimization. |
| 8469 function->shared()->IncrementAndCheckDeoptCount(); |
| 8467 } else { | 8470 } else { |
| 8468 Deoptimizer::DeoptimizeFunction(*function); | 8471 Deoptimizer::DeoptimizeFunction(*function); |
| 8469 } | 8472 } |
| 8470 return isolate->heap()->undefined_value(); | 8473 return isolate->heap()->undefined_value(); |
| 8471 } | 8474 } |
| 8472 | 8475 |
| 8473 | 8476 |
| 8474 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { | 8477 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { |
| 8475 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8478 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8476 delete deoptimizer; | 8479 delete deoptimizer; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8519 } | 8522 } |
| 8520 if (FLAG_always_opt) { | 8523 if (FLAG_always_opt) { |
| 8521 return Smi::FromInt(3); // 3 == "always". | 8524 return Smi::FromInt(3); // 3 == "always". |
| 8522 } | 8525 } |
| 8523 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8526 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8524 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 8527 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". |
| 8525 : Smi::FromInt(2); // 2 == "no". | 8528 : Smi::FromInt(2); // 2 == "no". |
| 8526 } | 8529 } |
| 8527 | 8530 |
| 8528 | 8531 |
| 8529 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { | 8532 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDeoptimizationCount) { |
| 8530 HandleScope scope(isolate); | 8533 HandleScope scope(isolate); |
| 8531 ASSERT(args.length() == 1); | 8534 ASSERT(args.length() == 1); |
| 8532 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8535 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8533 return Smi::FromInt(function->shared()->opt_count()); | 8536 return Smi::FromInt(function->shared()->deopt_count()); |
| 8534 } | 8537 } |
| 8535 | 8538 |
| 8536 | 8539 |
| 8537 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { | 8540 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| 8538 HandleScope scope(isolate); | 8541 HandleScope scope(isolate); |
| 8539 ASSERT(args.length() == 1); | 8542 ASSERT(args.length() == 1); |
| 8540 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8543 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8541 | 8544 |
| 8542 // We're not prepared to handle a function with arguments object. | 8545 // We're not prepared to handle a function with arguments object. |
| 8543 ASSERT(!function->shared()->uses_arguments()); | 8546 ASSERT(!function->shared()->uses_arguments()); |
| (...skipping 5003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13547 } else { | 13550 } else { |
| 13548 // Handle last resort GC and make sure to allow future allocations | 13551 // Handle last resort GC and make sure to allow future allocations |
| 13549 // to grow the heap without causing GCs (if possible). | 13552 // to grow the heap without causing GCs (if possible). |
| 13550 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13553 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13551 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13554 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13552 } | 13555 } |
| 13553 } | 13556 } |
| 13554 | 13557 |
| 13555 | 13558 |
| 13556 } } // namespace v8::internal | 13559 } } // namespace v8::internal |
| OLD | NEW |