| OLD | NEW | 
|     1 // Copyright 2012 the V8 project authors. All rights reserved. |     1 // Copyright 2012 the V8 project authors. All rights reserved. | 
|     2 // Use of this source code is governed by a BSD-style license that can be |     2 // Use of this source code is governed by a BSD-style license that can be | 
|     3 // found in the LICENSE file. |     3 // found in the LICENSE file. | 
|     4  |     4  | 
|     5 #include "src/v8.h" |     5 #include "src/v8.h" | 
|     6  |     6  | 
|     7 #include "src/accessors.h" |     7 #include "src/accessors.h" | 
|     8 #include "src/bootstrapper.h" |     8 #include "src/bootstrapper.h" | 
|     9 #include "src/messages.h" |     9 #include "src/messages.h" | 
|    10 #include "src/parser.h" |    10 #include "src/parser.h" | 
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   586   static int Compare(const VarAndOrder* a, const VarAndOrder* b) { |   586   static int Compare(const VarAndOrder* a, const VarAndOrder* b) { | 
|   587     return a->order_ - b->order_; |   587     return a->order_ - b->order_; | 
|   588   } |   588   } | 
|   589  |   589  | 
|   590  private: |   590  private: | 
|   591   Variable* var_; |   591   Variable* var_; | 
|   592   int order_; |   592   int order_; | 
|   593 }; |   593 }; | 
|   594  |   594  | 
|   595  |   595  | 
|   596 void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals, |   596 void Scope::CollectStackAndContextLocals( | 
|   597                                          ZoneList<Variable*>* context_locals) { |   597     ZoneList<Variable*>* stack_locals, ZoneList<Variable*>* context_locals, | 
 |   598     ZoneList<Variable*>* strong_mode_free_variables) { | 
|   598   DCHECK(stack_locals != NULL); |   599   DCHECK(stack_locals != NULL); | 
|   599   DCHECK(context_locals != NULL); |   600   DCHECK(context_locals != NULL); | 
|   600  |   601  | 
|   601   // Collect internals which are always allocated on the heap. |   602   // Collect internals which are always allocated on the heap. | 
|   602   for (int i = 0; i < internals_.length(); i++) { |   603   for (int i = 0; i < internals_.length(); i++) { | 
|   603     Variable* var = internals_[i]; |   604     Variable* var = internals_[i]; | 
|   604     if (var->is_used()) { |   605     if (var->is_used()) { | 
|   605       DCHECK(var->IsContextSlot()); |   606       DCHECK(var->IsContextSlot()); | 
|   606       context_locals->Add(var, zone()); |   607       context_locals->Add(var, zone()); | 
|   607     } |   608     } | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   621       } |   622       } | 
|   622     } |   623     } | 
|   623   } |   624   } | 
|   624  |   625  | 
|   625   // Collect declared local variables. |   626   // Collect declared local variables. | 
|   626   ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); |   627   ZoneList<VarAndOrder> vars(variables_.occupancy(), zone()); | 
|   627   for (VariableMap::Entry* p = variables_.Start(); |   628   for (VariableMap::Entry* p = variables_.Start(); | 
|   628        p != NULL; |   629        p != NULL; | 
|   629        p = variables_.Next(p)) { |   630        p = variables_.Next(p)) { | 
|   630     Variable* var = reinterpret_cast<Variable*>(p->value); |   631     Variable* var = reinterpret_cast<Variable*>(p->value); | 
 |   632     if (is_strong(language_mode()) && strong_mode_free_variables && | 
 |   633         var->mode() == DYNAMIC_GLOBAL) { | 
 |   634       strong_mode_free_variables->Add(var, zone()); | 
 |   635     } | 
 |   636  | 
|   631     if (var->is_used()) { |   637     if (var->is_used()) { | 
|   632       vars.Add(VarAndOrder(var, p->order), zone()); |   638       vars.Add(VarAndOrder(var, p->order), zone()); | 
|   633     } |   639     } | 
|   634   } |   640   } | 
|   635   vars.Sort(VarAndOrder::Compare); |   641   vars.Sort(VarAndOrder::Compare); | 
|   636   int var_count = vars.length(); |   642   int var_count = vars.length(); | 
|   637   for (int i = 0; i < var_count; i++) { |   643   for (int i = 0; i < var_count; i++) { | 
|   638     Variable* var = vars[i].var(); |   644     Variable* var = vars[i].var(); | 
|   639     if (var->IsStackLocal()) { |   645     if (var->IsStackLocal()) { | 
|   640       stack_locals->Add(var, zone()); |   646       stack_locals->Add(var, zone()); | 
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1458       (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); |  1464       (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); | 
|  1459 } |  1465 } | 
|  1460  |  1466  | 
|  1461  |  1467  | 
|  1462 int Scope::ContextLocalCount() const { |  1468 int Scope::ContextLocalCount() const { | 
|  1463   if (num_heap_slots() == 0) return 0; |  1469   if (num_heap_slots() == 0) return 0; | 
|  1464   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |  1470   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 
|  1465       (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |  1471       (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 
|  1466 } |  1472 } | 
|  1467 } }  // namespace v8::internal |  1473 } }  // namespace v8::internal | 
| OLD | NEW |