v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scopes.cc
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 #include "v8.h"
29 
30 #include "scopes.h"
31 
32 #include "bootstrapper.h"
33 #include "compiler.h"
34 #include "messages.h"
35 #include "scopeinfo.h"
36 
37 #include "allocation-inl.h"
38 
39 namespace v8 {
40 namespace internal {
41 
42 // ----------------------------------------------------------------------------
43 // Implementation of LocalsMap
44 //
45 // Note: We are storing the handle locations as key values in the hash map.
46 // When inserting a new variable via Declare(), we rely on the fact that
47 // the handle location remains alive for the duration of that variable
48 // use. Because a Variable holding a handle with the same location exists
49 // this is ensured.
50 
51 static bool Match(void* key1, void* key2) {
52  String* name1 = *reinterpret_cast<String**>(key1);
53  String* name2 = *reinterpret_cast<String**>(key2);
54  ASSERT(name1->IsSymbol());
55  ASSERT(name2->IsSymbol());
56  return name1 == name2;
57 }
58 
59 
61  : ZoneHashMap(Match, 8, ZoneAllocationPolicy(zone)),
62  zone_(zone) {}
64 
65 
67  Scope* scope,
69  VariableMode mode,
70  bool is_valid_lhs,
71  Variable::Kind kind,
72  InitializationFlag initialization_flag,
73  Interface* interface) {
74  Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), true,
76  if (p->value == NULL) {
77  // The variable has not been declared yet -> insert it.
78  ASSERT(p->key == name.location());
79  p->value = new(zone()) Variable(scope,
80  name,
81  mode,
82  is_valid_lhs,
83  kind,
84  initialization_flag,
85  interface);
86  }
87  return reinterpret_cast<Variable*>(p->value);
88 }
89 
90 
92  Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), false,
94  if (p != NULL) {
95  ASSERT(*reinterpret_cast<String**>(p->key) == *name);
96  ASSERT(p->value != NULL);
97  return reinterpret_cast<Variable*>(p->value);
98  }
99  return NULL;
100 }
101 
102 
103 // ----------------------------------------------------------------------------
104 // Implementation of Scope
105 
106 Scope::Scope(Scope* outer_scope, ScopeType type, Zone* zone)
107  : isolate_(Isolate::Current()),
108  inner_scopes_(4, zone),
109  variables_(zone),
110  temps_(4, zone),
111  params_(4, zone),
112  unresolved_(16, zone),
113  decls_(4, zone),
114  interface_(FLAG_harmony_modules &&
115  (type == MODULE_SCOPE || type == GLOBAL_SCOPE)
116  ? Interface::NewModule(zone) : NULL),
117  already_resolved_(false),
118  zone_(zone) {
119  SetDefaults(type, outer_scope, Handle<ScopeInfo>::null());
120  // At some point we might want to provide outer scopes to
121  // eval scopes (by walking the stack and reading the scope info).
122  // In that case, the ASSERT below needs to be adjusted.
123  ASSERT_EQ(type == GLOBAL_SCOPE, outer_scope == NULL);
125 }
126 
127 
128 Scope::Scope(Scope* inner_scope,
129  ScopeType type,
130  Handle<ScopeInfo> scope_info,
131  Zone* zone)
132  : isolate_(Isolate::Current()),
133  inner_scopes_(4, zone),
134  variables_(zone),
135  temps_(4, zone),
136  params_(4, zone),
137  unresolved_(16, zone),
138  decls_(4, zone),
139  interface_(NULL),
140  already_resolved_(true),
141  zone_(zone) {
142  SetDefaults(type, NULL, scope_info);
143  if (!scope_info.is_null()) {
144  num_heap_slots_ = scope_info_->ContextLength();
145  }
146  // Ensure at least MIN_CONTEXT_SLOTS to indicate a materialized context.
148  static_cast<int>(Context::MIN_CONTEXT_SLOTS));
149  AddInnerScope(inner_scope);
150 }
151 
152 
153 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone)
154  : isolate_(Isolate::Current()),
155  inner_scopes_(1, zone),
156  variables_(zone),
157  temps_(0, zone),
158  params_(0, zone),
159  unresolved_(0, zone),
160  decls_(0, zone),
161  interface_(NULL),
162  already_resolved_(true),
163  zone_(zone) {
164  SetDefaults(CATCH_SCOPE, NULL, Handle<ScopeInfo>::null());
165  AddInnerScope(inner_scope);
168  Variable* variable = variables_.Declare(this,
169  catch_variable_name,
170  VAR,
171  true, // Valid left-hand side.
174  AllocateHeapSlot(variable);
175 }
176 
177 
178 void Scope::SetDefaults(ScopeType type,
179  Scope* outer_scope,
180  Handle<ScopeInfo> scope_info) {
182  type_ = type;
183  scope_name_ = isolate_->factory()->empty_symbol();
184  dynamics_ = NULL;
185  receiver_ = NULL;
186  function_ = NULL;
187  arguments_ = NULL;
189  scope_inside_with_ = false;
190  scope_contains_with_ = false;
191  scope_calls_eval_ = false;
192  // Inherit the strict mode from the parent scope.
193  language_mode_ = (outer_scope != NULL)
194  ? outer_scope->language_mode_ : CLASSIC_MODE;
196  inner_scope_calls_eval_ = false;
197  force_eager_compilation_ = false;
198  num_var_or_const_ = 0;
199  num_stack_slots_ = 0;
200  num_heap_slots_ = 0;
201  scope_info_ = scope_info;
202  start_position_ = RelocInfo::kNoPosition;
203  end_position_ = RelocInfo::kNoPosition;
204  if (!scope_info.is_null()) {
205  scope_calls_eval_ = scope_info->CallsEval();
206  language_mode_ = scope_info->language_mode();
207  }
208 }
209 
210 
212  Zone* zone) {
213  // Reconstruct the outer scope chain from a closure's context chain.
214  Scope* current_scope = NULL;
215  Scope* innermost_scope = NULL;
216  bool contains_with = false;
217  while (!context->IsGlobalContext()) {
218  if (context->IsWithContext()) {
219  Scope* with_scope = new(zone) Scope(current_scope,
220  WITH_SCOPE,
222  zone);
223  current_scope = with_scope;
224  // All the inner scopes are inside a with.
225  contains_with = true;
226  for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
227  s->scope_inside_with_ = true;
228  }
229  } else if (context->IsFunctionContext()) {
230  ScopeInfo* scope_info = context->closure()->shared()->scope_info();
231  current_scope = new(zone) Scope(current_scope,
233  Handle<ScopeInfo>(scope_info),
234  zone);
235  } else if (context->IsBlockContext()) {
236  ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
237  current_scope = new(zone) Scope(current_scope,
238  BLOCK_SCOPE,
239  Handle<ScopeInfo>(scope_info),
240  zone);
241  } else {
242  ASSERT(context->IsCatchContext());
243  String* name = String::cast(context->extension());
244  current_scope = new(zone) Scope(
245  current_scope, Handle<String>(name), zone);
246  }
247  if (contains_with) current_scope->RecordWithStatement();
248  if (innermost_scope == NULL) innermost_scope = current_scope;
249 
250  // Forget about a with when we move to a context for a different function.
251  if (context->previous()->closure() != context->closure()) {
252  contains_with = false;
253  }
254  context = context->previous();
255  }
256 
257  global_scope->AddInnerScope(current_scope);
258  global_scope->PropagateScopeInfo(false);
259  return (innermost_scope == NULL) ? global_scope : innermost_scope;
260 }
261 
262 
263 bool Scope::Analyze(CompilationInfo* info) {
264  ASSERT(info->function() != NULL);
265  Scope* scope = info->function()->scope();
266  Scope* top = scope;
267 
268  // Traverse the scope tree up to the first unresolved scope or the global
269  // scope and start scope resolution and variable allocation from that scope.
270  while (!top->is_global_scope() &&
271  !top->outer_scope()->already_resolved()) {
272  top = top->outer_scope();
273  }
274 
275  // Allocate the variables.
276  {
277  AstNodeFactory<AstNullVisitor> ast_node_factory(info->isolate());
278  if (!top->AllocateVariables(info, &ast_node_factory)) return false;
279  }
280 
281 #ifdef DEBUG
282  if (info->isolate()->bootstrapper()->IsActive()
283  ? FLAG_print_builtin_scopes
284  : FLAG_print_scopes) {
285  scope->Print();
286  }
287 
288  if (FLAG_harmony_modules && FLAG_print_interfaces && top->is_global_scope()) {
289  PrintF("global : ");
290  top->interface()->Print();
291  }
292 #endif
293 
294  if (FLAG_harmony_scoping) {
295  VariableProxy* proxy = scope->CheckAssignmentToConst();
296  if (proxy != NULL) {
297  // Found an assignment to const. Throw a syntax error.
298  MessageLocation location(info->script(),
299  proxy->position(),
300  proxy->position());
301  Isolate* isolate = info->isolate();
302  Factory* factory = isolate->factory();
303  Handle<JSArray> array = factory->NewJSArray(0);
304  Handle<Object> result =
305  factory->NewSyntaxError("harmony_const_assign", array);
306  isolate->Throw(*result, &location);
307  return false;
308  }
309  }
310 
311  info->SetScope(scope);
312  return true;
313 }
314 
315 
318 
319  // Add this scope as a new inner scope of the outer scope.
320  if (outer_scope_ != NULL) {
321  outer_scope_->inner_scopes_.Add(this, zone());
323  } else {
325  }
326 
327  // Declare convenience variables.
328  // Declare and allocate receiver (even for the global scope, and even
329  // if naccesses_ == 0).
330  // NOTE: When loading parameters in the global scope, we must take
331  // care not to access them as properties of the global object, but
332  // instead load them directly from the stack. Currently, the only
333  // such parameter is 'this' which is passed on the stack when
334  // invoking scripts
335  if (is_declaration_scope()) {
336  Variable* var =
337  variables_.Declare(this,
338  isolate_->factory()->this_symbol(),
339  VAR,
340  false,
344  receiver_ = var;
345  } else {
346  ASSERT(outer_scope() != NULL);
348  }
349 
350  if (is_function_scope()) {
351  // Declare 'arguments' variable which exists in all functions.
352  // Note that it might never be accessed, in which case it won't be
353  // allocated during variable allocation.
354  variables_.Declare(this,
355  isolate_->factory()->arguments_symbol(),
356  VAR,
357  true,
360  }
361 }
362 
363 
366  ASSERT(temps_.is_empty());
367  ASSERT(params_.is_empty());
368 
369  if (num_var_or_const() > 0) return this;
370 
371  // Remove this scope from outer scope.
372  for (int i = 0; i < outer_scope_->inner_scopes_.length(); i++) {
373  if (outer_scope_->inner_scopes_[i] == this) {
374  outer_scope_->inner_scopes_.Remove(i);
375  break;
376  }
377  }
378 
379  // Reparent inner scopes.
380  for (int i = 0; i < inner_scopes_.length(); i++) {
381  outer_scope()->AddInnerScope(inner_scopes_[i]);
382  }
383 
384  // Move unresolved variables
385  for (int i = 0; i < unresolved_.length(); i++) {
386  outer_scope()->unresolved_.Add(unresolved_[i], zone());
387  }
388 
389  return NULL;
390 }
391 
392 
394  Variable* result = variables_.Lookup(name);
395  if (result != NULL || scope_info_.is_null()) {
396  return result;
397  }
398  // If we have a serialized scope info, we might find the variable there.
399  // There should be no local slot with the given name.
400  ASSERT(scope_info_->StackSlotIndex(*name) < 0);
401 
402  // Check context slot lookup.
403  VariableMode mode;
405  InitializationFlag init_flag;
406  int index = scope_info_->ContextSlotIndex(*name, &mode, &init_flag);
407  if (index < 0) {
408  // Check parameters.
409  index = scope_info_->ParameterIndex(*name);
410  if (index < 0) return NULL;
411 
412  mode = DYNAMIC;
413  location = Variable::LOOKUP;
414  init_flag = kCreatedInitialized;
415  }
416 
417  Variable* var = variables_.Declare(this, name, mode, true, Variable::NORMAL,
418  init_flag);
419  var->AllocateTo(location, index);
420  return var;
421 }
422 
423 
426  if (function_ != NULL && function_->proxy()->name().is_identical_to(name)) {
427  return function_->proxy()->var();
428  } else if (!scope_info_.is_null()) {
429  // If we are backed by a scope info, try to lookup the variable there.
430  VariableMode mode;
431  int index = scope_info_->FunctionContextSlotIndex(*name, &mode);
432  if (index < 0) return NULL;
433  Variable* var = new(zone()) Variable(
434  this, name, mode, true /* is valid LHS */,
436  VariableProxy* proxy = factory->NewVariableProxy(var);
437  VariableDeclaration* declaration =
438  factory->NewVariableDeclaration(proxy, mode, this);
439  DeclareFunctionVar(declaration);
440  var->AllocateTo(Variable::CONTEXT, index);
441  return var;
442  } else {
443  return NULL;
444  }
445 }
446 
447 
449  for (Scope* scope = this;
450  scope != NULL;
451  scope = scope->outer_scope()) {
452  Variable* var = scope->LocalLookup(name);
453  if (var != NULL) return var;
454  }
455  return NULL;
456 }
457 
458 
462  Variable* var = variables_.Declare(this, name, mode, true, Variable::NORMAL,
464  params_.Add(var, zone());
465 }
466 
467 
469  VariableMode mode,
470  InitializationFlag init_flag,
471  Interface* interface) {
473  // This function handles VAR and CONST modes. DYNAMIC variables are
474  // introduces during variable allocation, INTERNAL variables are allocated
475  // explicitly, and TEMPORARY variables are allocated via NewTemporary().
476  ASSERT(mode == VAR ||
477  mode == CONST ||
478  mode == CONST_HARMONY ||
479  mode == LET);
481  return variables_.Declare(
482  this, name, mode, true, Variable::NORMAL, init_flag, interface);
483 }
484 
485 
488  return variables_.Declare(this,
489  name,
491  true,
494 }
495 
496 
498  // Most likely (always?) any variable we want to remove
499  // was just added before, so we search backwards.
500  for (int i = unresolved_.length(); i-- > 0;) {
501  if (unresolved_[i] == var) {
502  unresolved_.Remove(i);
503  return;
504  }
505  }
506 }
507 
508 
511  Variable* var = new(zone()) Variable(this,
512  name,
513  TEMPORARY,
514  true,
517  temps_.Add(var, zone());
518  return var;
519 }
520 
521 
522 void Scope::AddDeclaration(Declaration* declaration) {
523  decls_.Add(declaration, zone());
524 }
525 
526 
528  // Record only the first illegal redeclaration.
529  if (!HasIllegalRedeclaration()) {
530  illegal_redecl_ = expression;
531  }
533 }
534 
535 
536 void Scope::VisitIllegalRedeclaration(AstVisitor* visitor) {
538  illegal_redecl_->Accept(visitor);
539 }
540 
541 
543  int length = decls_.length();
544  for (int i = 0; i < length; i++) {
545  Declaration* decl = decls_[i];
546  if (decl->mode() != VAR) continue;
547  Handle<String> name = decl->proxy()->name();
548 
549  // Iterate through all scopes until and including the declaration scope.
550  Scope* previous = NULL;
551  Scope* current = decl->scope();
552  do {
553  // There is a conflict if there exists a non-VAR binding.
554  Variable* other_var = current->variables_.Lookup(name);
555  if (other_var != NULL && other_var->mode() != VAR) {
556  return decl;
557  }
558  previous = current;
559  current = current->outer_scope_;
560  } while (!previous->is_declaration_scope());
561  }
562  return NULL;
563 }
564 
565 
567  // Check this scope.
568  if (is_extended_mode()) {
569  for (int i = 0; i < unresolved_.length(); i++) {
570  ASSERT(unresolved_[i]->var() != NULL);
571  if (unresolved_[i]->var()->is_const_mode() &&
572  unresolved_[i]->IsLValue()) {
573  return unresolved_[i];
574  }
575  }
576  }
577 
578  // Check inner scopes.
579  for (int i = 0; i < inner_scopes_.length(); i++) {
580  VariableProxy* proxy = inner_scopes_[i]->CheckAssignmentToConst();
581  if (proxy != NULL) return proxy;
582  }
583 
584  // No assignments to const found.
585  return NULL;
586 }
587 
588 
590  ZoneList<Variable*>* context_locals) {
591  ASSERT(stack_locals != NULL);
592  ASSERT(context_locals != NULL);
593 
594  // Collect temporaries which are always allocated on the stack.
595  for (int i = 0; i < temps_.length(); i++) {
596  Variable* var = temps_[i];
597  if (var->is_used()) {
598  ASSERT(var->IsStackLocal());
599  stack_locals->Add(var, zone());
600  }
601  }
602 
603  // Collect declared local variables.
604  for (VariableMap::Entry* p = variables_.Start();
605  p != NULL;
606  p = variables_.Next(p)) {
607  Variable* var = reinterpret_cast<Variable*>(p->value);
608  if (var->is_used()) {
609  if (var->IsStackLocal()) {
610  stack_locals->Add(var, zone());
611  } else if (var->IsContextSlot()) {
612  context_locals->Add(var, zone());
613  }
614  }
615  }
616 }
617 
618 
619 bool Scope::AllocateVariables(CompilationInfo* info,
621  // 1) Propagate scope information.
623  if (outer_scope_ != NULL) {
624  outer_scope_calls_non_strict_eval =
627  }
628  PropagateScopeInfo(outer_scope_calls_non_strict_eval);
629 
630  // 2) Resolve variables.
631  if (!ResolveVariablesRecursively(info, factory)) return false;
632 
633  // 3) Allocate variables.
635 
636  return true;
637 }
638 
639 
642 }
643 
644 
646  // A function scope has a trivial context if it always is the global
647  // context. We iteratively scan out the context chain to see if
648  // there is anything that makes this scope non-trivial; otherwise we
649  // return true.
650  for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
651  if (scope->is_eval_scope()) return false;
652  if (scope->scope_inside_with_) return false;
653  if (scope->num_heap_slots_ > 0) return false;
654  }
655  return true;
656 }
657 
658 
660  Scope* outer = outer_scope_;
661  if (outer == NULL) return true;
662  // Note that the outer context may be trivial in general, but the current
663  // scope may be inside a 'with' statement in which case the outer context
664  // for this scope is not trivial.
665  return !scope_inside_with_ && outer->HasTrivialContext();
666 }
667 
668 
670  return !force_eager_compilation_ &&
672 }
673 
674 
676  Scope* outer = outer_scope_;
677  if (outer == NULL) return false;
678  outer = outer->DeclarationScope();
679  while (outer != NULL) {
680  if (outer->is_with_scope()) return true;
681  if (outer->is_declaration_scope() && outer->num_heap_slots() > 0)
682  return false;
683  outer = outer->outer_scope_;
684  }
685  return false;
686 }
687 
688 
690  int n = 0;
691  for (Scope* s = this; s != scope; s = s->outer_scope_) {
692  ASSERT(s != NULL); // scope must be in the scope chain
693  if (s->num_heap_slots() > 0) n++;
694  }
695  return n;
696 }
697 
698 
700  Scope* scope = this;
701  while (!scope->is_declaration_scope()) {
702  scope = scope->outer_scope();
703  }
704  return scope;
705 }
706 
707 
709  if (scope_info_.is_null()) {
711  }
712  return scope_info_;
713 }
714 
715 
717  List<Handle<ScopeInfo> >* chain,
718  int position) {
719  if (!is_eval_scope()) chain->Add(Handle<ScopeInfo>(GetScopeInfo()));
720 
721  for (int i = 0; i < inner_scopes_.length(); i++) {
722  Scope* scope = inner_scopes_[i];
723  int beg_pos = scope->start_position();
724  int end_pos = scope->end_position();
725  ASSERT(beg_pos >= 0 && end_pos >= 0);
726  if (beg_pos <= position && position < end_pos) {
727  scope->GetNestedScopeChain(chain, position);
728  return;
729  }
730  }
731 }
732 
733 
734 #ifdef DEBUG
735 static const char* Header(ScopeType type) {
736  switch (type) {
737  case EVAL_SCOPE: return "eval";
738  case FUNCTION_SCOPE: return "function";
739  case MODULE_SCOPE: return "module";
740  case GLOBAL_SCOPE: return "global";
741  case CATCH_SCOPE: return "catch";
742  case BLOCK_SCOPE: return "block";
743  case WITH_SCOPE: return "with";
744  }
745  UNREACHABLE();
746  return NULL;
747 }
748 
749 
750 static void Indent(int n, const char* str) {
751  PrintF("%*s%s", n, "", str);
752 }
753 
754 
755 static void PrintName(Handle<String> name) {
756  SmartArrayPointer<char> s = name->ToCString(DISALLOW_NULLS);
757  PrintF("%s", *s);
758 }
759 
760 
761 static void PrintLocation(Variable* var) {
762  switch (var->location()) {
764  break;
765  case Variable::PARAMETER:
766  PrintF("parameter[%d]", var->index());
767  break;
768  case Variable::LOCAL:
769  PrintF("local[%d]", var->index());
770  break;
771  case Variable::CONTEXT:
772  PrintF("context[%d]", var->index());
773  break;
774  case Variable::LOOKUP:
775  PrintF("lookup");
776  break;
777  }
778 }
779 
780 
781 static void PrintVar(int indent, Variable* var) {
782  if (var->is_used() || !var->IsUnallocated()) {
783  Indent(indent, Variable::Mode2String(var->mode()));
784  PrintF(" ");
785  PrintName(var->name());
786  PrintF("; // ");
787  PrintLocation(var);
788  if (var->has_forced_context_allocation()) {
789  if (!var->IsUnallocated()) PrintF(", ");
790  PrintF("forced context allocation");
791  }
792  PrintF("\n");
793  }
794 }
795 
796 
797 static void PrintMap(int indent, VariableMap* map) {
798  for (VariableMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
799  Variable* var = reinterpret_cast<Variable*>(p->value);
800  PrintVar(indent, var);
801  }
802 }
803 
804 
805 void Scope::Print(int n) {
806  int n0 = (n > 0 ? n : 0);
807  int n1 = n0 + 2; // indentation
808 
809  // Print header.
810  Indent(n0, Header(type_));
811  if (scope_name_->length() > 0) {
812  PrintF(" ");
813  PrintName(scope_name_);
814  }
815 
816  // Print parameters, if any.
817  if (is_function_scope()) {
818  PrintF(" (");
819  for (int i = 0; i < params_.length(); i++) {
820  if (i > 0) PrintF(", ");
821  PrintName(params_[i]->name());
822  }
823  PrintF(")");
824  }
825 
826  PrintF(" { // (%d, %d)\n", start_position(), end_position());
827 
828  // Function name, if any (named function literals, only).
829  if (function_ != NULL) {
830  Indent(n1, "// (local) function name: ");
831  PrintName(function_->proxy()->name());
832  PrintF("\n");
833  }
834 
835  // Scope info.
836  if (HasTrivialOuterContext()) {
837  Indent(n1, "// scope has trivial outer context\n");
838  }
839  switch (language_mode()) {
840  case CLASSIC_MODE:
841  break;
842  case STRICT_MODE:
843  Indent(n1, "// strict mode scope\n");
844  break;
845  case EXTENDED_MODE:
846  Indent(n1, "// extended mode scope\n");
847  break;
848  }
849  if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
850  if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
851  if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
853  Indent(n1, "// outer scope calls 'eval' in non-strict context\n");
854  }
855  if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
856  if (num_stack_slots_ > 0) { Indent(n1, "// ");
857  PrintF("%d stack slots\n", num_stack_slots_); }
858  if (num_heap_slots_ > 0) { Indent(n1, "// ");
859  PrintF("%d heap slots\n", num_heap_slots_); }
860 
861  // Print locals.
862  Indent(n1, "// function var\n");
863  if (function_ != NULL) {
864  PrintVar(n1, function_->proxy()->var());
865  }
866 
867  Indent(n1, "// temporary vars\n");
868  for (int i = 0; i < temps_.length(); i++) {
869  PrintVar(n1, temps_[i]);
870  }
871 
872  Indent(n1, "// local vars\n");
873  PrintMap(n1, &variables_);
874 
875  Indent(n1, "// dynamic vars\n");
876  if (dynamics_ != NULL) {
880  }
881 
882  // Print inner scopes (disable by providing negative n).
883  if (n >= 0) {
884  for (int i = 0; i < inner_scopes_.length(); i++) {
885  PrintF("\n");
886  inner_scopes_[i]->Print(n1);
887  }
888  }
889 
890  Indent(n0, "}\n");
891 }
892 #endif // DEBUG
893 
894 
896  if (dynamics_ == NULL) dynamics_ = new(zone()) DynamicScopePart(zone());
897  VariableMap* map = dynamics_->GetMap(mode);
898  Variable* var = map->Lookup(name);
899  if (var == NULL) {
900  // Declare a new non-local.
901  InitializationFlag init_flag = (mode == VAR)
903  var = map->Declare(NULL,
904  name,
905  mode,
906  true,
908  init_flag);
909  // Allocate it by giving it a dynamic lookup.
910  var->AllocateTo(Variable::LOOKUP, -1);
911  }
912  return var;
913 }
914 
915 
917  BindingKind* binding_kind,
919  ASSERT(binding_kind != NULL);
920  // Try to find the variable in this scope.
921  Variable* var = LocalLookup(name);
922 
923  // We found a variable and we are done. (Even if there is an 'eval' in
924  // this scope which introduces the same variable again, the resulting
925  // variable remains the same.)
926  if (var != NULL) {
927  *binding_kind = BOUND;
928  return var;
929  }
930 
931  // We did not find a variable locally. Check against the function variable,
932  // if any. We can do this for all scopes, since the function variable is
933  // only present - if at all - for function scopes.
934  *binding_kind = UNBOUND;
935  var = LookupFunctionVar(name, factory);
936  if (var != NULL) {
937  *binding_kind = BOUND;
938  } else if (outer_scope_ != NULL) {
939  var = outer_scope_->LookupRecursive(name, binding_kind, factory);
940  if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) {
941  var->ForceContextAllocation();
942  }
943  } else {
945  }
946 
947  if (is_with_scope()) {
948  // The current scope is a with scope, so the variable binding can not be
949  // statically resolved. However, note that it was necessary to do a lookup
950  // in the outer scope anyway, because if a binding exists in an outer scope,
951  // the associated variable has to be marked as potentially being accessed
952  // from inside of an inner with scope (the property may not be in the 'with'
953  // object).
954  *binding_kind = DYNAMIC_LOOKUP;
955  return NULL;
956  } else if (calls_non_strict_eval()) {
957  // A variable binding may have been found in an outer scope, but the current
958  // scope makes a non-strict 'eval' call, so the found variable may not be
959  // the correct one (the 'eval' may introduce a binding with the same name).
960  // In that case, change the lookup result to reflect this situation.
961  if (*binding_kind == BOUND) {
962  *binding_kind = BOUND_EVAL_SHADOWED;
963  } else if (*binding_kind == UNBOUND) {
964  *binding_kind = UNBOUND_EVAL_SHADOWED;
965  }
966  }
967  return var;
968 }
969 
970 
971 bool Scope::ResolveVariable(CompilationInfo* info,
972  VariableProxy* proxy,
974  ASSERT(info->global_scope()->is_global_scope());
975 
976  // If the proxy is already resolved there's nothing to do
977  // (functions and consts may be resolved by the parser).
978  if (proxy->var() != NULL) return true;
979 
980  // Otherwise, try to resolve the variable.
981  BindingKind binding_kind;
982  Variable* var = LookupRecursive(proxy->name(), &binding_kind, factory);
983  switch (binding_kind) {
984  case BOUND:
985  // We found a variable binding.
986  break;
987 
988  case BOUND_EVAL_SHADOWED:
989  // We either found a variable binding that might be shadowed by eval or
990  // gave up on it (e.g. by encountering a local with the same in the outer
991  // scope which was not promoted to a context, this can happen if we use
992  // debugger to evaluate arbitrary expressions at a break point).
993  if (var->is_global()) {
994  var = NonLocal(proxy->name(), DYNAMIC_GLOBAL);
995  } else if (var->is_dynamic()) {
996  var = NonLocal(proxy->name(), DYNAMIC);
997  } else {
998  Variable* invalidated = var;
999  var = NonLocal(proxy->name(), DYNAMIC_LOCAL);
1000  var->set_local_if_not_shadowed(invalidated);
1001  }
1002  break;
1003 
1004  case UNBOUND:
1005  // No binding has been found. Declare a variable in global scope.
1006  var = info->global_scope()->DeclareGlobal(proxy->name());
1007  break;
1008 
1009  case UNBOUND_EVAL_SHADOWED:
1010  // No binding has been found. But some scope makes a
1011  // non-strict 'eval' call.
1012  var = NonLocal(proxy->name(), DYNAMIC_GLOBAL);
1013  break;
1014 
1015  case DYNAMIC_LOOKUP:
1016  // The variable could not be resolved statically.
1017  var = NonLocal(proxy->name(), DYNAMIC);
1018  break;
1019  }
1020 
1021  ASSERT(var != NULL);
1022  proxy->BindTo(var);
1023 
1024  if (FLAG_harmony_modules) {
1025  bool ok;
1026 #ifdef DEBUG
1027  if (FLAG_print_interface_details)
1028  PrintF("# Resolve %s:\n", var->name()->ToAsciiArray());
1029 #endif
1030  proxy->interface()->Unify(var->interface(), zone(), &ok);
1031  if (!ok) {
1032 #ifdef DEBUG
1033  if (FLAG_print_interfaces) {
1034  PrintF("SCOPES TYPE ERROR\n");
1035  PrintF("proxy: ");
1036  proxy->interface()->Print();
1037  PrintF("var: ");
1038  var->interface()->Print();
1039  }
1040 #endif
1041 
1042  // Inconsistent use of module. Throw a syntax error.
1043  // TODO(rossberg): generate more helpful error message.
1044  MessageLocation location(info->script(),
1045  proxy->position(),
1046  proxy->position());
1047  Isolate* isolate = Isolate::Current();
1048  Factory* factory = isolate->factory();
1049  Handle<JSArray> array = factory->NewJSArray(1);
1050  USE(JSObject::SetElement(array, 0, var->name(), NONE, kStrictMode));
1051  Handle<Object> result =
1052  factory->NewSyntaxError("module_type_error", array);
1053  isolate->Throw(*result, &location);
1054  return false;
1055  }
1056  }
1057 
1058  return true;
1059 }
1060 
1061 
1063  CompilationInfo* info,
1064  AstNodeFactory<AstNullVisitor>* factory) {
1065  ASSERT(info->global_scope()->is_global_scope());
1066 
1067  // Resolve unresolved variables for this scope.
1068  for (int i = 0; i < unresolved_.length(); i++) {
1069  if (!ResolveVariable(info, unresolved_[i], factory)) return false;
1070  }
1071 
1072  // Resolve unresolved variables for inner scopes.
1073  for (int i = 0; i < inner_scopes_.length(); i++) {
1074  if (!inner_scopes_[i]->ResolveVariablesRecursively(info, factory))
1075  return false;
1076  }
1077 
1078  return true;
1079 }
1080 
1081 
1082 bool Scope::PropagateScopeInfo(bool outer_scope_calls_non_strict_eval ) {
1083  if (outer_scope_calls_non_strict_eval) {
1085  }
1086 
1087  bool calls_non_strict_eval =
1089  for (int i = 0; i < inner_scopes_.length(); i++) {
1090  Scope* inner_scope = inner_scopes_[i];
1091  if (inner_scope->PropagateScopeInfo(calls_non_strict_eval)) {
1092  inner_scope_calls_eval_ = true;
1093  }
1094  if (inner_scope->force_eager_compilation_) {
1095  force_eager_compilation_ = true;
1096  }
1097  }
1098 
1100 }
1101 
1102 
1104  // Give var a read/write use if there is a chance it might be accessed
1105  // via an eval() call. This is only possible if the variable has a
1106  // visible name.
1107  if ((var->is_this() || var->name()->length() > 0) &&
1112  is_catch_scope() ||
1113  is_block_scope())) {
1114  var->set_is_used(true);
1115  }
1116  // Global variables do not need to be allocated.
1117  return !var->is_global() && var->is_used();
1118 }
1119 
1120 
1122  // If var is accessed from an inner scope, or if there is a possibility
1123  // that it might be accessed from the current or an inner scope (through
1124  // an eval() call or a runtime with lookup), it must be allocated in the
1125  // context.
1126  //
1127  // Exceptions: temporary variables are never allocated in a context;
1128  // catch-bound variables are always allocated in a context.
1129  if (var->mode() == TEMPORARY) return false;
1130  if (is_catch_scope() || is_block_scope() || is_module_scope()) return true;
1131  return var->has_forced_context_allocation() ||
1135  var->is_global();
1136 }
1137 
1138 
1140  for (int i = 0; i < params_.length(); i++) {
1141  if (params_[i]->name().is_identical_to(
1142  isolate_->factory()->arguments_symbol())) {
1143  return true;
1144  }
1145  }
1146  return false;
1147 }
1148 
1149 
1152 }
1153 
1154 
1157 }
1158 
1159 
1162  Variable* arguments = LocalLookup(isolate_->factory()->arguments_symbol());
1163  ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly
1164 
1165  bool uses_nonstrict_arguments = false;
1166 
1167  if (MustAllocate(arguments) && !HasArgumentsParameter()) {
1168  // 'arguments' is used. Unless there is also a parameter called
1169  // 'arguments', we must be conservative and allocate all parameters to
1170  // the context assuming they will be captured by the arguments object.
1171  // If we have a parameter named 'arguments', a (new) value is always
1172  // assigned to it via the function invocation. Then 'arguments' denotes
1173  // that specific parameter value and cannot be used to access the
1174  // parameters, which is why we don't need to allocate an arguments
1175  // object in that case.
1176 
1177  // We are using 'arguments'. Tell the code generator that is needs to
1178  // allocate the arguments object by setting 'arguments_'.
1180 
1181  // In strict mode 'arguments' does not alias formal parameters.
1182  // Therefore in strict mode we allocate parameters as if 'arguments'
1183  // were not used.
1184  uses_nonstrict_arguments = is_classic_mode();
1185  }
1186 
1187  // The same parameter may occur multiple times in the parameters_ list.
1188  // If it does, and if it is not copied into the context object, it must
1189  // receive the highest parameter index for that parameter; thus iteration
1190  // order is relevant!
1191  for (int i = params_.length() - 1; i >= 0; --i) {
1192  Variable* var = params_[i];
1193  ASSERT(var->scope() == this);
1194  if (uses_nonstrict_arguments) {
1195  // Force context allocation of the parameter.
1196  var->ForceContextAllocation();
1197  }
1198 
1199  if (MustAllocate(var)) {
1200  if (MustAllocateInContext(var)) {
1201  ASSERT(var->IsUnallocated() || var->IsContextSlot());
1202  if (var->IsUnallocated()) {
1203  AllocateHeapSlot(var);
1204  }
1205  } else {
1206  ASSERT(var->IsUnallocated() || var->IsParameter());
1207  if (var->IsUnallocated()) {
1209  }
1210  }
1211  }
1212  }
1213 }
1214 
1215 
1217  ASSERT(var->scope() == this);
1218  ASSERT(!var->IsVariable(isolate_->factory()->result_symbol()) ||
1219  !var->IsStackLocal());
1220  if (var->IsUnallocated() && MustAllocate(var)) {
1221  if (MustAllocateInContext(var)) {
1222  AllocateHeapSlot(var);
1223  } else {
1224  AllocateStackSlot(var);
1225  }
1226  }
1227 }
1228 
1229 
1231  // All variables that have no rewrite yet are non-parameter locals.
1232  for (int i = 0; i < temps_.length(); i++) {
1234  }
1235 
1236  for (VariableMap::Entry* p = variables_.Start();
1237  p != NULL;
1238  p = variables_.Next(p)) {
1239  Variable* var = reinterpret_cast<Variable*>(p->value);
1241  }
1242 
1243  // For now, function_ must be allocated at the very end. If it gets
1244  // allocated in the context, it must be the last slot in the context,
1245  // because of the current ScopeInfo implementation (see
1246  // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor).
1247  if (function_ != NULL) {
1249  }
1250 }
1251 
1252 
1254  // Allocate variables for inner scopes.
1255  for (int i = 0; i < inner_scopes_.length(); i++) {
1256  inner_scopes_[i]->AllocateVariablesRecursively();
1257  }
1258 
1259  // If scope is already resolved, we still need to allocate
1260  // variables in inner scopes which might not had been resolved yet.
1261  if (already_resolved()) return;
1262  // The number of slots required for variables.
1263  num_stack_slots_ = 0;
1265 
1266  // Allocate variables for this scope.
1267  // Parameters must be allocated first, if any.
1270 
1271  // Force allocation of a context for this scope if necessary. For a 'with'
1272  // scope and for a function scope that makes an 'eval' call we need a context,
1273  // even if no local variables were statically allocated in the scope.
1274  // Likewise for modules.
1275  bool must_have_context = is_with_scope() || is_module_scope() ||
1276  (is_function_scope() && calls_eval());
1277 
1278  // If we didn't allocate any locals in the local context, then we only
1279  // need the minimal number of slots if we must have a context.
1280  if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) {
1281  num_heap_slots_ = 0;
1282  }
1283 
1284  // Allocation done.
1286 }
1287 
1288 
1290  return num_stack_slots() -
1291  (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0);
1292 }
1293 
1294 
1296  if (num_heap_slots() == 0) return 0;
1298  (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1299 }
1300 
1301 } } // namespace v8::internal
bool is_global_scope() const
Definition: scopes.h:278
void AllocateTo(Location location, int index)
Definition: variables.h:160
Scope * DeclarationScope()
Definition: scopes.cc:699
bool scope_contains_with_
Definition: scopes.h:472
VariableDeclaration * function() const
Definition: scopes.h:323
Declaration * CheckConflictingVarDeclarations()
Definition: scopes.cc:542
bool scope_calls_eval_
Definition: scopes.h:475
virtual ~VariableMap()
Definition: scopes.cc:63
bool calls_eval() const
Definition: scopes.h:296
void PrintF(const char *format,...)
Definition: v8utils.cc:40
void ForceContextAllocation()
Definition: variables.h:101
static String * cast(Object *obj)
Context * previous()
Definition: contexts.h:304
Handle< ScopeInfo > GetScopeInfo()
Definition: scopes.cc:708
ZoneList< Scope * > inner_scopes_
Definition: scopes.h:431
Variable * receiver()
Definition: scopes.h:319
bool already_resolved()
Definition: scopes.h:500
bool force_eager_compilation_
Definition: scopes.h:485
void CollectStackAndContextLocals(ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
Definition: scopes.cc:589
bool outer_scope_calls_non_strict_eval() const
Definition: scopes.h:300
Scope * FinalizeBlockScope()
Definition: scopes.cc:364
Handle< JSArray > NewJSArray(int capacity, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:1005
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
Definition: flags.cc:1349
Variable * DeclareGlobal(Handle< String > name)
Definition: scopes.cc:486
Variable * arguments_
Definition: scopes.h:460
static bool Analyze(CompilationInfo *info)
Definition: scopes.cc:263
Scope * outer_scope() const
Definition: scopes.h:347
ScopeType type_
Definition: scopes.h:434
bool HasIllegalRedeclaration() const
Definition: scopes.h:214
bool is_identical_to(const Handle< T > other) const
Definition: handles.h:67
ZoneList< VariableProxy * > unresolved_
Definition: scopes.h:452
Expression * illegal_redecl_
Definition: scopes.h:465
void set_local_if_not_shadowed(Variable *local)
Definition: variables.h:149
bool is_classic_mode() const
Definition: scopes.h:285
Handle< String > scope_name_
Definition: scopes.h:437
Zone * zone() const
Definition: scopes.h:57
void DeclareParameter(Handle< String > name, VariableMode mode)
Definition: scopes.cc:459
VariableProxy * CheckAssignmentToConst()
Definition: scopes.cc:566
bool HasTrivialContext() const
Definition: scopes.cc:645
#define ASSERT(condition)
Definition: checks.h:270
v8::Handle< v8::Value > Print(const v8::Arguments &args)
Variable * NewTemporary(Handle< String > name)
Definition: scopes.cc:509
Interface * interface() const
Definition: variables.h:158
bool is_this() const
Definition: variables.h:136
VariableMap * GetMap(VariableMode mode)
Definition: scopes.h:75
VariableDeclaration * function_
Definition: scopes.h:458
Variable * LookupRecursive(Handle< String > name, BindingKind *binding_kind, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:916
LanguageMode language_mode_
Definition: scopes.h:477
Factory * factory()
Definition: isolate.h:977
Handle< String > name() const
Definition: ast.h:1483
bool outer_scope_calls_non_strict_eval_
Definition: scopes.h:483
void Unify(Interface *that, Zone *zone, bool *ok)
Definition: interface.cc:119
bool is_block_scope() const
Definition: scopes.h:280
Handle< Object > NewSyntaxError(const char *type, Handle< JSArray > args)
Definition: factory.cc:636
Handle< String > name() const
Definition: variables.h:96
static Handle< ScopeInfo > Create(Scope *scope, Zone *zone)
Definition: scopeinfo.cc:41
bool MustAllocateInContext(Variable *var)
Definition: scopes.cc:1121
ZoneList< Declaration * > decls_
Definition: scopes.h:454
Handle< ScopeInfo > scope_info_
Definition: scopes.h:499
int ContextChainLength(Scope *scope)
Definition: scopes.cc:689
bool is_global() const
Definition: variables.cc:84
static ScopeInfo * cast(Object *object)
bool HasTrivialOuterContext() const
Definition: scopes.cc:659
bool is_dynamic() const
Definition: variables.h:122
bool AllowsLazyCompilation() const
Definition: scopes.cc:640
void DeclareFunctionVar(VariableDeclaration *declaration)
Definition: scopes.h:142
void AllocateNonParameterLocal(Variable *var)
Definition: scopes.cc:1216
T ** location() const
Definition: handles.h:75
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:468
Variable * var() const
Definition: ast.h:1484
#define UNREACHABLE()
Definition: checks.h:50
VariableProxy * proxy() const
Definition: ast.h:452
bool TrivialDeclarationScopesBeforeWithScope() const
Definition: scopes.cc:675
void AllocateVariablesRecursively()
Definition: scopes.cc:1253
VariableMode mode() const
Definition: variables.h:97
bool is_eval_scope() const
Definition: scopes.h:275
bool HasArgumentsParameter()
Definition: scopes.cc:1139
Variable * arguments() const
Definition: scopes.h:338
int num_stack_slots() const
Definition: scopes.h:365
Isolate *const isolate_
Definition: scopes.h:427
bool has_forced_context_allocation() const
Definition: variables.h:98
void GetNestedScopeChain(List< Handle< ScopeInfo > > *chain, int statement_position)
Definition: scopes.cc:716
void AllocateHeapSlot(Variable *var)
Definition: scopes.cc:1155
ScopeType type() const
Definition: scopes.h:313
bool AllowsLazyRecompilation() const
Definition: scopes.cc:669
bool PropagateScopeInfo(bool outer_scope_calls_non_strict_eval)
Definition: scopes.cc:1082
bool calls_non_strict_eval()
Definition: scopes.h:297
Scope * scope() const
Definition: variables.h:94
void PrintMap(map< string, string > *m)
Definition: process.cc:591
bool is_declaration_scope() const
Definition: scopes.h:282
bool inner_scope_calls_eval_
Definition: scopes.h:484
Entry * Lookup(void *key, uint32_t hash, bool insert, ZoneAllocationPolicyallocator=ZoneAllocationPolicy())
void AllocateStackSlot(Variable *var)
Definition: scopes.cc:1150
Variable * receiver_
Definition: scopes.h:456
bool IsContextSlot() const
Definition: variables.h:119
static MUST_USE_RESULT Handle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attr, StrictModeFlag strict_mode, SetPropertyMode set_mode=SET_PROPERTY)
Definition: objects.cc:9663
static const char * Mode2String(VariableMode mode)
Definition: variables.cc:40
bool MustAllocate(Variable *var)
Definition: scopes.cc:1103
Variable * LocalLookup(Handle< String > name)
Definition: scopes.cc:393
bool IsVariable(Handle< String > n) const
Definition: variables.h:111
int end_position() const
Definition: scopes.h:266
bool IsStackLocal() const
Definition: variables.h:117
ZoneList< Variable * > params_
Definition: scopes.h:448
Interface * interface() const
Definition: scopes.h:350
void AllocateParameterLocals()
Definition: scopes.cc:1160
int StackLocalCount() const
Definition: scopes.cc:1289
VariableMap variables_
Definition: scopes.h:444
void AddDeclaration(Declaration *declaration)
Definition: scopes.cc:522
int num_heap_slots() const
Definition: scopes.h:366
void VisitIllegalRedeclaration(AstVisitor *visitor)
Definition: scopes.cc:536
Scope * scope() const
Definition: ast.h:454
bool is_null() const
Definition: handles.h:87
int position() const
Definition: ast.h:1486
bool IsParameter() const
Definition: variables.h:116
bool is_with_scope() const
Definition: scopes.h:281
void AllocateNonParameterLocals()
Definition: scopes.cc:1230
ZoneList< Variable * > temps_
Definition: scopes.h:446
int num_var_or_const()
Definition: scopes.h:362
bool contains_with() const
Definition: scopes.h:307
bool IsFunctionContext()
Definition: contexts.h:339
Zone * zone() const
Definition: scopes.h:120
bool IsUnallocated() const
Definition: variables.h:115
int ContextLocalCount() const
Definition: scopes.cc:1295
Variable * Lookup(Handle< String > name)
Definition: scopes.cc:91
#define ASSERT_EQ(v1, v2)
Definition: checks.h:271
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
Definition: flags.cc:274
Object * extension()
Definition: contexts.h:312
void BindTo(Variable *var)
Definition: ast.cc:103
void USE(T)
Definition: globals.h:303
void set_is_used(bool flag)
Definition: variables.h:106
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 true
Definition: flags.cc:157
MUST_USE_RESULT bool AllocateVariables(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:619
Variable * NonLocal(Handle< String > name, VariableMode mode)
Definition: scopes.cc:895
Interface * interface() const
Definition: ast.h:1487
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
MUST_USE_RESULT bool ResolveVariable(CompilationInfo *info, VariableProxy *proxy, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:971
LanguageMode language_mode() const
Definition: scopes.h:316
DynamicScopePart * dynamics_
Definition: scopes.h:450
JSFunction * closure()
Definition: contexts.h:301
bool is_function_scope() const
Definition: scopes.h:276
Variable * Lookup(Handle< String > name)
Definition: scopes.cc:448
virtual void Accept(AstVisitor *v)=0
VariableMode mode() const
Definition: ast.h:453
VariableMap(Zone *zone)
Definition: scopes.cc:60
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:66
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:288
static Scope * DeserializeScopeChain(Context *context, Scope *global_scope, Zone *zone)
Definition: scopes.cc:211
Scope(Scope *outer_scope, ScopeType type, Zone *zone)
Definition: scopes.cc:106
Scope * outer_scope_
Definition: scopes.h:430
void RemoveUnresolved(VariableProxy *var)
Definition: scopes.cc:497
FlagType type() const
Definition: flags.cc:1358
Entry * Next(Entry *p) const
Definition: hashmap.h:241
Variable * LookupFunctionVar(Handle< String > name, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:424
bool scope_inside_with_
Definition: scopes.h:470
MUST_USE_RESULT bool ResolveVariablesRecursively(CompilationInfo *info, AstNodeFactory< AstNullVisitor > *factory)
Definition: scopes.cc:1062
void SetIllegalRedeclaration(Expression *expression)
Definition: scopes.cc:527