v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
full-codegen.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_FULL_CODEGEN_H_
29 #define V8_FULL_CODEGEN_H_
30 
31 #include "v8.h"
32 
33 #include "allocation.h"
34 #include "ast.h"
35 #include "code-stubs.h"
36 #include "codegen.h"
37 #include "compiler.h"
38 
39 namespace v8 {
40 namespace internal {
41 
42 // Forward declarations.
43 class JumpPatchSite;
44 
45 // AST node visitor which can tell whether a given statement will be breakable
46 // when the code is compiled by the full compiler in the debugger. This means
47 // that there will be an IC (load/store/call) in the code generated for the
48 // debugger to piggybag on.
49 class BreakableStatementChecker: public AstVisitor {
50  public:
51  BreakableStatementChecker() : is_breakable_(false) {}
52 
53  void Check(Statement* stmt);
54  void Check(Expression* stmt);
55 
56  bool is_breakable() { return is_breakable_; }
57 
58  private:
59  // AST node visit functions.
60 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
62 #undef DECLARE_VISIT
63 
64  bool is_breakable_;
65 
66  DISALLOW_COPY_AND_ASSIGN(BreakableStatementChecker);
67 };
68 
69 
70 // -----------------------------------------------------------------------------
71 // Full code generator.
72 
73 class FullCodeGenerator: public AstVisitor {
74  public:
75  enum State {
78  };
79 
80  FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info,
81  Zone* zone)
82  : masm_(masm),
83  info_(info),
84  scope_(info->scope()),
85  nesting_stack_(NULL),
86  loop_depth_(0),
87  globals_(NULL),
88  context_(NULL),
89  bailout_entries_(info->HasDeoptimizationSupport()
90  ? info->function()->ast_node_count() : 0, zone),
91  stack_checks_(2, zone), // There's always at least one.
92  type_feedback_cells_(info->HasDeoptimizationSupport()
93  ? info->function()->ast_node_count() : 0, zone),
94  ic_total_count_(0),
95  zone_(zone) { }
96 
97  static bool MakeCode(CompilationInfo* info);
98 
99  // Encode state and pc-offset as a BitField<type, start, size>.
100  // Only use 30 bits because we encode the result as a smi.
101  class StateField : public BitField<State, 0, 1> { };
102  class PcField : public BitField<unsigned, 1, 30-1> { };
103 
104  static const char* State2String(State state) {
105  switch (state) {
106  case NO_REGISTERS: return "NO_REGISTERS";
107  case TOS_REG: return "TOS_REG";
108  }
109  UNREACHABLE();
110  return NULL;
111  }
112 
113  Zone* zone() const { return zone_; }
114 
115  private:
116  class Breakable;
117  class Iteration;
118 
119  class TestContext;
120 
122  public:
123  explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) {
124  // Link into codegen's nesting stack.
125  previous_ = codegen->nesting_stack_;
126  codegen->nesting_stack_ = this;
127  }
128  virtual ~NestedStatement() {
129  // Unlink from codegen's nesting stack.
130  ASSERT_EQ(this, codegen_->nesting_stack_);
131  codegen_->nesting_stack_ = previous_;
132  }
133 
134  virtual Breakable* AsBreakable() { return NULL; }
135  virtual Iteration* AsIteration() { return NULL; }
136 
137  virtual bool IsContinueTarget(Statement* target) { return false; }
138  virtual bool IsBreakTarget(Statement* target) { return false; }
139 
140  // Notify the statement that we are exiting it via break, continue, or
141  // return and give it a chance to generate cleanup code. Return the
142  // next outer statement in the nesting stack. We accumulate in
143  // *stack_depth the amount to drop the stack and in *context_length the
144  // number of context chain links to unwind as we traverse the nesting
145  // stack from an exit to its target.
146  virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
147  return previous_;
148  }
149 
150  protected:
151  MacroAssembler* masm() { return codegen_->masm(); }
152 
153  FullCodeGenerator* codegen_;
154  NestedStatement* previous_;
155 
156  private:
158  };
159 
160  // A breakable statement such as a block.
161  class Breakable : public NestedStatement {
162  public:
163  Breakable(FullCodeGenerator* codegen, BreakableStatement* statement)
164  : NestedStatement(codegen), statement_(statement) {
165  }
166  virtual ~Breakable() {}
167 
168  virtual Breakable* AsBreakable() { return this; }
169  virtual bool IsBreakTarget(Statement* target) {
170  return statement() == target;
171  }
172 
173  BreakableStatement* statement() { return statement_; }
174  Label* break_label() { return &break_label_; }
175 
176  private:
177  BreakableStatement* statement_;
178  Label break_label_;
179  };
180 
181  // An iteration statement such as a while, for, or do loop.
182  class Iteration : public Breakable {
183  public:
184  Iteration(FullCodeGenerator* codegen, IterationStatement* statement)
185  : Breakable(codegen, statement) {
186  }
187  virtual ~Iteration() {}
188 
189  virtual Iteration* AsIteration() { return this; }
190  virtual bool IsContinueTarget(Statement* target) {
191  return statement() == target;
192  }
193 
194  Label* continue_label() { return &continue_label_; }
195 
196  private:
197  Label continue_label_;
198  };
199 
200  // A nested block statement.
201  class NestedBlock : public Breakable {
202  public:
203  NestedBlock(FullCodeGenerator* codegen, Block* block)
204  : Breakable(codegen, block) {
205  }
206  virtual ~NestedBlock() {}
207 
208  virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
209  if (statement()->AsBlock()->scope() != NULL) {
210  ++(*context_length);
211  }
212  return previous_;
213  };
214  };
215 
216  // The try block of a try/catch statement.
217  class TryCatch : public NestedStatement {
218  public:
219  explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) {
220  }
221  virtual ~TryCatch() {}
222 
223  virtual NestedStatement* Exit(int* stack_depth, int* context_length);
224  };
225 
226  // The try block of a try/finally statement.
227  class TryFinally : public NestedStatement {
228  public:
229  TryFinally(FullCodeGenerator* codegen, Label* finally_entry)
230  : NestedStatement(codegen), finally_entry_(finally_entry) {
231  }
232  virtual ~TryFinally() {}
233 
234  virtual NestedStatement* Exit(int* stack_depth, int* context_length);
235 
236  private:
237  Label* finally_entry_;
238  };
239 
240  // The finally block of a try/finally statement.
241  class Finally : public NestedStatement {
242  public:
243  static const int kElementCount = 5;
244 
245  explicit Finally(FullCodeGenerator* codegen) : NestedStatement(codegen) { }
246  virtual ~Finally() {}
247 
248  virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
249  *stack_depth += kElementCount;
250  return previous_;
251  }
252  };
253 
254  // The body of a for/in loop.
255  class ForIn : public Iteration {
256  public:
257  static const int kElementCount = 5;
258 
259  ForIn(FullCodeGenerator* codegen, ForInStatement* statement)
260  : Iteration(codegen, statement) {
261  }
262  virtual ~ForIn() {}
263 
264  virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
265  *stack_depth += kElementCount;
266  return previous_;
267  }
268  };
269 
270 
271  // The body of a with or catch.
272  class WithOrCatch : public NestedStatement {
273  public:
274  explicit WithOrCatch(FullCodeGenerator* codegen)
275  : NestedStatement(codegen) {
276  }
277  virtual ~WithOrCatch() {}
278 
279  virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
280  ++(*context_length);
281  return previous_;
282  }
283  };
284 
285  // Type of a member function that generates inline code for a native function.
286  typedef void (FullCodeGenerator::*InlineFunctionGenerator)(CallRuntime* expr);
287 
288  static const InlineFunctionGenerator kInlineFunctionGenerators[];
289 
290  // A platform-specific utility to overwrite the accumulator register
291  // with a GC-safe value.
292  void ClearAccumulator();
293 
294  // Determine whether or not to inline the smi case for the given
295  // operation.
296  bool ShouldInlineSmiCase(Token::Value op);
297 
298  // Helper function to convert a pure value into a test context. The value
299  // is expected on the stack or the accumulator, depending on the platform.
300  // See the platform-specific implementation for details.
301  void DoTest(Expression* condition,
302  Label* if_true,
303  Label* if_false,
304  Label* fall_through);
305  void DoTest(const TestContext* context);
306 
307  // Helper function to split control flow and avoid a branch to the
308  // fall-through label if it is set up.
309 #ifdef V8_TARGET_ARCH_MIPS
310  void Split(Condition cc,
311  Register lhs,
312  const Operand& rhs,
313  Label* if_true,
314  Label* if_false,
315  Label* fall_through);
316 #else // All non-mips arch.
317  void Split(Condition cc,
318  Label* if_true,
319  Label* if_false,
320  Label* fall_through);
321 #endif // V8_TARGET_ARCH_MIPS
322 
323  // Load the value of a known (PARAMETER, LOCAL, or CONTEXT) variable into
324  // a register. Emits a context chain walk if if necessary (so does
325  // SetVar) so avoid calling both on the same variable.
326  void GetVar(Register destination, Variable* var);
327 
328  // Assign to a known (PARAMETER, LOCAL, or CONTEXT) variable. If it's in
329  // the context, the write barrier will be emitted and source, scratch0,
330  // scratch1 will be clobbered. Emits a context chain walk if if necessary
331  // (so does GetVar) so avoid calling both on the same variable.
332  void SetVar(Variable* var,
333  Register source,
334  Register scratch0,
335  Register scratch1);
336 
337  // An operand used to read/write a stack-allocated (PARAMETER or LOCAL)
338  // variable. Writing does not need the write barrier.
339  MemOperand StackOperand(Variable* var);
340 
341  // An operand used to read/write a known (PARAMETER, LOCAL, or CONTEXT)
342  // variable. May emit code to traverse the context chain, loading the
343  // found context into the scratch register. Writing to this operand will
344  // need the write barrier if location is CONTEXT.
345  MemOperand VarOperand(Variable* var, Register scratch);
346 
347  void VisitForEffect(Expression* expr) {
348  EffectContext context(this);
349  Visit(expr);
350  PrepareForBailout(expr, NO_REGISTERS);
351  }
352 
353  void VisitForAccumulatorValue(Expression* expr) {
354  AccumulatorValueContext context(this);
355  Visit(expr);
356  PrepareForBailout(expr, TOS_REG);
357  }
358 
359  void VisitForStackValue(Expression* expr) {
360  StackValueContext context(this);
361  Visit(expr);
362  PrepareForBailout(expr, NO_REGISTERS);
363  }
364 
365  void VisitForControl(Expression* expr,
366  Label* if_true,
367  Label* if_false,
368  Label* fall_through) {
369  TestContext context(this, expr, if_true, if_false, fall_through);
370  Visit(expr);
371  // For test contexts, we prepare for bailout before branching, not at
372  // the end of the entire expression. This happens as part of visiting
373  // the expression.
374  }
375 
376  void VisitInDuplicateContext(Expression* expr);
377 
378  void VisitDeclarations(ZoneList<Declaration*>* declarations);
379  void DeclareGlobals(Handle<FixedArray> pairs);
380  int DeclareGlobalsFlags();
381 
382  // Try to perform a comparison as a fast inlined literal compare if
383  // the operands allow it. Returns true if the compare operations
384  // has been matched and all code generated; false otherwise.
385  bool TryLiteralCompare(CompareOperation* compare);
386 
387  // Platform-specific code for comparing the type of a value with
388  // a given literal string.
389  void EmitLiteralCompareTypeof(Expression* expr,
390  Expression* sub_expr,
391  Handle<String> check);
392 
393  // Platform-specific code for equality comparison with a nil-like value.
394  void EmitLiteralCompareNil(CompareOperation* expr,
395  Expression* sub_expr,
396  NilValue nil);
397 
398  // Bailout support.
399  void PrepareForBailout(Expression* node, State state);
400  void PrepareForBailoutForId(unsigned id, State state);
401 
402  // Cache cell support. This associates AST ids with global property cells
403  // that will be cleared during GC and collected by the type-feedback oracle.
404  void RecordTypeFeedbackCell(unsigned id, Handle<JSGlobalPropertyCell> cell);
405 
406  // Record a call's return site offset, used to rebuild the frame if the
407  // called function was inlined at the site.
408  void RecordJSReturnSite(Call* call);
409 
410  // Prepare for bailout before a test (or compare) and branch. If
411  // should_normalize, then the following comparison will not handle the
412  // canonical JS true value so we will insert a (dead) test against true at
413  // the actual bailout target from the optimized code. If not
414  // should_normalize, the true and false labels are ignored.
415  void PrepareForBailoutBeforeSplit(Expression* expr,
416  bool should_normalize,
417  Label* if_true,
418  Label* if_false);
419 
420  // If enabled, emit debug code for checking that the current context is
421  // neither a with nor a catch context.
422  void EmitDebugCheckDeclarationContext(Variable* variable);
423 
424  // Platform-specific code for checking the stack limit at the back edge of
425  // a loop.
426  // This is meant to be called at loop back edges, |back_edge_target| is
427  // the jump target of the back edge and is used to approximate the amount
428  // of code inside the loop.
429  void EmitStackCheck(IterationStatement* stmt, Label* back_edge_target);
430  // Record the OSR AST id corresponding to a stack check in the code.
431  void RecordStackCheck(unsigned osr_ast_id);
432  // Emit a table of stack check ids and pcs into the code stream. Return
433  // the offset of the start of the table.
434  unsigned EmitStackCheckTable();
435 
436  void EmitProfilingCounterDecrement(int delta);
437  void EmitProfilingCounterReset();
438 
439  // Platform-specific return sequence
440  void EmitReturnSequence();
441 
442  // Platform-specific code sequences for calls
443  void EmitCallWithStub(Call* expr, CallFunctionFlags flags);
444  void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode);
445  void EmitKeyedCallWithIC(Call* expr, Expression* key);
446 
447  // Platform-specific code for inline runtime calls.
448  InlineFunctionGenerator FindInlineFunctionGenerator(Runtime::FunctionId id);
449 
450  void EmitInlineRuntimeCall(CallRuntime* expr);
451 
452 #define EMIT_INLINE_RUNTIME_CALL(name, x, y) \
453  void Emit##name(CallRuntime* expr);
456 #undef EMIT_INLINE_RUNTIME_CALL
457 
458  // Platform-specific code for loading variables.
459  void EmitLoadGlobalCheckExtensions(Variable* var,
460  TypeofState typeof_state,
461  Label* slow);
462  MemOperand ContextSlotOperandCheckExtensions(Variable* var, Label* slow);
463  void EmitDynamicLookupFastCase(Variable* var,
464  TypeofState typeof_state,
465  Label* slow,
466  Label* done);
467  void EmitVariableLoad(VariableProxy* proxy);
468 
469  void EmitAccessor(Expression* expression);
470 
471  // Expects the arguments and the function already pushed.
472  void EmitResolvePossiblyDirectEval(int arg_count);
473 
474  // Platform-specific support for allocating a new closure based on
475  // the given function info.
476  void EmitNewClosure(Handle<SharedFunctionInfo> info, bool pretenure);
477 
478  // Platform-specific support for compiling assignments.
479 
480  // Load a value from a named property.
481  // The receiver is left on the stack by the IC.
482  void EmitNamedPropertyLoad(Property* expr);
483 
484  // Load a value from a keyed property.
485  // The receiver and the key is left on the stack by the IC.
486  void EmitKeyedPropertyLoad(Property* expr);
487 
488  // Apply the compound assignment operator. Expects the left operand on top
489  // of the stack and the right one in the accumulator.
490  void EmitBinaryOp(BinaryOperation* expr,
491  Token::Value op,
492  OverwriteMode mode);
493 
494  // Helper functions for generating inlined smi code for certain
495  // binary operations.
496  void EmitInlineSmiBinaryOp(BinaryOperation* expr,
497  Token::Value op,
498  OverwriteMode mode,
499  Expression* left,
500  Expression* right);
501 
502  // Assign to the given expression as if via '='. The right-hand-side value
503  // is expected in the accumulator.
504  void EmitAssignment(Expression* expr);
505 
506  // Complete a variable assignment. The right-hand-side value is expected
507  // in the accumulator.
508  void EmitVariableAssignment(Variable* var,
509  Token::Value op);
510 
511  // Complete a named property assignment. The receiver is expected on top
512  // of the stack and the right-hand-side value in the accumulator.
513  void EmitNamedPropertyAssignment(Assignment* expr);
514 
515  // Complete a keyed property assignment. The receiver and key are
516  // expected on top of the stack and the right-hand-side value in the
517  // accumulator.
518  void EmitKeyedPropertyAssignment(Assignment* expr);
519 
520  void CallIC(Handle<Code> code,
521  RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
522  unsigned ast_id = kNoASTId);
523 
524  void SetFunctionPosition(FunctionLiteral* fun);
525  void SetReturnPosition(FunctionLiteral* fun);
526  void SetStatementPosition(Statement* stmt);
527  void SetExpressionPosition(Expression* expr, int pos);
528  void SetStatementPosition(int pos);
529  void SetSourcePosition(int pos);
530 
531  // Non-local control flow support.
532  void EnterFinallyBlock();
533  void ExitFinallyBlock();
534 
535  // Loop nesting counter.
536  int loop_depth() { return loop_depth_; }
537  void increment_loop_depth() { loop_depth_++; }
538  void decrement_loop_depth() {
539  ASSERT(loop_depth_ > 0);
540  loop_depth_--;
541  }
542 
543  MacroAssembler* masm() { return masm_; }
544 
545  class ExpressionContext;
546  const ExpressionContext* context() { return context_; }
547  void set_new_context(const ExpressionContext* context) { context_ = context; }
548 
549  Handle<Script> script() { return info_->script(); }
550  bool is_eval() { return info_->is_eval(); }
551  bool is_native() { return info_->is_native(); }
552  bool is_classic_mode() { return language_mode() == CLASSIC_MODE; }
553  LanguageMode language_mode() { return function()->language_mode(); }
554  FunctionLiteral* function() { return info_->function(); }
555  Scope* scope() { return scope_; }
556 
557  static Register result_register();
558  static Register context_register();
559 
560  // Set fields in the stack frame. Offsets are the frame pointer relative
561  // offsets defined in, e.g., StandardFrameConstants.
562  void StoreToFrameField(int frame_offset, Register value);
563 
564  // Load a value from the current context. Indices are defined as an enum
565  // in v8::internal::Context.
566  void LoadContextField(Register dst, int context_index);
567 
568  // Push the function argument for the runtime functions PushWithContext
569  // and PushCatchContext.
570  void PushFunctionArgumentForContextAllocation();
571 
572  // AST node visit functions.
573 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
575 #undef DECLARE_VISIT
576 
577  void EmitUnaryOperation(UnaryOperation* expr, const char* comment);
578 
579  void VisitComma(BinaryOperation* expr);
580  void VisitLogicalExpression(BinaryOperation* expr);
581  void VisitArithmeticExpression(BinaryOperation* expr);
582 
583  void VisitForTypeofValue(Expression* expr);
584 
585  void Generate();
586  void PopulateDeoptimizationData(Handle<Code> code);
587  void PopulateTypeFeedbackInfo(Handle<Code> code);
588  void PopulateTypeFeedbackCells(Handle<Code> code);
589 
590  Handle<FixedArray> handler_table() { return handler_table_; }
591 
592  struct BailoutEntry {
593  unsigned id;
594  unsigned pc_and_state;
595  };
596 
597  struct TypeFeedbackCellEntry {
598  unsigned ast_id;
599  Handle<JSGlobalPropertyCell> cell;
600  };
601 
602 
603  class ExpressionContext BASE_EMBEDDED {
604  public:
605  explicit ExpressionContext(FullCodeGenerator* codegen)
606  : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) {
607  codegen->set_new_context(this);
608  }
609 
610  virtual ~ExpressionContext() {
611  codegen_->set_new_context(old_);
612  }
613 
614  Isolate* isolate() const { return codegen_->isolate(); }
615 
616  // Convert constant control flow (true or false) to the result expected for
617  // this expression context.
618  virtual void Plug(bool flag) const = 0;
619 
620  // Emit code to convert a pure value (in a register, known variable
621  // location, as a literal, or on top of the stack) into the result
622  // expected according to this expression context.
623  virtual void Plug(Register reg) const = 0;
624  virtual void Plug(Variable* var) const = 0;
625  virtual void Plug(Handle<Object> lit) const = 0;
626  virtual void Plug(Heap::RootListIndex index) const = 0;
627  virtual void PlugTOS() const = 0;
628 
629  // Emit code to convert pure control flow to a pair of unbound labels into
630  // the result expected according to this expression context. The
631  // implementation will bind both labels unless it's a TestContext, which
632  // won't bind them at this point.
633  virtual void Plug(Label* materialize_true,
634  Label* materialize_false) const = 0;
635 
636  // Emit code to discard count elements from the top of stack, then convert
637  // a pure value into the result expected according to this expression
638  // context.
639  virtual void DropAndPlug(int count, Register reg) const = 0;
640 
641  // Set up branch labels for a test expression. The three Label** parameters
642  // are output parameters.
643  virtual void PrepareTest(Label* materialize_true,
644  Label* materialize_false,
645  Label** if_true,
646  Label** if_false,
647  Label** fall_through) const = 0;
648 
649  // Returns true if we are evaluating only for side effects (i.e. if the
650  // result will be discarded).
651  virtual bool IsEffect() const { return false; }
652 
653  // Returns true if we are evaluating for the value (in accu/on stack).
654  virtual bool IsAccumulatorValue() const { return false; }
655  virtual bool IsStackValue() const { return false; }
656 
657  // Returns true if we are branching on the value rather than materializing
658  // it. Only used for asserts.
659  virtual bool IsTest() const { return false; }
660 
661  protected:
662  FullCodeGenerator* codegen() const { return codegen_; }
663  MacroAssembler* masm() const { return masm_; }
664  MacroAssembler* masm_;
665 
666  private:
667  const ExpressionContext* old_;
668  FullCodeGenerator* codegen_;
669  };
670 
671  class AccumulatorValueContext : public ExpressionContext {
672  public:
673  explicit AccumulatorValueContext(FullCodeGenerator* codegen)
674  : ExpressionContext(codegen) { }
675 
676  virtual void Plug(bool flag) const;
677  virtual void Plug(Register reg) const;
678  virtual void Plug(Label* materialize_true, Label* materialize_false) const;
679  virtual void Plug(Variable* var) const;
680  virtual void Plug(Handle<Object> lit) const;
681  virtual void Plug(Heap::RootListIndex) const;
682  virtual void PlugTOS() const;
683  virtual void DropAndPlug(int count, Register reg) const;
684  virtual void PrepareTest(Label* materialize_true,
685  Label* materialize_false,
686  Label** if_true,
687  Label** if_false,
688  Label** fall_through) const;
689  virtual bool IsAccumulatorValue() const { return true; }
690  };
691 
692  class StackValueContext : public ExpressionContext {
693  public:
694  explicit StackValueContext(FullCodeGenerator* codegen)
695  : ExpressionContext(codegen) { }
696 
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;
702  virtual void Plug(Heap::RootListIndex) 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,
707  Label** if_true,
708  Label** if_false,
709  Label** fall_through) const;
710  virtual bool IsStackValue() const { return true; }
711  };
712 
713  class TestContext : public ExpressionContext {
714  public:
715  TestContext(FullCodeGenerator* codegen,
716  Expression* condition,
717  Label* true_label,
718  Label* false_label,
719  Label* fall_through)
720  : ExpressionContext(codegen),
721  condition_(condition),
722  true_label_(true_label),
723  false_label_(false_label),
724  fall_through_(fall_through) { }
725 
726  static const TestContext* cast(const ExpressionContext* context) {
727  ASSERT(context->IsTest());
728  return reinterpret_cast<const TestContext*>(context);
729  }
730 
731  Expression* condition() const { return condition_; }
732  Label* true_label() const { return true_label_; }
733  Label* false_label() const { return false_label_; }
734  Label* fall_through() const { return fall_through_; }
735 
736  virtual void Plug(bool flag) const;
737  virtual void Plug(Register reg) const;
738  virtual void Plug(Label* materialize_true, Label* materialize_false) const;
739  virtual void Plug(Variable* var) const;
740  virtual void Plug(Handle<Object> lit) const;
741  virtual void Plug(Heap::RootListIndex) const;
742  virtual void PlugTOS() const;
743  virtual void DropAndPlug(int count, Register reg) const;
744  virtual void PrepareTest(Label* materialize_true,
745  Label* materialize_false,
746  Label** if_true,
747  Label** if_false,
748  Label** fall_through) const;
749  virtual bool IsTest() const { return true; }
750 
751  private:
752  Expression* condition_;
753  Label* true_label_;
754  Label* false_label_;
755  Label* fall_through_;
756  };
757 
758  class EffectContext : public ExpressionContext {
759  public:
760  explicit EffectContext(FullCodeGenerator* codegen)
761  : ExpressionContext(codegen) { }
762 
763  virtual void Plug(bool flag) const;
764  virtual void Plug(Register reg) const;
765  virtual void Plug(Label* materialize_true, Label* materialize_false) const;
766  virtual void Plug(Variable* var) const;
767  virtual void Plug(Handle<Object> lit) const;
768  virtual void Plug(Heap::RootListIndex) const;
769  virtual void PlugTOS() const;
770  virtual void DropAndPlug(int count, Register reg) const;
771  virtual void PrepareTest(Label* materialize_true,
772  Label* materialize_false,
773  Label** if_true,
774  Label** if_false,
775  Label** fall_through) const;
776  virtual bool IsEffect() const { return true; }
777  };
778 
779  MacroAssembler* masm_;
780  CompilationInfo* info_;
781  Scope* scope_;
782  Label return_label_;
783  NestedStatement* nesting_stack_;
784  int loop_depth_;
785  ZoneList<Handle<Object> >* globals_;
786  const ExpressionContext* context_;
787  ZoneList<BailoutEntry> bailout_entries_;
788  ZoneList<BailoutEntry> stack_checks_;
789  ZoneList<TypeFeedbackCellEntry> type_feedback_cells_;
790  int ic_total_count_;
791  Handle<FixedArray> handler_table_;
792  Handle<JSGlobalPropertyCell> profiling_counter_;
793  Zone* zone_;
794 
795  friend class NestedStatement;
796 
798 };
799 
800 
801 // A map from property names to getter/setter pairs allocated in the zone.
802 class AccessorTable: public TemplateHashMap<Literal,
803  ObjectLiteral::Accessors,
804  ZoneAllocationPolicy> {
805  public:
806  explicit AccessorTable(Zone* zone) :
809  ZoneAllocationPolicy(zone)),
810  zone_(zone) { }
811 
812  Iterator lookup(Literal* literal) {
813  Iterator it = find(literal, true, ZoneAllocationPolicy(zone_));
814  if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors();
815  return it;
816  }
817 
818  private:
819  Zone* zone_;
820 };
821 
822 
823 } } // namespace v8::internal
824 
825 #endif // V8_FULL_CODEGEN_H_
#define INLINE_FUNCTION_LIST(F)
Definition: runtime.h:493
#define DECLARE_VISIT(type)
Definition: full-codegen.h:573
static bool MakeCode(CompilationInfo *info)
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
Definition: flags.cc:1349
Flag flags[]
Definition: flags.cc:1467
Iterator find(Literal *key, bool insert=false, ZoneAllocationPolicyallocator=ZoneAllocationPolicy())
Definition: hashmap.h:352
#define ASSERT(condition)
Definition: checks.h:270
const char * comment() const
Definition: flags.cc:1362
const unsigned kNoASTId
Definition: assembler.h:54
#define UNREACHABLE()
Definition: checks.h:50
NilValue
Definition: v8.h:141
FullCodeGenerator(MacroAssembler *masm, CompilationInfo *info, Zone *zone)
Definition: full-codegen.h:80
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:321
static const char * State2String(State state)
Definition: full-codegen.h:104
#define BASE_EMBEDDED
Definition: allocation.h:68
#define AST_NODE_LIST(V)
Definition: ast.h:115
#define EMIT_INLINE_RUNTIME_CALL(name, x, y)
Definition: full-codegen.h:452
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kThisPropertyAssignmentsOffset flag
Definition: objects-inl.h:3682
#define ASSERT_EQ(v1, v2)
Definition: checks.h:271
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
Definition: flags.cc:274
Iterator lookup(Literal *literal)
Definition: full-codegen.h:812
#define INLINE_RUNTIME_FUNCTION_LIST(F)
Definition: runtime.h:531
void check(i::Vector< const char > string)
TypeofState
Definition: codegen.h:70