V8 Project
scopes.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_SCOPES_H_
6 #define V8_SCOPES_H_
7 
8 #include "src/ast.h"
9 #include "src/zone.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 class CompilationInfo;
15 
16 
17 // A hash map to support fast variable declaration and lookup.
18 class VariableMap: public ZoneHashMap {
19  public:
20  explicit VariableMap(Zone* zone);
21 
22  virtual ~VariableMap();
23 
25  bool is_valid_lhs, Variable::Kind kind,
26  InitializationFlag initialization_flag,
27  MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
28  Interface* interface = Interface::NewValue());
29 
31 
32  Zone* zone() const { return zone_; }
33 
34  private:
36 };
37 
38 
39 // The dynamic scope part holds hash maps for the variables that will
40 // be looked up dynamically from within eval and with scopes. The objects
41 // are allocated on-demand from Scope::NonLocal to avoid wasting memory
42 // and setup time for scopes that don't need them.
43 class DynamicScopePart : public ZoneObject {
44  public:
45  explicit DynamicScopePart(Zone* zone) {
46  for (int i = 0; i < 3; i++)
47  maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone);
48  }
49 
51  int index = mode - DYNAMIC;
52  DCHECK(index >= 0 && index < 3);
53  return maps_[index];
54  }
55 
56  private:
58 };
59 
60 
61 // Global invariants after AST construction: Each reference (i.e. identifier)
62 // to a JavaScript variable (including global properties) is represented by a
63 // VariableProxy node. Immediately after AST construction and before variable
64 // allocation, most VariableProxy nodes are "unresolved", i.e. not bound to a
65 // corresponding variable (though some are bound during parse time). Variable
66 // allocation binds each unresolved VariableProxy to one Variable and assigns
67 // a location. Note that many VariableProxy nodes may refer to the same Java-
68 // Script variable.
69 
70 class Scope: public ZoneObject {
71  public:
72  // ---------------------------------------------------------------------------
73  // Construction
74 
76  AstValueFactory* value_factory, Zone* zone);
77 
78  // Compute top scope and allocate variables. For lazy compilation the top
79  // scope only contains the single lazily compiled function, so this
80  // doesn't re-allocate variables repeatedly.
81  static bool Analyze(CompilationInfo* info);
82 
83  static Scope* DeserializeScopeChain(Context* context, Scope* global_scope,
84  Zone* zone);
85 
86  // The scope name is only used for printing/debugging.
87  void SetScopeName(const AstRawString* scope_name) {
88  scope_name_ = scope_name;
89  }
90 
91  void Initialize();
92 
93  // Checks if the block scope is redundant, i.e. it does not contain any
94  // block scoped declarations. In that case it is removed from the scope
95  // tree and its children are reparented.
97 
98  Zone* zone() const { return zone_; }
99 
100  // ---------------------------------------------------------------------------
101  // Declarations
102 
103  // Lookup a variable in this scope. Returns the variable or NULL if not found.
105 
106  // This lookup corresponds to a lookup in the "intermediate" scope sitting
107  // between this scope and the outer scope. (ECMA-262, 3rd., requires that
108  // the name of named function literal is kept in an intermediate scope
109  // in between this scope and the next outer scope.)
112 
113  // Lookup a variable in this scope or outer scopes.
114  // Returns the variable or NULL if not found.
115  Variable* Lookup(const AstRawString* name);
116 
117  // Declare the function variable for a function literal. This variable
118  // is in an intermediate scope between this function scope and the the
119  // outer scope. Only possible for function scopes; at most one variable.
120  void DeclareFunctionVar(VariableDeclaration* declaration) {
122  function_ = declaration;
123  }
124 
125  // Declare a parameter in this scope. When there are duplicated
126  // parameters the rightmost one 'wins'. However, the implementation
127  // expects all parameters to be declared and from left to right.
129 
130  // Declare a local variable in this scope. If the variable has been
131  // declared before, the previously declared variable is returned.
133  InitializationFlag init_flag,
134  MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
136 
137  // Declare an implicit global variable in this scope which must be a
138  // global scope. The variable was introduced (possibly from an inner
139  // scope) by a reference to an unresolved variable with no intervening
140  // with statements or eval calls.
142 
143  // Create a new unresolved variable.
144  template<class Visitor>
145  VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory,
146  const AstRawString* name,
148  int position = RelocInfo::kNoPosition) {
149  // Note that we must not share the unresolved variables with
150  // the same name because they may be removed selectively via
151  // RemoveUnresolved().
153  VariableProxy* proxy =
154  factory->NewVariableProxy(name, false, interface, position);
155  unresolved_.Add(proxy, zone_);
156  return proxy;
157  }
158 
159  // Remove a unresolved variable. During parsing, an unresolved variable
160  // may have been added optimistically, but then only the variable name
161  // was used (typically for labels). If the variable was not declared, the
162  // addition introduced a new unresolved variable which may end up being
163  // allocated globally as a "ghost" variable. RemoveUnresolved removes
164  // such a variable again if it was added; otherwise this is a no-op.
165  void RemoveUnresolved(VariableProxy* var);
166 
167  // Creates a new internal variable in this scope. The name is only used
168  // for printing and cannot be used to find the variable. In particular,
169  // the only way to get hold of the temporary is by keeping the Variable*
170  // around.
172 
173  // Creates a new temporary variable in this scope. The name is only used
174  // for printing and cannot be used to find the variable. In particular,
175  // the only way to get hold of the temporary is by keeping the Variable*
176  // around. The name should not clash with a legitimate variable names.
178 
179  // Adds the specific declaration node to the list of declarations in
180  // this scope. The declarations are processed as part of entering
181  // the scope; see codegen.cc:ProcessDeclarations.
182  void AddDeclaration(Declaration* declaration);
183 
184  // ---------------------------------------------------------------------------
185  // Illegal redeclaration support.
186 
187  // Set an expression node that will be executed when the scope is
188  // entered. We only keep track of one illegal redeclaration node per
189  // scope - the first one - so if you try to set it multiple times
190  // the additional requests will be silently ignored.
191  void SetIllegalRedeclaration(Expression* expression);
192 
193  // Visit the illegal redeclaration expression. Do not call if the
194  // scope doesn't have an illegal redeclaration node.
195  void VisitIllegalRedeclaration(AstVisitor* visitor);
196 
197  // Check if the scope has (at least) one illegal redeclaration.
198  bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }
199 
200  // For harmony block scoping mode: Check if the scope has conflicting var
201  // declarations, i.e. a var declaration that has been hoisted from a nested
202  // scope over a let binding of the same name.
204 
205  // ---------------------------------------------------------------------------
206  // Scope-specific info.
207 
208  // Inform the scope that the corresponding code contains a with statement.
210 
211  // Inform the scope that the corresponding code contains an eval call.
213 
214  // Set the strict mode flag (unless disabled by a global flag).
216 
217  // Set the ASM module flag.
218  void SetAsmModule() { asm_module_ = true; }
219 
220  // Position in the source where this scope begins and ends.
221  //
222  // * For the scope of a with statement
223  // with (obj) stmt
224  // start position: start position of first token of 'stmt'
225  // end position: end position of last token of 'stmt'
226  // * For the scope of a block
227  // { stmts }
228  // start position: start position of '{'
229  // end position: end position of '}'
230  // * For the scope of a function literal or decalaration
231  // function fun(a,b) { stmts }
232  // start position: start position of '('
233  // end position: end position of '}'
234  // * For the scope of a catch block
235  // try { stms } catch(e) { stmts }
236  // start position: start position of '('
237  // end position: end position of ')'
238  // * For the scope of a for-statement
239  // for (let x ...) stmt
240  // start position: start position of '('
241  // end position: end position of last token of 'stmt'
242  int start_position() const { return start_position_; }
243  void set_start_position(int statement_pos) {
244  start_position_ = statement_pos;
245  }
246  int end_position() const { return end_position_; }
247  void set_end_position(int statement_pos) {
248  end_position_ = statement_pos;
249  }
250 
251  // In some cases we want to force context allocation for a whole scope.
255  }
258  }
259 
260  // ---------------------------------------------------------------------------
261  // Predicates.
262 
263  // Specific scope types.
264  bool is_eval_scope() const { return scope_type_ == EVAL_SCOPE; }
265  bool is_function_scope() const { return scope_type_ == FUNCTION_SCOPE; }
266  bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; }
267  bool is_global_scope() const { return scope_type_ == GLOBAL_SCOPE; }
268  bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
269  bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
270  bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
271  bool is_declaration_scope() const {
272  return is_eval_scope() || is_function_scope() ||
274  }
275  bool is_strict_eval_scope() const {
276  return is_eval_scope() && strict_mode_ == STRICT;
277  }
278 
279  // Information about which scopes calls eval.
280  bool calls_eval() const { return scope_calls_eval_; }
283  }
286  }
287  bool asm_module() const { return asm_module_; }
288  bool asm_function() const { return asm_function_; }
289 
290  // Is this scope inside a with statement.
291  bool inside_with() const { return scope_inside_with_; }
292  // Does this scope contain a with statement.
293  bool contains_with() const { return scope_contains_with_; }
294 
295  // ---------------------------------------------------------------------------
296  // Accessors.
297 
298  // The type of this scope.
299  ScopeType scope_type() const { return scope_type_; }
300 
301  // The language mode of this scope.
302  StrictMode strict_mode() const { return strict_mode_; }
303 
304  // The variable corresponding the 'this' value.
305  Variable* receiver() { return receiver_; }
306 
307  // The variable holding the function literal for named function
308  // literals, or NULL. Only valid for function scopes.
309  VariableDeclaration* function() const {
311  return function_;
312  }
313 
314  // Parameters. The left-most parameter has index 0.
315  // Only valid for function scopes.
316  Variable* parameter(int index) const {
318  return params_[index];
319  }
320 
321  int num_parameters() const { return params_.length(); }
322 
323  // The local variable 'arguments' if we need to allocate it; NULL otherwise.
324  Variable* arguments() const { return arguments_; }
325 
326  // Declarations list.
328 
329  // Inner scope list.
331 
332  // The scope immediately surrounding this scope, or NULL.
333  Scope* outer_scope() const { return outer_scope_; }
334 
335  // The interface as inferred so far; only for module scopes.
336  Interface* interface() const { return interface_; }
337 
338  // ---------------------------------------------------------------------------
339  // Variable allocation.
340 
341  // Collect stack and context allocated local variables in this scope. Note
342  // that the function variable - if present - is not collected and should be
343  // handled separately.
345  ZoneList<Variable*>* context_locals);
346 
347  // Current number of var or const locals.
349 
350  // Result of variable allocation.
351  int num_stack_slots() const { return num_stack_slots_; }
352  int num_heap_slots() const { return num_heap_slots_; }
353 
354  int StackLocalCount() const;
355  int ContextLocalCount() const;
356 
357  // For global scopes, the number of module literals (including nested ones).
358  int num_modules() const { return num_modules_; }
359 
360  // For module scopes, the host scope's internal variable binding this module.
361  Variable* module_var() const { return module_var_; }
362 
363  // Make sure this scope and all outer scopes are eagerly compiled.
365 
366  // Determine if we can use lazy compilation for this scope.
367  bool AllowsLazyCompilation() const;
368 
369  // Determine if we can use lazy compilation for this scope without a context.
371 
372  // True if the outer context of this scope is always the native context.
373  bool HasTrivialOuterContext() const;
374 
375  // True if the outer context allows lazy compilation of this scope.
376  bool HasLazyCompilableOuterContext() const;
377 
378  // The number of contexts between this and scope; zero if this == scope.
379  int ContextChainLength(Scope* scope);
380 
381  // Find the innermost global scope.
382  Scope* GlobalScope();
383 
384  // Find the first function, global, or eval scope. This is the scope
385  // where var declarations will be hoisted to in the implementation.
387 
389 
390  // Get the chain of nested scopes within this scope for the source statement
391  // position. The scopes will be added to the list from the outermost scope to
392  // the innermost scope. Only nested block, catch or with scopes are tracked
393  // and will be returned, but no inner function scopes.
395  int statement_position);
396 
397  // ---------------------------------------------------------------------------
398  // Strict mode support.
399  bool IsDeclared(const AstRawString* name) {
400  // During formal parameter list parsing the scope only contains
401  // two variables inserted at initialization: "this" and "arguments".
402  // "this" is an invalid parameter name and "arguments" is invalid parameter
403  // name in strict mode. Therefore looking up with the map which includes
404  // "this" and "arguments" in addition to all formal parameters is safe.
405  return variables_.Lookup(name) != NULL;
406  }
407 
408  // ---------------------------------------------------------------------------
409  // Debugging.
410 
411 #ifdef DEBUG
412  void Print(int n = 0); // n = indentation; n < 0 => don't print recursively
413 #endif
414 
415  // ---------------------------------------------------------------------------
416  // Implementation.
417  protected:
418  friend class ParserFactory;
419 
421 
422  // Scope tree.
423  Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
424  ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
425 
426  // The scope type.
428 
429  // Debugging support.
431 
432  // The variables declared in this scope:
433  //
434  // All user-declared variables (incl. parameters). For global scopes
435  // variables may be implicitly 'declared' by being used (possibly in
436  // an inner scope) with no intervening with statements or eval calls.
438  // Compiler-allocated (user-invisible) internals.
440  // Compiler-allocated (user-invisible) temporaries.
442  // Parameter list in source order.
444  // Variables that must be looked up dynamically.
446  // Unresolved variables referred to from this scope.
448  // Declarations.
450  // Convenience variable.
452  // Function variable, if any; function scopes only.
453  VariableDeclaration* function_;
454  // Convenience variable; function scopes only.
456  // Interface; module scopes only.
458 
459  // Illegal redeclaration.
461 
462  // Scope-specific information computed during parsing.
463  //
464  // This scope is inside a 'with' of some outer scope.
466  // This scope contains a 'with' statement.
468  // This scope or a nested catch scope or with scope contain an 'eval' call. At
469  // the 'eval' call site this scope is the declaration scope.
471  // This scope contains an "use asm" annotation.
473  // This scope's outer context is an asm module.
475  // The strict mode of this scope.
477  // Source positions.
480 
481  // Computed via PropagateScopeInfo.
486 
487  // True if it doesn't need scope resolution (e.g., if the scope was
488  // constructed based on a serialized scope info or a catch context).
490 
491  // Computed as variables are declared.
493 
494  // Computed via AllocateVariables; function, block and catch scopes only.
497 
498  // The number of modules (including nested ones).
500 
501  // For module scopes, the host scope's internal variable binding this module.
503 
504  // Serialized scope info support.
507 
508  // Create a non-local variable with a given name.
509  // These variables are looked up dynamically at runtime.
511 
512  // Variable resolution.
513  // Possible results of a recursive variable lookup telling if and how a
514  // variable is bound. These are returned in the output parameter *binding_kind
515  // of the LookupRecursive function.
516  enum BindingKind {
517  // The variable reference could be statically resolved to a variable binding
518  // which is returned. There is no 'with' statement between the reference and
519  // the binding and no scope between the reference scope (inclusive) and
520  // binding scope (exclusive) makes a sloppy 'eval' call.
522 
523  // The variable reference could be statically resolved to a variable binding
524  // which is returned. There is no 'with' statement between the reference and
525  // the binding, but some scope between the reference scope (inclusive) and
526  // binding scope (exclusive) makes a sloppy 'eval' call, that might
527  // possibly introduce variable bindings shadowing the found one. Thus the
528  // found variable binding is just a guess.
530 
531  // The variable reference could not be statically resolved to any binding
532  // and thus should be considered referencing a global variable. NULL is
533  // returned. The variable reference is not inside any 'with' statement and
534  // no scope between the reference scope (inclusive) and global scope
535  // (exclusive) makes a sloppy 'eval' call.
537 
538  // The variable reference could not be statically resolved to any binding
539  // NULL is returned. The variable reference is not inside any 'with'
540  // statement, but some scope between the reference scope (inclusive) and
541  // global scope (exclusive) makes a sloppy 'eval' call, that might
542  // possibly introduce a variable binding. Thus the reference should be
543  // considered referencing a global variable unless it is shadowed by an
544  // 'eval' introduced binding.
546 
547  // The variable could not be statically resolved and needs to be looked up
548  // dynamically. NULL is returned. There are two possible reasons:
549  // * A 'with' statement has been encountered and there is no variable
550  // binding for the name between the variable reference and the 'with'.
551  // The variable potentially references a property of the 'with' object.
552  // * The code is being executed as part of a call to 'eval' and the calling
553  // context chain contains either a variable binding for the name or it
554  // contains a 'with' context.
556  };
557 
558  // Lookup a variable reference given by name recursively starting with this
559  // scope. If the code is executed because of a call to 'eval', the context
560  // parameter should be set to the calling context of 'eval'.
561  Variable* LookupRecursive(VariableProxy* proxy,
562  BindingKind* binding_kind,
565  bool ResolveVariable(CompilationInfo* info,
566  VariableProxy* proxy,
571 
572  // Scope analysis.
574  bool HasTrivialContext() const;
575 
576  // Predicates.
577  bool MustAllocate(Variable* var);
578  bool MustAllocateInContext(Variable* var);
579  bool HasArgumentsParameter();
580 
581  // Variable allocation.
582  void AllocateStackSlot(Variable* var);
583  void AllocateHeapSlot(Variable* var);
588  void AllocateModulesRecursively(Scope* host_scope);
589 
590  // Resolve and fill in the allocation information for all variables
591  // in this scopes. Must be called *after* all scopes have been
592  // processed (parsed) to ensure that unresolved variables can be
593  // resolved properly.
594  //
595  // In the case of code compiled and run using 'eval', the context
596  // parameter is the context in which eval was called. In all other
597  // cases the context parameter is an empty handle.
601 
602  private:
603  // Construct a scope based on the scope info.
604  Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info,
605  AstValueFactory* value_factory, Zone* zone);
606 
607  // Construct a catch scope with a binding for the name.
608  Scope(Scope* inner_scope,
609  const AstRawString* catch_variable_name,
610  AstValueFactory* value_factory, Zone* zone);
611 
612  void AddInnerScope(Scope* inner_scope) {
613  if (inner_scope != NULL) {
614  inner_scopes_.Add(inner_scope, zone_);
615  inner_scope->outer_scope_ = this;
616  }
617  }
618 
619  void SetDefaults(ScopeType type,
621  Handle<ScopeInfo> scope_info);
622 
625 };
626 
627 } } // namespace v8::internal
628 
629 #endif // V8_SCOPES_H_
DynamicScopePart(Zone *zone)
Definition: scopes.h:45
VariableMap * maps_[3]
Definition: scopes.h:57
VariableMap * GetMap(VariableMode mode)
Definition: scopes.h:50
static Interface * NewValue()
Definition: interface.h:44
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17
static const int kNoPosition
Definition: assembler.h:317
int ContextLocalCount() const
Definition: scopes.cc:1405
Variable * module_var() const
Definition: scopes.h:361
void SetDefaults(ScopeType type, Scope *outer_scope, Handle< ScopeInfo > scope_info)
Definition: scopes.cc:149
void SetStrictMode(StrictMode strict_mode)
Definition: scopes.h:215
void AllocateNonParameterLocal(Variable *var)
Definition: scopes.cc:1299
int num_heap_slots() const
Definition: scopes.h:352
void AllocateHeapSlot(Variable *var)
Definition: scopes.cc:1238
bool asm_function() const
Definition: scopes.h:288
bool outer_scope_calls_sloppy_eval_
Definition: scopes.h:482
StrictMode strict_mode_
Definition: scopes.h:476
void ForceContextAllocation()
Definition: scopes.h:252
ZoneList< Scope * > * inner_scopes()
Definition: scopes.h:330
bool contains_with() const
Definition: scopes.h:293
void set_end_position(int statement_pos)
Definition: scopes.h:247
bool is_global_scope() const
Definition: scopes.h:267
bool AllowsLazyCompilationWithoutContext() const
Definition: scopes.cc:710
Variable * LookupFunctionVar(const AstRawString *name, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:416
ZoneList< Variable * > temps_
Definition: scopes.h:441
MUST_USE_RESULT bool AllocateVariables(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:636
bool force_eager_compilation_
Definition: scopes.h:484
static bool Analyze(CompilationInfo *info)
Definition: scopes.cc:260
Variable * Lookup(const AstRawString *name)
Definition: scopes.cc:440
void DeclareFunctionVar(VariableDeclaration *declaration)
Definition: scopes.h:120
const AstRawString * scope_name_
Definition: scopes.h:430
ScopeType scope_type_
Definition: scopes.h:427
ZoneList< VariableProxy * > unresolved_
Definition: scopes.h:447
void AllocateParameterLocals()
Definition: scopes.cc:1243
Handle< ScopeInfo > scope_info_
Definition: scopes.h:505
Scope * outer_scope() const
Definition: scopes.h:333
int num_parameters() const
Definition: scopes.h:321
bool scope_calls_eval_
Definition: scopes.h:470
bool HasTrivialOuterContext() const
Definition: scopes.cc:677
Variable * DeclareDynamicGlobal(const AstRawString *name)
Definition: scopes.cc:476
Variable * module_var_
Definition: scopes.h:502
Variable * DeclareLocal(const AstRawString *name, VariableMode mode, InitializationFlag init_flag, MaybeAssignedFlag maybe_assigned_flag=kNotAssigned, Interface *interface=Interface::NewValue())
Definition: scopes.cc:461
void AllocateNonParameterLocals()
Definition: scopes.cc:1313
Variable * LookupRecursive(VariableProxy *proxy, BindingKind *binding_kind, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:963
bool HasLazyCompilableOuterContext() const
Definition: scopes.cc:687
int ContextChainLength(Scope *scope)
Definition: scopes.cc:715
Scope * outer_scope_
Definition: scopes.h:423
ZoneList< Scope * > inner_scopes_
Definition: scopes.h:424
bool HasTrivialContext() const
Definition: scopes.cc:663
bool calls_sloppy_eval()
Definition: scopes.h:281
void AllocateVariablesRecursively()
Definition: scopes.cc:1346
Variable * NewInternal(const AstRawString *name)
Definition: scopes.cc:499
VariableMap variables_
Definition: scopes.h:437
void AddInnerScope(Scope *inner_scope)
Definition: scopes.h:612
void ForceEagerCompilation()
Definition: scopes.h:364
bool scope_inside_with_
Definition: scopes.h:465
void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval)
Definition: scopes.cc:1156
bool calls_eval() const
Definition: scopes.h:280
ZoneList< Variable * > params_
Definition: scopes.h:443
bool HasIllegalRedeclaration() const
Definition: scopes.h:198
Variable * receiver()
Definition: scopes.h:305
VariableProxy * NewUnresolved(AstNodeFactory< Visitor > *factory, const AstRawString *name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
Definition: scopes.h:145
bool is_eval_scope() const
Definition: scopes.h:264
void SetIllegalRedeclaration(Expression *expression)
Definition: scopes.cc:530
void CollectStackAndContextLocals(ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
Definition: scopes.cc:584
bool is_function_scope() const
Definition: scopes.h:265
ZoneList< Declaration * > decls_
Definition: scopes.h:449
ScopeType scope_type() const
Definition: scopes.h:299
bool AllowsLazyCompilation() const
Definition: scopes.cc:705
void AllocateStackSlot(Variable *var)
Definition: scopes.cc:1233
bool asm_module() const
Definition: scopes.h:287
MUST_USE_RESULT bool ResolveVariable(CompilationInfo *info, VariableProxy *proxy, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1027
bool MustAllocateInContext(Variable *var)
Definition: scopes.cc:1200
ZoneList< Declaration * > * declarations()
Definition: scopes.h:327
bool outer_scope_calls_sloppy_eval() const
Definition: scopes.h:284
void VisitIllegalRedeclaration(AstVisitor *visitor)
Definition: scopes.cc:539
Isolate *const isolate_
Definition: scopes.h:420
bool HasArgumentsParameter()
Definition: scopes.cc:1222
bool already_resolved_
Definition: scopes.h:489
Variable * receiver_
Definition: scopes.h:451
void AllocateModulesRecursively(Scope *host_scope)
Definition: scopes.cc:1382
void RemoveUnresolved(VariableProxy *var)
Definition: scopes.cc:487
bool IsDeclared(const AstRawString *name)
Definition: scopes.h:399
Variable * NonLocal(const AstRawString *name, VariableMode mode)
Definition: scopes.cc:942
ZoneList< Variable * > internals_
Definition: scopes.h:439
bool inside_with() const
Definition: scopes.h:291
Scope * DeclarationScope()
Definition: scopes.cc:737
Variable * arguments() const
Definition: scopes.h:324
Expression * illegal_redecl_
Definition: scopes.h:460
Variable * NewTemporary(const AstRawString *name)
Definition: scopes.cc:512
Zone * zone() const
Definition: scopes.h:98
DynamicScopePart * dynamics_
Definition: scopes.h:445
bool inner_scope_calls_eval_
Definition: scopes.h:483
bool is_with_scope() const
Definition: scopes.h:270
void set_start_position(int statement_pos)
Definition: scopes.h:243
int num_modules() const
Definition: scopes.h:358
void RecordEvalCall()
Definition: scopes.h:212
bool scope_contains_with_
Definition: scopes.h:467
AstValueFactory * ast_value_factory_
Definition: scopes.h:623
Scope * GlobalScope()
Definition: scopes.cc:728
Scope(Scope *outer_scope, ScopeType scope_type, AstValueFactory *value_factory, Zone *zone)
Definition: scopes.cc:70
bool is_block_scope() const
Definition: scopes.h:269
Scope * FinalizeBlockScope()
Definition: scopes.cc:345
int num_stack_slots() const
Definition: scopes.h:351
StrictMode strict_mode() const
Definition: scopes.h:302
friend class ParserFactory
Definition: scopes.h:418
Declaration * CheckConflictingVarDeclarations()
Definition: scopes.cc:545
int end_position() const
Definition: scopes.h:246
bool has_forced_context_allocation() const
Definition: scopes.h:256
bool MustAllocate(Variable *var)
Definition: scopes.cc:1179
Variable * DeclareParameter(const AstRawString *name, VariableMode mode)
Definition: scopes.cc:451
VariableDeclaration * function_
Definition: scopes.h:453
Interface * interface() const
Definition: scopes.h:336
void RecordWithStatement()
Definition: scopes.h:209
Variable * parameter(int index) const
Definition: scopes.h:316
bool already_resolved()
Definition: scopes.h:506
bool force_context_allocation_
Definition: scopes.h:485
void SetAsmModule()
Definition: scopes.h:218
Handle< ScopeInfo > GetScopeInfo()
Definition: scopes.cc:746
int num_var_or_const()
Definition: scopes.h:348
void AddDeclaration(Declaration *declaration)
Definition: scopes.cc:525
void SetScopeName(const AstRawString *scope_name)
Definition: scopes.h:87
static Scope * DeserializeScopeChain(Context *context, Scope *global_scope, Zone *zone)
Definition: scopes.cc:187
Variable * arguments_
Definition: scopes.h:455
Interface * interface_
Definition: scopes.h:457
bool is_catch_scope() const
Definition: scopes.h:268
int start_position() const
Definition: scopes.h:242
bool is_module_scope() const
Definition: scopes.h:266
void GetNestedScopeChain(List< Handle< ScopeInfo > > *chain, int statement_position)
Definition: scopes.cc:754
MUST_USE_RESULT bool ResolveVariablesRecursively(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1136
int StackLocalCount() const
Definition: scopes.cc:1399
bool is_declaration_scope() const
Definition: scopes.h:271
Variable * LookupLocal(const AstRawString *name)
Definition: scopes.cc:375
bool is_strict_eval_scope() const
Definition: scopes.h:275
Variable * Declare(Scope *scope, const AstRawString *name, VariableMode mode, bool is_valid_lhs, Variable::Kind kind, InitializationFlag initialization_flag, MaybeAssignedFlag maybe_assigned_flag=kNotAssigned, Interface *interface=Interface::NewValue())
Definition: scopes.cc:33
Zone * zone() const
Definition: scopes.h:32
Variable * Lookup(const AstRawString *name)
Definition: scopes.cc:55
virtual ~VariableMap()
Definition: scopes.cc:30
VariableMap(Zone *zone)
Definition: scopes.cc:27
void * New(int size)
Definition: zone.cc:65
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205
#define MUST_USE_RESULT
Definition: macros.h:266
InitializationFlag
Definition: globals.h:751
@ kNotAssigned
Definition: globals.h:757
@ FUNCTION_SCOPE
Definition: globals.h:647
@ MODULE_SCOPE
Definition: globals.h:648
@ GLOBAL_SCOPE
Definition: globals.h:649
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20