• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_COMMON_EXTERNAL_POINTER_H_
6 #define V8_COMMON_EXTERNAL_POINTER_H_
7 
8 #include "src/common/globals.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 // Convert external pointer from on-V8-heap representation to an actual external
14 // pointer value.
15 V8_INLINE Address DecodeExternalPointer(IsolateRoot isolate,
16                                         ExternalPointer_t encoded_pointer,
17                                         ExternalPointerTag tag);
18 
19 constexpr ExternalPointer_t kNullExternalPointer = 0;
20 
21 // Creates uninitialized entry in external pointer table and writes the entry id
22 // to the field.
23 // When sandbox is not enabled, it's a no-op.
24 V8_INLINE void InitExternalPointerField(Address field_address,
25                                         Isolate* isolate);
26 
27 // Creates and initializes entry in external pointer table and writes the entry
28 // id to the field.
29 // Basically, it's InitExternalPointerField() followed by
30 // WriteExternalPointerField().
31 V8_INLINE void InitExternalPointerField(Address field_address, Isolate* isolate,
32                                         Address value, ExternalPointerTag tag);
33 
34 // Reads external pointer for the field, and decodes it if the sandbox is
35 // enabled.
36 V8_INLINE Address ReadExternalPointerField(Address field_address,
37                                            IsolateRoot isolate,
38                                            ExternalPointerTag tag);
39 
40 // Encodes value if the sandbox is enabled and writes it into the field.
41 V8_INLINE void WriteExternalPointerField(Address field_address,
42                                          Isolate* isolate, Address value,
43                                          ExternalPointerTag tag);
44 
45 }  // namespace internal
46 }  // namespace v8
47 
48 #endif  // V8_COMMON_EXTERNAL_POINTER_H_
49