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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 class LookupIterator; | 945 class LookupIterator; |
946 class FieldType; | 946 class FieldType; |
947 class Module; | 947 class Module; |
948 class ModuleDescriptor; | 948 class ModuleDescriptor; |
949 class ModuleInfoEntry; | 949 class ModuleInfoEntry; |
950 class ModuleInfo; | 950 class ModuleInfo; |
951 class ObjectHashTable; | 951 class ObjectHashTable; |
952 class ObjectVisitor; | 952 class ObjectVisitor; |
953 class PropertyCell; | 953 class PropertyCell; |
954 class PropertyDescriptor; | 954 class PropertyDescriptor; |
| 955 class RootVisitor; |
955 class SafepointEntry; | 956 class SafepointEntry; |
956 class SharedFunctionInfo; | 957 class SharedFunctionInfo; |
957 class StringStream; | 958 class StringStream; |
958 class TypeFeedbackInfo; | 959 class TypeFeedbackInfo; |
959 class FeedbackMetadata; | 960 class FeedbackMetadata; |
960 class FeedbackVector; | 961 class FeedbackVector; |
961 class WeakCell; | 962 class WeakCell; |
962 class TransitionArray; | 963 class TransitionArray; |
963 class TemplateList; | 964 class TemplateList; |
964 | 965 |
(...skipping 7784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8749 }; | 8750 }; |
8750 | 8751 |
8751 | 8752 |
8752 // Utility superclass for stack-allocated objects that must be updated | 8753 // Utility superclass for stack-allocated objects that must be updated |
8753 // on gc. It provides two ways for the gc to update instances, either | 8754 // on gc. It provides two ways for the gc to update instances, either |
8754 // iterating or updating after gc. | 8755 // iterating or updating after gc. |
8755 class Relocatable BASE_EMBEDDED { | 8756 class Relocatable BASE_EMBEDDED { |
8756 public: | 8757 public: |
8757 explicit inline Relocatable(Isolate* isolate); | 8758 explicit inline Relocatable(Isolate* isolate); |
8758 inline virtual ~Relocatable(); | 8759 inline virtual ~Relocatable(); |
8759 virtual void IterateInstance(ObjectVisitor* v) { } | 8760 virtual void IterateInstance(RootVisitor* v) {} |
8760 virtual void PostGarbageCollection() { } | 8761 virtual void PostGarbageCollection() { } |
8761 | 8762 |
8762 static void PostGarbageCollectionProcessing(Isolate* isolate); | 8763 static void PostGarbageCollectionProcessing(Isolate* isolate); |
8763 static int ArchiveSpacePerThread(); | 8764 static int ArchiveSpacePerThread(); |
8764 static char* ArchiveState(Isolate* isolate, char* to); | 8765 static char* ArchiveState(Isolate* isolate, char* to); |
8765 static char* RestoreState(Isolate* isolate, char* from); | 8766 static char* RestoreState(Isolate* isolate, char* from); |
8766 static void Iterate(Isolate* isolate, ObjectVisitor* v); | 8767 static void Iterate(Isolate* isolate, RootVisitor* v); |
8767 static void Iterate(ObjectVisitor* v, Relocatable* top); | 8768 static void Iterate(RootVisitor* v, Relocatable* top); |
8768 static char* Iterate(ObjectVisitor* v, char* t); | 8769 static char* Iterate(RootVisitor* v, char* t); |
8769 | 8770 |
8770 private: | 8771 private: |
8771 Isolate* isolate_; | 8772 Isolate* isolate_; |
8772 Relocatable* prev_; | 8773 Relocatable* prev_; |
8773 }; | 8774 }; |
8774 | 8775 |
8775 | 8776 |
8776 // A flat string reader provides random access to the contents of a | 8777 // A flat string reader provides random access to the contents of a |
8777 // string independent of the character width of the string. The handle | 8778 // string independent of the character width of the string. The handle |
8778 // must be valid as long as the reader is being used. | 8779 // must be valid as long as the reader is being used. |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10188 | 10189 |
10189 static const int kSourcePositionTableIndex = Struct::kHeaderSize; | 10190 static const int kSourcePositionTableIndex = Struct::kHeaderSize; |
10190 static const int kStackFrameCacheIndex = | 10191 static const int kStackFrameCacheIndex = |
10191 kSourcePositionTableIndex + kPointerSize; | 10192 kSourcePositionTableIndex + kPointerSize; |
10192 static const int kSize = kStackFrameCacheIndex + kPointerSize; | 10193 static const int kSize = kStackFrameCacheIndex + kPointerSize; |
10193 | 10194 |
10194 private: | 10195 private: |
10195 DISALLOW_IMPLICIT_CONSTRUCTORS(SourcePositionTableWithFrameCache); | 10196 DISALLOW_IMPLICIT_CONSTRUCTORS(SourcePositionTableWithFrameCache); |
10196 }; | 10197 }; |
10197 | 10198 |
10198 #define VISITOR_SYNCHRONIZATION_TAGS_LIST(V) \ | |
10199 V(kStringTable, "string_table", "(Internalized strings)") \ | |
10200 V(kExternalStringsTable, "external_strings_table", "(External strings)") \ | |
10201 V(kStrongRootList, "strong_root_list", "(Strong roots)") \ | |
10202 V(kSmiRootList, "smi_root_list", "(Smi roots)") \ | |
10203 V(kBootstrapper, "bootstrapper", "(Bootstrapper)") \ | |
10204 V(kTop, "top", "(Isolate)") \ | |
10205 V(kRelocatable, "relocatable", "(Relocatable)") \ | |
10206 V(kDebug, "debug", "(Debugger)") \ | |
10207 V(kCompilationCache, "compilationcache", "(Compilation cache)") \ | |
10208 V(kHandleScope, "handlescope", "(Handle scope)") \ | |
10209 V(kDispatchTable, "dispatchtable", "(Dispatch table)") \ | |
10210 V(kBuiltins, "builtins", "(Builtins)") \ | |
10211 V(kGlobalHandles, "globalhandles", "(Global handles)") \ | |
10212 V(kEternalHandles, "eternalhandles", "(Eternal handles)") \ | |
10213 V(kThreadManager, "threadmanager", "(Thread manager)") \ | |
10214 V(kStrongRoots, "strong roots", "(Strong roots)") \ | |
10215 V(kExtensions, "Extensions", "(Extensions)") | |
10216 | |
10217 class VisitorSynchronization : public AllStatic { | |
10218 public: | |
10219 #define DECLARE_ENUM(enum_item, ignore1, ignore2) enum_item, | |
10220 enum SyncTag { | |
10221 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_ENUM) | |
10222 kNumberOfSyncTags | |
10223 }; | |
10224 #undef DECLARE_ENUM | |
10225 | |
10226 static const char* const kTags[kNumberOfSyncTags]; | |
10227 static const char* const kTagNames[kNumberOfSyncTags]; | |
10228 }; | |
10229 | |
10230 // Abstract base class for visiting, and optionally modifying, the | 10199 // Abstract base class for visiting, and optionally modifying, the |
10231 // pointers contained in Objects. Used in GC and serialization/deserialization. | 10200 // pointers contained in Objects. Used in GC and serialization/deserialization. |
| 10201 // TODO(ulan): move to src/visitors.h |
10232 class ObjectVisitor BASE_EMBEDDED { | 10202 class ObjectVisitor BASE_EMBEDDED { |
10233 public: | 10203 public: |
10234 virtual ~ObjectVisitor() {} | 10204 virtual ~ObjectVisitor() {} |
10235 | 10205 |
10236 // Visits a contiguous arrays of pointers in the half-open range | 10206 // Visits a contiguous arrays of pointers in the half-open range |
10237 // [start, end). Any or all of the values may be modified on return. | 10207 // [start, end). Any or all of the values may be modified on return. |
10238 virtual void VisitPointers(Object** start, Object** end) = 0; | 10208 virtual void VisitPointers(Object** start, Object** end) = 0; |
10239 | 10209 |
10240 // Handy shorthand for visiting a single pointer. | 10210 // Handy shorthand for visiting a single pointer. |
10241 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 10211 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
(...skipping 27 matching lines...) Expand all Loading... |
10269 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); | 10239 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); |
10270 | 10240 |
10271 // Visits an external reference embedded into a code object. | 10241 // Visits an external reference embedded into a code object. |
10272 virtual void VisitExternalReference(RelocInfo* rinfo); | 10242 virtual void VisitExternalReference(RelocInfo* rinfo); |
10273 | 10243 |
10274 // Visits an external reference. | 10244 // Visits an external reference. |
10275 virtual void VisitExternalReference(Address* p) {} | 10245 virtual void VisitExternalReference(Address* p) {} |
10276 | 10246 |
10277 // Visits an (encoded) internal reference. | 10247 // Visits an (encoded) internal reference. |
10278 virtual void VisitInternalReference(RelocInfo* rinfo) {} | 10248 virtual void VisitInternalReference(RelocInfo* rinfo) {} |
10279 | |
10280 // Intended for serialization/deserialization checking: insert, or | |
10281 // check for the presence of, a tag at this position in the stream. | |
10282 // Also used for marking up GC roots in heap snapshots. | |
10283 virtual void Synchronize(VisitorSynchronization::SyncTag tag) {} | |
10284 }; | 10249 }; |
10285 | 10250 |
10286 | 10251 |
10287 // BooleanBit is a helper class for setting and getting a bit in an integer. | 10252 // BooleanBit is a helper class for setting and getting a bit in an integer. |
10288 class BooleanBit : public AllStatic { | 10253 class BooleanBit : public AllStatic { |
10289 public: | 10254 public: |
10290 static inline bool get(int value, int bit_position) { | 10255 static inline bool get(int value, int bit_position) { |
10291 return (value & (1 << bit_position)) != 0; | 10256 return (value & (1 << bit_position)) != 0; |
10292 } | 10257 } |
10293 | 10258 |
10294 static inline int set(int value, int bit_position, bool v) { | 10259 static inline int set(int value, int bit_position, bool v) { |
10295 if (v) { | 10260 if (v) { |
10296 value |= (1 << bit_position); | 10261 value |= (1 << bit_position); |
10297 } else { | 10262 } else { |
10298 value &= ~(1 << bit_position); | 10263 value &= ~(1 << bit_position); |
10299 } | 10264 } |
10300 return value; | 10265 return value; |
10301 } | 10266 } |
10302 }; | 10267 }; |
10303 | 10268 |
10304 | 10269 |
10305 } // NOLINT, false-positive due to second-order macros. | 10270 } // NOLINT, false-positive due to second-order macros. |
10306 } // NOLINT, false-positive due to second-order macros. | 10271 } // NOLINT, false-positive due to second-order macros. |
10307 | 10272 |
10308 #include "src/objects/object-macros-undef.h" | 10273 #include "src/objects/object-macros-undef.h" |
10309 | 10274 |
10310 #endif // V8_OBJECTS_H_ | 10275 #endif // V8_OBJECTS_H_ |
OLD | NEW |