| 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 17 matching lines...) Expand all Loading... |
| 28 #ifndef V8_SCOPEINFO_H_ | 28 #ifndef V8_SCOPEINFO_H_ |
| 29 #define V8_SCOPEINFO_H_ | 29 #define V8_SCOPEINFO_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "variables.h" | 32 #include "variables.h" |
| 33 #include "zone-inl.h" | 33 #include "zone-inl.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 // ScopeInfo represents information about different scopes of a source | |
| 39 // program and the allocation of the scope's variables. Scope information | |
| 40 // is stored in a compressed form in SerializedScopeInfo objects and is used | |
| 41 // at runtime (stack dumps, deoptimization, etc.). | |
| 42 | |
| 43 // Forward defined as | |
| 44 // template <class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; | |
| 45 template<class Allocator> | |
| 46 class ScopeInfo BASE_EMBEDDED { | |
| 47 public: | |
| 48 // Create a ScopeInfo instance from a scope. | |
| 49 explicit ScopeInfo(Scope* scope); | |
| 50 | |
| 51 // Create a ScopeInfo instance from SerializedScopeInfo. | |
| 52 explicit ScopeInfo(SerializedScopeInfo* data); | |
| 53 | |
| 54 // Creates a SerializedScopeInfo holding the serialized scope info. | |
| 55 Handle<SerializedScopeInfo> Serialize(); | |
| 56 | |
| 57 // -------------------------------------------------------------------------- | |
| 58 // Lookup | |
| 59 | |
| 60 Handle<String> function_name() const { return function_name_; } | |
| 61 | |
| 62 Handle<String> parameter_name(int i) const { return parameters_[i]; } | |
| 63 int number_of_parameters() const { return parameters_.length(); } | |
| 64 | |
| 65 Handle<String> stack_slot_name(int i) const { return stack_slots_[i]; } | |
| 66 int number_of_stack_slots() const { return stack_slots_.length(); } | |
| 67 | |
| 68 Handle<String> context_slot_name(int i) const { | |
| 69 return context_slots_[i - Context::MIN_CONTEXT_SLOTS]; | |
| 70 } | |
| 71 int number_of_context_slots() const { | |
| 72 int l = context_slots_.length(); | |
| 73 return l == 0 ? 0 : l + Context::MIN_CONTEXT_SLOTS; | |
| 74 } | |
| 75 | |
| 76 Handle<String> LocalName(int i) const; | |
| 77 int NumberOfLocals() const; | |
| 78 | |
| 79 ScopeType type() const { return type_; } | |
| 80 // -------------------------------------------------------------------------- | |
| 81 // Debugging support | |
| 82 | |
| 83 #ifdef DEBUG | |
| 84 void Print(); | |
| 85 #endif | |
| 86 | |
| 87 private: | |
| 88 Handle<String> function_name_; | |
| 89 bool calls_eval_; | |
| 90 bool is_strict_mode_; | |
| 91 ScopeType type_; | |
| 92 List<Handle<String>, Allocator > parameters_; | |
| 93 List<Handle<String>, Allocator > stack_slots_; | |
| 94 List<Handle<String>, Allocator > context_slots_; | |
| 95 List<VariableMode, Allocator > context_modes_; | |
| 96 }; | |
| 97 | |
| 98 | |
| 99 // Cache for mapping (data, property name) into context slot index. | 38 // Cache for mapping (data, property name) into context slot index. |
| 100 // The cache contains both positive and negative results. | 39 // The cache contains both positive and negative results. |
| 101 // Slot index equals -1 means the property is absent. | 40 // Slot index equals -1 means the property is absent. |
| 102 // Cleared at startup and prior to mark sweep collection. | 41 // Cleared at startup and prior to mark sweep collection. |
| 103 class ContextSlotCache { | 42 class ContextSlotCache { |
| 104 public: | 43 public: |
| 105 // Lookup context slot index for (data, name). | 44 // Lookup context slot index for (data, name). |
| 106 // If absent, kNotFound is returned. | 45 // If absent, kNotFound is returned. |
| 107 int Lookup(Object* data, | 46 int Lookup(Object* data, |
| 108 String* name, | 47 String* name, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 uint32_t values_[kLength]; | 111 uint32_t values_[kLength]; |
| 173 | 112 |
| 174 friend class Isolate; | 113 friend class Isolate; |
| 175 DISALLOW_COPY_AND_ASSIGN(ContextSlotCache); | 114 DISALLOW_COPY_AND_ASSIGN(ContextSlotCache); |
| 176 }; | 115 }; |
| 177 | 116 |
| 178 | 117 |
| 179 } } // namespace v8::internal | 118 } } // namespace v8::internal |
| 180 | 119 |
| 181 #endif // V8_SCOPEINFO_H_ | 120 #endif // V8_SCOPEINFO_H_ |
| OLD | NEW |