28 #ifndef V8_FULL_CODEGEN_H_
29 #define V8_FULL_CODEGEN_H_
60 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
83 scope_(info->scope()),
88 bailout_entries_(info->HasDeoptimizationSupport()
89 ? info->function()->ast_node_count() : 0,
91 stack_checks_(2, info->
zone()),
92 type_feedback_cells_(info->HasDeoptimizationSupport()
93 ? info->function()->ast_node_count() : 0,
112 case TOS_REG:
return "TOS_REG";
122 #if V8_TARGET_ARCH_IA32
123 static const int kBackEdgeDistanceUnit = 100;
124 #elif V8_TARGET_ARCH_X64
125 static const int kBackEdgeDistanceUnit = 162;
126 #elif V8_TARGET_ARCH_ARM
127 static const int kBackEdgeDistanceUnit = 142;
128 #elif V8_TARGET_ARCH_MIPS
129 static const int kBackEdgeDistanceUnit = 142;
131 #error Unsupported target architecture.
145 previous_ = codegen->nesting_stack_;
146 codegen->nesting_stack_ =
this;
150 ASSERT_EQ(
this, codegen_->nesting_stack_);
151 codegen_->nesting_stack_ = previous_;
154 virtual Breakable* AsBreakable() {
return NULL; }
155 virtual Iteration* AsIteration() {
return NULL; }
157 virtual bool IsContinueTarget(Statement* target) {
return false; }
158 virtual bool IsBreakTarget(Statement* target) {
return false; }
171 MacroAssembler* masm() {
return codegen_->masm(); }
186 virtual ~Breakable() {}
188 virtual Breakable* AsBreakable() {
return this; }
189 virtual bool IsBreakTarget(Statement* target) {
190 return statement() == target;
193 BreakableStatement* statement() {
return statement_; }
194 Label* break_label() {
return &break_label_; }
197 BreakableStatement* statement_;
202 class Iteration :
public Breakable {
205 : Breakable(codegen, statement) {
207 virtual ~Iteration() {}
209 virtual Iteration* AsIteration() {
return this; }
210 virtual bool IsContinueTarget(Statement* target) {
211 return statement() == target;
214 Label* continue_label() {
return &continue_label_; }
217 Label continue_label_;
221 class NestedBlock :
public Breakable {
224 : Breakable(codegen, block) {
226 virtual ~NestedBlock() {}
229 if (statement()->AsBlock()->scope() !=
NULL) {
241 virtual ~TryCatch() {}
252 virtual ~TryFinally() {}
257 Label* finally_entry_;
263 static const int kElementCount = 5;
266 virtual ~Finally() {}
269 *stack_depth += kElementCount;
275 class ForIn :
public Iteration {
277 static const int kElementCount = 5;
280 : Iteration(codegen, statement) {
285 *stack_depth += kElementCount;
297 virtual ~WithOrCatch() {}
308 static const InlineFunctionGenerator kInlineFunctionGenerators[];
312 void ClearAccumulator();
321 void DoTest(Expression* condition,
324 Label* fall_through);
325 void DoTest(
const TestContext* context);
329 #ifdef V8_TARGET_ARCH_MIPS
335 Label* fall_through);
336 #else // All non-mips arch.
340 Label* fall_through);
341 #endif // V8_TARGET_ARCH_MIPS
346 void GetVar(Register destination, Variable* var);
352 void SetVar(Variable* var,
365 MemOperand VarOperand(Variable* var, Register scratch);
367 void VisitForEffect(Expression* expr) {
368 EffectContext context(
this);
373 void VisitForAccumulatorValue(Expression* expr) {
374 AccumulatorValueContext context(
this);
376 PrepareForBailout(expr,
TOS_REG);
379 void VisitForStackValue(Expression* expr) {
380 StackValueContext context(
this);
385 void VisitForControl(Expression* expr,
388 Label* fall_through) {
389 TestContext context(
this, expr, if_true, if_false, fall_through);
396 void VisitInDuplicateContext(Expression* expr);
398 void VisitDeclarations(ZoneList<Declaration*>* declarations);
399 void DeclareGlobals(Handle<FixedArray>
pairs);
400 int DeclareGlobalsFlags();
405 bool TryLiteralCompare(CompareOperation* compare);
409 void EmitLiteralCompareTypeof(Expression* expr,
410 Expression* sub_expr,
411 Handle<String>
check);
414 void EmitLiteralCompareNil(CompareOperation* expr,
415 Expression* sub_expr,
419 void PrepareForBailout(Expression* node,
State state);
420 void PrepareForBailoutForId(BailoutId
id,
State state);
424 void RecordTypeFeedbackCell(TypeFeedbackId
id,
425 Handle<JSGlobalPropertyCell> cell);
429 void RecordJSReturnSite(Call* call);
436 void PrepareForBailoutBeforeSplit(Expression* expr,
437 bool should_normalize,
443 void EmitDebugCheckDeclarationContext(Variable* variable);
450 void EmitStackCheck(IterationStatement* stmt, Label* back_edge_target);
452 void RecordStackCheck(BailoutId osr_ast_id);
455 unsigned EmitStackCheckTable();
457 void EmitProfilingCounterDecrement(
int delta);
458 void EmitProfilingCounterReset();
461 void EmitReturnSequence();
465 void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode);
466 void EmitKeyedCallWithIC(Call* expr, Expression* key);
471 void EmitInlineRuntimeCall(CallRuntime* expr);
473 #define EMIT_INLINE_RUNTIME_CALL(name, x, y) \
474 void Emit##name(CallRuntime* expr);
477 #undef EMIT_INLINE_RUNTIME_CALL
480 void EmitLoadGlobalCheckExtensions(Variable* var,
483 MemOperand ContextSlotOperandCheckExtensions(Variable* var, Label* slow);
484 void EmitDynamicLookupFastCase(Variable* var,
488 void EmitVariableLoad(VariableProxy* proxy);
490 void EmitAccessor(Expression* expression);
493 void EmitResolvePossiblyDirectEval(
int arg_count);
497 void EmitNewClosure(Handle<SharedFunctionInfo> info,
bool pretenure);
503 void EmitNamedPropertyLoad(Property* expr);
507 void EmitKeyedPropertyLoad(Property* expr);
511 void EmitBinaryOp(BinaryOperation* expr,
517 void EmitInlineSmiBinaryOp(BinaryOperation* expr,
525 void EmitAssignment(Expression* expr);
529 void EmitVariableAssignment(Variable* var,
534 void EmitNamedPropertyAssignment(Assignment* expr);
539 void EmitKeyedPropertyAssignment(Assignment* expr);
541 void CallIC(Handle<Code>
code,
542 RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
545 void SetFunctionPosition(FunctionLiteral* fun);
546 void SetReturnPosition(FunctionLiteral* fun);
547 void SetStatementPosition(Statement* stmt);
548 void SetExpressionPosition(Expression* expr,
int pos);
549 void SetStatementPosition(
int pos);
550 void SetSourcePosition(
int pos);
553 void EnterFinallyBlock();
554 void ExitFinallyBlock();
557 int loop_depth() {
return loop_depth_; }
558 void increment_loop_depth() { loop_depth_++; }
559 void decrement_loop_depth() {
564 MacroAssembler* masm() {
return masm_; }
566 class ExpressionContext;
567 const ExpressionContext* context() {
return context_; }
568 void set_new_context(
const ExpressionContext* context) { context_ = context; }
570 Handle<Script> script() {
return info_->
script(); }
571 bool is_eval() {
return info_->
is_eval(); }
572 bool is_native() {
return info_->
is_native(); }
573 bool is_classic_mode() {
return language_mode() ==
CLASSIC_MODE; }
574 LanguageMode language_mode() {
return function()->language_mode(); }
575 FunctionLiteral*
function() {
return info_->
function(); }
576 Scope* scope() {
return scope_; }
578 static Register result_register();
579 static Register context_register();
583 void StoreToFrameField(
int frame_offset, Register value);
587 void LoadContextField(Register dst,
int context_index);
591 void PushFunctionArgumentForContextAllocation();
594 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
598 void EmitUnaryOperation(UnaryOperation* expr,
const char* comment);
600 void VisitComma(BinaryOperation* expr);
601 void VisitLogicalExpression(BinaryOperation* expr);
602 void VisitArithmeticExpression(BinaryOperation* expr);
604 void VisitForTypeofValue(Expression* expr);
607 void PopulateDeoptimizationData(Handle<Code> code);
608 void PopulateTypeFeedbackInfo(Handle<Code> code);
609 void PopulateTypeFeedbackCells(Handle<Code> code);
611 Handle<FixedArray> handler_table() {
return handler_table_; }
613 struct BailoutEntry {
615 unsigned pc_and_state;
618 struct TypeFeedbackCellEntry {
619 TypeFeedbackId ast_id;
620 Handle<JSGlobalPropertyCell> cell;
627 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) {
628 codegen->set_new_context(
this);
631 virtual ~ExpressionContext() {
632 codegen_->set_new_context(old_);
635 Isolate* isolate()
const {
return codegen_->isolate(); }
639 virtual void Plug(
bool flag)
const = 0;
644 virtual void Plug(Register reg)
const = 0;
645 virtual void Plug(Variable* var)
const = 0;
646 virtual void Plug(Handle<Object> lit)
const = 0;
648 virtual void PlugTOS()
const = 0;
654 virtual void Plug(Label* materialize_true,
655 Label* materialize_false)
const = 0;
660 virtual void DropAndPlug(
int count, Register reg)
const = 0;
664 virtual void PrepareTest(Label* materialize_true,
665 Label* materialize_false,
668 Label** fall_through)
const = 0;
672 virtual bool IsEffect()
const {
return false; }
675 virtual bool IsAccumulatorValue()
const {
return false; }
676 virtual bool IsStackValue()
const {
return false; }
680 virtual bool IsTest()
const {
return false; }
684 MacroAssembler* masm()
const {
return masm_; }
685 MacroAssembler* masm_;
688 const ExpressionContext* old_;
692 class AccumulatorValueContext :
public ExpressionContext {
695 : ExpressionContext(codegen) { }
697 virtual void Plug(
bool flag)
const;
698 virtual void Plug(Register reg)
const;
699 virtual void Plug(Label* materialize_true, Label* materialize_false)
const;
700 virtual void Plug(Variable* var)
const;
701 virtual void Plug(Handle<Object> lit)
const;
703 virtual void PlugTOS()
const;
704 virtual void DropAndPlug(
int count, Register reg)
const;
705 virtual void PrepareTest(Label* materialize_true,
706 Label* materialize_false,
709 Label** fall_through)
const;
710 virtual bool IsAccumulatorValue()
const {
return true; }
713 class StackValueContext :
public ExpressionContext {
716 : ExpressionContext(codegen) { }
718 virtual void Plug(
bool flag)
const;
719 virtual void Plug(Register reg)
const;
720 virtual void Plug(Label* materialize_true, Label* materialize_false)
const;
721 virtual void Plug(Variable* var)
const;
722 virtual void Plug(Handle<Object> lit)
const;
724 virtual void PlugTOS()
const;
725 virtual void DropAndPlug(
int count, Register reg)
const;
726 virtual void PrepareTest(Label* materialize_true,
727 Label* materialize_false,
730 Label** fall_through)
const;
731 virtual bool IsStackValue()
const {
return true; }
734 class TestContext :
public ExpressionContext {
737 Expression* condition,
741 : ExpressionContext(codegen),
742 condition_(condition),
743 true_label_(true_label),
744 false_label_(false_label),
745 fall_through_(fall_through) { }
747 static const TestContext* cast(
const ExpressionContext* context) {
748 ASSERT(context->IsTest());
749 return reinterpret_cast<const TestContext*
>(context);
752 Expression* condition()
const {
return condition_; }
753 Label* true_label()
const {
return true_label_; }
754 Label* false_label()
const {
return false_label_; }
755 Label* fall_through()
const {
return fall_through_; }
757 virtual void Plug(
bool flag)
const;
758 virtual void Plug(Register reg)
const;
759 virtual void Plug(Label* materialize_true, Label* materialize_false)
const;
760 virtual void Plug(Variable* var)
const;
761 virtual void Plug(Handle<Object> lit)
const;
763 virtual void PlugTOS()
const;
764 virtual void DropAndPlug(
int count, Register reg)
const;
765 virtual void PrepareTest(Label* materialize_true,
766 Label* materialize_false,
769 Label** fall_through)
const;
770 virtual bool IsTest()
const {
return true; }
773 Expression* condition_;
776 Label* fall_through_;
779 class EffectContext :
public ExpressionContext {
782 : ExpressionContext(codegen) { }
784 virtual void Plug(
bool flag)
const;
785 virtual void Plug(Register reg)
const;
786 virtual void Plug(Label* materialize_true, Label* materialize_false)
const;
787 virtual void Plug(Variable* var)
const;
788 virtual void Plug(Handle<Object> lit)
const;
790 virtual void PlugTOS()
const;
791 virtual void DropAndPlug(
int count, Register reg)
const;
792 virtual void PrepareTest(Label* materialize_true,
793 Label* materialize_false,
796 Label** fall_through)
const;
797 virtual bool IsEffect()
const {
return true; }
800 MacroAssembler* masm_;
801 CompilationInfo* info_;
806 ZoneList<Handle<Object> >* globals_;
807 const ExpressionContext* context_;
808 ZoneList<BailoutEntry> bailout_entries_;
809 ZoneList<BailoutEntry> stack_checks_;
810 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_;
812 Handle<FixedArray> handler_table_;
813 Handle<JSGlobalPropertyCell> profiling_counter_;
814 bool generate_debug_code_;
825 ObjectLiteral::Accessors,
826 ZoneAllocationPolicy> {
847 #endif // V8_FULL_CODEGEN_H_
#define INLINE_FUNCTION_LIST(F)
#define DECLARE_VISIT(type)
static bool MakeCode(CompilationInfo *info)
static TypeFeedbackId None()
Handle< Script > script() const
Iterator find(Literal *key, bool insert=false, ZoneAllocationPolicyallocator=ZoneAllocationPolicy())
#define ASSERT(condition)
BreakableStatementChecker()
static const int kMaxBackEdgeWeight
FullCodeGenerator(MacroAssembler *masm, CompilationInfo *info)
FunctionLiteral * function() const
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
AccessorTable(Zone *zone)
static const char * State2String(State state)
activate correct semantics for inheriting readonliness false
friend class NestedStatement
#define EMIT_INLINE_RUNTIME_CALL(name, x, y)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction pairs(ARM only)") DEFINE_bool(enable_unaligned_accesses
#define ASSERT_EQ(v1, v2)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
Iterator lookup(Literal *literal)
void Check(Statement *stmt)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
#define INLINE_RUNTIME_FUNCTION_LIST(F)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
void check(i::Vector< const char > string)
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset flag