1 | // Copyright 2018 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_OBJECTS_FOREIGN_H_ |
6 | #define V8_OBJECTS_FOREIGN_H_ |
7 | |
8 | #include "src/objects/heap-object.h" |
9 | #include "torque-generated/class-definitions-from-dsl.h" |
10 | |
11 | // Has to be the last include (doesn't have include guards): |
12 | #include "src/objects/object-macros.h" |
13 | |
14 | namespace v8 { |
15 | namespace internal { |
16 | |
17 | // Foreign describes objects pointing from JavaScript to C structures. |
18 | class Foreign : public HeapObject { |
19 | public: |
20 | // [address]: field containing the address. |
21 | inline Address foreign_address(); |
22 | |
23 | static inline bool IsNormalized(Object object); |
24 | |
25 | DECL_CAST(Foreign) |
26 | |
27 | // Dispatched behavior. |
28 | DECL_PRINTER(Foreign) |
29 | DECL_VERIFIER(Foreign) |
30 | |
31 | DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, |
32 | TORQUE_GENERATED_FOREIGN_FIELDS) |
33 | |
34 | #ifdef V8_COMPRESS_POINTERS |
35 | // TODO(ishell, v8:8875): When pointer compression is enabled the |
36 | // kForeignAddressOffset is only kTaggedSize aligned but we can keep using |
37 | // unaligned access since both x64 and arm64 architectures (where pointer |
38 | // compression is supported) allow unaligned access to full words. |
39 | STATIC_ASSERT(IsAligned(kForeignAddressOffset, kTaggedSize)); |
40 | #else |
41 | STATIC_ASSERT(IsAligned(kForeignAddressOffset, kSystemPointerSize)); |
42 | #endif |
43 | |
44 | STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset); |
45 | |
46 | class BodyDescriptor; |
47 | |
48 | private: |
49 | friend class Factory; |
50 | friend class SerializerDeserializer; |
51 | friend class StartupSerializer; |
52 | |
53 | inline void set_foreign_address(Address value); |
54 | |
55 | OBJECT_CONSTRUCTORS(Foreign, HeapObject); |
56 | }; |
57 | |
58 | } // namespace internal |
59 | } // namespace v8 |
60 | |
61 | #include "src/objects/object-macros-undef.h" |
62 | |
63 | #endif // V8_OBJECTS_FOREIGN_H_ |
64 |