| OLD | NEW | 
|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 107   static SerializedScopeInfo* cast(Object* object) { | 107   static SerializedScopeInfo* cast(Object* object) { | 
| 108     ASSERT(object->IsFixedArray()); | 108     ASSERT(object->IsFixedArray()); | 
| 109     return reinterpret_cast<SerializedScopeInfo*>(object); | 109     return reinterpret_cast<SerializedScopeInfo*>(object); | 
| 110   } | 110   } | 
| 111 | 111 | 
| 112   // Does this scope call eval? | 112   // Does this scope call eval? | 
| 113   bool CallsEval(); | 113   bool CallsEval(); | 
| 114 | 114 | 
| 115   // Does this scope have an arguments shadow? | 115   // Does this scope have an arguments shadow? | 
| 116   bool HasArgumentsShadow() { | 116   bool HasArgumentsShadow() { | 
| 117     return StackSlotIndex(Heap::arguments_shadow_symbol()) >= 0; | 117     return StackSlotIndex(GetHeap()->arguments_shadow_symbol()) >= 0; | 
| 118   } | 118   } | 
| 119 | 119 | 
| 120   // Return the number of stack slots for code. | 120   // Return the number of stack slots for code. | 
| 121   int NumberOfStackSlots(); | 121   int NumberOfStackSlots(); | 
| 122 | 122 | 
| 123   // Return the number of context slots for code. | 123   // Return the number of context slots for code. | 
| 124   int NumberOfContextSlots(); | 124   int NumberOfContextSlots(); | 
| 125 | 125 | 
| 126   // Return if this has context slots besides MIN_CONTEXT_SLOTS; | 126   // Return if this has context slots besides MIN_CONTEXT_SLOTS; | 
| 127   bool HasHeapAllocatedLocals(); | 127   bool HasHeapAllocatedLocals(); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 166 | 166 | 
| 167 | 167 | 
| 168 // Cache for mapping (data, property name) into context slot index. | 168 // Cache for mapping (data, property name) into context slot index. | 
| 169 // The cache contains both positive and negative results. | 169 // The cache contains both positive and negative results. | 
| 170 // Slot index equals -1 means the property is absent. | 170 // Slot index equals -1 means the property is absent. | 
| 171 // Cleared at startup and prior to mark sweep collection. | 171 // Cleared at startup and prior to mark sweep collection. | 
| 172 class ContextSlotCache { | 172 class ContextSlotCache { | 
| 173  public: | 173  public: | 
| 174   // Lookup context slot index for (data, name). | 174   // Lookup context slot index for (data, name). | 
| 175   // If absent, kNotFound is returned. | 175   // If absent, kNotFound is returned. | 
| 176   static int Lookup(Object* data, | 176   int Lookup(Object* data, | 
| 177                     String* name, | 177              String* name, | 
| 178                     Variable::Mode* mode); | 178              Variable::Mode* mode); | 
| 179 | 179 | 
| 180   // Update an element in the cache. | 180   // Update an element in the cache. | 
| 181   static void Update(Object* data, | 181   void Update(Object* data, | 
|  | 182               String* name, | 
|  | 183               Variable::Mode mode, | 
|  | 184               int slot_index); | 
|  | 185 | 
|  | 186   // Clear the cache. | 
|  | 187   void Clear(); | 
|  | 188 | 
|  | 189   static const int kNotFound = -2; | 
|  | 190  private: | 
|  | 191   ContextSlotCache() { | 
|  | 192     for (int i = 0; i < kLength; ++i) { | 
|  | 193       keys_[i].data = NULL; | 
|  | 194       keys_[i].name = NULL; | 
|  | 195       values_[i] = kNotFound; | 
|  | 196     } | 
|  | 197   } | 
|  | 198 | 
|  | 199   inline static int Hash(Object* data, String* name); | 
|  | 200 | 
|  | 201 #ifdef DEBUG | 
|  | 202   void ValidateEntry(Object* data, | 
| 182                      String* name, | 203                      String* name, | 
| 183                      Variable::Mode mode, | 204                      Variable::Mode mode, | 
| 184                      int slot_index); | 205                      int slot_index); | 
| 185 |  | 
| 186   // Clear the cache. |  | 
| 187   static void Clear(); |  | 
| 188 |  | 
| 189   static const int kNotFound = -2; |  | 
| 190  private: |  | 
| 191   inline static int Hash(Object* data, String* name); |  | 
| 192 |  | 
| 193 #ifdef DEBUG |  | 
| 194   static void ValidateEntry(Object* data, |  | 
| 195                             String* name, |  | 
| 196                             Variable::Mode mode, |  | 
| 197                             int slot_index); |  | 
| 198 #endif | 206 #endif | 
| 199 | 207 | 
| 200   static const int kLength = 256; | 208   static const int kLength = 256; | 
| 201   struct Key { | 209   struct Key { | 
| 202     Object* data; | 210     Object* data; | 
| 203     String* name; | 211     String* name; | 
| 204   }; | 212   }; | 
| 205 | 213 | 
| 206   struct Value { | 214   struct Value { | 
| 207     Value(Variable::Mode mode, int index) { | 215     Value(Variable::Mode mode, int index) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 221     int index() { return IndexField::decode(value_); } | 229     int index() { return IndexField::decode(value_); } | 
| 222 | 230 | 
| 223     // Bit fields in value_ (type, shift, size). Must be public so the | 231     // Bit fields in value_ (type, shift, size). Must be public so the | 
| 224     // constants can be embedded in generated code. | 232     // constants can be embedded in generated code. | 
| 225     class ModeField:  public BitField<Variable::Mode, 0, 3> {}; | 233     class ModeField:  public BitField<Variable::Mode, 0, 3> {}; | 
| 226     class IndexField: public BitField<int,            3, 32-3> {}; | 234     class IndexField: public BitField<int,            3, 32-3> {}; | 
| 227    private: | 235    private: | 
| 228     uint32_t value_; | 236     uint32_t value_; | 
| 229   }; | 237   }; | 
| 230 | 238 | 
| 231   static Key keys_[kLength]; | 239   Key keys_[kLength]; | 
| 232   static uint32_t values_[kLength]; | 240   uint32_t values_[kLength]; | 
|  | 241 | 
|  | 242   friend class Isolate; | 
|  | 243   DISALLOW_COPY_AND_ASSIGN(ContextSlotCache); | 
| 233 }; | 244 }; | 
| 234 | 245 | 
| 235 | 246 | 
| 236 } }  // namespace v8::internal | 247 } }  // namespace v8::internal | 
| 237 | 248 | 
| 238 #endif  // V8_SCOPEINFO_H_ | 249 #endif  // V8_SCOPEINFO_H_ | 
| OLD | NEW | 
|---|