| 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 3986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3997 // present; otherwise returns a value < 0. The name must be an internalized | 3997 // present; otherwise returns a value < 0. The name must be an internalized |
| 3998 // string. | 3998 // string. |
| 3999 int StackSlotIndex(String* name); | 3999 int StackSlotIndex(String* name); |
| 4000 | 4000 |
| 4001 // Lookup support for serialized scope info. Returns the | 4001 // Lookup support for serialized scope info. Returns the |
| 4002 // context slot index for a given slot name if the slot is present; otherwise | 4002 // context slot index for a given slot name if the slot is present; otherwise |
| 4003 // returns a value < 0. The name must be an internalized string. | 4003 // returns a value < 0. The name must be an internalized string. |
| 4004 // If the slot is present and mode != NULL, sets *mode to the corresponding | 4004 // If the slot is present and mode != NULL, sets *mode to the corresponding |
| 4005 // mode for that variable. | 4005 // mode for that variable. |
| 4006 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, | 4006 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, |
| 4007 VariableMode* mode, InitializationFlag* init_flag, | 4007 VariableMode* mode, |
| 4008 ContextSlotKindFlag* context_slot_kind, |
| 4009 InitializationFlag* init_flag, |
| 4008 MaybeAssignedFlag* maybe_assigned_flag); | 4010 MaybeAssignedFlag* maybe_assigned_flag); |
| 4009 | 4011 |
| 4010 // Lookup support for serialized scope info. Returns the | 4012 // Lookup support for serialized scope info. Returns the |
| 4011 // parameter index for a given parameter name if the parameter is present; | 4013 // parameter index for a given parameter name if the parameter is present; |
| 4012 // otherwise returns a value < 0. The name must be an internalized string. | 4014 // otherwise returns a value < 0. The name must be an internalized string. |
| 4013 int ParameterIndex(String* name); | 4015 int ParameterIndex(String* name); |
| 4014 | 4016 |
| 4015 // Lookup support for serialized scope info. Returns the function context | 4017 // Lookup support for serialized scope info. Returns the function context |
| 4016 // slot index if the function name is present and context-allocated (named | 4018 // slot index if the function name is present and context-allocated (named |
| 4017 // function expressions, only), otherwise returns a value < 0. The name | 4019 // function expressions, only), otherwise returns a value < 0. The name |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4048 // 2. The number of parameters. This only applies to function scopes. For | 4050 // 2. The number of parameters. This only applies to function scopes. For |
| 4049 // non-function scopes this is 0. | 4051 // non-function scopes this is 0. |
| 4050 // 3. The number of non-parameter variables allocated on the stack. | 4052 // 3. The number of non-parameter variables allocated on the stack. |
| 4051 // 4. The number of non-parameter and parameter variables allocated in the | 4053 // 4. The number of non-parameter and parameter variables allocated in the |
| 4052 // context. | 4054 // context. |
| 4053 #define FOR_EACH_NUMERIC_FIELD(V) \ | 4055 #define FOR_EACH_NUMERIC_FIELD(V) \ |
| 4054 V(Flags) \ | 4056 V(Flags) \ |
| 4055 V(ParameterCount) \ | 4057 V(ParameterCount) \ |
| 4056 V(StackLocalCount) \ | 4058 V(StackLocalCount) \ |
| 4057 V(ContextLocalCount) \ | 4059 V(ContextLocalCount) \ |
| 4060 V(ContextGlobalCount) \ |
| 4058 V(StrongModeFreeVariableCount) | 4061 V(StrongModeFreeVariableCount) |
| 4059 | 4062 |
| 4060 #define FIELD_ACCESSORS(name) \ | 4063 #define FIELD_ACCESSORS(name) \ |
| 4061 void Set##name(int value) { \ | 4064 void Set##name(int value) { \ |
| 4062 set(k##name, Smi::FromInt(value)); \ | 4065 set(k##name, Smi::FromInt(value)); \ |
| 4063 } \ | 4066 } \ |
| 4064 int name() { \ | 4067 int name() { \ |
| 4065 if (length() > 0) { \ | 4068 if (length() > 0) { \ |
| 4066 return Smi::cast(get(k##name))->value(); \ | 4069 return Smi::cast(get(k##name))->value(); \ |
| 4067 } else { \ | 4070 } else { \ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 // context or stack slot index for the variable. | 4119 // context or stack slot index for the variable. |
| 4117 // 9. FunctionNameEntryIndex: | 4120 // 9. FunctionNameEntryIndex: |
| 4118 // If the scope belongs to a named function expression this part contains | 4121 // If the scope belongs to a named function expression this part contains |
| 4119 // information about the function variable. It always occupies two array | 4122 // information about the function variable. It always occupies two array |
| 4120 // slots: a. The name of the function variable. | 4123 // slots: a. The name of the function variable. |
| 4121 // b. The context or stack slot index for the variable. | 4124 // b. The context or stack slot index for the variable. |
| 4122 int ParameterEntriesIndex(); | 4125 int ParameterEntriesIndex(); |
| 4123 int StackLocalFirstSlotIndex(); | 4126 int StackLocalFirstSlotIndex(); |
| 4124 int StackLocalEntriesIndex(); | 4127 int StackLocalEntriesIndex(); |
| 4125 int ContextLocalNameEntriesIndex(); | 4128 int ContextLocalNameEntriesIndex(); |
| 4129 int ContextGlobalNameEntriesIndex(); |
| 4126 int ContextLocalInfoEntriesIndex(); | 4130 int ContextLocalInfoEntriesIndex(); |
| 4131 int ContextGlobalInfoEntriesIndex(); |
| 4127 int StrongModeFreeVariableNameEntriesIndex(); | 4132 int StrongModeFreeVariableNameEntriesIndex(); |
| 4128 int StrongModeFreeVariablePositionEntriesIndex(); | 4133 int StrongModeFreeVariablePositionEntriesIndex(); |
| 4129 int ReceiverEntryIndex(); | 4134 int ReceiverEntryIndex(); |
| 4130 int FunctionNameEntryIndex(); | 4135 int FunctionNameEntryIndex(); |
| 4131 | 4136 |
| 4137 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, |
| 4138 ContextSlotKindFlag* context_slot_kind, |
| 4139 InitializationFlag* init_flag, |
| 4140 MaybeAssignedFlag* maybe_assigned_flag); |
| 4141 |
| 4132 // Used for the function name variable for named function expressions, and for | 4142 // Used for the function name variable for named function expressions, and for |
| 4133 // the receiver. | 4143 // the receiver. |
| 4134 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; | 4144 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; |
| 4135 | 4145 |
| 4136 // Properties of scopes. | 4146 // Properties of scopes. |
| 4137 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; | 4147 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; |
| 4138 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {}; | 4148 class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {}; |
| 4139 STATIC_ASSERT(LANGUAGE_END == 3); | 4149 STATIC_ASSERT(LANGUAGE_END == 3); |
| 4140 class LanguageModeField | 4150 class LanguageModeField |
| 4141 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {}; | 4151 : public BitField<LanguageMode, CallsEvalField::kNext, 2> {}; |
| (...skipping 6675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10817 } else { | 10827 } else { |
| 10818 value &= ~(1 << bit_position); | 10828 value &= ~(1 << bit_position); |
| 10819 } | 10829 } |
| 10820 return value; | 10830 return value; |
| 10821 } | 10831 } |
| 10822 }; | 10832 }; |
| 10823 | 10833 |
| 10824 } } // namespace v8::internal | 10834 } } // namespace v8::internal |
| 10825 | 10835 |
| 10826 #endif // V8_OBJECTS_H_ | 10836 #endif // V8_OBJECTS_H_ |
| OLD | NEW |