| 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 7934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7945 const int length = args.smi_at(2); | 7945 const int length = args.smi_at(2); |
| 7946 | 7946 |
| 7947 Object* result; | 7947 Object* result; |
| 7948 { MaybeObject* maybe_result = | 7948 { MaybeObject* maybe_result = |
| 7949 isolate->heap()->AllocateArgumentsObject(callee, length); | 7949 isolate->heap()->AllocateArgumentsObject(callee, length); |
| 7950 if (!maybe_result->ToObject(&result)) return maybe_result; | 7950 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 7951 } | 7951 } |
| 7952 // Allocate the elements if needed. | 7952 // Allocate the elements if needed. |
| 7953 if (length > 0) { | 7953 if (length > 0) { |
| 7954 // Allocate the fixed array. | 7954 // Allocate the fixed array. |
| 7955 Object* obj; | 7955 FixedArray* array; |
| 7956 { MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length); | 7956 { MaybeObject* maybe_obj = |
| 7957 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7957 isolate->heap()->AllocateUninitializedFixedArray(length); |
| 7958 if (!maybe_obj->To(&array)) return maybe_obj; |
| 7958 } | 7959 } |
| 7959 | 7960 |
| 7960 DisallowHeapAllocation no_gc; | 7961 DisallowHeapAllocation no_gc; |
| 7961 FixedArray* array = reinterpret_cast<FixedArray*>(obj); | |
| 7962 array->set_map_no_write_barrier(isolate->heap()->fixed_array_map()); | |
| 7963 array->set_length(length); | |
| 7964 | |
| 7965 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 7962 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 7966 for (int i = 0; i < length; i++) { | 7963 for (int i = 0; i < length; i++) { |
| 7967 array->set(i, *--parameters, mode); | 7964 array->set(i, *--parameters, mode); |
| 7968 } | 7965 } |
| 7969 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | 7966 JSObject::cast(result)->set_elements(array); |
| 7970 } | 7967 } |
| 7971 return result; | 7968 return result; |
| 7972 } | 7969 } |
| 7973 | 7970 |
| 7974 | 7971 |
| 7975 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosureFromStubFailure) { | 7972 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosureFromStubFailure) { |
| 7976 HandleScope scope(isolate); | 7973 HandleScope scope(isolate); |
| 7977 ASSERT(args.length() == 1); | 7974 ASSERT(args.length() == 1); |
| 7978 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 7975 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 7979 Handle<Context> context(isolate->context()); | 7976 Handle<Context> context(isolate->context()); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8436 } | 8433 } |
| 8437 // Evict optimized code for this function from the cache so that it doesn't | 8434 // Evict optimized code for this function from the cache so that it doesn't |
| 8438 // get used for new closures. | 8435 // get used for new closures. |
| 8439 function->shared()->EvictFromOptimizedCodeMap(*optimized_code, | 8436 function->shared()->EvictFromOptimizedCodeMap(*optimized_code, |
| 8440 "notify deoptimized"); | 8437 "notify deoptimized"); |
| 8441 | 8438 |
| 8442 return isolate->heap()->undefined_value(); | 8439 return isolate->heap()->undefined_value(); |
| 8443 } | 8440 } |
| 8444 | 8441 |
| 8445 | 8442 |
| 8446 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { | |
| 8447 SealHandleScope shs(isolate); | |
| 8448 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | |
| 8449 delete deoptimizer; | |
| 8450 return isolate->heap()->undefined_value(); | |
| 8451 } | |
| 8452 | |
| 8453 | |
| 8454 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { | 8443 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { |
| 8455 HandleScope scope(isolate); | 8444 HandleScope scope(isolate); |
| 8456 ASSERT(args.length() == 1); | 8445 ASSERT(args.length() == 1); |
| 8457 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8446 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8458 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 8447 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
| 8459 | 8448 |
| 8460 Deoptimizer::DeoptimizeFunction(*function); | 8449 Deoptimizer::DeoptimizeFunction(*function); |
| 8461 | 8450 |
| 8462 return isolate->heap()->undefined_value(); | 8451 return isolate->heap()->undefined_value(); |
| 8463 } | 8452 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8610 ASSERT(pc_offset == | 8599 ASSERT(pc_offset == |
| 8611 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start())); | 8600 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start())); |
| 8612 #endif // DEBUG | 8601 #endif // DEBUG |
| 8613 | 8602 |
| 8614 // We're not prepared to handle a function with arguments object. | 8603 // We're not prepared to handle a function with arguments object. |
| 8615 ASSERT(!function->shared()->uses_arguments()); | 8604 ASSERT(!function->shared()->uses_arguments()); |
| 8616 | 8605 |
| 8617 Handle<Code> result = Handle<Code>::null(); | 8606 Handle<Code> result = Handle<Code>::null(); |
| 8618 BailoutId ast_id = BailoutId::None(); | 8607 BailoutId ast_id = BailoutId::None(); |
| 8619 | 8608 |
| 8620 if (FLAG_concurrent_recompilation && FLAG_concurrent_osr) { | 8609 if (FLAG_concurrent_osr) { |
| 8621 if (isolate->optimizing_compiler_thread()-> | 8610 if (isolate->optimizing_compiler_thread()-> |
| 8622 IsQueuedForOSR(function, pc_offset)) { | 8611 IsQueuedForOSR(function, pc_offset)) { |
| 8623 // Still waiting for the optimizing compiler thread to finish. Carry on. | 8612 // Still waiting for the optimizing compiler thread to finish. Carry on. |
| 8624 if (FLAG_trace_osr) { | 8613 if (FLAG_trace_osr) { |
| 8625 PrintF("[COSR - polling recompile tasks for "); | 8614 PrintF("[COSR - polling recompile tasks for "); |
| 8626 function->PrintName(); | 8615 function->PrintName(); |
| 8627 PrintF("]\n"); | 8616 PrintF("]\n"); |
| 8628 } | 8617 } |
| 8629 return NULL; | 8618 return NULL; |
| 8630 } | 8619 } |
| 8631 | 8620 |
| 8632 OptimizingCompiler* compiler = isolate->optimizing_compiler_thread()-> | 8621 RecompileJob* job = isolate->optimizing_compiler_thread()-> |
| 8633 FindReadyOSRCandidate(function, pc_offset); | 8622 FindReadyOSRCandidate(function, pc_offset); |
| 8634 | 8623 |
| 8635 if (compiler == NULL) { | 8624 if (job == NULL) { |
| 8636 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && | 8625 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && |
| 8637 Compiler::RecompileConcurrent(function, pc_offset)) { | 8626 Compiler::RecompileConcurrent(function, pc_offset)) { |
| 8638 if (function->IsMarkedForLazyRecompilation() || | 8627 if (function->IsMarkedForLazyRecompilation() || |
| 8639 function->IsMarkedForConcurrentRecompilation()) { | 8628 function->IsMarkedForConcurrentRecompilation()) { |
| 8640 // Prevent regular recompilation if we queue this for OSR. | 8629 // Prevent regular recompilation if we queue this for OSR. |
| 8641 // TODO(yangguo): remove this as soon as OSR becomes one-shot. | 8630 // TODO(yangguo): remove this as soon as OSR becomes one-shot. |
| 8642 function->ReplaceCode(function->shared()->code()); | 8631 function->ReplaceCode(*unoptimized); |
| 8643 } | 8632 } |
| 8644 return NULL; | 8633 return NULL; |
| 8645 } | 8634 } |
| 8646 // Fall through to the end in case of failure. | 8635 // Fall through to the end in case of failure. |
| 8647 } else { | 8636 } else { |
| 8648 // TODO(titzer): don't install the OSR code into the function. | 8637 // TODO(titzer): don't install the OSR code into the function. |
| 8649 ast_id = compiler->info()->osr_ast_id(); | 8638 ast_id = job->info()->osr_ast_id(); |
| 8650 result = Compiler::InstallOptimizedCode(compiler); | 8639 result = Compiler::InstallOptimizedCode(job); |
| 8651 } | 8640 } |
| 8652 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { | 8641 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { |
| 8653 ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); | 8642 ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); |
| 8654 ASSERT(!ast_id.IsNone()); | 8643 ASSERT(!ast_id.IsNone()); |
| 8655 if (FLAG_trace_osr) { | 8644 if (FLAG_trace_osr) { |
| 8656 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); | 8645 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); |
| 8657 function->PrintName(); | 8646 function->PrintName(); |
| 8658 PrintF("]\n"); | 8647 PrintF("]\n"); |
| 8659 } | 8648 } |
| 8660 // Attempt OSR compilation. | 8649 // Attempt OSR compilation. |
| (...skipping 6147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14808 // Handle last resort GC and make sure to allow future allocations | 14797 // Handle last resort GC and make sure to allow future allocations |
| 14809 // to grow the heap without causing GCs (if possible). | 14798 // to grow the heap without causing GCs (if possible). |
| 14810 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14799 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14811 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14800 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14812 "Runtime::PerformGC"); | 14801 "Runtime::PerformGC"); |
| 14813 } | 14802 } |
| 14814 } | 14803 } |
| 14815 | 14804 |
| 14816 | 14805 |
| 14817 } } // namespace v8::internal | 14806 } } // namespace v8::internal |
| OLD | NEW |