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 8565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8576 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { | 8576 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { |
8577 HandleScope scope(isolate); | 8577 HandleScope scope(isolate); |
8578 ASSERT(args.length() == 1); | 8578 ASSERT(args.length() == 1); |
8579 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8579 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8580 return Smi::FromInt(function->shared()->opt_count()); | 8580 return Smi::FromInt(function->shared()->opt_count()); |
8581 } | 8581 } |
8582 | 8582 |
8583 | 8583 |
8584 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { | 8584 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
8585 HandleScope scope(isolate); | 8585 HandleScope scope(isolate); |
8586 ASSERT(args.length() == 1); | 8586 ASSERT(args.length() == 2); |
8587 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8587 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8588 CONVERT_NUMBER_CHECKED(uint32_t, pc_offset, Uint32, args[1]); |
| 8589 |
| 8590 #ifdef DEBUG |
| 8591 JavaScriptFrameIterator it(isolate); |
| 8592 JavaScriptFrame* frame = it.frame(); |
| 8593 Handle<Code> unoptimized(function->shared()->code(), isolate); |
| 8594 ASSERT_EQ(frame->function(), *function); |
| 8595 ASSERT_EQ(frame->LookupCode(), *unoptimized); |
| 8596 ASSERT(unoptimized->contains(frame->pc())); |
| 8597 |
| 8598 ASSERT(pc_offset == |
| 8599 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start())); |
| 8600 #endif // DEBUG |
8588 | 8601 |
8589 // We're not prepared to handle a function with arguments object. | 8602 // We're not prepared to handle a function with arguments object. |
8590 ASSERT(!function->shared()->uses_arguments()); | 8603 ASSERT(!function->shared()->uses_arguments()); |
8591 | 8604 |
8592 // If the optimization attempt succeeds, return the code object which | 8605 // If the optimization attempt succeeds, return the code object which |
8593 // the unoptimized code can jump into. | 8606 // the unoptimized code can jump into. |
8594 Handle<Code> code = | 8607 Handle<Code> code = |
8595 (FLAG_concurrent_recompilation && FLAG_concurrent_osr) | 8608 (FLAG_concurrent_recompilation && FLAG_concurrent_osr) |
8596 ? Compiler::CompileForConcurrentOSR(function) | 8609 ? Compiler::CompileForConcurrentOSR(function, pc_offset) |
8597 : Compiler::CompileForOnStackReplacement(function); | 8610 : Compiler::CompileForOnStackReplacement(function, pc_offset); |
8598 if (!code.is_null()) { | 8611 if (!code.is_null()) { |
8599 #if DEBUG | 8612 #if DEBUG |
8600 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 8613 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
8601 DeoptimizationInputData* data = | 8614 DeoptimizationInputData* data = |
8602 DeoptimizationInputData::cast(code->deoptimization_data()); | 8615 DeoptimizationInputData::cast(code->deoptimization_data()); |
8603 ASSERT(!BailoutId(data->OsrAstId()->value()).IsNone()); | 8616 ASSERT(!BailoutId(data->OsrAstId()->value()).IsNone()); |
8604 #endif | 8617 #endif |
8605 // TODO(titzer): this is a massive hack to make the deopt counts | 8618 // TODO(titzer): this is a massive hack to make the deopt counts |
8606 // match. Fix heuristics for reenabling optimizations! | 8619 // match. Fix heuristics for reenabling optimizations! |
8607 function->shared()->increment_deopt_count(); | 8620 function->shared()->increment_deopt_count(); |
(...skipping 6068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14676 // Handle last resort GC and make sure to allow future allocations | 14689 // Handle last resort GC and make sure to allow future allocations |
14677 // to grow the heap without causing GCs (if possible). | 14690 // to grow the heap without causing GCs (if possible). |
14678 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14691 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14679 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14692 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14680 "Runtime::PerformGC"); | 14693 "Runtime::PerformGC"); |
14681 } | 14694 } |
14682 } | 14695 } |
14683 | 14696 |
14684 | 14697 |
14685 } } // namespace v8::internal | 14698 } } // namespace v8::internal |
OLD | NEW |