summaryrefslogtreecommitdiff
path: root/deps/v8/src/common/ptr-compr.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/common/ptr-compr.h')
-rw-r--r--deps/v8/src/common/ptr-compr.h73
1 files changed, 61 insertions, 12 deletions
diff --git a/deps/v8/src/common/ptr-compr.h b/deps/v8/src/common/ptr-compr.h
index 5a47331a54..bfe99cea9e 100644
--- a/deps/v8/src/common/ptr-compr.h
+++ b/deps/v8/src/common/ptr-compr.h
@@ -13,7 +13,7 @@ namespace v8::internal {
// This is just a collection of compression scheme related functions. Having
// such a class allows plugging different decompression scheme in certain
// places by introducing another CompressionScheme class with a customized
-// implementation. This is useful, for example, for CodeDataContainer::code
+// implementation. This is useful, for example, for Code::code
// field (see CodeObjectSlot).
class V8HeapCompressionScheme {
public:
@@ -24,20 +24,20 @@ class V8HeapCompressionScheme {
// Compresses full-pointer representation of a tagged value to on-heap
// representation.
- V8_INLINE static Tagged_t CompressTagged(Address tagged);
+ // Must only be used for compressing object pointers since this function
+ // assumes that we deal with a valid address inside the pointer compression
+ // cage.
+ V8_INLINE static Tagged_t CompressObject(Address tagged);
+ // Compress a potentially invalid pointer.
+ V8_INLINE static Tagged_t CompressAny(Address tagged);
// Decompresses smi value.
V8_INLINE static Address DecompressTaggedSigned(Tagged_t raw_value);
- // Decompresses weak or strong heap object pointer or forwarding pointer,
- // preserving both weak- and smi- tags.
- template <typename TOnHeapAddress>
- V8_INLINE static Address DecompressTaggedPointer(TOnHeapAddress on_heap_addr,
- Tagged_t raw_value);
// Decompresses any tagged value, preserving both weak- and smi- tags.
template <typename TOnHeapAddress>
- V8_INLINE static Address DecompressTaggedAny(TOnHeapAddress on_heap_addr,
- Tagged_t raw_value);
+ V8_INLINE static Address DecompressTagged(TOnHeapAddress on_heap_addr,
+ Tagged_t raw_value);
// Given a 64bit raw value, found on the stack, calls the callback function
// with all possible pointers that may be "contained" in compressed form in
@@ -47,12 +47,61 @@ class V8HeapCompressionScheme {
V8_INLINE static void ProcessIntermediatePointers(
PtrComprCageBase cage_base, Address raw_value,
ProcessPointerCallback callback);
+
+#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
+ // Process-wide cage base value used for decompression.
+ V8_INLINE static void InitBase(Address base);
+ V8_INLINE static Address base();
+
+ private:
+ static V8_EXPORT_PRIVATE uintptr_t base_ V8_CONSTINIT;
+#endif // V8_COMPRESS_POINTERS_IN_SHARED_CAGE
};
#ifdef V8_EXTERNAL_CODE_SPACE
-// Compression scheme used for fields containing Code objects (namely for the
-// CodeDataContainer::code field).
-using ExternalCodeCompressionScheme = V8HeapCompressionScheme;
+
+// Compression scheme used for fields containing InstructionStream objects
+// (namely for the Code::code field). Same as
+// V8HeapCompressionScheme but with a different base value.
+class ExternalCodeCompressionScheme {
+ public:
+ V8_INLINE static Address PrepareCageBaseAddress(Address on_heap_addr);
+
+ // Note that this compression scheme doesn't allow reconstruction of the cage
+ // base value from any arbitrary value, thus the cage base has to be passed
+ // explicitly to the decompression functions.
+ static Address GetPtrComprCageBaseAddress(Address on_heap_addr) = delete;
+
+ V8_INLINE static Address GetPtrComprCageBaseAddress(
+ PtrComprCageBase cage_base);
+
+ // Compresses full-pointer representation of a tagged value to on-heap
+ // representation.
+ // Must only be used for compressing object pointers (incl. SMI) since this
+ // function assumes pointers to be inside the pointer compression cage.
+ V8_INLINE static Tagged_t CompressObject(Address tagged);
+ // Compress anything that does not follow the above requirements (e.g. a maybe
+ // object, or a marker bit pattern).
+ V8_INLINE static Tagged_t CompressAny(Address tagged);
+
+ // Decompresses smi value.
+ V8_INLINE static Address DecompressTaggedSigned(Tagged_t raw_value);
+
+ // Decompresses any tagged value, preserving both weak- and smi- tags.
+ template <typename TOnHeapAddress>
+ V8_INLINE static Address DecompressTagged(TOnHeapAddress on_heap_addr,
+ Tagged_t raw_value);
+
+#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
+ // Process-wide cage base value used for decompression.
+ V8_INLINE static void InitBase(Address base);
+ V8_INLINE static Address base();
+
+ private:
+ static V8_EXPORT_PRIVATE uintptr_t base_ V8_CONSTINIT;
+#endif // V8_COMPRESS_POINTERS_IN_SHARED_CAGE
+};
+
#endif // V8_EXTERNAL_CODE_SPACE
// Accessors for fields that may be unaligned due to pointer compression.