diff options
Diffstat (limited to 'deps/v8/src/deoptimizer.h')
-rw-r--r-- | deps/v8/src/deoptimizer.h | 128 |
1 files changed, 38 insertions, 90 deletions
diff --git a/deps/v8/src/deoptimizer.h b/deps/v8/src/deoptimizer.h index e5afd1ae6..7ee5908f7 100644 --- a/deps/v8/src/deoptimizer.h +++ b/deps/v8/src/deoptimizer.h @@ -58,7 +58,6 @@ static inline double read_double_value(Address p) { class FrameDescription; class TranslationIterator; -class DeoptimizingCodeListNode; class DeoptimizedFrameInfo; class HeapNumberMaterializationDescriptor BASE_EMBEDDED { @@ -121,29 +120,22 @@ class OptimizedFunctionVisitor BASE_EMBEDDED { }; -class OptimizedFunctionFilter BASE_EMBEDDED { - public: - virtual ~OptimizedFunctionFilter() {} - - virtual bool TakeFunction(JSFunction* function) = 0; -}; - - -class Deoptimizer; - - class Deoptimizer : public Malloced { public: enum BailoutType { EAGER, LAZY, SOFT, - OSR, // This last bailout type is not really a bailout, but used by the // debugger to deoptimize stack frames to allow inspection. DEBUGGER }; + enum InterruptPatchState { + NOT_PATCHED, + PATCHED_FOR_OSR + }; + static const int kBailoutTypesWithCodeEntry = SOFT + 1; struct JumpTableEntry { @@ -203,68 +195,54 @@ class Deoptimizer : public Malloced { // execution returns. static void DeoptimizeFunction(JSFunction* function); - // Iterate over all the functions which share the same code object - // and make them use unoptimized version. - static void ReplaceCodeForRelatedFunctions(JSFunction* function, Code* code); - - // Deoptimize all functions in the heap. + // Deoptimize all code in the given isolate. static void DeoptimizeAll(Isolate* isolate); + // Deoptimize code associated with the given global object. static void DeoptimizeGlobalObject(JSObject* object); - static void DeoptimizeAllFunctionsWith(Isolate* isolate, - OptimizedFunctionFilter* filter); - - static void DeoptimizeCodeList(Isolate* isolate, ZoneList<Code*>* codes); - - static void DeoptimizeAllFunctionsForContext( - Context* context, OptimizedFunctionFilter* filter); - - static void VisitAllOptimizedFunctionsForContext( - Context* context, OptimizedFunctionVisitor* visitor); + // Deoptimizes all optimized code that has been previously marked + // (via code->set_marked_for_deoptimization) and unlinks all functions that + // refer to that code. + static void DeoptimizeMarkedCode(Isolate* isolate); - static void VisitAllOptimizedFunctions(Isolate* isolate, - OptimizedFunctionVisitor* visitor); + // Visit all the known optimized functions in a given isolate. + static void VisitAllOptimizedFunctions( + Isolate* isolate, OptimizedFunctionVisitor* visitor); // The size in bytes of the code required at a lazy deopt patch site. static int patch_size(); // Patch all interrupts with allowed loop depth in the unoptimized code to // unconditionally call replacement_code. - static void PatchInterruptCode(Code* unoptimized_code, - Code* interrupt_code, - Code* replacement_code); + static void PatchInterruptCode(Isolate* isolate, + Code* unoptimized_code); // Patch the interrupt at the instruction before pc_after in // the unoptimized code to unconditionally call replacement_code. static void PatchInterruptCodeAt(Code* unoptimized_code, Address pc_after, - Code* interrupt_code, Code* replacement_code); // Change all patched interrupts patched in the unoptimized code // back to normal interrupts. - static void RevertInterruptCode(Code* unoptimized_code, - Code* interrupt_code, - Code* replacement_code); + static void RevertInterruptCode(Isolate* isolate, + Code* unoptimized_code); // Change patched interrupt in the unoptimized code // back to a normal interrupt. static void RevertInterruptCodeAt(Code* unoptimized_code, Address pc_after, - Code* interrupt_code, - Code* replacement_code); + Code* interrupt_code); #ifdef DEBUG - static bool InterruptCodeIsPatched(Code* unoptimized_code, - Address pc_after, - Code* interrupt_code, - Code* replacement_code); + static InterruptPatchState GetInterruptPatchState(Isolate* isolate, + Code* unoptimized_code, + Address pc_after); // Verify that all back edges of a certain loop depth are patched. - static void VerifyInterruptCode(Code* unoptimized_code, - Code* interrupt_code, - Code* replacement_code, + static bool VerifyInterruptCode(Isolate* isolate, + Code* unoptimized_code, int loop_nesting_level); #endif // DEBUG @@ -377,7 +355,6 @@ class Deoptimizer : public Malloced { void DeleteFrameDescriptions(); void DoComputeOutputFrames(); - void DoComputeOsrOutputFrame(); void DoComputeJSFrame(TranslationIterator* iterator, int frame_index); void DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, int frame_index); @@ -403,13 +380,6 @@ class Deoptimizer : public Malloced { unsigned output_offset, DeoptimizerTranslatedValueType value_type = TRANSLATED_VALUE_IS_TAGGED); - // Translate a command for OSR. Updates the input offset to be used for - // the next command. Returns false if translation of the command failed - // (e.g., a number conversion failed) and may or may not have updated the - // input offset. - bool DoOsrTranslateCommand(TranslationIterator* iterator, - int* input_offset); - unsigned ComputeInputFrameSize() const; unsigned ComputeFixedSize(JSFunction* function) const; @@ -443,17 +413,24 @@ class Deoptimizer : public Malloced { static void GenerateDeoptimizationEntries( MacroAssembler* masm, int count, BailoutType type); - // Weak handle callback for deoptimizing code objects. - static void HandleWeakDeoptimizedCode(v8::Isolate* isolate, - v8::Persistent<v8::Value>* obj, - void* data); + // Marks all the code in the given context for deoptimization. + static void MarkAllCodeForContext(Context* native_context); - // Deoptimize the given code and add to appropriate deoptimization lists. - static void DeoptimizeCode(Isolate* isolate, Code* code); + // Visit all the known optimized functions in a given context. + static void VisitAllOptimizedFunctionsForContext( + Context* context, OptimizedFunctionVisitor* visitor); + + // Deoptimizes all code marked in the given context. + static void DeoptimizeMarkedCodeForContext(Context* native_context); // Patch the given code so that it will deoptimize itself. static void PatchCodeForDeoptimization(Isolate* isolate, Code* code); + // Searches the list of known deoptimizing code for a Code object + // containing the given address (which is supposedly faster than + // searching all code objects). + Code* FindDeoptimizingCode(Address addr); + // Fill the input from from a JavaScript frame. This is used when // the debugger needs to inspect an optimized frame. For normal // deoptimizations the input frame is filled in generated code. @@ -515,7 +492,6 @@ class Deoptimizer : public Malloced { static const int table_entry_size_; friend class FrameDescription; - friend class DeoptimizingCodeListNode; friend class DeoptimizedFrameInfo; }; @@ -689,24 +665,16 @@ class DeoptimizerData { void Iterate(ObjectVisitor* v); #endif - Code* FindDeoptimizingCode(Address addr); - void RemoveDeoptimizingCode(Code* code); - private: MemoryAllocator* allocator_; int deopt_entry_code_entries_[Deoptimizer::kBailoutTypesWithCodeEntry]; MemoryChunk* deopt_entry_code_[Deoptimizer::kBailoutTypesWithCodeEntry]; - Deoptimizer* current_; #ifdef ENABLE_DEBUGGER_SUPPORT DeoptimizedFrameInfo* deoptimized_frame_info_; #endif - // List of deoptimized code which still have references from active stack - // frames. These code objects are needed by the deoptimizer when deoptimizing - // a frame for which the code object for the function function has been - // changed from the code present when deoptimizing was done. - DeoptimizingCodeListNode* deoptimizing_code_list_; + Deoptimizer* current_; friend class Deoptimizer; @@ -824,26 +792,6 @@ class Translation BASE_EMBEDDED { }; -// Linked list holding deoptimizing code objects. The deoptimizing code objects -// are kept as weak handles until they are no longer activated on the stack. -class DeoptimizingCodeListNode : public Malloced { - public: - explicit DeoptimizingCodeListNode(Code* code); - ~DeoptimizingCodeListNode(); - - DeoptimizingCodeListNode* next() const { return next_; } - void set_next(DeoptimizingCodeListNode* next) { next_ = next; } - Handle<Code> code() const { return code_; } - - private: - // Global (weak) handle to the deoptimizing code object. - Handle<Code> code_; - - // Next pointer for linked list. - DeoptimizingCodeListNode* next_; -}; - - class SlotRef BASE_EMBEDDED { public: enum SlotRepresentation { |