Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: src/objects.h

Issue 2277253003: [modules] Partial scope info support of modules (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@modules-refactor
Patch Set: This is so much fun. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // - MapCache 87 // - MapCache
88 // - OrderedHashTable 88 // - OrderedHashTable
89 // - OrderedHashSet 89 // - OrderedHashSet
90 // - OrderedHashMap 90 // - OrderedHashMap
91 // - Context 91 // - Context
92 // - TypeFeedbackMetadata 92 // - TypeFeedbackMetadata
93 // - TypeFeedbackVector 93 // - TypeFeedbackVector
94 // - TemplateList 94 // - TemplateList
95 // - TransitionArray 95 // - TransitionArray
96 // - ScopeInfo 96 // - ScopeInfo
97 // - ModuleInfo
97 // - ScriptContextTable 98 // - ScriptContextTable
98 // - WeakFixedArray 99 // - WeakFixedArray
99 // - FixedDoubleArray 100 // - FixedDoubleArray
100 // - Name 101 // - Name
101 // - String 102 // - String
102 // - SeqString 103 // - SeqString
103 // - SeqOneByteString 104 // - SeqOneByteString
104 // - SeqTwoByteString 105 // - SeqTwoByteString
105 // - SlicedString 106 // - SlicedString
106 // - ConsString 107 // - ConsString
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 class ConsString; 873 class ConsString;
873 class ElementsAccessor; 874 class ElementsAccessor;
874 class FixedArrayBase; 875 class FixedArrayBase;
875 class FunctionLiteral; 876 class FunctionLiteral;
876 class JSGlobalObject; 877 class JSGlobalObject;
877 class KeyAccumulator; 878 class KeyAccumulator;
878 class LayoutDescriptor; 879 class LayoutDescriptor;
879 class LiteralsArray; 880 class LiteralsArray;
880 class LookupIterator; 881 class LookupIterator;
881 class FieldType; 882 class FieldType;
883 class ModuleDescriptor;
884 class ModuleInfo;
882 class ObjectHashTable; 885 class ObjectHashTable;
883 class ObjectVisitor; 886 class ObjectVisitor;
884 class PropertyCell; 887 class PropertyCell;
885 class PropertyDescriptor; 888 class PropertyDescriptor;
886 class SafepointEntry; 889 class SafepointEntry;
887 class SharedFunctionInfo; 890 class SharedFunctionInfo;
888 class StringStream; 891 class StringStream;
889 class TypeFeedbackInfo; 892 class TypeFeedbackInfo;
890 class TypeFeedbackMetadata; 893 class TypeFeedbackMetadata;
891 class TypeFeedbackVector; 894 class TypeFeedbackVector;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 V(DependentCode) \ 975 V(DependentCode) \
973 V(HandlerTable) \ 976 V(HandlerTable) \
974 V(FixedArray) \ 977 V(FixedArray) \
975 V(FixedDoubleArray) \ 978 V(FixedDoubleArray) \
976 V(WeakFixedArray) \ 979 V(WeakFixedArray) \
977 V(ArrayList) \ 980 V(ArrayList) \
978 V(Context) \ 981 V(Context) \
979 V(ScriptContextTable) \ 982 V(ScriptContextTable) \
980 V(NativeContext) \ 983 V(NativeContext) \
981 V(ScopeInfo) \ 984 V(ScopeInfo) \
985 V(ModuleInfo) \
982 V(JSBoundFunction) \ 986 V(JSBoundFunction) \
983 V(JSFunction) \ 987 V(JSFunction) \
984 V(Code) \ 988 V(Code) \
985 V(AbstractCode) \ 989 V(AbstractCode) \
986 V(Oddball) \ 990 V(Oddball) \
987 V(SharedFunctionInfo) \ 991 V(SharedFunctionInfo) \
988 V(JSValue) \ 992 V(JSValue) \
989 V(JSDate) \ 993 V(JSDate) \
990 V(JSMessageObject) \ 994 V(JSMessageObject) \
991 V(StringWrapper) \ 995 V(StringWrapper) \
(...skipping 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 inline bool IsAsmModule(); 4314 inline bool IsAsmModule();
4311 4315
4312 // Return if this is a nested function within an asm module scope. 4316 // Return if this is a nested function within an asm module scope.
4313 inline bool IsAsmFunction(); 4317 inline bool IsAsmFunction();
4314 4318
4315 inline bool HasSimpleParameters(); 4319 inline bool HasSimpleParameters();
4316 4320
4317 // Return the function_name if present. 4321 // Return the function_name if present.
4318 String* FunctionName(); 4322 String* FunctionName();
4319 4323
4324 ModuleInfo* ModuleDescriptorInfo();
4325
4320 // Return the name of the given parameter. 4326 // Return the name of the given parameter.
4321 String* ParameterName(int var); 4327 String* ParameterName(int var);
4322 4328
4323 // Return the name of the given local. 4329 // Return the name of the given local.
4324 String* LocalName(int var); 4330 String* LocalName(int var);
4325 4331
4326 // Return the name of the given stack local. 4332 // Return the name of the given stack local.
4327 String* StackLocalName(int var); 4333 String* StackLocalName(int var);
4328 4334
4329 // Return the name of the given stack local. 4335 // Return the name of the given stack local.
(...skipping 23 matching lines...) Expand all
4353 4359
4354 // Lookup support for serialized scope info. Returns the local context slot 4360 // Lookup support for serialized scope info. Returns the local context slot
4355 // index for a given slot name if the slot is present; otherwise 4361 // index for a given slot name if the slot is present; otherwise
4356 // returns a value < 0. The name must be an internalized string. 4362 // 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 4363 // If the slot is present and mode != NULL, sets *mode to the corresponding
4358 // mode for that variable. 4364 // mode for that variable.
4359 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name, 4365 static int ContextSlotIndex(Handle<ScopeInfo> scope_info, Handle<String> name,
4360 VariableMode* mode, InitializationFlag* init_flag, 4366 VariableMode* mode, InitializationFlag* init_flag,
4361 MaybeAssignedFlag* maybe_assigned_flag); 4367 MaybeAssignedFlag* maybe_assigned_flag);
4362 4368
4369 // Lookup metadata of a MODULE-allocated variable. Return a negative value if
4370 // there is no module variable with the given name.
4371 int ModuleIndex(Handle<String> name, VariableMode* mode,
4372 InitializationFlag* init_flag,
4373 MaybeAssignedFlag* maybe_assigned_flag);
4374
4363 // Lookup the name of a certain context slot by its index. 4375 // Lookup the name of a certain context slot by its index.
4364 String* ContextSlotName(int slot_index); 4376 String* ContextSlotName(int slot_index);
4365 4377
4366 // Lookup support for serialized scope info. Returns the 4378 // Lookup support for serialized scope info. Returns the
4367 // parameter index for a given parameter name if the parameter is present; 4379 // parameter index for a given parameter name if the parameter is present;
4368 // otherwise returns a value < 0. The name must be an internalized string. 4380 // otherwise returns a value < 0. The name must be an internalized string.
4369 int ParameterIndex(String* name); 4381 int ParameterIndex(String* name);
4370 4382
4371 // Lookup support for serialized scope info. Returns the function context 4383 // Lookup support for serialized scope info. Returns the function context
4372 // slot index if the function name is present and context-allocated (named 4384 // slot index if the function name is present and context-allocated (named
(...skipping 14 matching lines...) Expand all
4387 // Serializes empty scope info. 4399 // Serializes empty scope info.
4388 static ScopeInfo* Empty(Isolate* isolate); 4400 static ScopeInfo* Empty(Isolate* isolate);
4389 4401
4390 #ifdef DEBUG 4402 #ifdef DEBUG
4391 void Print(); 4403 void Print();
4392 #endif 4404 #endif
4393 4405
4394 // The layout of the static part of a ScopeInfo is as follows. Each entry is 4406 // The layout of the static part of a ScopeInfo is as follows. Each entry is
4395 // numeric and occupies one array slot. 4407 // numeric and occupies one array slot.
4396 // 1. A set of properties of the scope 4408 // 1. A set of properties of the scope
4397 // 2. The number of parameters. This only applies to function scopes. For 4409 // 2. The number of parameters. For non-function scopes this is 0.
4398 // non-function scopes this is 0. 4410 // 3. The number of non-parameter variables allocated on the stack.
4399 // 3. The number of non-parameter variables allocated on the stack. 4411 // 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 4412 // context.
4401 // context.
4402 #define FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(V) \ 4413 #define FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(V) \
4403 V(Flags) \ 4414 V(Flags) \
4404 V(ParameterCount) \ 4415 V(ParameterCount) \
4405 V(StackLocalCount) \ 4416 V(StackLocalCount) \
4406 V(ContextLocalCount) 4417 V(ContextLocalCount)
4407 4418
4408 #define FIELD_ACCESSORS(name) \ 4419 #define FIELD_ACCESSORS(name) \
4409 inline void Set##name(int value); \ 4420 inline void Set##name(int value); \
4410 inline int name(); 4421 inline int name();
4411 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS) 4422 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS)
(...skipping 26 matching lines...) Expand all
4438 // Contains the names of local variables and parameters that are allocated 4449 // Contains the names of local variables and parameters that are allocated
4439 // in the context. They are stored in increasing order of the context slot 4450 // in the context. They are stored in increasing order of the context slot
4440 // index starting with Context::MIN_CONTEXT_SLOTS. One slot is used per 4451 // index starting with Context::MIN_CONTEXT_SLOTS. One slot is used per
4441 // context local, so in total this part occupies ContextLocalCount() slots 4452 // context local, so in total this part occupies ContextLocalCount() slots
4442 // in the array. 4453 // in the array.
4443 // 5. ContextLocalInfoEntries: 4454 // 5. ContextLocalInfoEntries:
4444 // Contains the variable modes and initialization flags corresponding to 4455 // Contains the variable modes and initialization flags corresponding to
4445 // the context locals in ContextLocalNameEntries. One slot is used per 4456 // the context locals in ContextLocalNameEntries. One slot is used per
4446 // context local, so in total this part occupies ContextLocalCount() 4457 // context local, so in total this part occupies ContextLocalCount()
4447 // slots in the array. 4458 // slots in the array.
4448 // 6. RecieverEntryIndex: 4459 // 6. ReceiverEntry:
4449 // If the scope binds a "this" value, one slot is reserved to hold the 4460 // If the scope binds a "this" value, one slot is reserved to hold the
4450 // context or stack slot index for the variable. 4461 // context or stack slot index for the variable.
4451 // 7. FunctionNameEntryIndex: 4462 // 7. FunctionNameEntry:
4452 // If the scope belongs to a named function expression this part contains 4463 // If the scope belongs to a named function expression this part contains
4453 // information about the function variable. It always occupies two array 4464 // information about the function variable. It always occupies two array
4454 // slots: a. The name of the function variable. 4465 // slots: a. The name of the function variable.
4455 // b. The context or stack slot index for the variable. 4466 // b. The context or stack slot index for the variable.
4467 // 8. ModuleInfoEntry, ModuleVariableCount, and ModuleVariableEntries:
4468 // For a module scope, this part contains the ModuleInfo, the number of
4469 // MODULE-allocated variables, and the metadata of those variables. For
4470 // non-module scopes it is empty.
4456 int ParameterEntriesIndex(); 4471 int ParameterEntriesIndex();
4457 int StackLocalFirstSlotIndex(); 4472 int StackLocalFirstSlotIndex();
4458 int StackLocalEntriesIndex(); 4473 int StackLocalEntriesIndex();
4459 int ContextLocalNameEntriesIndex(); 4474 int ContextLocalNameEntriesIndex();
4460 int ContextLocalInfoEntriesIndex(); 4475 int ContextLocalInfoEntriesIndex();
4461 int ReceiverEntryIndex(); 4476 int ReceiverEntryIndex();
4462 int FunctionNameEntryIndex(); 4477 int FunctionNameEntryIndex();
4478 int ModuleInfoEntryIndex();
4479 int ModuleVariableCountIndex();
4480 int ModuleVariableEntriesIndex();
4463 4481
4464 int Lookup(Handle<String> name, int start, int end, VariableMode* mode, 4482 int Lookup(Handle<String> name, int start, int end, VariableMode* mode,
4465 VariableLocation* location, InitializationFlag* init_flag, 4483 VariableLocation* location, InitializationFlag* init_flag,
4466 MaybeAssignedFlag* maybe_assigned_flag); 4484 MaybeAssignedFlag* maybe_assigned_flag);
4467 4485
4468 // Used for the function name variable for named function expressions, and for 4486 // Used for the function name variable for named function expressions, and for
4469 // the receiver. 4487 // the receiver.
4470 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED }; 4488 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
4471 4489
4472 // Properties of scopes. 4490 // Properties of scopes.
(...skipping 22 matching lines...) Expand all
4495 : public BitField<FunctionKind, HasSimpleParametersField::kNext, 9> {}; 4513 : public BitField<FunctionKind, HasSimpleParametersField::kNext, 9> {};
4496 4514
4497 // Properties of variables. 4515 // Properties of variables.
4498 class VariableModeField : public BitField<VariableMode, 0, 3> {}; 4516 class VariableModeField : public BitField<VariableMode, 0, 3> {};
4499 class InitFlagField : public BitField<InitializationFlag, 3, 1> {}; 4517 class InitFlagField : public BitField<InitializationFlag, 3, 1> {};
4500 class MaybeAssignedFlagField : public BitField<MaybeAssignedFlag, 4, 1> {}; 4518 class MaybeAssignedFlagField : public BitField<MaybeAssignedFlag, 4, 1> {};
4501 4519
4502 friend class ScopeIterator; 4520 friend class ScopeIterator;
4503 }; 4521 };
4504 4522
4523 // ModuleInfo is to ModuleDescriptor what ScopeInfo is to Scope.
4524 class ModuleInfo : public FixedArray {
4525 public:
4526 DECLARE_CAST(ModuleInfo)
4527 static Handle<ModuleInfo> New(Isolate* isolate, ModuleDescriptor* descr);
4528 inline FixedArray* special_exports() const;
4529 inline FixedArray* regular_exports() const;
4530
4531 private:
4532 friend class Factory;
4533 enum { kSpecialExportsIndex, kRegularExportsIndex, kLength };
4534 };
4505 4535
4506 // The cache for maps used by normalized (dictionary mode) objects. 4536 // The cache for maps used by normalized (dictionary mode) objects.
4507 // Such maps do not have property descriptors, so a typical program 4537 // Such maps do not have property descriptors, so a typical program
4508 // needs very limited number of distinct normalized maps. 4538 // needs very limited number of distinct normalized maps.
4509 class NormalizedMapCache: public FixedArray { 4539 class NormalizedMapCache: public FixedArray {
4510 public: 4540 public:
4511 static Handle<NormalizedMapCache> New(Isolate* isolate); 4541 static Handle<NormalizedMapCache> New(Isolate* isolate);
4512 4542
4513 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map, 4543 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map,
4514 PropertyNormalizationMode mode); 4544 PropertyNormalizationMode mode);
(...skipping 6658 matching lines...) Expand 10 before | Expand all | Expand 10 after
11173 } 11203 }
11174 return value; 11204 return value;
11175 } 11205 }
11176 }; 11206 };
11177 11207
11178 11208
11179 } // NOLINT, false-positive due to second-order macros. 11209 } // NOLINT, false-positive due to second-order macros.
11180 } // NOLINT, false-positive due to second-order macros. 11210 } // NOLINT, false-positive due to second-order macros.
11181 11211
11182 #endif // V8_OBJECTS_H_ 11212 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698