| 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 28 matching lines...) Expand all Loading... |
| 39 // and the allocation of the scope's variables. Scope information | 39 // and the allocation of the scope's variables. Scope information |
| 40 // is stored in a compressed form with Code objects and is used | 40 // is stored in a compressed form with Code objects and is used |
| 41 // at runtime (stack dumps, deoptimization, etc.). | 41 // at runtime (stack dumps, deoptimization, etc.). |
| 42 // | 42 // |
| 43 // Historical note: In other VMs built by this team, ScopeInfo was | 43 // Historical note: In other VMs built by this team, ScopeInfo was |
| 44 // usually called DebugInfo since the information was used (among | 44 // usually called DebugInfo since the information was used (among |
| 45 // other things) for on-demand debugging (Self, Smalltalk). However, | 45 // other things) for on-demand debugging (Self, Smalltalk). However, |
| 46 // DebugInfo seems misleading, since this information is primarily used | 46 // DebugInfo seems misleading, since this information is primarily used |
| 47 // in debugging-unrelated contexts. | 47 // in debugging-unrelated contexts. |
| 48 | 48 |
| 49 // Define state of the function execution. It reflects whether locals are |
| 50 // available or not. |
| 51 enum FunctionScopeState { |
| 52 // Function is in a normal state. |
| 53 FUNCTION_SCOPE_NORMAL, |
| 54 |
| 55 // LiveEdit stack manipulation has reset the function execution: |
| 56 // all below frame pointer (arguments, 'this' and outer context) is |
| 57 // available, but locals are not. |
| 58 FUNCTION_SCOPE_NOT_ENTERED |
| 59 }; |
| 60 |
| 49 // Forward defined as | 61 // Forward defined as |
| 50 // template <class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; | 62 // template <class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; |
| 51 template<class Allocator> | 63 template<class Allocator> |
| 52 class ScopeInfo BASE_EMBEDDED { | 64 class ScopeInfo BASE_EMBEDDED { |
| 53 public: | 65 public: |
| 54 // Create a ScopeInfo instance from a scope. | 66 // Create a ScopeInfo instance from a scope. |
| 55 explicit ScopeInfo(Scope* scope); | 67 explicit ScopeInfo(Scope* scope); |
| 56 | 68 |
| 57 // Create a ScopeInfo instance from a Code object. | 69 // Create a ScopeInfo instance from a Code object. |
| 58 explicit ScopeInfo(Code* code); | 70 explicit ScopeInfo(Code* code, FunctionScopeState scope_state); |
| 59 | 71 |
| 60 // Write the ScopeInfo data into a Code object, and returns the | 72 // Write the ScopeInfo data into a Code object, and returns the |
| 61 // amount of space that was needed. If no Code object is provided | 73 // amount of space that was needed. If no Code object is provided |
| 62 // (NULL handle), Serialize() only returns the amount of space needed. | 74 // (NULL handle), Serialize() only returns the amount of space needed. |
| 63 // | 75 // |
| 64 // This operations requires that the Code object has the correct amount | 76 // This operations requires that the Code object has the correct amount |
| 65 // of space for the ScopeInfo data; otherwise the operation fails (fatal | 77 // of space for the ScopeInfo data; otherwise the operation fails (fatal |
| 66 // error). Any existing scope info in the Code object is simply overwritten. | 78 // error). Any existing scope info in the Code object is simply overwritten. |
| 67 int Serialize(Code* code); | 79 int Serialize(Code* code); |
| 68 | 80 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 List<Variable::Mode, Allocator > context_modes_; | 167 List<Variable::Mode, Allocator > context_modes_; |
| 156 }; | 168 }; |
| 157 | 169 |
| 158 class ZoneScopeInfo: public ScopeInfo<ZoneListAllocationPolicy> { | 170 class ZoneScopeInfo: public ScopeInfo<ZoneListAllocationPolicy> { |
| 159 public: | 171 public: |
| 160 // Create a ZoneScopeInfo instance from a scope. | 172 // Create a ZoneScopeInfo instance from a scope. |
| 161 explicit ZoneScopeInfo(Scope* scope) | 173 explicit ZoneScopeInfo(Scope* scope) |
| 162 : ScopeInfo<ZoneListAllocationPolicy>(scope) {} | 174 : ScopeInfo<ZoneListAllocationPolicy>(scope) {} |
| 163 | 175 |
| 164 // Create a ZoneScopeInfo instance from a Code object. | 176 // Create a ZoneScopeInfo instance from a Code object. |
| 165 explicit ZoneScopeInfo(Code* code) | 177 explicit ZoneScopeInfo(Code* code, FunctionScopeState scope_state) |
| 166 : ScopeInfo<ZoneListAllocationPolicy>(code) {} | 178 : ScopeInfo<ZoneListAllocationPolicy>(code, scope_state) {} |
| 167 }; | 179 }; |
| 168 | 180 |
| 169 | 181 |
| 170 // Cache for mapping (code, property name) into context slot index. | 182 // Cache for mapping (code, property name) into context slot index. |
| 171 // The cache contains both positive and negative results. | 183 // The cache contains both positive and negative results. |
| 172 // Slot index equals -1 means the property is absent. | 184 // Slot index equals -1 means the property is absent. |
| 173 // Cleared at startup and prior to mark sweep collection. | 185 // Cleared at startup and prior to mark sweep collection. |
| 174 class ContextSlotCache { | 186 class ContextSlotCache { |
| 175 public: | 187 public: |
| 176 // Lookup context slot index for (code, name). | 188 // Lookup context slot index for (code, name). |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 }; | 243 }; |
| 232 | 244 |
| 233 static Key keys_[kLength]; | 245 static Key keys_[kLength]; |
| 234 static uint32_t values_[kLength]; | 246 static uint32_t values_[kLength]; |
| 235 }; | 247 }; |
| 236 | 248 |
| 237 | 249 |
| 238 } } // namespace v8::internal | 250 } } // namespace v8::internal |
| 239 | 251 |
| 240 #endif // V8_SCOPEINFO_H_ | 252 #endif // V8_SCOPEINFO_H_ |
| OLD | NEW |