| 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 4373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4384 // must be an internalized string. | 4384 // must be an internalized string. |
| 4385 int FunctionContextSlotIndex(String* name); | 4385 int FunctionContextSlotIndex(String* name); |
| 4386 | 4386 |
| 4387 // Lookup support for serialized scope info. Returns the receiver context | 4387 // Lookup support for serialized scope info. Returns the receiver context |
| 4388 // slot index if scope has a "this" binding, and the binding is | 4388 // slot index if scope has a "this" binding, and the binding is |
| 4389 // context-allocated. Otherwise returns a value < 0. | 4389 // context-allocated. Otherwise returns a value < 0. |
| 4390 int ReceiverContextSlotIndex(); | 4390 int ReceiverContextSlotIndex(); |
| 4391 | 4391 |
| 4392 FunctionKind function_kind(); | 4392 FunctionKind function_kind(); |
| 4393 | 4393 |
| 4394 static Handle<ScopeInfo> Create(Isolate* isolate, Zone* zone, Scope* scope); | 4394 // Returns true if this ScopeInfo is linked to a outer ScopeInfo. |
| 4395 static Handle<ScopeInfo> CreateForWithScope(Isolate* isolate); | 4395 bool HasOuterScopeInfo(); |
| 4396 |
| 4397 // Return the outer ScopeInfo if present. |
| 4398 ScopeInfo* OuterScopeInfo(); |
| 4399 |
| 4400 #ifdef DEBUG |
| 4401 bool Equals(ScopeInfo* other) const; |
| 4402 #endif |
| 4403 |
| 4404 static Handle<ScopeInfo> Create(Isolate* isolate, Zone* zone, Scope* scope, |
| 4405 MaybeHandle<ScopeInfo> outer_scope); |
| 4406 static Handle<ScopeInfo> CreateForWithScope( |
| 4407 Isolate* isolate, MaybeHandle<ScopeInfo> outer_scope); |
| 4396 static Handle<ScopeInfo> CreateGlobalThisBinding(Isolate* isolate); | 4408 static Handle<ScopeInfo> CreateGlobalThisBinding(Isolate* isolate); |
| 4397 | 4409 |
| 4398 // Serializes empty scope info. | 4410 // Serializes empty scope info. |
| 4399 static ScopeInfo* Empty(Isolate* isolate); | 4411 static ScopeInfo* Empty(Isolate* isolate); |
| 4400 | 4412 |
| 4401 #ifdef DEBUG | 4413 #ifdef DEBUG |
| 4402 void Print(); | 4414 void Print(); |
| 4403 #endif | 4415 #endif |
| 4404 | 4416 |
| 4405 // The layout of the static part of a ScopeInfo is as follows. Each entry is | 4417 // The layout of the static part of a ScopeInfo is as follows. Each entry is |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4456 // context local, so in total this part occupies ContextLocalCount() | 4468 // context local, so in total this part occupies ContextLocalCount() |
| 4457 // slots in the array. | 4469 // slots in the array. |
| 4458 // 6. ReceiverEntry: | 4470 // 6. ReceiverEntry: |
| 4459 // If the scope binds a "this" value, one slot is reserved to hold the | 4471 // If the scope binds a "this" value, one slot is reserved to hold the |
| 4460 // context or stack slot index for the variable. | 4472 // context or stack slot index for the variable. |
| 4461 // 7. FunctionNameEntry: | 4473 // 7. FunctionNameEntry: |
| 4462 // If the scope belongs to a named function expression this part contains | 4474 // If the scope belongs to a named function expression this part contains |
| 4463 // information about the function variable. It always occupies two array | 4475 // information about the function variable. It always occupies two array |
| 4464 // slots: a. The name of the function variable. | 4476 // slots: a. The name of the function variable. |
| 4465 // b. The context or stack slot index for the variable. | 4477 // b. The context or stack slot index for the variable. |
| 4466 // 8. ModuleInfoEntry, ModuleVariableCount, and ModuleVariableEntries: | 4478 // 8. OuterScopeInfoEntryIndex: |
| 4479 // The outer scope's ScopeInfo or the hole if there's none. |
| 4480 // 9. ModuleInfoEntry, ModuleVariableCount, and ModuleVariableEntries: |
| 4467 // For a module scope, this part contains the ModuleInfo, the number of | 4481 // For a module scope, this part contains the ModuleInfo, the number of |
| 4468 // MODULE-allocated variables, and the metadata of those variables. For | 4482 // MODULE-allocated variables, and the metadata of those variables. For |
| 4469 // non-module scopes it is empty. | 4483 // non-module scopes it is empty. |
| 4470 int ParameterEntriesIndex(); | 4484 int ParameterEntriesIndex(); |
| 4471 int StackLocalFirstSlotIndex(); | 4485 int StackLocalFirstSlotIndex(); |
| 4472 int StackLocalEntriesIndex(); | 4486 int StackLocalEntriesIndex(); |
| 4473 int ContextLocalNameEntriesIndex(); | 4487 int ContextLocalNameEntriesIndex(); |
| 4474 int ContextLocalInfoEntriesIndex(); | 4488 int ContextLocalInfoEntriesIndex(); |
| 4475 int ReceiverEntryIndex(); | 4489 int ReceiverEntryIndex(); |
| 4476 int FunctionNameEntryIndex(); | 4490 int FunctionNameEntryIndex(); |
| 4491 int OuterScopeInfoEntryIndex(); |
| 4477 int ModuleInfoEntryIndex(); | 4492 int ModuleInfoEntryIndex(); |
| 4478 int ModuleVariableCountIndex(); | 4493 int ModuleVariableCountIndex(); |
| 4479 int ModuleVariableEntriesIndex(); | 4494 int ModuleVariableEntriesIndex(); |
| 4480 | 4495 |
| 4481 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, | 4496 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, |
| 4482 VariableLocation* location, InitializationFlag* init_flag, | 4497 VariableLocation* location, InitializationFlag* init_flag, |
| 4483 MaybeAssignedFlag* maybe_assigned_flag); | 4498 MaybeAssignedFlag* maybe_assigned_flag); |
| 4484 | 4499 |
| 4485 // Used for the function name variable for named function expressions, and for | 4500 // Used for the function name variable for named function expressions, and for |
| 4486 // the receiver. | 4501 // the receiver. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4501 : public BitField<bool, ReceiverVariableField::kNext, 1> {}; | 4516 : public BitField<bool, ReceiverVariableField::kNext, 1> {}; |
| 4502 class FunctionVariableField | 4517 class FunctionVariableField |
| 4503 : public BitField<VariableAllocationInfo, HasNewTargetField::kNext, 2> {}; | 4518 : public BitField<VariableAllocationInfo, HasNewTargetField::kNext, 2> {}; |
| 4504 class AsmModuleField | 4519 class AsmModuleField |
| 4505 : public BitField<bool, FunctionVariableField::kNext, 1> {}; | 4520 : public BitField<bool, FunctionVariableField::kNext, 1> {}; |
| 4506 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {}; | 4521 class AsmFunctionField : public BitField<bool, AsmModuleField::kNext, 1> {}; |
| 4507 class HasSimpleParametersField | 4522 class HasSimpleParametersField |
| 4508 : public BitField<bool, AsmFunctionField::kNext, 1> {}; | 4523 : public BitField<bool, AsmFunctionField::kNext, 1> {}; |
| 4509 class FunctionKindField | 4524 class FunctionKindField |
| 4510 : public BitField<FunctionKind, HasSimpleParametersField::kNext, 9> {}; | 4525 : public BitField<FunctionKind, HasSimpleParametersField::kNext, 9> {}; |
| 4526 class HasOuterScopeInfoField |
| 4527 : public BitField<bool, FunctionKindField::kNext, 1> {}; |
| 4511 | 4528 |
| 4512 // Properties of variables. | 4529 // Properties of variables. |
| 4513 class VariableModeField : public BitField<VariableMode, 0, 3> {}; | 4530 class VariableModeField : public BitField<VariableMode, 0, 3> {}; |
| 4514 class InitFlagField : public BitField<InitializationFlag, 3, 1> {}; | 4531 class InitFlagField : public BitField<InitializationFlag, 3, 1> {}; |
| 4515 class MaybeAssignedFlagField : public BitField<MaybeAssignedFlag, 4, 1> {}; | 4532 class MaybeAssignedFlagField : public BitField<MaybeAssignedFlag, 4, 1> {}; |
| 4516 | 4533 |
| 4517 friend class ScopeIterator; | 4534 friend class ScopeIterator; |
| 4518 }; | 4535 }; |
| 4519 | 4536 |
| 4520 // ModuleInfo is to ModuleDescriptor what ScopeInfo is to Scope. | 4537 // ModuleInfo is to ModuleDescriptor what ScopeInfo is to Scope. |
| 4521 class ModuleInfo : public FixedArray { | 4538 class ModuleInfo : public FixedArray { |
| 4522 public: | 4539 public: |
| 4523 DECLARE_CAST(ModuleInfo) | 4540 DECLARE_CAST(ModuleInfo) |
| 4524 static Handle<ModuleInfo> New(Isolate* isolate, ModuleDescriptor* descr); | 4541 static Handle<ModuleInfo> New(Isolate* isolate, ModuleDescriptor* descr); |
| 4525 inline FixedArray* special_exports() const; | 4542 inline FixedArray* special_exports() const; |
| 4526 inline FixedArray* regular_exports() const; | 4543 inline FixedArray* regular_exports() const; |
| 4527 | 4544 |
| 4545 #ifdef DEBUG |
| 4546 inline bool Equals(ModuleInfo* other) const; |
| 4547 #endif |
| 4548 |
| 4528 private: | 4549 private: |
| 4529 friend class Factory; | 4550 friend class Factory; |
| 4530 enum { kSpecialExportsIndex, kRegularExportsIndex, kLength }; | 4551 enum { kSpecialExportsIndex, kRegularExportsIndex, kLength }; |
| 4531 }; | 4552 }; |
| 4532 | 4553 |
| 4533 // The cache for maps used by normalized (dictionary mode) objects. | 4554 // The cache for maps used by normalized (dictionary mode) objects. |
| 4534 // Such maps do not have property descriptors, so a typical program | 4555 // Such maps do not have property descriptors, so a typical program |
| 4535 // needs very limited number of distinct normalized maps. | 4556 // needs very limited number of distinct normalized maps. |
| 4536 class NormalizedMapCache: public FixedArray { | 4557 class NormalizedMapCache: public FixedArray { |
| 4537 public: | 4558 public: |
| (...skipping 6666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11204 } | 11225 } |
| 11205 return value; | 11226 return value; |
| 11206 } | 11227 } |
| 11207 }; | 11228 }; |
| 11208 | 11229 |
| 11209 | 11230 |
| 11210 } // NOLINT, false-positive due to second-order macros. | 11231 } // NOLINT, false-positive due to second-order macros. |
| 11211 } // NOLINT, false-positive due to second-order macros. | 11232 } // NOLINT, false-positive due to second-order macros. |
| 11212 | 11233 |
| 11213 #endif // V8_OBJECTS_H_ | 11234 #endif // V8_OBJECTS_H_ |
| OLD | NEW |