| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 4342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4353 | 4353 |
| 4354 // Lookup support for serialized scope info. Returns the local context slot | 4354 // Lookup support for serialized scope info. Returns the local context slot |
| 4355 // index for a given slot name if the slot is present; otherwise | 4355 // index for a given slot name if the slot is present; otherwise |
| 4356 // returns a value < 0. The name must be an internalized string. | 4356 // returns a value < 0. The name must be an internalized string. |
| 4357 // If the slot is present and mode != NULL, sets *mode to the corresponding | 4357 // If the slot is present and mode != NULL, sets *mode to the corresponding |
| 4358 // mode for that variable. | 4358 // mode for that variable. |
| 4359 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, | 4359 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, |
| 4360 VariableMode* mode, InitializationFlag* init_flag, | 4360 VariableMode* mode, InitializationFlag* init_flag, |
| 4361 MaybeAssignedFlag* maybe_assigned_flag); | 4361 MaybeAssignedFlag* maybe_assigned_flag); |
| 4362 | 4362 |
| 4363 // Similar to ContextSlotIndex() but this method searches only among | |
| 4364 // global slots of the serialized scope info. Returns the context slot index | |
| 4365 // for a given slot name if the slot is present; otherwise returns a | |
| 4366 // value < 0. The name must be an internalized string. If the slot is present | |
| 4367 // and mode != NULL, sets *mode to the corresponding mode for that variable. | |
| 4368 static int ContextGlobalSlotIndex(Handle<ScopeInfo> scope_info, | |
| 4369 Handle<String> name, VariableMode* mode, | |
| 4370 InitializationFlag* init_flag, | |
| 4371 MaybeAssignedFlag* maybe_assigned_flag); | |
| 4372 | |
| 4373 // Lookup the name of a certain context slot by its index. | 4363 // Lookup the name of a certain context slot by its index. |
| 4374 String* ContextSlotName(int slot_index); | 4364 String* ContextSlotName(int slot_index); |
| 4375 | 4365 |
| 4376 // Lookup support for serialized scope info. Returns the | 4366 // Lookup support for serialized scope info. Returns the |
| 4377 // parameter index for a given parameter name if the parameter is present; | 4367 // parameter index for a given parameter name if the parameter is present; |
| 4378 // otherwise returns a value < 0. The name must be an internalized string. | 4368 // otherwise returns a value < 0. The name must be an internalized string. |
| 4379 int ParameterIndex(String* name); | 4369 int ParameterIndex(String* name); |
| 4380 | 4370 |
| 4381 // Lookup support for serialized scope info. Returns the function context | 4371 // Lookup support for serialized scope info. Returns the function context |
| 4382 // slot index if the function name is present and context-allocated (named | 4372 // slot index if the function name is present and context-allocated (named |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4406 // 1. A set of properties of the scope | 4396 // 1. A set of properties of the scope |
| 4407 // 2. The number of parameters. This only applies to function scopes. For | 4397 // 2. The number of parameters. This only applies to function scopes. For |
| 4408 // non-function scopes this is 0. | 4398 // non-function scopes this is 0. |
| 4409 // 3. The number of non-parameter variables allocated on the stack. | 4399 // 3. The number of non-parameter variables allocated on the stack. |
| 4410 // 4. The number of non-parameter and parameter variables allocated in the | 4400 // 4. The number of non-parameter and parameter variables allocated in the |
| 4411 // context. | 4401 // context. |
| 4412 #define FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(V) \ | 4402 #define FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(V) \ |
| 4413 V(Flags) \ | 4403 V(Flags) \ |
| 4414 V(ParameterCount) \ | 4404 V(ParameterCount) \ |
| 4415 V(StackLocalCount) \ | 4405 V(StackLocalCount) \ |
| 4416 V(ContextLocalCount) \ | 4406 V(ContextLocalCount) |
| 4417 V(ContextGlobalCount) | |
| 4418 | 4407 |
| 4419 #define FIELD_ACCESSORS(name) \ | 4408 #define FIELD_ACCESSORS(name) \ |
| 4420 inline void Set##name(int value); \ | 4409 inline void Set##name(int value); \ |
| 4421 inline int name(); | 4410 inline int name(); |
| 4422 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS) | 4411 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS) |
| 4423 #undef FIELD_ACCESSORS | 4412 #undef FIELD_ACCESSORS |
| 4424 | 4413 |
| 4425 enum { | 4414 enum { |
| 4426 #define DECL_INDEX(name) k##name, | 4415 #define DECL_INDEX(name) k##name, |
| 4427 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(DECL_INDEX) | 4416 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(DECL_INDEX) |
| 4428 #undef DECL_INDEX | 4417 #undef DECL_INDEX |
| 4429 kVariablePartIndex | 4418 kVariablePartIndex |
| 4430 }; | 4419 }; |
| 4431 | 4420 |
| 4432 private: | 4421 private: |
| 4433 // The layout of the variable part of a ScopeInfo is as follows: | 4422 // The layout of the variable part of a ScopeInfo is as follows: |
| 4434 // 1. ParameterEntries: | 4423 // 1. ParameterEntries: |
| 4435 // This part stores the names of the parameters for function scopes. One | 4424 // This part stores the names of the parameters for function scopes. One |
| 4436 // slot is used per parameter, so in total this part occupies | 4425 // slot is used per parameter, so in total this part occupies |
| 4437 // ParameterCount() slots in the array. For other scopes than function | 4426 // ParameterCount() slots in the array. For other scopes than function |
| 4438 // scopes ParameterCount() is 0. | 4427 // scopes ParameterCount() is 0. |
| 4439 // 2. StackLocalFirstSlot: | 4428 // 2. StackLocalFirstSlot: |
| 4440 // Index of a first stack slot for stack local. Stack locals belonging to | 4429 // Index of a first stack slot for stack local. Stack locals belonging to |
| 4441 // this scope are located on a stack at slots starting from this index. | 4430 // this scope are located on a stack at slots starting from this index. |
| 4442 // 3. StackLocalEntries: | 4431 // 3. StackLocalEntries: |
| 4443 // Contains the names of local variables that are allocated on the stack, | 4432 // Contains the names of local variables that are allocated on the stack, |
| 4444 // in increasing order of the stack slot index. First local variable has | 4433 // in increasing order of the stack slot index. First local variable has a |
| 4445 // a stack slot index defined in StackLocalFirstSlot (point 2 above). | 4434 // stack slot index defined in StackLocalFirstSlot (point 2 above). |
| 4446 // One slot is used per stack local, so in total this part occupies | 4435 // One slot is used per stack local, so in total this part occupies |
| 4447 // StackLocalCount() slots in the array. | 4436 // StackLocalCount() slots in the array. |
| 4448 // 4. ContextLocalNameEntries: | 4437 // 4. ContextLocalNameEntries: |
| 4449 // Contains the names of local variables and parameters that are allocated | 4438 // Contains the names of local variables and parameters that are allocated |
| 4450 // in the context. They are stored in increasing order of the context slot | 4439 // in the context. They are stored in increasing order of the context slot |
| 4451 // index starting with Context::MIN_CONTEXT_SLOTS. One slot is used per | 4440 // index starting with Context::MIN_CONTEXT_SLOTS. One slot is used per |
| 4452 // context local, so in total this part occupies ContextLocalCount() slots | 4441 // context local, so in total this part occupies ContextLocalCount() slots |
| 4453 // in the array. | 4442 // in the array. |
| 4454 // 5. ContextLocalInfoEntries: | 4443 // 5. ContextLocalInfoEntries: |
| 4455 // Contains the variable modes and initialization flags corresponding to | 4444 // Contains the variable modes and initialization flags corresponding to |
| 4456 // the context locals in ContextLocalNameEntries. One slot is used per | 4445 // the context locals in ContextLocalNameEntries. One slot is used per |
| 4457 // context local, so in total this part occupies ContextLocalCount() | 4446 // context local, so in total this part occupies ContextLocalCount() |
| 4458 // slots in the array. | 4447 // slots in the array. |
| 4459 // 6. RecieverEntryIndex: | 4448 // 6. RecieverEntryIndex: |
| 4460 // If the scope binds a "this" value, one slot is reserved to hold the | 4449 // If the scope binds a "this" value, one slot is reserved to hold the |
| 4461 // context or stack slot index for the variable. | 4450 // context or stack slot index for the variable. |
| 4462 // 7. FunctionNameEntryIndex: | 4451 // 7. FunctionNameEntryIndex: |
| 4463 // If the scope belongs to a named function expression this part contains | 4452 // If the scope belongs to a named function expression this part contains |
| 4464 // information about the function variable. It always occupies two array | 4453 // information about the function variable. It always occupies two array |
| 4465 // slots: a. The name of the function variable. | 4454 // slots: a. The name of the function variable. |
| 4466 // b. The context or stack slot index for the variable. | 4455 // b. The context or stack slot index for the variable. |
| 4467 int ParameterEntriesIndex(); | 4456 int ParameterEntriesIndex(); |
| 4468 int StackLocalFirstSlotIndex(); | 4457 int StackLocalFirstSlotIndex(); |
| 4469 int StackLocalEntriesIndex(); | 4458 int StackLocalEntriesIndex(); |
| 4470 int ContextLocalNameEntriesIndex(); | 4459 int ContextLocalNameEntriesIndex(); |
| 4471 int ContextGlobalNameEntriesIndex(); | |
| 4472 int ContextLocalInfoEntriesIndex(); | 4460 int ContextLocalInfoEntriesIndex(); |
| 4473 int ContextGlobalInfoEntriesIndex(); | |
| 4474 int ReceiverEntryIndex(); | 4461 int ReceiverEntryIndex(); |
| 4475 int FunctionNameEntryIndex(); | 4462 int FunctionNameEntryIndex(); |
| 4476 | 4463 |
| 4477 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, | 4464 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, |
| 4478 VariableLocation* location, InitializationFlag* init_flag, | 4465 VariableLocation* location, InitializationFlag* init_flag, |
| 4479 MaybeAssignedFlag* maybe_assigned_flag); | 4466 MaybeAssignedFlag* maybe_assigned_flag); |
| 4480 | 4467 |
| 4481 // Used for the function name variable for named function expressions, and for | 4468 // Used for the function name variable for named function expressions, and for |
| 4482 // the receiver. | 4469 // the receiver. |
| 4483 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; | 4470 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; |
| (...skipping 6693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11177 } | 11164 } |
| 11178 return value; | 11165 return value; |
| 11179 } | 11166 } |
| 11180 }; | 11167 }; |
| 11181 | 11168 |
| 11182 | 11169 |
| 11183 } // NOLINT, false-positive due to second-order macros. | 11170 } // NOLINT, false-positive due to second-order macros. |
| 11184 } // NOLINT, false-positive due to second-order macros. | 11171 } // NOLINT, false-positive due to second-order macros. |
| 11185 | 11172 |
| 11186 #endif // V8_OBJECTS_H_ | 11173 #endif // V8_OBJECTS_H_ |
| OLD | NEW |