5 #ifndef V8_DEOPTIMIZER_H_
6 #define V8_DEOPTIMIZER_H_
21 memcpy(&d, p,
sizeof(d));
26 class FrameDescription;
27 class TranslationIterator;
28 class DeoptimizedFrameInfo;
34 : destination_(destination), value_(value) { }
37 double value()
const {
return value_; }
48 Address slot_address,
int frame,
int length,
int duplicate,
bool is_args)
49 : slot_address_(slot_address),
50 jsframe_index_(frame),
51 object_length_(length),
52 duplicate_object_(duplicate),
53 is_arguments_(is_args) { }
63 slot_address_ =
reinterpret_cast<Address>(slot);
105 Reason(
int r,
const char* m,
const char* d)
253 : masm_(masm), type_(type) { }
304 Code* optimized_code);
317 bool is_setter_stub_frame);
344 void AddObjectStart(intptr_t slot_address,
int argc,
bool is_arguments);
352 int reverse_jsframe_index =
jsframe_count_ - desc.jsframe_index() - 1;
358 int reverse_jsframe_index =
jsframe_count_ - desc.jsframe_index() - 1;
469 void operator delete(
void* pointer,
uint32_t frame_size) {
473 void operator delete(
void* description) {
626 return reinterpret_cast<intptr_t*
>(
673 : buffer_(buffer), index_(index) {
674 DCHECK(index >= 0 && index < buffer->length());
679 bool HasNext()
const {
return index_ < buffer_->length(); }
682 for (
int i = 0;
i < n;
i++) Next();
691 #define TRANSLATION_OPCODE_LIST(V) \
694 V(CONSTRUCT_STUB_FRAME) \
695 V(GETTER_STUB_FRAME) \
696 V(SETTER_STUB_FRAME) \
697 V(ARGUMENTS_ADAPTOR_FRAME) \
698 V(COMPILED_STUB_FRAME) \
699 V(DUPLICATED_OBJECT) \
700 V(ARGUMENTS_OBJECT) \
707 V(INT32_STACK_SLOT) \
708 V(UINT32_STACK_SLOT) \
709 V(DOUBLE_STACK_SLOT) \
715 #define DECLARE_TRANSLATION_OPCODE_ENUM(item) item,
720 #undef DECLARE_TRANSLATION_OPCODE_ENUM
722 Translation(TranslationBuffer* buffer,
int frame_count,
int jsframe_count,
725 index_(buffer->CurrentIndex()),
727 buffer_->Add(BEGIN, zone);
728 buffer_->Add(frame_count, zone);
729 buffer_->Add(jsframe_count, zone);
732 int index()
const {
return index_; }
759 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
760 static const char* StringFor(
Opcode opcode);
764 static const int kSelfLiteralId = -239;
796 : addr_(addr), representation_(representation) { }
799 : literal_(literal, isolate), representation_(LITERAL) { }
803 slot.representation_ = ARGUMENTS_OBJECT;
804 slot.deferred_object_length_ = length;
810 slot.representation_ = DEFERRED_OBJECT;
811 slot.deferred_object_length_ = length;
819 slot.representation_ = DUPLICATE_OBJECT;
820 slot.duplicate_object_id_ = id;
825 if (representation_ == DEFERRED_OBJECT ||
826 representation_ == ARGUMENTS_OBJECT) {
827 return deferred_object_length_;
849 int inlined_frame_index,
850 int formal_parameter_count);
870 TranslationIterator* iterator,
877 if (slot_index >= 0) {
879 return frame->fp() + offset - (slot_index *
kPointerSize);
882 return frame->fp() + offset - ((slot_index + 1) *
kPointerSize);
920 bool has_arguments_adaptor,
921 bool has_construct_stub);
int prev_materialized_count_
void BeginCompiledStubFrame()
TranslationBuffer * buffer_
Handle< Object > GetDeferredObject(Isolate *isolate)
ZoneList< uint8_t > contents_
void StoreLiteral(int literal_id)
SlotRef(Isolate *isolate, Object *literal)
void patch_slot_address(intptr_t slot)
TranslationBuffer(Zone *zone)
static SlotRef ComputeSlotForNextArgument(Translation::Opcode opcode, TranslationIterator *iterator, DeoptimizationInputData *data, JavaScriptFrame *frame)
HeapNumberMaterializationDescriptor(T destination, double value)
void Prepare(Isolate *isolate)
void Add(int32_t value, Zone *zone)
void BeginConstructStubFrame(int literal_id, unsigned height)
Handle< FixedArray > previously_materialized_objects_
void BeginArgumentsAdaptorFrame(int literal_id, unsigned height)
List< Handle< Object > > materialized_objects_
bool is_arguments() const
void StoreArgumentsObject(bool args_known, int args_index, int args_length)
void BeginJSFrame(BailoutId node_id, int literal_id, unsigned height)
Handle< ByteArray > CreateByteArray(Factory *factory)
virtual void EnterContext(Context *context)=0
SlotRef(Address addr, SlotRepresentation representation)
void StoreDoubleStackSlot(int index)
void StoreRegister(Register reg)
Handle< Object > GetNext(Isolate *isolate, int level)
void StoreInt32Register(Register reg)
virtual void LeaveContext(Context *context)=0
virtual void VisitFunction(JSFunction *function)=0
void BeginGetterStubFrame(int literal_id)
Handle< Object > literal_
int duplicate_object() const
void StoreUint32StackSlot(int index)
ObjectMaterializationDescriptor(Address slot_address, int frame, int length, int duplicate, bool is_args)
void DuplicateObject(int object_index)
static SlotRef NewDeferredObject(int length)
Translation(TranslationBuffer *buffer, int frame_count, int jsframe_count, Zone *zone)
static int NumberOfOperandsFor(Opcode opcode)
TranslationIterator(ByteArray *buffer, int index)
static SlotRef NewArgumentsObject(int length)
void StoreUint32Register(Register reg)
Address slot_address() const
Handle< Object > GetPreviouslyMaterialized(Isolate *isolate, int length)
void StoreStackSlot(int index)
int jsframe_index() const
Handle< Object > GetValue(Isolate *isolate)
int object_length() const
static Address SlotAddress(JavaScriptFrame *frame, int slot_index)
void BeginArgumentsObject(int args_length)
void StoreDoubleRegister(DoubleRegister reg)
List< SlotRef > slot_refs_
int deferred_object_length_
void BeginSetterStubFrame(int literal_id)
static SlotRef NewDuplicateObject(int id)
SlotRepresentation Representation()
void BeginCapturedObject(int length)
void Finish(Isolate *isolate)
SlotRefValueBuilder(JavaScriptFrame *frame, int inlined_frame_index, int formal_parameter_count)
SlotRepresentation representation_
void StoreInt32StackSlot(int index)
virtual ~OptimizedFunctionVisitor()
virtual ~DeoptimizedFrameInfo()
void Iterate(ObjectVisitor *v)
Object ** expression_stack_
DeoptimizedFrameInfo(Deoptimizer *deoptimizer, int frame_index, bool has_arguments_adaptor, bool has_construct_stub)
JSFunction * GetFunction()
Object * GetExpression(int index)
Object * GetParameter(int index)
void SetParameter(int index, Object *obj)
void SetExpression(int index, Object *obj)
MemoryChunk * deopt_entry_code_[Deoptimizer::kBailoutTypesWithCodeEntry]
int deopt_entry_code_entries_[Deoptimizer::kBailoutTypesWithCodeEntry]
DeoptimizerData(MemoryAllocator *allocator)
DeoptimizedFrameInfo * deoptimized_frame_info_
MemoryAllocator * allocator_
void Iterate(ObjectVisitor *v)
DISALLOW_COPY_AND_ASSIGN(DeoptimizerData)
Isolate * isolate() const
Deoptimizer::BailoutType type_
EntryGenerator(MacroAssembler *masm, BailoutType type)
virtual ~EntryGenerator()
MacroAssembler * masm() const
virtual void GeneratePrologue()
virtual void GeneratePrologue()
TableEntryGenerator(MacroAssembler *masm, BailoutType type, int count)
unsigned ComputeInputFrameSize() const
int has_alignment_padding_
BailoutType bailout_type_
void DoComputeAccessorStubFrame(TranslationIterator *iterator, int frame_index, bool is_setter_stub_frame)
List< Handle< Object > > * materialized_objects_
static Deoptimizer * Grab(Isolate *isolate)
Handle< Object > MaterializeNextHeapObject()
static void MarkAllCodeForContext(Context *native_context)
static const int kBailoutTypesWithCodeEntry
int ConvertJSFrameIndexToFrameIndex(int jsframe_index)
void AddObjectStart(intptr_t slot_address, int argc, bool is_arguments)
Code * FindOptimizedCode(JSFunction *function, Code *optimized_code)
void MaterializeHeapObjects(JavaScriptFrameIterator *it)
static int has_alignment_padding_offset()
void AddDoubleValue(intptr_t slot_address, double value)
static int output_offset()
bool ArgumentsObjectIsAdapted(int object_index)
static void EnsureRelocSpaceForLazyDeoptimization(Handle< Code > code)
void MaterializeHeapNumbersForDebuggerInspectableFrame(Address parameters_top, uint32_t parameters_size, Address expressions_top, uint32_t expressions_size, DeoptimizedFrameInfo *info)
static void ComputeOutputFrames(Deoptimizer *deoptimizer)
static Deoptimizer * New(JSFunction *function, BailoutType type, unsigned bailout_id, Address from, int fp_to_sp_delta, Isolate *isolate)
List< Handle< Object > > * materialized_values_
static const int table_entry_size_
unsigned ComputeFixedSize(JSFunction *function) const
Object * ComputeLiteral(int index) const
static void DeoptimizeFunction(JSFunction *function)
void CopyDoubleRegisters(FrameDescription *output_frame)
int materialization_value_index_
void AddObjectDoubleValue(double value)
Deoptimizer(Isolate *isolate, JSFunction *function, BailoutType type, unsigned bailout_id, Address from, int fp_to_sp_delta, Code *optimized_code)
static void GenerateDeoptimizationEntries(MacroAssembler *masm, int count, BailoutType type)
void DoTranslateCommand(TranslationIterator *iterator, int frame_index, unsigned output_offset)
Code * FindDeoptimizingCode(Address addr)
List< ObjectMaterializationDescriptor > deferred_objects_
int prev_materialized_count_
unsigned ComputeOutgoingArgumentSize() const
List< Handle< JSFunction > > jsframe_functions_
static Address GetDeoptimizationEntry(Isolate *isolate, int id, BailoutType type, GetEntryMode mode=ENSURE_ENTRY_CODE)
static void DeoptimizeGlobalObject(JSObject *object)
Handle< FixedArray > previously_materialized_objects_
List< bool > jsframe_has_adapted_arguments_
static int input_offset()
static void EnsureCodeForDeoptimizationEntry(Isolate *isolate, BailoutType type, int max_entry_id)
static const char * MessageFor(BailoutType type)
static void PatchCodeForDeoptimization(Isolate *isolate, Code *code)
static DeoptimizedFrameInfo * DebuggerInspectableFrame(JavaScriptFrame *frame, int jsframe_index, Isolate *isolate)
@ CALCULATE_ENTRY_ADDRESS
static void VisitAllOptimizedFunctions(Isolate *isolate, OptimizedFunctionVisitor *visitor)
static bool TraceEnabledFor(BailoutType deopt_type, StackFrame::Type frame_type)
static const int kNotDeoptimizationEntry
void DoComputeOutputFrames()
static void DeoptimizeAll(Isolate *isolate)
static int output_count_offset()
static void VisitAllOptimizedFunctionsForContext(Context *context, OptimizedFunctionVisitor *visitor)
static const int kMaxNumberOfEntries
void DoComputeCompiledStubFrame(TranslationIterator *iterator, int frame_index)
static void DeoptimizeMarkedCode(Isolate *isolate)
void SetPlatformCompiledStubRegisters(FrameDescription *output_frame, CodeStubDescriptor *desc)
Handle< Code > compiled_code() const
static int GetDeoptimizedCodeCount(Isolate *isolate)
void DeleteFrameDescriptions()
Handle< JSFunction > ArgumentsObjectFunction(int object_index)
static int GetOutputInfo(DeoptimizationOutputData *data, BailoutId node_id, SharedFunctionInfo *shared)
void DoTranslateObject(TranslationIterator *iterator, int object_index, int field_index)
void DoComputeConstructStubFrame(TranslationIterator *iterator, int frame_index)
int materialization_object_index_
void AddObjectDuplication(intptr_t slot, int object_index)
List< HeapNumberMaterializationDescriptor< int > > deferred_objects_double_values_
void DoComputeJSFrame(TranslationIterator *iterator, int frame_index)
unsigned ComputeIncomingArgumentSize(JSFunction *function) const
FrameDescription ** output_
bool HasAlignmentPadding(JSFunction *function)
List< Object * > deferred_objects_tagged_values_
FrameDescription * input_
BailoutType bailout_type() const
static void DeoptimizeMarkedCodeForContext(Context *native_context)
static const int kMinNumberOfEntries
CodeTracer::Scope * trace_scope_
Handle< Object > MaterializeNextValue()
Isolate * isolate() const
void FillInputFrame(Address tos, JavaScriptFrame *frame)
void DoTranslateObjectAndSkip(TranslationIterator *iterator)
int jsframe_count() const
static size_t GetMaxDeoptTableSize()
static int GetDeoptimizationId(Isolate *isolate, Address addr, BailoutType type)
List< HeapNumberMaterializationDescriptor< Address > > deferred_heap_numbers_
void AddObjectTaggedValue(intptr_t value)
void DoComputeArgumentsAdaptorFrame(TranslationIterator *iterator, int frame_index)
static void DeleteDebuggerInspectableFrame(DeoptimizedFrameInfo *info, Isolate *isolate)
static int frame_size_offset()
unsigned GetOffsetFromSlotIndex(int slot_index)
int ComputeParametersCount()
void SetCallerFp(unsigned offset, intptr_t value)
uint32_t GetFrameSize() const
void SetTop(intptr_t top)
double double_registers_[DoubleRegister::kMaxNumRegisters]
static int continuation_offset()
void SetContext(intptr_t context)
static int frame_content_offset()
void SetCallerConstantPool(unsigned offset, intptr_t value)
intptr_t * GetFrameSlotPointer(unsigned offset)
static const uint32_t kZapUint32
intptr_t registers_[Register::kNumRegisters]
JSFunction * GetFunction() const
static int state_offset()
intptr_t GetConstantPool() const
Object * GetExpression(int index)
double GetDoubleFrameSlot(unsigned offset)
Object * GetParameter(int index)
void SetFrameType(StackFrame::Type type)
FrameDescription(uint32_t frame_size, JSFunction *function)
intptr_t GetContext() const
void SetConstantPool(intptr_t constant_pool)
static int registers_offset()
double GetDoubleRegister(unsigned n) const
void SetState(Smi *state)
intptr_t frame_content_[1]
StackFrame::Type GetFrameType() const
intptr_t GetFrameSlot(unsigned offset)
static int double_registers_offset()
void SetRegister(unsigned n, intptr_t value)
intptr_t GetRegister(unsigned n) const
void SetCallerPc(unsigned offset, intptr_t value)
unsigned GetExpressionCount()
void SetFrameSlot(unsigned offset, intptr_t value)
void SetContinuation(intptr_t pc)
void SetDoubleRegister(unsigned n, double value)
static const int kLastParameterOffset
static const int kLocal0Offset
void Set(Address fp, Handle< FixedArray > materialized_objects)
Handle< FixedArray > EnsureStackEntries(int size)
Handle< FixedArray > Get(Address fp)
Handle< FixedArray > GetStackEntries()
List< Address > frame_fps_
MaterializedObjectStore(Isolate *isolate)
int StackIdToIndex(Address fp)
#define DECLARE_TRANSLATION_OPCODE_ENUM(item)
#define TRANSLATION_OPCODE_LIST(V)
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
#define OFFSET_OF(type, field)
TypeImpl< ZoneTypeConfig > Type
bool CStringEquals(const char *s1, const char *s2)
static double read_double_value(Address p)
Debugger support for the V8 JavaScript engine.
bool IsEquivalentTo(const JumpTableEntry &other) const
JumpTableEntry(Address entry, const Reason &the_reason, Deoptimizer::BailoutType type, bool frame)
Deoptimizer::BailoutType bailout_type
Reason(int r, const char *m, const char *d)
bool operator!=(const Reason &other) const
bool operator==(const Reason &other) const
static const int kMaxNumRegisters
static const int kNumRegisters
#define T(name, string, precedence)