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 10 namespace v8 { 11 namespace internal { 12 13 // Computes isolate from any read only or writable heap object. The resulting 14 // value is intended to be used only as a hoisted computation of isolate root 15 // inside trivial accessors for optmizing value decompression. 16 // When pointer compression is disabled this function always returns nullptr. 17 V8_INLINE IsolateRoot GetIsolateForPtrCompr(HeapObject object); 18 19 V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object); 20 21 V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object); 22 23 // Returns true if it succeeded to obtain isolate from given object. 24 // If it fails then the object is definitely a read-only object but it may also 25 // succeed for read only objects if pointer compression is enabled. 26 V8_INLINE bool GetIsolateFromHeapObject(HeapObject object, Isolate** isolate); 27 28 } // namespace internal 29 } // namespace v8 30 31 #endif // V8_EXECUTION_ISOLATE_UTILS_H_ 32