28 #ifndef V8_DEOPTIMIZER_H_
29 #define V8_DEOPTIMIZER_H_
41 class FrameDescription;
42 class TranslationIterator;
43 class DeoptimizingCodeListNode;
44 class DeoptimizedFrameInfo;
49 : slot_address_(slot_address), val_(val) { }
52 double value()
const {
return val_; }
66 virtual void EnterContext(
Context* context) = 0;
68 virtual void VisitFunction(
JSFunction*
function) = 0;
72 virtual void LeaveContext(
Context* context) = 0;
84 #ifdef ENABLE_DEBUGGER_SUPPORT
85 void Iterate(ObjectVisitor* v);
93 #ifdef ENABLE_DEBUGGER_SUPPORT
94 DeoptimizedFrameInfo* deoptimized_frame_info_;
133 #ifdef ENABLE_DEBUGGER_SUPPORT
161 Context* context, OptimizedFunctionVisitor* visitor);
164 JSObject*
object, OptimizedFunctionVisitor* visitor);
175 Code* replacement_code);
182 Code* replacement_code);
188 Code* replacement_code);
195 Code* replacement_code);
200 #ifdef ENABLE_DEBUGGER_SUPPORT
201 void MaterializeHeapNumbersForDebuggerInspectableFrame(
203 uint32_t parameters_size,
205 uint32_t expressions_size,
236 : masm_(masm),
type_(type) { }
255 : EntryGenerator(masm, type), count_(count) { }
261 int count()
const {
return count_; }
269 static const int kNumberOfEntries = 16384;
272 JSFunction*
function,
277 Code* optimized_code);
278 void DeleteFrameDescriptions();
280 void DoComputeOutputFrames();
281 void DoComputeOsrOutputFrame();
282 void DoComputeJSFrame(TranslationIterator* iterator,
int frame_index);
283 void DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
285 void DoComputeConstructStubFrame(TranslationIterator* iterator,
287 void DoTranslateCommand(TranslationIterator* iterator,
294 bool DoOsrTranslateCommand(TranslationIterator* iterator,
297 unsigned ComputeInputFrameSize()
const;
298 unsigned ComputeFixedSize(JSFunction*
function)
const;
300 unsigned ComputeIncomingArgumentSize(JSFunction*
function)
const;
301 unsigned ComputeOutgoingArgumentSize()
const;
303 Object* ComputeLiteral(
int index)
const;
305 void AddDoubleValue(intptr_t slot_address,
double value);
308 static void GenerateDeoptimizationEntries(
312 static void HandleWeakDeoptimizedCode(
314 static Code* FindDeoptimizingCodeFromAddress(
Address addr);
315 static void RemoveDeoptimizingCode(Code* code);
320 void FillInputFrame(
Address tos, JavaScriptFrame* frame);
323 JSFunction* function_;
324 Code* optimized_code_;
325 unsigned bailout_id_;
329 int has_alignment_padding_;
340 List<HeapNumberMaterializationDescriptor> deferred_heap_numbers_;
342 static const int table_entry_size_;
355 void*
operator new(
size_t size, uint32_t frame_size) {
361 void operator delete(
void* pointer, uint32_t frame_size) {
365 void operator delete(
void* description) {
370 ASSERT(static_cast<uint32_t>(frame_size_) == frame_size_);
371 return static_cast<uint32_t
>(frame_size_);
379 return *GetFrameSlotPointer(offset);
383 intptr_t* ptr = GetFrameSlotPointer(offset);
384 #if V8_TARGET_ARCH_MIPS
391 c.u[0] = *
reinterpret_cast<uint32_t*
>(ptr);
392 c.u[1] = *(
reinterpret_cast<uint32_t*
>(ptr) + 1);
395 return *
reinterpret_cast<double*
>(ptr);
400 *GetFrameSlotPointer(offset) = value;
405 return registers_[n];
410 return double_registers_[n];
415 registers_[n] = value;
420 double_registers_[n] = value;
424 void SetTop(intptr_t top) { top_ = top; }
426 intptr_t
GetPc()
const {
return pc_; }
429 intptr_t
GetFp()
const {
return fp_; }
484 static const uint32_t kZapUint32 = 0xbeeddead;
489 uintptr_t frame_size_;
497 StackFrame::Type type_;
505 intptr_t continuation_;
509 intptr_t frame_content_[1];
511 intptr_t* GetFrameSlotPointer(
unsigned offset) {
512 ASSERT(offset < frame_size_);
513 return reinterpret_cast<intptr_t*
>(
517 int ComputeFixedSize();
538 :
buffer_(buffer), index_(index) {
539 ASSERT(index >= 0 && index < buffer->length());
547 for (
int i = 0; i < n; i++) Next();
577 Translation(TranslationBuffer* buffer,
int frame_count,
int jsframe_count,
580 index_(buffer->CurrentIndex()),
583 buffer_->Add(frame_count, zone);
584 buffer_->Add(jsframe_count, zone);
587 int index()
const {
return index_; }
590 void BeginJSFrame(
int node_id,
int literal_id,
unsigned height);
591 void BeginArgumentsAdaptorFrame(
int literal_id,
unsigned height);
592 void BeginConstructStubFrame(
int literal_id,
unsigned height);
594 void StoreInt32Register(
Register reg);
596 void StoreStackSlot(
int index);
597 void StoreInt32StackSlot(
int index);
598 void StoreDoubleStackSlot(
int index);
599 void StoreLiteral(
int literal_id);
600 void StoreArgumentsObject();
601 void MarkDuplicate();
605 static int NumberOfOperandsFor(
Opcode opcode);
607 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
608 static const char* StringFor(
Opcode opcode);
652 : addr_(addr), representation_(representation) { }
655 : literal_(literal), representation_(LITERAL) { }
658 switch (representation_) {
667 return Isolate::Current()->factory()->NewNumberFromInt(value);
673 return Isolate::Current()->factory()->NewNumber(value);
687 int inlined_frame_index,
693 SlotRepresentation representation_;
696 if (slot_index >= 0) {
698 return frame->fp() + offset - (slot_index *
kPointerSize);
701 return frame->fp() + offset - ((slot_index + 1) *
kPointerSize);
705 static SlotRef ComputeSlotForNextArgument(TranslationIterator* iterator,
706 DeoptimizationInputData* data,
707 JavaScriptFrame* frame);
709 static void ComputeSlotsForArguments(
710 Vector<SlotRef>* args_slots,
711 TranslationIterator* iterator,
712 DeoptimizationInputData* data,
713 JavaScriptFrame* frame);
717 #ifdef ENABLE_DEBUGGER_SUPPORT
724 class DeoptimizedFrameInfo :
public Malloced {
726 DeoptimizedFrameInfo(Deoptimizer* deoptimizer,
728 bool has_arguments_adaptor,
729 bool has_construct_stub);
730 virtual ~DeoptimizedFrameInfo();
733 void Iterate(ObjectVisitor* v);
736 int parameters_count() {
return parameters_count_; }
739 int expression_count() {
return expression_count_; }
742 JSFunction* GetFunction() {
748 bool HasConstructStub() {
749 return has_construct_stub_;
753 Object* GetParameter(
int index) {
754 ASSERT(0 <= index && index < parameters_count());
755 return parameters_[index];
759 Object* GetExpression(
int index) {
760 ASSERT(0 <= index && index < expression_count());
761 return expression_stack_[index];
764 int GetSourcePosition() {
765 return source_position_;
770 void SetParameter(
int index,
Object* obj) {
771 ASSERT(0 <= index && index < parameters_count());
772 parameters_[index] = obj;
776 void SetExpression(
int index,
Object* obj) {
777 ASSERT(0 <= index && index < expression_count());
778 expression_stack_[index] = obj;
781 JSFunction* function_;
782 bool has_construct_stub_;
783 int parameters_count_;
784 int expression_count_;
786 Object** expression_stack_;
787 int source_position_;
789 friend class Deoptimizer;
795 #endif // V8_DEOPTIMIZER_H_
static int registers_offset()
DeoptimizingCodeListNode * next() const
static const int kLastParameterOffset
static Object *& Object_at(Address addr)
Handle< Code > code() const
HeapNumberMaterializationDescriptor(Address slot_address, double val)
static Smi * FromInt(int value)
unsigned GetOffsetFromSlotIndex(int slot_index)
static double & double_at(Address addr)
void SetFrameSlot(unsigned offset, intptr_t value)
static void RevertStackCheckCode(Code *unoptimized_code, Code *check_code, Code *replacement_code)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kThisPropertyAssignmentsOffset kNeedsAccessCheckBit kIsExpressionBit kHasOnlySimpleThisPropertyAssignments kUsesArguments formal_parameter_count
static void ComputeOutputFrames(Deoptimizer *deoptimizer)
Address slot_address() const
virtual void GeneratePrologue()
void SetState(Smi *state)
static const int kNumAllocatableRegisters
SlotRef(Address addr, SlotRepresentation representation)
#define ASSERT(condition)
static void DeoptimizeFunction(JSFunction *function)
static void DeoptimizeAll()
Handle< Object > GetValue()
double GetDoubleRegister(unsigned n) const
intptr_t GetContext() const
void SetFrameType(StackFrame::Type type)
StringInputBuffer *const buffer_
DeoptimizingCodeListNode(Code *code)
static const int kNumRegisters
static int double_registers_offset()
MacroAssembler * masm() const
static int frame_content_offset()
int ComputeParametersCount()
JSFunction * GetFunction() const
static void DeoptimizeGlobalObject(JSObject *object)
static int output_offset()
TableEntryGenerator(MacroAssembler *masm, BailoutType type, int count)
#define OFFSET_OF(type, field)
static bool IsValid(intptr_t value)
Translation(TranslationBuffer *buffer, int frame_count, int jsframe_count, Zone *zone)
static int state_offset()
static int32_t & int32_at(Address addr)
EntryGenerator(MacroAssembler *masm, BailoutType type)
void SetRegister(unsigned n, intptr_t value)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static int GetDeoptimizedCodeCount(Isolate *isolate)
void set_next(DeoptimizingCodeListNode *next)
unsigned GetExpressionCount()
static int GetOutputInfo(DeoptimizationOutputData *data, unsigned node_id, SharedFunctionInfo *shared)
static void EnsureRelocSpaceForLazyDeoptimization(Handle< Code > code)
static void PatchStackCheckCode(Code *unoptimized_code, Code *check_code, Code *replacement_code)
~DeoptimizingCodeListNode()
uint32_t GetFrameSize() const
static void VisitAllOptimizedFunctionsForContext(Context *context, OptimizedFunctionVisitor *visitor)
void SetContinuation(intptr_t pc)
virtual ~OptimizedFunctionVisitor()
static int frame_size_offset()
static int output_count_offset()
static void RevertStackCheckCodeAt(Code *unoptimized_code, Address pc_after, Code *check_code, Code *replacement_code)
intptr_t GetFrameSlot(unsigned offset)
TranslationBuffer(Zone *zone)
friend class DeoptimizedFrameInfo
void MaterializeHeapNumbers()
static Address GetDeoptimizationEntry(int id, BailoutType type)
TranslationIterator(ByteArray *buffer, int index)
static Deoptimizer * Grab(Isolate *isolate)
static const int kNotDeoptimizationEntry
static Handle< T > null()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
friend class FrameDescription
StackFrame::Type GetFrameType() const
virtual void GeneratePrologue()
double GetDoubleFrameSlot(unsigned offset)
FrameDescription(uint32_t frame_size, JSFunction *function)
virtual ~EntryGenerator()
static void VisitAllOptimizedFunctions(OptimizedFunctionVisitor *visitor)
void SetContext(intptr_t context)
int ConvertJSFrameIndexToFrameIndex(int jsframe_index)
static void VisitAllOptimizedFunctionsForGlobalObject(JSObject *object, OptimizedFunctionVisitor *visitor)
intptr_t GetRegister(unsigned n) const
void SetDoubleRegister(unsigned n, double value)
int jsframe_count() const
static const int kLocal0Offset
static int GetDeoptimizationId(Address addr, BailoutType type)
static void PatchStackCheckCodeAt(Code *unoptimized_code, Address pc_after, Code *check_code, Code *replacement_code)
void SetTop(intptr_t top)
static int continuation_offset()
static int has_alignment_padding_offset()
static Deoptimizer * New(JSFunction *function, BailoutType type, unsigned bailout_id, Address from, int fp_to_sp_delta, Isolate *isolate)
static int input_offset()
Object * GetExpression(int index)
Object * GetParameter(int index)