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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 class LookupIterator; | 944 class LookupIterator; |
945 class FieldType; | 945 class FieldType; |
946 class Module; | 946 class Module; |
947 class ModuleDescriptor; | 947 class ModuleDescriptor; |
948 class ModuleInfoEntry; | 948 class ModuleInfoEntry; |
949 class ModuleInfo; | 949 class ModuleInfo; |
950 class ObjectHashTable; | 950 class ObjectHashTable; |
951 class ObjectVisitor; | 951 class ObjectVisitor; |
952 class PropertyCell; | 952 class PropertyCell; |
953 class PropertyDescriptor; | 953 class PropertyDescriptor; |
| 954 class RootVisitor; |
954 class SafepointEntry; | 955 class SafepointEntry; |
955 class SharedFunctionInfo; | 956 class SharedFunctionInfo; |
956 class StringStream; | 957 class StringStream; |
957 class TypeFeedbackInfo; | 958 class TypeFeedbackInfo; |
958 class FeedbackMetadata; | 959 class FeedbackMetadata; |
959 class FeedbackVector; | 960 class FeedbackVector; |
960 class WeakCell; | 961 class WeakCell; |
961 class TransitionArray; | 962 class TransitionArray; |
962 class TemplateList; | 963 class TemplateList; |
963 | 964 |
(...skipping 7738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8702 }; | 8703 }; |
8703 | 8704 |
8704 | 8705 |
8705 // Utility superclass for stack-allocated objects that must be updated | 8706 // Utility superclass for stack-allocated objects that must be updated |
8706 // on gc. It provides two ways for the gc to update instances, either | 8707 // on gc. It provides two ways for the gc to update instances, either |
8707 // iterating or updating after gc. | 8708 // iterating or updating after gc. |
8708 class Relocatable BASE_EMBEDDED { | 8709 class Relocatable BASE_EMBEDDED { |
8709 public: | 8710 public: |
8710 explicit inline Relocatable(Isolate* isolate); | 8711 explicit inline Relocatable(Isolate* isolate); |
8711 inline virtual ~Relocatable(); | 8712 inline virtual ~Relocatable(); |
8712 virtual void IterateInstance(ObjectVisitor* v) { } | 8713 virtual void IterateInstance(RootVisitor* v) {} |
8713 virtual void PostGarbageCollection() { } | 8714 virtual void PostGarbageCollection() { } |
8714 | 8715 |
8715 static void PostGarbageCollectionProcessing(Isolate* isolate); | 8716 static void PostGarbageCollectionProcessing(Isolate* isolate); |
8716 static int ArchiveSpacePerThread(); | 8717 static int ArchiveSpacePerThread(); |
8717 static char* ArchiveState(Isolate* isolate, char* to); | 8718 static char* ArchiveState(Isolate* isolate, char* to); |
8718 static char* RestoreState(Isolate* isolate, char* from); | 8719 static char* RestoreState(Isolate* isolate, char* from); |
8719 static void Iterate(Isolate* isolate, ObjectVisitor* v); | 8720 static void Iterate(Isolate* isolate, RootVisitor* v); |
8720 static void Iterate(ObjectVisitor* v, Relocatable* top); | 8721 static void Iterate(RootVisitor* v, Relocatable* top); |
8721 static char* Iterate(ObjectVisitor* v, char* t); | 8722 static char* Iterate(RootVisitor* v, char* t); |
8722 | 8723 |
8723 private: | 8724 private: |
8724 Isolate* isolate_; | 8725 Isolate* isolate_; |
8725 Relocatable* prev_; | 8726 Relocatable* prev_; |
8726 }; | 8727 }; |
8727 | 8728 |
8728 | 8729 |
8729 // A flat string reader provides random access to the contents of a | 8730 // A flat string reader provides random access to the contents of a |
8730 // string independent of the character width of the string. The handle | 8731 // string independent of the character width of the string. The handle |
8731 // must be valid as long as the reader is being used. | 8732 // must be valid as long as the reader is being used. |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10134 | 10135 |
10135 private: | 10136 private: |
10136 // Bit position in the flag, from least significant bit position. | 10137 // Bit position in the flag, from least significant bit position. |
10137 static const int kIsEvalBit = 0; | 10138 static const int kIsEvalBit = 0; |
10138 static const int kIsConstructorBit = 1; | 10139 static const int kIsConstructorBit = 1; |
10139 static const int kIsWasmBit = 2; | 10140 static const int kIsWasmBit = 2; |
10140 | 10141 |
10141 DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrameInfo); | 10142 DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrameInfo); |
10142 }; | 10143 }; |
10143 | 10144 |
10144 #define VISITOR_SYNCHRONIZATION_TAGS_LIST(V) \ | |
10145 V(kStringTable, "string_table", "(Internalized strings)") \ | |
10146 V(kExternalStringsTable, "external_strings_table", "(External strings)") \ | |
10147 V(kStrongRootList, "strong_root_list", "(Strong roots)") \ | |
10148 V(kSmiRootList, "smi_root_list", "(Smi roots)") \ | |
10149 V(kBootstrapper, "bootstrapper", "(Bootstrapper)") \ | |
10150 V(kTop, "top", "(Isolate)") \ | |
10151 V(kRelocatable, "relocatable", "(Relocatable)") \ | |
10152 V(kDebug, "debug", "(Debugger)") \ | |
10153 V(kCompilationCache, "compilationcache", "(Compilation cache)") \ | |
10154 V(kHandleScope, "handlescope", "(Handle scope)") \ | |
10155 V(kDispatchTable, "dispatchtable", "(Dispatch table)") \ | |
10156 V(kBuiltins, "builtins", "(Builtins)") \ | |
10157 V(kGlobalHandles, "globalhandles", "(Global handles)") \ | |
10158 V(kEternalHandles, "eternalhandles", "(Eternal handles)") \ | |
10159 V(kThreadManager, "threadmanager", "(Thread manager)") \ | |
10160 V(kStrongRoots, "strong roots", "(Strong roots)") \ | |
10161 V(kExtensions, "Extensions", "(Extensions)") | |
10162 | |
10163 class VisitorSynchronization : public AllStatic { | |
10164 public: | |
10165 #define DECLARE_ENUM(enum_item, ignore1, ignore2) enum_item, | |
10166 enum SyncTag { | |
10167 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_ENUM) | |
10168 kNumberOfSyncTags | |
10169 }; | |
10170 #undef DECLARE_ENUM | |
10171 | |
10172 static const char* const kTags[kNumberOfSyncTags]; | |
10173 static const char* const kTagNames[kNumberOfSyncTags]; | |
10174 }; | |
10175 | |
10176 // Abstract base class for visiting, and optionally modifying, the | 10145 // Abstract base class for visiting, and optionally modifying, the |
10177 // pointers contained in Objects. Used in GC and serialization/deserialization. | 10146 // pointers contained in Objects. Used in GC and serialization/deserialization. |
| 10147 // TODO(ulan): move to src/visitors.h |
10178 class ObjectVisitor BASE_EMBEDDED { | 10148 class ObjectVisitor BASE_EMBEDDED { |
10179 public: | 10149 public: |
10180 virtual ~ObjectVisitor() {} | 10150 virtual ~ObjectVisitor() {} |
10181 | 10151 |
10182 // Visits a contiguous arrays of pointers in the half-open range | 10152 // Visits a contiguous arrays of pointers in the half-open range |
10183 // [start, end). Any or all of the values may be modified on return. | 10153 // [start, end). Any or all of the values may be modified on return. |
10184 virtual void VisitPointers(Object** start, Object** end) = 0; | 10154 virtual void VisitPointers(Object** start, Object** end) = 0; |
10185 | 10155 |
10186 // Handy shorthand for visiting a single pointer. | 10156 // Handy shorthand for visiting a single pointer. |
10187 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 10157 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
(...skipping 27 matching lines...) Expand all Loading... |
10215 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); | 10185 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); |
10216 | 10186 |
10217 // Visits an external reference embedded into a code object. | 10187 // Visits an external reference embedded into a code object. |
10218 virtual void VisitExternalReference(RelocInfo* rinfo); | 10188 virtual void VisitExternalReference(RelocInfo* rinfo); |
10219 | 10189 |
10220 // Visits an external reference. | 10190 // Visits an external reference. |
10221 virtual void VisitExternalReference(Address* p) {} | 10191 virtual void VisitExternalReference(Address* p) {} |
10222 | 10192 |
10223 // Visits an (encoded) internal reference. | 10193 // Visits an (encoded) internal reference. |
10224 virtual void VisitInternalReference(RelocInfo* rinfo) {} | 10194 virtual void VisitInternalReference(RelocInfo* rinfo) {} |
10225 | |
10226 // Intended for serialization/deserialization checking: insert, or | |
10227 // check for the presence of, a tag at this position in the stream. | |
10228 // Also used for marking up GC roots in heap snapshots. | |
10229 virtual void Synchronize(VisitorSynchronization::SyncTag tag) {} | |
10230 }; | 10195 }; |
10231 | 10196 |
10232 | 10197 |
10233 // BooleanBit is a helper class for setting and getting a bit in an integer. | 10198 // BooleanBit is a helper class for setting and getting a bit in an integer. |
10234 class BooleanBit : public AllStatic { | 10199 class BooleanBit : public AllStatic { |
10235 public: | 10200 public: |
10236 static inline bool get(int value, int bit_position) { | 10201 static inline bool get(int value, int bit_position) { |
10237 return (value & (1 << bit_position)) != 0; | 10202 return (value & (1 << bit_position)) != 0; |
10238 } | 10203 } |
10239 | 10204 |
10240 static inline int set(int value, int bit_position, bool v) { | 10205 static inline int set(int value, int bit_position, bool v) { |
10241 if (v) { | 10206 if (v) { |
10242 value |= (1 << bit_position); | 10207 value |= (1 << bit_position); |
10243 } else { | 10208 } else { |
10244 value &= ~(1 << bit_position); | 10209 value &= ~(1 << bit_position); |
10245 } | 10210 } |
10246 return value; | 10211 return value; |
10247 } | 10212 } |
10248 }; | 10213 }; |
10249 | 10214 |
10250 | 10215 |
10251 } // NOLINT, false-positive due to second-order macros. | 10216 } // NOLINT, false-positive due to second-order macros. |
10252 } // NOLINT, false-positive due to second-order macros. | 10217 } // NOLINT, false-positive due to second-order macros. |
10253 | 10218 |
10254 #include "src/objects/object-macros-undef.h" | 10219 #include "src/objects/object-macros-undef.h" |
10255 | 10220 |
10256 #endif // V8_OBJECTS_H_ | 10221 #endif // V8_OBJECTS_H_ |
OLD | NEW |