v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scopes.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_SCOPES_H_
29 #define V8_SCOPES_H_
30 
31 #include "ast.h"
32 #include "zone.h"
33 
34 namespace v8 {
35 namespace internal {
36 
37 class CompilationInfo;
38 
39 
40 // A hash map to support fast variable declaration and lookup.
41 class VariableMap: public ZoneHashMap {
42  public:
43  explicit VariableMap(Zone* zone);
44 
45  virtual ~VariableMap();
46 
47  Variable* Declare(Scope* scope,
50  bool is_valid_lhs,
51  Variable::Kind kind,
52  InitializationFlag initialization_flag,
54 
56 
57  Zone* zone() const { return zone_; }
58 
59  private:
60  Zone* zone_;
61 };
62 
63 
64 // The dynamic scope part holds hash maps for the variables that will
65 // be looked up dynamically from within eval and with scopes. The objects
66 // are allocated on-demand from Scope::NonLocal to avoid wasting memory
67 // and setup time for scopes that don't need them.
68 class DynamicScopePart : public ZoneObject {
69  public:
70  explicit DynamicScopePart(Zone* zone) {
71  for (int i = 0; i < 3; i++)
72  maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone);
73  }
74 
76  int index = mode - DYNAMIC;
77  ASSERT(index >= 0 && index < 3);
78  return maps_[index];
79  }
80 
81  private:
82  VariableMap *maps_[3];
83 };
84 
85 
86 // Global invariants after AST construction: Each reference (i.e. identifier)
87 // to a JavaScript variable (including global properties) is represented by a
88 // VariableProxy node. Immediately after AST construction and before variable
89 // allocation, most VariableProxy nodes are "unresolved", i.e. not bound to a
90 // corresponding variable (though some are bound during parse time). Variable
91 // allocation binds each unresolved VariableProxy to one Variable and assigns
92 // a location. Note that many VariableProxy nodes may refer to the same Java-
93 // Script variable.
94 
95 class Scope: public ZoneObject {
96  public:
97  // ---------------------------------------------------------------------------
98  // Construction
99 
101 
102  // Compute top scope and allocate variables. For lazy compilation the top
103  // scope only contains the single lazily compiled function, so this
104  // doesn't re-allocate variables repeatedly.
105  static bool Analyze(CompilationInfo* info);
106 
107  static Scope* DeserializeScopeChain(Context* context, Scope* global_scope,
108  Zone* zone);
109 
110  // The scope name is only used for printing/debugging.
111  void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; }
112 
113  void Initialize();
114 
115  // Checks if the block scope is redundant, i.e. it does not contain any
116  // block scoped declarations. In that case it is removed from the scope
117  // tree and its children are reparented.
119 
120  Zone* zone() const { return zone_; }
121 
122  // ---------------------------------------------------------------------------
123  // Declarations
124 
125  // Lookup a variable in this scope. Returns the variable or NULL if not found.
127 
128  // This lookup corresponds to a lookup in the "intermediate" scope sitting
129  // between this scope and the outer scope. (ECMA-262, 3rd., requires that
130  // the name of named function literal is kept in an intermediate scope
131  // in between this scope and the next outer scope.)
134 
135  // Lookup a variable in this scope or outer scopes.
136  // Returns the variable or NULL if not found.
138 
139  // Declare the function variable for a function literal. This variable
140  // is in an intermediate scope between this function scope and the the
141  // outer scope. Only possible for function scopes; at most one variable.
142  void DeclareFunctionVar(VariableDeclaration* declaration) {
144  function_ = declaration;
145  }
146 
147  // Declare a parameter in this scope. When there are duplicated
148  // parameters the rightmost one 'wins'. However, the implementation
149  // expects all parameters to be declared and from left to right.
151 
152  // Declare a local variable in this scope. If the variable has been
153  // declared before, the previously declared variable is returned.
156  InitializationFlag init_flag,
158 
159  // Declare an implicit global variable in this scope which must be a
160  // global scope. The variable was introduced (possibly from an inner
161  // scope) by a reference to an unresolved variable with no intervening
162  // with statements or eval calls.
164 
165  // Create a new unresolved variable.
166  template<class Visitor>
167  VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory,
168  Handle<String> name,
170  int position = RelocInfo::kNoPosition) {
171  // Note that we must not share the unresolved variables with
172  // the same name because they may be removed selectively via
173  // RemoveUnresolved().
175  VariableProxy* proxy =
176  factory->NewVariableProxy(name, false, interface, position);
177  unresolved_.Add(proxy, zone_);
178  return proxy;
179  }
180 
181  // Remove a unresolved variable. During parsing, an unresolved variable
182  // may have been added optimistically, but then only the variable name
183  // was used (typically for labels). If the variable was not declared, the
184  // addition introduced a new unresolved variable which may end up being
185  // allocated globally as a "ghost" variable. RemoveUnresolved removes
186  // such a variable again if it was added; otherwise this is a no-op.
187  void RemoveUnresolved(VariableProxy* var);
188 
189  // Creates a new internal variable in this scope. The name is only used
190  // for printing and cannot be used to find the variable. In particular,
191  // the only way to get hold of the temporary is by keeping the Variable*
192  // around.
194 
195  // Creates a new temporary variable in this scope. The name is only used
196  // for printing and cannot be used to find the variable. In particular,
197  // the only way to get hold of the temporary is by keeping the Variable*
198  // around. The name should not clash with a legitimate variable names.
200 
201  // Adds the specific declaration node to the list of declarations in
202  // this scope. The declarations are processed as part of entering
203  // the scope; see codegen.cc:ProcessDeclarations.
204  void AddDeclaration(Declaration* declaration);
205 
206  // ---------------------------------------------------------------------------
207  // Illegal redeclaration support.
208 
209  // Set an expression node that will be executed when the scope is
210  // entered. We only keep track of one illegal redeclaration node per
211  // scope - the first one - so if you try to set it multiple times
212  // the additional requests will be silently ignored.
213  void SetIllegalRedeclaration(Expression* expression);
214 
215  // Visit the illegal redeclaration expression. Do not call if the
216  // scope doesn't have an illegal redeclaration node.
217  void VisitIllegalRedeclaration(AstVisitor* visitor);
218 
219  // Check if the scope has (at least) one illegal redeclaration.
220  bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }
221 
222  // For harmony block scoping mode: Check if the scope has conflicting var
223  // declarations, i.e. a var declaration that has been hoisted from a nested
224  // scope over a let binding of the same name.
226 
227  // ---------------------------------------------------------------------------
228  // Scope-specific info.
229 
230  // Inform the scope that the corresponding code contains a with statement.
232 
233  // Inform the scope that the corresponding code contains an eval call.
235 
236  // Set the strict mode flag (unless disabled by a global flag).
238 
239  // Position in the source where this scope begins and ends.
240  //
241  // * For the scope of a with statement
242  // with (obj) stmt
243  // start position: start position of first token of 'stmt'
244  // end position: end position of last token of 'stmt'
245  // * For the scope of a block
246  // { stmts }
247  // start position: start position of '{'
248  // end position: end position of '}'
249  // * For the scope of a function literal or decalaration
250  // function fun(a,b) { stmts }
251  // start position: start position of '('
252  // end position: end position of '}'
253  // * For the scope of a catch block
254  // try { stms } catch(e) { stmts }
255  // start position: start position of '('
256  // end position: end position of ')'
257  // * For the scope of a for-statement
258  // for (let x ...) stmt
259  // start position: start position of '('
260  // end position: end position of last token of 'stmt'
261  int start_position() const { return start_position_; }
262  void set_start_position(int statement_pos) {
263  start_position_ = statement_pos;
264  }
265  int end_position() const { return end_position_; }
266  void set_end_position(int statement_pos) {
267  end_position_ = statement_pos;
268  }
269 
270  // In some cases we want to force context allocation for a whole scope.
274  }
277  }
278 
279  // ---------------------------------------------------------------------------
280  // Predicates.
281 
282  // Specific scope types.
283  bool is_eval_scope() const { return scope_type_ == EVAL_SCOPE; }
284  bool is_function_scope() const { return scope_type_ == FUNCTION_SCOPE; }
285  bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; }
286  bool is_global_scope() const { return scope_type_ == GLOBAL_SCOPE; }
287  bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
288  bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
289  bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
290  bool is_declaration_scope() const {
291  return is_eval_scope() || is_function_scope() ||
293  }
294  bool is_strict_eval_scope() const {
295  return is_eval_scope() && strict_mode_ == STRICT;
296  }
297 
298  // Information about which scopes calls eval.
299  bool calls_eval() const { return scope_calls_eval_; }
302  }
305  }
306 
307  // Is this scope inside a with statement.
308  bool inside_with() const { return scope_inside_with_; }
309  // Does this scope contain a with statement.
310  bool contains_with() const { return scope_contains_with_; }
311 
312  // ---------------------------------------------------------------------------
313  // Accessors.
314 
315  // The type of this scope.
316  ScopeType scope_type() const { return scope_type_; }
317 
318  // The language mode of this scope.
319  StrictMode strict_mode() const { return strict_mode_; }
320 
321  // The variable corresponding the 'this' value.
322  Variable* receiver() { return receiver_; }
323 
324  // The variable holding the function literal for named function
325  // literals, or NULL. Only valid for function scopes.
326  VariableDeclaration* function() const {
328  return function_;
329  }
330 
331  // Parameters. The left-most parameter has index 0.
332  // Only valid for function scopes.
333  Variable* parameter(int index) const {
335  return params_[index];
336  }
337 
338  int num_parameters() const { return params_.length(); }
339 
340  // The local variable 'arguments' if we need to allocate it; NULL otherwise.
341  Variable* arguments() const { return arguments_; }
342 
343  // Declarations list.
345 
346  // Inner scope list.
348 
349  // The scope immediately surrounding this scope, or NULL.
350  Scope* outer_scope() const { return outer_scope_; }
351 
352  // The interface as inferred so far; only for module scopes.
353  Interface* interface() const { return interface_; }
354 
355  // ---------------------------------------------------------------------------
356  // Variable allocation.
357 
358  // Collect stack and context allocated local variables in this scope. Note
359  // that the function variable - if present - is not collected and should be
360  // handled separately.
362  ZoneList<Variable*>* context_locals);
363 
364  // Current number of var or const locals.
366 
367  // Result of variable allocation.
368  int num_stack_slots() const { return num_stack_slots_; }
369  int num_heap_slots() const { return num_heap_slots_; }
370 
371  int StackLocalCount() const;
372  int ContextLocalCount() const;
373 
374  // For global scopes, the number of module literals (including nested ones).
375  int num_modules() const { return num_modules_; }
376 
377  // For module scopes, the host scope's internal variable binding this module.
378  Variable* module_var() const { return module_var_; }
379 
380  // Make sure this scope and all outer scopes are eagerly compiled.
382 
383  // Determine if we can use lazy compilation for this scope.
384  bool AllowsLazyCompilation() const;
385 
386  // Determine if we can use lazy compilation for this scope without a context.
388 
389  // True if the outer context of this scope is always the native context.
390  bool HasTrivialOuterContext() const;
391 
392  // True if the outer context allows lazy compilation of this scope.
393  bool HasLazyCompilableOuterContext() const;
394 
395  // The number of contexts between this and scope; zero if this == scope.
396  int ContextChainLength(Scope* scope);
397 
398  // Find the innermost global scope.
399  Scope* GlobalScope();
400 
401  // Find the first function, global, or eval scope. This is the scope
402  // where var declarations will be hoisted to in the implementation.
404 
406 
407  // Get the chain of nested scopes within this scope for the source statement
408  // position. The scopes will be added to the list from the outermost scope to
409  // the innermost scope. Only nested block, catch or with scopes are tracked
410  // and will be returned, but no inner function scopes.
412  int statement_position);
413 
414  // ---------------------------------------------------------------------------
415  // Strict mode support.
417  // During formal parameter list parsing the scope only contains
418  // two variables inserted at initialization: "this" and "arguments".
419  // "this" is an invalid parameter name and "arguments" is invalid parameter
420  // name in strict mode. Therefore looking up with the map which includes
421  // "this" and "arguments" in addition to all formal parameters is safe.
422  return variables_.Lookup(name) != NULL;
423  }
424 
425  // ---------------------------------------------------------------------------
426  // Debugging.
427 
428 #ifdef DEBUG
429  void Print(int n = 0); // n = indentation; n < 0 => don't print recursively
430 #endif
431 
432  // ---------------------------------------------------------------------------
433  // Implementation.
434  protected:
435  friend class ParserFactory;
436 
438 
439  // Scope tree.
440  Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
441  ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
442 
443  // The scope type.
445 
446  // Debugging support.
448 
449  // The variables declared in this scope:
450  //
451  // All user-declared variables (incl. parameters). For global scopes
452  // variables may be implicitly 'declared' by being used (possibly in
453  // an inner scope) with no intervening with statements or eval calls.
455  // Compiler-allocated (user-invisible) internals.
457  // Compiler-allocated (user-invisible) temporaries.
459  // Parameter list in source order.
461  // Variables that must be looked up dynamically.
463  // Unresolved variables referred to from this scope.
465  // Declarations.
467  // Convenience variable.
469  // Function variable, if any; function scopes only.
470  VariableDeclaration* function_;
471  // Convenience variable; function scopes only.
473  // Interface; module scopes only.
475 
476  // Illegal redeclaration.
478 
479  // Scope-specific information computed during parsing.
480  //
481  // This scope is inside a 'with' of some outer scope.
483  // This scope contains a 'with' statement.
485  // This scope or a nested catch scope or with scope contain an 'eval' call. At
486  // the 'eval' call site this scope is the declaration scope.
488  // The strict mode of this scope.
490  // Source positions.
493 
494  // Computed via PropagateScopeInfo.
499 
500  // True if it doesn't need scope resolution (e.g., if the scope was
501  // constructed based on a serialized scope info or a catch context).
503 
504  // Computed as variables are declared.
506 
507  // Computed via AllocateVariables; function, block and catch scopes only.
510 
511  // The number of modules (including nested ones).
513 
514  // For module scopes, the host scope's internal variable binding this module.
516 
517  // Serialized scope info support.
520 
521  // Create a non-local variable with a given name.
522  // These variables are looked up dynamically at runtime.
524 
525  // Variable resolution.
526  // Possible results of a recursive variable lookup telling if and how a
527  // variable is bound. These are returned in the output parameter *binding_kind
528  // of the LookupRecursive function.
529  enum BindingKind {
530  // The variable reference could be statically resolved to a variable binding
531  // which is returned. There is no 'with' statement between the reference and
532  // the binding and no scope between the reference scope (inclusive) and
533  // binding scope (exclusive) makes a sloppy 'eval' call.
535 
536  // The variable reference could be statically resolved to a variable binding
537  // which is returned. There is no 'with' statement between the reference and
538  // the binding, but some scope between the reference scope (inclusive) and
539  // binding scope (exclusive) makes a sloppy 'eval' call, that might
540  // possibly introduce variable bindings shadowing the found one. Thus the
541  // found variable binding is just a guess.
543 
544  // The variable reference could not be statically resolved to any binding
545  // and thus should be considered referencing a global variable. NULL is
546  // returned. The variable reference is not inside any 'with' statement and
547  // no scope between the reference scope (inclusive) and global scope
548  // (exclusive) makes a sloppy 'eval' call.
550 
551  // The variable reference could not be statically resolved to any binding
552  // NULL is returned. The variable reference is not inside any 'with'
553  // statement, but some scope between the reference scope (inclusive) and
554  // global scope (exclusive) makes a sloppy 'eval' call, that might
555  // possibly introduce a variable binding. Thus the reference should be
556  // considered referencing a global variable unless it is shadowed by an
557  // 'eval' introduced binding.
559 
560  // The variable could not be statically resolved and needs to be looked up
561  // dynamically. NULL is returned. There are two possible reasons:
562  // * A 'with' statement has been encountered and there is no variable
563  // binding for the name between the variable reference and the 'with'.
564  // The variable potentially references a property of the 'with' object.
565  // * The code is being executed as part of a call to 'eval' and the calling
566  // context chain contains either a variable binding for the name or it
567  // contains a 'with' context.
569  };
570 
571  // Lookup a variable reference given by name recursively starting with this
572  // scope. If the code is executed because of a call to 'eval', the context
573  // parameter should be set to the calling context of 'eval'.
575  BindingKind* binding_kind,
578  bool ResolveVariable(CompilationInfo* info,
579  VariableProxy* proxy,
584 
585  // Scope analysis.
587  bool HasTrivialContext() const;
588 
589  // Predicates.
590  bool MustAllocate(Variable* var);
591  bool MustAllocateInContext(Variable* var);
592  bool HasArgumentsParameter();
593 
594  // Variable allocation.
595  void AllocateStackSlot(Variable* var);
596  void AllocateHeapSlot(Variable* var);
601  void AllocateModulesRecursively(Scope* host_scope);
602 
603  // Resolve and fill in the allocation information for all variables
604  // in this scopes. Must be called *after* all scopes have been
605  // processed (parsed) to ensure that unresolved variables can be
606  // resolved properly.
607  //
608  // In the case of code compiled and run using 'eval', the context
609  // parameter is the context in which eval was called. In all other
610  // cases the context parameter is an empty handle.
614 
615  private:
616  // Construct a scope based on the scope info.
617  Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info,
618  Zone* zone);
619 
620  // Construct a catch scope with a binding for the name.
621  Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone);
622 
623  void AddInnerScope(Scope* inner_scope) {
624  if (inner_scope != NULL) {
625  inner_scopes_.Add(inner_scope, zone_);
626  inner_scope->outer_scope_ = this;
627  }
628  }
629 
630  void SetDefaults(ScopeType type,
631  Scope* outer_scope,
632  Handle<ScopeInfo> scope_info);
633 
634  Zone* zone_;
635 };
636 
637 } } // namespace v8::internal
638 
639 #endif // V8_SCOPES_H_
bool PropagateScopeInfo(bool outer_scope_calls_sloppy_eval)
Definition: scopes.cc:1151
bool is_global_scope() const
Definition: scopes.h:286
Variable * module_var() const
Definition: scopes.h:378
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
Definition: flags.cc:269
Scope * DeclarationScope()
Definition: scopes.cc:743
bool scope_contains_with_
Definition: scopes.h:484
Declaration * CheckConflictingVarDeclarations()
Definition: scopes.cc:551
bool scope_calls_eval_
Definition: scopes.h:487
virtual ~VariableMap()
Definition: scopes.cc:62
bool calls_eval() const
Definition: scopes.h:299
bool outer_scope_calls_sloppy_eval_
Definition: scopes.h:495
Handle< ScopeInfo > GetScopeInfo()
Definition: scopes.cc:752
ZoneList< Scope * > inner_scopes_
Definition: scopes.h:441
Variable * receiver()
Definition: scopes.h:322
bool already_resolved()
Definition: scopes.h:519
bool force_eager_compilation_
Definition: scopes.h:497
int num_modules() const
Definition: scopes.h:375
void CollectStackAndContextLocals(ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
Definition: scopes.cc:590
Scope * FinalizeBlockScope()
Definition: scopes.cc:362
Variable * arguments_
Definition: scopes.h:472
static bool Analyze(CompilationInfo *info)
Definition: scopes.cc:278
Scope * outer_scope() const
Definition: scopes.h:350
bool HasIllegalRedeclaration() const
Definition: scopes.h:220
ZoneList< VariableProxy * > unresolved_
Definition: scopes.h:464
Expression * illegal_redecl_
Definition: scopes.h:477
bool already_resolved_
Definition: scopes.h:502
VariableProxy * NewUnresolved(AstNodeFactory< Visitor > *factory, Handle< String > name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
Definition: scopes.h:167
Scope(Scope *outer_scope, ScopeType scope_type, Zone *zone)
Definition: scopes.cc:105
Handle< String > scope_name_
Definition: scopes.h:447
Zone * zone() const
Definition: scopes.h:57
void DeclareParameter(Handle< String > name, VariableMode mode)
Definition: scopes.cc:458
bool HasTrivialContext() const
Definition: scopes.cc:669
#define ASSERT(condition)
Definition: checks.h:329
Variable * NewTemporary(Handle< String > name)
Definition: scopes.cc:518
void ForceEagerCompilation()
Definition: scopes.h:381
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing 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 statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT interface(disables compacting GC)") DEFINE_bool(gdbjit_full
VariableMap * GetMap(VariableMode mode)
Definition: scopes.h:75
VariableDeclaration * function_
Definition: scopes.h:470
bool has_forced_context_allocation() const
Definition: scopes.h:275
Variable * LookupRecursive(Handle< String > name, BindingKind *binding_kind, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:964
void set_end_position(int statement_pos)
Definition: scopes.h:266
Variable * parameter(int index) const
Definition: scopes.h:333
StrictMode strict_mode() const
Definition: scopes.h:319
bool is_block_scope() const
Definition: scopes.h:288
bool MustAllocateInContext(Variable *var)
Definition: scopes.cc:1192
ZoneList< Declaration * > decls_
Definition: scopes.h:466
Handle< ScopeInfo > scope_info_
Definition: scopes.h:518
int ContextChainLength(Scope *scope)
Definition: scopes.cc:721
bool HasTrivialOuterContext() const
Definition: scopes.cc:683
bool AllowsLazyCompilation() const
Definition: scopes.cc:711
void DeclareFunctionVar(VariableDeclaration *declaration)
Definition: scopes.h:142
void AllocateNonParameterLocal(Variable *var)
Definition: scopes.cc:1291
static Interface * NewValue()
Definition: interface.h:66
int start_position() const
Definition: scopes.h:261
Variable * DeclareLocal(Handle< String > name, VariableMode mode, InitializationFlag init_flag, Interface *interface=Interface::NewValue())
Definition: scopes.cc:467
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
void AllocateVariablesRecursively()
Definition: scopes.cc:1338
#define MUST_USE_RESULT
Definition: globals.h:381
bool is_eval_scope() const
Definition: scopes.h:283
bool HasArgumentsParameter()
Definition: scopes.cc:1214
Variable * arguments() const
Definition: scopes.h:341
int num_stack_slots() const
Definition: scopes.h:368
Isolate *const isolate_
Definition: scopes.h:437
void GetNestedScopeChain(List< Handle< ScopeInfo > > *chain, int statement_position)
Definition: scopes.cc:760
void AllocateHeapSlot(Variable *var)
Definition: scopes.cc:1230
bool force_context_allocation_
Definition: scopes.h:498
ScopeType scope_type() const
Definition: scopes.h:316
void set_start_position(int statement_pos)
Definition: scopes.h:262
void SetScopeName(Handle< String > scope_name)
Definition: scopes.h:111
ZoneList< Scope * > * inner_scopes()
Definition: scopes.h:347
bool is_declaration_scope() const
Definition: scopes.h:290
ZoneList< Variable * > internals_
Definition: scopes.h:456
bool HasLazyCompilableOuterContext() const
Definition: scopes.cc:693
bool inner_scope_calls_eval_
Definition: scopes.h:496
Interface * interface_
Definition: scopes.h:474
void AllocateStackSlot(Variable *var)
Definition: scopes.cc:1225
Variable * receiver_
Definition: scopes.h:468
int num_parameters() const
Definition: scopes.h:338
bool MustAllocate(Variable *var)
Definition: scopes.cc:1172
Variable * LocalLookup(Handle< String > name)
Definition: scopes.cc:392
int end_position() const
Definition: scopes.h:265
bool IsDeclared(Handle< String > name)
Definition: scopes.h:416
ZoneList< Variable * > params_
Definition: scopes.h:460
Variable * NewInternal(Handle< String > name)
Definition: scopes.cc:505
Interface * interface() const
Definition: scopes.h:353
Scope * GlobalScope()
Definition: scopes.cc:734
void AllocateParameterLocals()
Definition: scopes.cc:1235
int StackLocalCount() const
Definition: scopes.cc:1392
VariableMap variables_
Definition: scopes.h:454
void AddDeclaration(Declaration *declaration)
Definition: scopes.cc:531
bool calls_sloppy_eval()
Definition: scopes.h:300
int num_heap_slots() const
Definition: scopes.h:369
StrictMode strict_mode_
Definition: scopes.h:489
ScopeType scope_type_
Definition: scopes.h:444
void VisitIllegalRedeclaration(AstVisitor *visitor)
Definition: scopes.cc:545
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
Definition: flags.cc:317
bool is_with_scope() const
Definition: scopes.h:289
void AllocateNonParameterLocals()
Definition: scopes.cc:1305
ZoneList< Variable * > temps_
Definition: scopes.h:458
int num_var_or_const()
Definition: scopes.h:365
bool contains_with() const
Definition: scopes.h:310
bool AllowsLazyCompilationWithoutContext() const
Definition: scopes.cc:716
void SetStrictMode(StrictMode strict_mode)
Definition: scopes.h:237
Zone * zone() const
Definition: scopes.h:120
bool is_strict_eval_scope() const
Definition: scopes.h:294
Variable * DeclareDynamicGlobal(Handle< String > name)
Definition: scopes.cc:482
int ContextLocalCount() const
Definition: scopes.cc:1398
Variable * Lookup(Handle< String > name)
Definition: scopes.cc:90
bool inside_with() const
Definition: scopes.h:308
MUST_USE_RESULT bool AllocateVariables(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:642
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
friend class ParserFactory
Definition: scopes.h:435
Variable * NonLocal(Handle< String > name, VariableMode mode)
Definition: scopes.cc:943
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:39
bool outer_scope_calls_sloppy_eval() const
Definition: scopes.h:303
MUST_USE_RESULT bool ResolveVariable(CompilationInfo *info, VariableProxy *proxy, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1027
Variable * module_var_
Definition: scopes.h:515
void RecordEvalCall()
Definition: scopes.h:234
DynamicScopePart * dynamics_
Definition: scopes.h:462
void AllocateModulesRecursively(Scope *host_scope)
Definition: scopes.cc:1374
DynamicScopePart(Zone *zone)
Definition: scopes.h:70
bool is_function_scope() const
Definition: scopes.h:284
Variable * Lookup(Handle< String > name)
Definition: scopes.cc:447
VariableMap(Zone *zone)
Definition: scopes.cc:59
Variable * Declare(Scope *scope, Handle< String > name, VariableMode mode, bool is_valid_lhs, Variable::Kind kind, InitializationFlag initialization_flag, Interface *interface=Interface::NewValue())
Definition: scopes.cc:65
void * New(int size)
Definition: zone-inl.h:51
void RecordWithStatement()
Definition: scopes.h:231
bool is_module_scope() const
Definition: scopes.h:285
bool is_catch_scope() const
Definition: scopes.h:287
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing 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 statistics of the maximum memory committed for the heap in name
Definition: flags.cc:505
static Scope * DeserializeScopeChain(Context *context, Scope *global_scope, Zone *zone)
Definition: scopes.cc:214
Scope * outer_scope_
Definition: scopes.h:440
void ForceContextAllocation()
Definition: scopes.h:271
void RemoveUnresolved(VariableProxy *var)
Definition: scopes.cc:493
ZoneList< Declaration * > * declarations()
Definition: scopes.h:344
Variable * LookupFunctionVar(Handle< String > name, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:423
bool scope_inside_with_
Definition: scopes.h:482
MUST_USE_RESULT bool ResolveVariablesRecursively(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1131
void SetIllegalRedeclaration(Expression *expression)
Definition: scopes.cc:536