v8  3.14.5(node0.10.28)
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,
48  Handle<String> name,
49  VariableMode mode,
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.
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.
155  VariableMode mode,
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>
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 temporary 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. The name should not clash with a legitimate variable names.
194 
195  // Adds the specific declaration node to the list of declarations in
196  // this scope. The declarations are processed as part of entering
197  // the scope; see codegen.cc:ProcessDeclarations.
198  void AddDeclaration(Declaration* declaration);
199 
200  // ---------------------------------------------------------------------------
201  // Illegal redeclaration support.
202 
203  // Set an expression node that will be executed when the scope is
204  // entered. We only keep track of one illegal redeclaration node per
205  // scope - the first one - so if you try to set it multiple times
206  // the additional requests will be silently ignored.
207  void SetIllegalRedeclaration(Expression* expression);
208 
209  // Visit the illegal redeclaration expression. Do not call if the
210  // scope doesn't have an illegal redeclaration node.
211  void VisitIllegalRedeclaration(AstVisitor* visitor);
212 
213  // Check if the scope has (at least) one illegal redeclaration.
214  bool HasIllegalRedeclaration() const { return illegal_redecl_ != NULL; }
215 
216  // For harmony block scoping mode: Check if the scope has conflicting var
217  // declarations, i.e. a var declaration that has been hoisted from a nested
218  // scope over a let binding of the same name.
220 
221  // For harmony block scoping mode: Check if the scope has variable proxies
222  // that are used as lvalues and point to const variables. Assumes that scopes
223  // have been analyzed and variables been resolved.
225 
226  // ---------------------------------------------------------------------------
227  // Scope-specific info.
228 
229  // Inform the scope that the corresponding code contains a with statement.
231 
232  // Inform the scope that the corresponding code contains an eval call.
234 
235  // Set the strict mode flag (unless disabled by a global flag).
238  }
239 
240  // Position in the source where this scope begins and ends.
241  //
242  // * For the scope of a with statement
243  // with (obj) stmt
244  // start position: start position of first token of 'stmt'
245  // end position: end position of last token of 'stmt'
246  // * For the scope of a block
247  // { stmts }
248  // start position: start position of '{'
249  // end position: end position of '}'
250  // * For the scope of a function literal or decalaration
251  // function fun(a,b) { stmts }
252  // start position: start position of '('
253  // end position: end position of '}'
254  // * For the scope of a catch block
255  // try { stms } catch(e) { stmts }
256  // start position: start position of '('
257  // end position: end position of ')'
258  // * For the scope of a for-statement
259  // for (let x ...) stmt
260  // start position: start position of '('
261  // end position: end position of last token of 'stmt'
262  int start_position() const { return start_position_; }
263  void set_start_position(int statement_pos) {
264  start_position_ = statement_pos;
265  }
266  int end_position() const { return end_position_; }
267  void set_end_position(int statement_pos) {
268  end_position_ = statement_pos;
269  }
270 
271  // ---------------------------------------------------------------------------
272  // Predicates.
273 
274  // Specific scope types.
275  bool is_eval_scope() const { return type_ == EVAL_SCOPE; }
276  bool is_function_scope() const { return type_ == FUNCTION_SCOPE; }
277  bool is_module_scope() const { return type_ == MODULE_SCOPE; }
278  bool is_global_scope() const { return type_ == GLOBAL_SCOPE; }
279  bool is_catch_scope() const { return type_ == CATCH_SCOPE; }
280  bool is_block_scope() const { return type_ == BLOCK_SCOPE; }
281  bool is_with_scope() const { return type_ == WITH_SCOPE; }
282  bool is_declaration_scope() const {
283  return is_eval_scope() || is_function_scope() ||
285  }
286  bool is_classic_mode() const {
287  return language_mode() == CLASSIC_MODE;
288  }
289  bool is_extended_mode() const {
290  return language_mode() == EXTENDED_MODE;
291  }
293  return is_eval_scope() && !is_classic_mode();
294  }
295 
296  // Information about which scopes calls eval.
297  bool calls_eval() const { return scope_calls_eval_; }
300  }
303  }
304 
305  // Is this scope inside a with statement.
306  bool inside_with() const { return scope_inside_with_; }
307  // Does this scope contain a with statement.
308  bool contains_with() const { return scope_contains_with_; }
309 
310  // ---------------------------------------------------------------------------
311  // Accessors.
312 
313  // The type of this scope.
314  ScopeType type() const { return type_; }
315 
316  // The language mode of this scope.
318 
319  // The variable corresponding the 'this' value.
320  Variable* receiver() { return receiver_; }
321 
322  // The variable holding the function literal for named function
323  // literals, or NULL. Only valid for function scopes.
324  VariableDeclaration* function() const {
326  return function_;
327  }
328 
329  // Parameters. The left-most parameter has index 0.
330  // Only valid for function scopes.
331  Variable* parameter(int index) const {
333  return params_[index];
334  }
335 
336  int num_parameters() const { return params_.length(); }
337 
338  // The local variable 'arguments' if we need to allocate it; NULL otherwise.
339  Variable* arguments() const { return arguments_; }
340 
341  // Declarations list.
343 
344  // Inner scope list.
346 
347  // The scope immediately surrounding this scope, or NULL.
348  Scope* outer_scope() const { return outer_scope_; }
349 
350  // The interface as inferred so far; only for module scopes.
351  Interface* interface() const { return interface_; }
352 
353  // ---------------------------------------------------------------------------
354  // Variable allocation.
355 
356  // Collect stack and context allocated local variables in this scope. Note
357  // that the function variable - if present - is not collected and should be
358  // handled separately.
360  ZoneList<Variable*>* context_locals);
361 
362  // Current number of var or const locals.
364 
365  // Result of variable allocation.
366  int num_stack_slots() const { return num_stack_slots_; }
367  int num_heap_slots() const { return num_heap_slots_; }
368 
369  int StackLocalCount() const;
370  int ContextLocalCount() const;
371 
372  // Make sure this scope and all outer scopes are eagerly compiled.
374 
375  // Determine if we can use lazy compilation for this scope.
376  bool AllowsLazyCompilation() const;
377 
378  // Determine if we can use lazy compilation for this scope without a context.
380 
381  // True if the outer context of this scope is always the native context.
382  bool HasTrivialOuterContext() const;
383 
384  // True if the outer context allows lazy compilation of this scope.
385  bool HasLazyCompilableOuterContext() const;
386 
387  // The number of contexts between this and scope; zero if this == scope.
388  int ContextChainLength(Scope* scope);
389 
390  // Find the first function, global, or eval scope. This is the scope
391  // where var declarations will be hoisted to in the implementation.
393 
395 
396  // Get the chain of nested scopes within this scope for the source statement
397  // position. The scopes will be added to the list from the outermost scope to
398  // the innermost scope. Only nested block, catch or with scopes are tracked
399  // and will be returned, but no inner function scopes.
401  int statement_position);
402 
403  // ---------------------------------------------------------------------------
404  // Strict mode support.
406  // During formal parameter list parsing the scope only contains
407  // two variables inserted at initialization: "this" and "arguments".
408  // "this" is an invalid parameter name and "arguments" is invalid parameter
409  // name in strict mode. Therefore looking up with the map which includes
410  // "this" and "arguments" in addition to all formal parameters is safe.
411  return variables_.Lookup(name) != NULL;
412  }
413 
414  // ---------------------------------------------------------------------------
415  // Debugging.
416 
417 #ifdef DEBUG
418  void Print(int n = 0); // n = indentation; n < 0 => don't print recursively
419 #endif
420 
421  // ---------------------------------------------------------------------------
422  // Implementation.
423  protected:
424  friend class ParserFactory;
425 
427 
428  // Scope tree.
429  Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
430  ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
431 
432  // The scope type.
434 
435  // Debugging support.
437 
438  // The variables declared in this scope:
439  //
440  // All user-declared variables (incl. parameters). For global scopes
441  // variables may be implicitly 'declared' by being used (possibly in
442  // an inner scope) with no intervening with statements or eval calls.
444  // Compiler-allocated (user-invisible) temporaries.
446  // Parameter list in source order.
448  // Variables that must be looked up dynamically.
450  // Unresolved variables referred to from this scope.
452  // Declarations.
454  // Convenience variable.
456  // Function variable, if any; function scopes only.
458  // Convenience variable; function scopes only.
460  // Interface; module scopes only.
462 
463  // Illegal redeclaration.
465 
466  // Scope-specific information computed during parsing.
467  //
468  // This scope is inside a 'with' of some outer scope.
470  // This scope contains a 'with' statement.
472  // This scope or a nested catch scope or with scope contain an 'eval' call. At
473  // the 'eval' call site this scope is the declaration scope.
475  // The language mode of this scope.
477  // Source positions.
480 
481  // Computed via PropagateScopeInfo.
485 
486  // True if it doesn't need scope resolution (e.g., if the scope was
487  // constructed based on a serialized scope info or a catch context).
489 
490  // Computed as variables are declared.
492 
493  // Computed via AllocateVariables; function, block and catch scopes only.
496 
497  // Serialized scope info support.
500 
501  // Create a non-local variable with a given name.
502  // These variables are looked up dynamically at runtime.
504 
505  // Variable resolution.
506  // Possible results of a recursive variable lookup telling if and how a
507  // variable is bound. These are returned in the output parameter *binding_kind
508  // of the LookupRecursive function.
509  enum BindingKind {
510  // The variable reference could be statically resolved to a variable binding
511  // which is returned. There is no 'with' statement between the reference and
512  // the binding and no scope between the reference scope (inclusive) and
513  // binding scope (exclusive) makes a non-strict 'eval' call.
515 
516  // The variable reference could be statically resolved to a variable binding
517  // which is returned. There is no 'with' statement between the reference and
518  // the binding, but some scope between the reference scope (inclusive) and
519  // binding scope (exclusive) makes a non-strict 'eval' call, that might
520  // possibly introduce variable bindings shadowing the found one. Thus the
521  // found variable binding is just a guess.
523 
524  // The variable reference could not be statically resolved to any binding
525  // and thus should be considered referencing a global variable. NULL is
526  // returned. The variable reference is not inside any 'with' statement and
527  // no scope between the reference scope (inclusive) and global scope
528  // (exclusive) makes a non-strict 'eval' call.
530 
531  // The variable reference could not be statically resolved to any binding
532  // NULL is returned. The variable reference is not inside any 'with'
533  // statement, but some scope between the reference scope (inclusive) and
534  // global scope (exclusive) makes a non-strict 'eval' call, that might
535  // possibly introduce a variable binding. Thus the reference should be
536  // considered referencing a global variable unless it is shadowed by an
537  // 'eval' introduced binding.
539 
540  // The variable could not be statically resolved and needs to be looked up
541  // dynamically. NULL is returned. There are two possible reasons:
542  // * A 'with' statement has been encountered and there is no variable
543  // binding for the name between the variable reference and the 'with'.
544  // The variable potentially references a property of the 'with' object.
545  // * The code is being executed as part of a call to 'eval' and the calling
546  // context chain contains either a variable binding for the name or it
547  // contains a 'with' context.
549  };
550 
551  // Lookup a variable reference given by name recursively starting with this
552  // scope. If the code is executed because of a call to 'eval', the context
553  // parameter should be set to the calling context of 'eval'.
555  BindingKind* binding_kind,
558  bool ResolveVariable(CompilationInfo* info,
559  VariableProxy* proxy,
564 
565  // Scope analysis.
567  bool HasTrivialContext() const;
568 
569  // Predicates.
570  bool MustAllocate(Variable* var);
571  bool MustAllocateInContext(Variable* var);
572  bool HasArgumentsParameter();
573 
574  // Variable allocation.
575  void AllocateStackSlot(Variable* var);
576  void AllocateHeapSlot(Variable* var);
581 
582  // Resolve and fill in the allocation information for all variables
583  // in this scopes. Must be called *after* all scopes have been
584  // processed (parsed) to ensure that unresolved variables can be
585  // resolved properly.
586  //
587  // In the case of code compiled and run using 'eval', the context
588  // parameter is the context in which eval was called. In all other
589  // cases the context parameter is an empty handle.
593 
594  // Instance objects have to be created ahead of time (before code generation)
595  // because of potentially cyclic references between them.
596  // Linking also has to be a separate stage, since populating one object may
597  // potentially require (forward) references to others.
598  void AllocateModules(CompilationInfo* info);
599  void LinkModules(CompilationInfo* info);
600 
601  private:
602  // Construct a scope based on the scope info.
603  Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info,
604  Zone* zone);
605 
606  // Construct a catch scope with a binding for the name.
607  Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone);
608 
609  void AddInnerScope(Scope* inner_scope) {
610  if (inner_scope != NULL) {
611  inner_scopes_.Add(inner_scope, zone_);
612  inner_scope->outer_scope_ = this;
613  }
614  }
615 
616  void SetDefaults(ScopeType type,
617  Scope* outer_scope,
618  Handle<ScopeInfo> scope_info);
619 
620  Zone* zone_;
621 };
622 
623 } } // namespace v8::internal
624 
625 #endif // V8_SCOPES_H_
bool is_global_scope() const
Definition: scopes.h:278
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT interface(disables compacting GC)") DEFINE_bool(gdbjit_full
Scope * DeclarationScope()
Definition: scopes.cc:745
bool scope_contains_with_
Definition: scopes.h:471
Declaration * CheckConflictingVarDeclarations()
Definition: scopes.cc:551
bool scope_calls_eval_
Definition: scopes.h:474
virtual ~VariableMap()
Definition: scopes.cc:64
bool calls_eval() const
Definition: scopes.h:297
Handle< ScopeInfo > GetScopeInfo()
Definition: scopes.cc:754
ZoneList< Scope * > inner_scopes_
Definition: scopes.h:430
Variable * receiver()
Definition: scopes.h:320
bool already_resolved()
Definition: scopes.h:499
bool force_eager_compilation_
Definition: scopes.h:484
void CollectStackAndContextLocals(ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
Definition: scopes.cc:613
bool outer_scope_calls_non_strict_eval() const
Definition: scopes.h:301
Scope * FinalizeBlockScope()
Definition: scopes.cc:376
Variable * arguments_
Definition: scopes.h:459
static bool Analyze(CompilationInfo *info)
Definition: scopes.cc:274
Scope * outer_scope() const
Definition: scopes.h:348
ScopeType type_
Definition: scopes.h:433
bool HasIllegalRedeclaration() const
Definition: scopes.h:214
ZoneList< VariableProxy * > unresolved_
Definition: scopes.h:451
Expression * illegal_redecl_
Definition: scopes.h:464
bool already_resolved_
Definition: scopes.h:488
bool is_classic_mode() const
Definition: scopes.h:286
VariableProxy * NewUnresolved(AstNodeFactory< Visitor > *factory, Handle< String > name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
Definition: scopes.h:167
Handle< String > scope_name_
Definition: scopes.h:436
Zone * zone() const
Definition: scopes.h:57
void DeclareParameter(Handle< String > name, VariableMode mode)
Definition: scopes.cc:471
VariableProxy * CheckAssignmentToConst()
Definition: scopes.cc:575
bool HasTrivialContext() const
Definition: scopes.cc:678
#define ASSERT(condition)
Definition: checks.h:270
v8::Handle< v8::Value > Print(const v8::Arguments &args)
Variable * NewTemporary(Handle< String > name)
Definition: scopes.cc:518
void ForceEagerCompilation()
Definition: scopes.h:373
VariableMap * GetMap(VariableMode mode)
Definition: scopes.h:75
VariableDeclaration * function_
Definition: scopes.h:457
Variable * LookupRecursive(Handle< String > name, BindingKind *binding_kind, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:962
void set_end_position(int statement_pos)
Definition: scopes.h:267
LanguageMode language_mode_
Definition: scopes.h:476
Variable * parameter(int index) const
Definition: scopes.h:331
bool outer_scope_calls_non_strict_eval_
Definition: scopes.h:482
bool is_block_scope() const
Definition: scopes.h:280
bool MustAllocateInContext(Variable *var)
Definition: scopes.cc:1169
ZoneList< Declaration * > decls_
Definition: scopes.h:453
bool is_strict_or_extended_eval_scope() const
Definition: scopes.h:292
Handle< ScopeInfo > scope_info_
Definition: scopes.h:498
int ContextChainLength(Scope *scope)
Definition: scopes.cc:735
bool HasTrivialOuterContext() const
Definition: scopes.cc:692
bool AllowsLazyCompilation() const
Definition: scopes.cc:725
void DeclareFunctionVar(VariableDeclaration *declaration)
Definition: scopes.h:142
void AllocateNonParameterLocal(Variable *var)
Definition: scopes.cc:1264
static Interface * NewValue()
Definition: interface.h:66
void AllocateModules(CompilationInfo *info)
Definition: scopes.cc:1358
int start_position() const
Definition: scopes.h:262
Variable * DeclareLocal(Handle< String > name, VariableMode mode, InitializationFlag init_flag, Interface *interface=Interface::NewValue())
Definition: scopes.cc:480
void AllocateVariablesRecursively()
Definition: scopes.cc:1309
#define MUST_USE_RESULT
Definition: globals.h:346
bool is_eval_scope() const
Definition: scopes.h:275
bool HasArgumentsParameter()
Definition: scopes.cc:1187
Variable * arguments() const
Definition: scopes.h:339
int num_stack_slots() const
Definition: scopes.h:366
Isolate *const isolate_
Definition: scopes.h:426
void GetNestedScopeChain(List< Handle< ScopeInfo > > *chain, int statement_position)
Definition: scopes.cc:762
void AllocateHeapSlot(Variable *var)
Definition: scopes.cc:1203
ScopeType type() const
Definition: scopes.h:314
void set_start_position(int statement_pos)
Definition: scopes.h:263
void SetScopeName(Handle< String > scope_name)
Definition: scopes.h:111
ZoneList< Scope * > * inner_scopes()
Definition: scopes.h:345
bool PropagateScopeInfo(bool outer_scope_calls_non_strict_eval)
Definition: scopes.cc:1128
bool calls_non_strict_eval()
Definition: scopes.h:298
bool is_declaration_scope() const
Definition: scopes.h:282
bool HasLazyCompilableOuterContext() const
Definition: scopes.cc:702
bool inner_scope_calls_eval_
Definition: scopes.h:483
Interface * interface_
Definition: scopes.h:461
void AllocateStackSlot(Variable *var)
Definition: scopes.cc:1198
Variable * receiver_
Definition: scopes.h:455
int num_parameters() const
Definition: scopes.h:336
bool MustAllocate(Variable *var)
Definition: scopes.cc:1149
Variable * LocalLookup(Handle< String > name)
Definition: scopes.cc:405
int end_position() const
Definition: scopes.h:266
bool IsDeclared(Handle< String > name)
Definition: scopes.h:405
ZoneList< Variable * > params_
Definition: scopes.h:447
Interface * interface() const
Definition: scopes.h:351
void AllocateParameterLocals()
Definition: scopes.cc:1208
int StackLocalCount() const
Definition: scopes.cc:1345
VariableMap variables_
Definition: scopes.h:443
void AddDeclaration(Declaration *declaration)
Definition: scopes.cc:531
void SetLanguageMode(LanguageMode language_mode)
Definition: scopes.h:236
int num_heap_slots() const
Definition: scopes.h:367
void VisitIllegalRedeclaration(AstVisitor *visitor)
Definition: scopes.cc:545
bool is_with_scope() const
Definition: scopes.h:281
void AllocateNonParameterLocals()
Definition: scopes.cc:1278
ZoneList< Variable * > temps_
Definition: scopes.h:445
int num_var_or_const()
Definition: scopes.h:363
bool contains_with() const
Definition: scopes.h:308
bool AllowsLazyCompilationWithoutContext() const
Definition: scopes.cc:730
Zone * zone() const
Definition: scopes.h:120
void LinkModules(CompilationInfo *info)
Definition: scopes.cc:1388
Variable * DeclareDynamicGlobal(Handle< String > name)
Definition: scopes.cc:495
int ContextLocalCount() const
Definition: scopes.cc:1351
Variable * Lookup(Handle< String > name)
Definition: scopes.cc:92
bool inside_with() const
Definition: scopes.h:306
MUST_USE_RESULT bool AllocateVariables(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:651
friend class ParserFactory
Definition: scopes.h:424
Variable * NonLocal(Handle< String > name, VariableMode mode)
Definition: scopes.cc:941
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
Definition: flags.cc:301
MUST_USE_RESULT bool ResolveVariable(CompilationInfo *info, VariableProxy *proxy, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1017
LanguageMode language_mode() const
Definition: scopes.h:317
void RecordEvalCall()
Definition: scopes.h:233
DynamicScopePart * dynamics_
Definition: scopes.h:449
DynamicScopePart(Zone *zone)
Definition: scopes.h:70
bool is_function_scope() const
Definition: scopes.h:276
Variable * Lookup(Handle< String > name)
Definition: scopes.cc:460
VariableMap(Zone *zone)
Definition: scopes.cc:61
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:67
void * New(int size)
Definition: zone-inl.h:42
void RecordWithStatement()
Definition: scopes.h:230
bool is_module_scope() const
Definition: scopes.h:277
bool is_catch_scope() const
Definition: scopes.h:279
bool is_extended_mode() const
Definition: scopes.h:289
static Scope * DeserializeScopeChain(Context *context, Scope *global_scope, Zone *zone)
Definition: scopes.cc:210
Scope(Scope *outer_scope, ScopeType type, Zone *zone)
Definition: scopes.cc:107
Scope * outer_scope_
Definition: scopes.h:429
void RemoveUnresolved(VariableProxy *var)
Definition: scopes.cc:506
ZoneList< Declaration * > * declarations()
Definition: scopes.h:342
Variable * LookupFunctionVar(Handle< String > name, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:436
bool scope_inside_with_
Definition: scopes.h:469
MUST_USE_RESULT bool ResolveVariablesRecursively(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1108
void SetIllegalRedeclaration(Expression *expression)
Definition: scopes.cc:536