| OLD | NEW | 
|     1 // Copyright 2011 the V8 project authors. All rights reserved. |     1 // Copyright 2011 the V8 project authors. All rights reserved. | 
|     2 // Redistribution and use in source and binary forms, with or without |     2 // Redistribution and use in source and binary forms, with or without | 
|     3 // modification, are permitted provided that the following conditions are |     3 // modification, are permitted provided that the following conditions are | 
|     4 // met: |     4 // met: | 
|     5 // |     5 // | 
|     6 //     * Redistributions of source code must retain the above copyright |     6 //     * Redistributions of source code must retain the above copyright | 
|     7 //       notice, this list of conditions and the following disclaimer. |     7 //       notice, this list of conditions and the following disclaimer. | 
|     8 //     * Redistributions in binary form must reproduce the above |     8 //     * Redistributions in binary form must reproduce the above | 
|     9 //       copyright notice, this list of conditions and the following |     9 //       copyright notice, this list of conditions and the following | 
|    10 //       disclaimer in the documentation and/or other materials provided |    10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   141       inner_scopes_(4), |   141       inner_scopes_(4), | 
|   142       variables_(), |   142       variables_(), | 
|   143       temps_(4), |   143       temps_(4), | 
|   144       params_(4), |   144       params_(4), | 
|   145       unresolved_(16), |   145       unresolved_(16), | 
|   146       decls_(4), |   146       decls_(4), | 
|   147       already_resolved_(true) { |   147       already_resolved_(true) { | 
|   148   SetDefaults(type, NULL, scope_info); |   148   SetDefaults(type, NULL, scope_info); | 
|   149   if (!scope_info.is_null()) { |   149   if (!scope_info.is_null()) { | 
|   150     num_heap_slots_ = scope_info_->ContextLength(); |   150     num_heap_slots_ = scope_info_->ContextLength(); | 
 |   151     if (*scope_info != ScopeInfo::Empty()) { | 
 |   152       language_mode_ = scope_info->language_mode(); | 
 |   153     } | 
|   151   } |   154   } | 
|   152   AddInnerScope(inner_scope); |   155   AddInnerScope(inner_scope); | 
|   153 } |   156 } | 
|   154  |   157  | 
|   155  |   158  | 
|   156 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name) |   159 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name) | 
|   157     : isolate_(Isolate::Current()), |   160     : isolate_(Isolate::Current()), | 
|   158       inner_scopes_(1), |   161       inner_scopes_(1), | 
|   159       variables_(), |   162       variables_(), | 
|   160       temps_(0), |   163       temps_(0), | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|   183   scope_name_ = isolate_->factory()->empty_symbol(); |   186   scope_name_ = isolate_->factory()->empty_symbol(); | 
|   184   dynamics_ = NULL; |   187   dynamics_ = NULL; | 
|   185   receiver_ = NULL; |   188   receiver_ = NULL; | 
|   186   function_ = NULL; |   189   function_ = NULL; | 
|   187   arguments_ = NULL; |   190   arguments_ = NULL; | 
|   188   illegal_redecl_ = NULL; |   191   illegal_redecl_ = NULL; | 
|   189   scope_inside_with_ = false; |   192   scope_inside_with_ = false; | 
|   190   scope_contains_with_ = false; |   193   scope_contains_with_ = false; | 
|   191   scope_calls_eval_ = false; |   194   scope_calls_eval_ = false; | 
|   192   // Inherit the strict mode from the parent scope. |   195   // Inherit the strict mode from the parent scope. | 
|   193   strict_mode_flag_ = (outer_scope != NULL) |   196   language_mode_ = (outer_scope != NULL) | 
|   194       ? outer_scope->strict_mode_flag_ : kNonStrictMode; |   197       ? outer_scope->language_mode_ : CLASSIC_MODE; | 
|   195   outer_scope_calls_non_strict_eval_ = false; |   198   outer_scope_calls_non_strict_eval_ = false; | 
|   196   inner_scope_calls_eval_ = false; |   199   inner_scope_calls_eval_ = false; | 
|   197   force_eager_compilation_ = false; |   200   force_eager_compilation_ = false; | 
|   198   num_var_or_const_ = 0; |   201   num_var_or_const_ = 0; | 
|   199   num_stack_slots_ = 0; |   202   num_stack_slots_ = 0; | 
|   200   num_heap_slots_ = 0; |   203   num_heap_slots_ = 0; | 
|   201   scope_info_ = scope_info; |   204   scope_info_ = scope_info; | 
|   202   start_position_ = RelocInfo::kNoPosition; |   205   start_position_ = RelocInfo::kNoPosition; | 
|   203   end_position_ = RelocInfo::kNoPosition; |   206   end_position_ = RelocInfo::kNoPosition; | 
|   204 } |   207 } | 
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   756   if (function_ != NULL) { |   759   if (function_ != NULL) { | 
|   757     Indent(n1, "// (local) function name: "); |   760     Indent(n1, "// (local) function name: "); | 
|   758     PrintName(function_->name()); |   761     PrintName(function_->name()); | 
|   759     PrintF("\n"); |   762     PrintF("\n"); | 
|   760   } |   763   } | 
|   761  |   764  | 
|   762   // Scope info. |   765   // Scope info. | 
|   763   if (HasTrivialOuterContext()) { |   766   if (HasTrivialOuterContext()) { | 
|   764     Indent(n1, "// scope has trivial outer context\n"); |   767     Indent(n1, "// scope has trivial outer context\n"); | 
|   765   } |   768   } | 
|   766   if (is_strict_mode()) Indent(n1, "// strict mode scope\n"); |   769   switch (language_mode()) { | 
 |   770     case CLASSIC_MODE: | 
 |   771       break; | 
 |   772     case STRICT_MODE: | 
 |   773       Indent(n1, "// strict mode scope\n"); | 
 |   774       break; | 
 |   775     case EXTENDED_MODE: | 
 |   776       Indent(n1, "// extended mode scope\n"); | 
 |   777       break; | 
 |   778   } | 
|   767   if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |   779   if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 
|   768   if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); |   780   if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 
|   769   if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |   781   if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 
|   770   if (outer_scope_calls_non_strict_eval_) { |   782   if (outer_scope_calls_non_strict_eval_) { | 
|   771     Indent(n1, "// outer scope calls 'eval' in non-strict context\n"); |   783     Indent(n1, "// outer scope calls 'eval' in non-strict context\n"); | 
|   772   } |   784   } | 
|   773   if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |   785   if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 
|   774   if (num_stack_slots_ > 0) { Indent(n1, "// "); |   786   if (num_stack_slots_ > 0) { Indent(n1, "// "); | 
|   775   PrintF("%d stack slots\n", num_stack_slots_); } |   787   PrintF("%d stack slots\n", num_stack_slots_); } | 
|   776   if (num_heap_slots_ > 0) { Indent(n1, "// "); |   788   if (num_heap_slots_ > 0) { Indent(n1, "// "); | 
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   966   } |   978   } | 
|   967 } |   979 } | 
|   968  |   980  | 
|   969  |   981  | 
|   970 bool Scope::PropagateScopeInfo(bool outer_scope_calls_non_strict_eval ) { |   982 bool Scope::PropagateScopeInfo(bool outer_scope_calls_non_strict_eval ) { | 
|   971   if (outer_scope_calls_non_strict_eval) { |   983   if (outer_scope_calls_non_strict_eval) { | 
|   972     outer_scope_calls_non_strict_eval_ = true; |   984     outer_scope_calls_non_strict_eval_ = true; | 
|   973   } |   985   } | 
|   974  |   986  | 
|   975   bool calls_non_strict_eval = |   987   bool calls_non_strict_eval = | 
|   976       (scope_calls_eval_ && !is_strict_mode()) || |   988       this->calls_non_strict_eval() || | 
|   977       outer_scope_calls_non_strict_eval_; |   989       outer_scope_calls_non_strict_eval_; | 
|   978   for (int i = 0; i < inner_scopes_.length(); i++) { |   990   for (int i = 0; i < inner_scopes_.length(); i++) { | 
|   979     Scope* inner_scope = inner_scopes_[i]; |   991     Scope* inner_scope = inner_scopes_[i]; | 
|   980     if (inner_scope->PropagateScopeInfo(calls_non_strict_eval)) { |   992     if (inner_scope->PropagateScopeInfo(calls_non_strict_eval)) { | 
|   981       inner_scope_calls_eval_ = true; |   993       inner_scope_calls_eval_ = true; | 
|   982     } |   994     } | 
|   983     if (inner_scope->force_eager_compilation_) { |   995     if (inner_scope->force_eager_compilation_) { | 
|   984       force_eager_compilation_ = true; |   996       force_eager_compilation_ = true; | 
|   985     } |   997     } | 
|   986   } |   998   } | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1063     // parameters, which is why we don't need to allocate an arguments |  1075     // parameters, which is why we don't need to allocate an arguments | 
|  1064     // object in that case. |  1076     // object in that case. | 
|  1065  |  1077  | 
|  1066     // We are using 'arguments'. Tell the code generator that is needs to |  1078     // We are using 'arguments'. Tell the code generator that is needs to | 
|  1067     // allocate the arguments object by setting 'arguments_'. |  1079     // allocate the arguments object by setting 'arguments_'. | 
|  1068     arguments_ = arguments; |  1080     arguments_ = arguments; | 
|  1069  |  1081  | 
|  1070     // In strict mode 'arguments' does not alias formal parameters. |  1082     // In strict mode 'arguments' does not alias formal parameters. | 
|  1071     // Therefore in strict mode we allocate parameters as if 'arguments' |  1083     // Therefore in strict mode we allocate parameters as if 'arguments' | 
|  1072     // were not used. |  1084     // were not used. | 
|  1073     uses_nonstrict_arguments = !is_strict_mode(); |  1085     uses_nonstrict_arguments = is_classic_mode(); | 
|  1074   } |  1086   } | 
|  1075  |  1087  | 
|  1076   // The same parameter may occur multiple times in the parameters_ list. |  1088   // The same parameter may occur multiple times in the parameters_ list. | 
|  1077   // If it does, and if it is not copied into the context object, it must |  1089   // If it does, and if it is not copied into the context object, it must | 
|  1078   // receive the highest parameter index for that parameter; thus iteration |  1090   // receive the highest parameter index for that parameter; thus iteration | 
|  1079   // order is relevant! |  1091   // order is relevant! | 
|  1080   for (int i = params_.length() - 1; i >= 0; --i) { |  1092   for (int i = params_.length() - 1; i >= 0; --i) { | 
|  1081     Variable* var = params_[i]; |  1093     Variable* var = params_[i]; | 
|  1082     ASSERT(var->scope() == this); |  1094     ASSERT(var->scope() == this); | 
|  1083     if (uses_nonstrict_arguments) { |  1095     if (uses_nonstrict_arguments) { | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1180 } |  1192 } | 
|  1181  |  1193  | 
|  1182  |  1194  | 
|  1183 int Scope::ContextLocalCount() const { |  1195 int Scope::ContextLocalCount() const { | 
|  1184   if (num_heap_slots() == 0) return 0; |  1196   if (num_heap_slots() == 0) return 0; | 
|  1185   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |  1197   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 
|  1186       (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0); |  1198       (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0); | 
|  1187 } |  1199 } | 
|  1188  |  1200  | 
|  1189 } }  // namespace v8::internal |  1201 } }  // namespace v8::internal | 
| OLD | NEW |