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 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 3993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4004 // present; otherwise returns a value < 0. The name must be an internalized | 4004 // present; otherwise returns a value < 0. The name must be an internalized |
4005 // string. | 4005 // string. |
4006 int StackSlotIndex(String* name); | 4006 int StackSlotIndex(String* name); |
4007 | 4007 |
4008 // Lookup support for serialized scope info. Returns the | 4008 // Lookup support for serialized scope info. Returns the |
4009 // context slot index for a given slot name if the slot is present; otherwise | 4009 // context slot index for a given slot name if the slot is present; otherwise |
4010 // returns a value < 0. The name must be an internalized string. | 4010 // returns a value < 0. The name must be an internalized string. |
4011 // If the slot is present and mode != NULL, sets *mode to the corresponding | 4011 // If the slot is present and mode != NULL, sets *mode to the corresponding |
4012 // mode for that variable. | 4012 // mode for that variable. |
4013 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, | 4013 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, |
4014 VariableMode* mode, InitializationFlag* init_flag, | 4014 VariableMode* mode, VariableLocation* location, |
| 4015 InitializationFlag* init_flag, |
4015 MaybeAssignedFlag* maybe_assigned_flag); | 4016 MaybeAssignedFlag* maybe_assigned_flag); |
4016 | 4017 |
4017 // Lookup support for serialized scope info. Returns the | 4018 // Lookup support for serialized scope info. Returns the |
4018 // parameter index for a given parameter name if the parameter is present; | 4019 // parameter index for a given parameter name if the parameter is present; |
4019 // otherwise returns a value < 0. The name must be an internalized string. | 4020 // otherwise returns a value < 0. The name must be an internalized string. |
4020 int ParameterIndex(String* name); | 4021 int ParameterIndex(String* name); |
4021 | 4022 |
4022 // Lookup support for serialized scope info. Returns the function context | 4023 // Lookup support for serialized scope info. Returns the function context |
4023 // slot index if the function name is present and context-allocated (named | 4024 // slot index if the function name is present and context-allocated (named |
4024 // function expressions, only), otherwise returns a value < 0. The name | 4025 // function expressions, only), otherwise returns a value < 0. The name |
(...skipping 29 matching lines...) Expand all Loading... |
4054 // 2. The number of parameters. This only applies to function scopes. For | 4055 // 2. The number of parameters. This only applies to function scopes. For |
4055 // non-function scopes this is 0. | 4056 // non-function scopes this is 0. |
4056 // 3. The number of non-parameter variables allocated on the stack. | 4057 // 3. The number of non-parameter variables allocated on the stack. |
4057 // 4. The number of non-parameter and parameter variables allocated in the | 4058 // 4. The number of non-parameter and parameter variables allocated in the |
4058 // context. | 4059 // context. |
4059 #define FOR_EACH_NUMERIC_FIELD(V) \ | 4060 #define FOR_EACH_NUMERIC_FIELD(V) \ |
4060 V(Flags) \ | 4061 V(Flags) \ |
4061 V(ParameterCount) \ | 4062 V(ParameterCount) \ |
4062 V(StackLocalCount) \ | 4063 V(StackLocalCount) \ |
4063 V(ContextLocalCount) \ | 4064 V(ContextLocalCount) \ |
| 4065 V(ContextGlobalCount) \ |
4064 V(StrongModeFreeVariableCount) | 4066 V(StrongModeFreeVariableCount) |
4065 | 4067 |
4066 #define FIELD_ACCESSORS(name) \ | 4068 #define FIELD_ACCESSORS(name) \ |
4067 void Set##name(int value) { \ | 4069 void Set##name(int value) { \ |
4068 set(k##name, Smi::FromInt(value)); \ | 4070 set(k##name, Smi::FromInt(value)); \ |
4069 } \ | 4071 } \ |
4070 int name() { \ | 4072 int name() { \ |
4071 if (length() > 0) { \ | 4073 if (length() > 0) { \ |
4072 return Smi::cast(get(k##name))->value(); \ | 4074 return Smi::cast(get(k##name))->value(); \ |
4073 } else { \ | 4075 } else { \ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4122 // context or stack slot index for the variable. | 4124 // context or stack slot index for the variable. |
4123 // 9. FunctionNameEntryIndex: | 4125 // 9. FunctionNameEntryIndex: |
4124 // If the scope belongs to a named function expression this part contains | 4126 // If the scope belongs to a named function expression this part contains |
4125 // information about the function variable. It always occupies two array | 4127 // information about the function variable. It always occupies two array |
4126 // slots: a. The name of the function variable. | 4128 // slots: a. The name of the function variable. |
4127 // b. The context or stack slot index for the variable. | 4129 // b. The context or stack slot index for the variable. |
4128 int ParameterEntriesIndex(); | 4130 int ParameterEntriesIndex(); |
4129 int StackLocalFirstSlotIndex(); | 4131 int StackLocalFirstSlotIndex(); |
4130 int StackLocalEntriesIndex(); | 4132 int StackLocalEntriesIndex(); |
4131 int ContextLocalNameEntriesIndex(); | 4133 int ContextLocalNameEntriesIndex(); |
| 4134 int ContextGlobalNameEntriesIndex(); |
4132 int ContextLocalInfoEntriesIndex(); | 4135 int ContextLocalInfoEntriesIndex(); |
| 4136 int ContextGlobalInfoEntriesIndex(); |
4133 int StrongModeFreeVariableNameEntriesIndex(); | 4137 int StrongModeFreeVariableNameEntriesIndex(); |
4134 int StrongModeFreeVariablePositionEntriesIndex(); | 4138 int StrongModeFreeVariablePositionEntriesIndex(); |
4135 int ReceiverEntryIndex(); | 4139 int ReceiverEntryIndex(); |
4136 int FunctionNameEntryIndex(); | 4140 int FunctionNameEntryIndex(); |
4137 | 4141 |
| 4142 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, |
| 4143 VariableLocation* location, InitializationFlag* init_flag, |
| 4144 MaybeAssignedFlag* maybe_assigned_flag); |
| 4145 |
4138 // Used for the function name variable for named function expressions, and for | 4146 // Used for the function name variable for named function expressions, and for |
4139 // the receiver. | 4147 // the receiver. |
4140 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; | 4148 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; |
4141 | 4149 |
4142 // Properties of scopes. | 4150 // Properties of scopes. |
4143 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; | 4151 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; |
4144 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {}; | 4152 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {}; |
4145 STATIC_ASSERT(LANGUAGE_END == 3); | 4153 STATIC_ASSERT(LANGUAGE_END == 3); |
4146 class LanguageModeField | 4154 class LanguageModeField |
4147 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {}; | 4155 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {}; |
(...skipping 6676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10824 } else { | 10832 } else { |
10825 value &= ~(1 << bit_position); | 10833 value &= ~(1 << bit_position); |
10826 } | 10834 } |
10827 return value; | 10835 return value; |
10828 } | 10836 } |
10829 }; | 10837 }; |
10830 | 10838 |
10831 } } // namespace v8::internal | 10839 } } // namespace v8::internal |
10832 | 10840 |
10833 #endif // V8_OBJECTS_H_ | 10841 #endif // V8_OBJECTS_H_ |
OLD | NEW |