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 | 38 // Scope information represents information about a functions's |
39 // program and the allocation of the scope's variables. Scope information | 39 // scopes (currently only one, because we don't do any inlining) |
40 // is stored in a compressed form in SerializedScopeInfo objects and is used | 40 // and the allocation of the scope's variables. Scope information |
| 41 // is stored in a compressed form in FixedArray objects and is used |
41 // at runtime (stack dumps, deoptimization, etc.). | 42 // at runtime (stack dumps, deoptimization, etc.). |
| 43 // |
| 44 // Historical note: In other VMs built by this team, ScopeInfo was |
| 45 // usually called DebugInfo since the information was used (among |
| 46 // other things) for on-demand debugging (Self, Smalltalk). However, |
| 47 // DebugInfo seems misleading, since this information is primarily used |
| 48 // in debugging-unrelated contexts. |
42 | 49 |
43 // Forward defined as | 50 // Forward defined as |
44 // template <class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; | 51 // template <class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; |
45 template<class Allocator> | 52 template<class Allocator> |
46 class ScopeInfo BASE_EMBEDDED { | 53 class ScopeInfo BASE_EMBEDDED { |
47 public: | 54 public: |
48 // Create a ScopeInfo instance from a scope. | 55 // Create a ScopeInfo instance from a scope. |
49 explicit ScopeInfo(Scope* scope); | 56 explicit ScopeInfo(Scope* scope); |
50 | 57 |
51 // Create a ScopeInfo instance from SerializedScopeInfo. | 58 // Create a ScopeInfo instance from SerializedScopeInfo. |
(...skipping 17 matching lines...) Expand all Loading... |
69 return context_slots_[i - Context::MIN_CONTEXT_SLOTS]; | 76 return context_slots_[i - Context::MIN_CONTEXT_SLOTS]; |
70 } | 77 } |
71 int number_of_context_slots() const { | 78 int number_of_context_slots() const { |
72 int l = context_slots_.length(); | 79 int l = context_slots_.length(); |
73 return l == 0 ? 0 : l + Context::MIN_CONTEXT_SLOTS; | 80 return l == 0 ? 0 : l + Context::MIN_CONTEXT_SLOTS; |
74 } | 81 } |
75 | 82 |
76 Handle<String> LocalName(int i) const; | 83 Handle<String> LocalName(int i) const; |
77 int NumberOfLocals() const; | 84 int NumberOfLocals() const; |
78 | 85 |
79 ScopeType type() const { return type_; } | |
80 // -------------------------------------------------------------------------- | 86 // -------------------------------------------------------------------------- |
81 // Debugging support | 87 // Debugging support |
82 | 88 |
83 #ifdef DEBUG | 89 #ifdef DEBUG |
84 void Print(); | 90 void Print(); |
85 #endif | 91 #endif |
86 | 92 |
87 private: | 93 private: |
88 Handle<String> function_name_; | 94 Handle<String> function_name_; |
89 bool calls_eval_; | 95 bool calls_eval_; |
90 bool is_strict_mode_; | 96 bool is_strict_mode_; |
91 ScopeType type_; | |
92 List<Handle<String>, Allocator > parameters_; | 97 List<Handle<String>, Allocator > parameters_; |
93 List<Handle<String>, Allocator > stack_slots_; | 98 List<Handle<String>, Allocator > stack_slots_; |
94 List<Handle<String>, Allocator > context_slots_; | 99 List<Handle<String>, Allocator > context_slots_; |
95 List<VariableMode, Allocator > context_modes_; | 100 List<VariableMode, Allocator > context_modes_; |
96 }; | 101 }; |
97 | 102 |
98 | 103 |
99 // Cache for mapping (data, property name) into context slot index. | 104 // Cache for mapping (data, property name) into context slot index. |
100 // The cache contains both positive and negative results. | 105 // The cache contains both positive and negative results. |
101 // Slot index equals -1 means the property is absent. | 106 // Slot index equals -1 means the property is absent. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 uint32_t values_[kLength]; | 177 uint32_t values_[kLength]; |
173 | 178 |
174 friend class Isolate; | 179 friend class Isolate; |
175 DISALLOW_COPY_AND_ASSIGN(ContextSlotCache); | 180 DISALLOW_COPY_AND_ASSIGN(ContextSlotCache); |
176 }; | 181 }; |
177 | 182 |
178 | 183 |
179 } } // namespace v8::internal | 184 } } // namespace v8::internal |
180 | 185 |
181 #endif // V8_SCOPEINFO_H_ | 186 #endif // V8_SCOPEINFO_H_ |
OLD | NEW |