1// Copyright 2019 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef V8_EXECUTION_ISOLATE_UTILS_H_ 6#define V8_EXECUTION_ISOLATE_UTILS_H_ 7 8#include "src/common/globals.h" 9 10namespace v8 { 11namespace internal { 12 13// Computes the pointer compression cage base from any read only or writable 14// heap object. The resulting value is intended to be used only as a hoisted 15// computation of cage base inside trivial accessors for optimizing value 16// decompression. When pointer compression is disabled this function always 17// returns nullptr. 18V8_INLINE PtrComprCageBase GetPtrComprCageBase(HeapObject object); 19 20V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object); 21 22V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object); 23 24// Returns true if it succeeded to obtain isolate from given object. 25// If it fails then the object is definitely a read-only object but it may also 26// succeed for read only objects if pointer compression is enabled. 27V8_INLINE bool GetIsolateFromHeapObject(HeapObject object, Isolate** isolate); 28 29} // namespace internal 30} // namespace v8 31 32#endif // V8_EXECUTION_ISOLATE_UTILS_H_ 33