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_STRUCT_INL_H_
6 #define V8_OBJECTS_STRUCT_INL_H_
7
8 #include "src/objects/struct.h"
9
10 #include "src/heap/heap-write-barrier-inl.h"
11 #include "src/objects/objects-inl.h"
12 #include "src/objects/oddball.h"
13 #include "src/roots/roots-inl.h"
14
15 // Has to be the last include (doesn't have include guards):
16 #include "src/objects/object-macros.h"
17
18 namespace v8 {
19 namespace internal {
20
21 #include "torque-generated/src/objects/struct-tq-inl.inc"
22
23 TQ_OBJECT_CONSTRUCTORS_IMPL(Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2)24 TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2)
25 TQ_OBJECT_CONSTRUCTORS_IMPL(AccessorPair)
26
27 NEVER_READ_ONLY_SPACE_IMPL(AccessorPair)
28
29 TQ_OBJECT_CONSTRUCTORS_IMPL(ClassPositions)
30
31 Object AccessorPair::get(AccessorComponent component) {
32 return component == ACCESSOR_GETTER ? getter() : setter();
33 }
34
set(AccessorComponent component,Object value)35 void AccessorPair::set(AccessorComponent component, Object value) {
36 if (component == ACCESSOR_GETTER) {
37 set_getter(value);
38 } else {
39 set_setter(value);
40 }
41 }
42
set(AccessorComponent component,Object value,ReleaseStoreTag tag)43 void AccessorPair::set(AccessorComponent component, Object value,
44 ReleaseStoreTag tag) {
45 if (component == ACCESSOR_GETTER) {
46 set_getter(value, tag);
47 } else {
48 set_setter(value, tag);
49 }
50 }
51
RELEASE_ACQUIRE_ACCESSORS(AccessorPair,getter,Object,kGetterOffset)52 RELEASE_ACQUIRE_ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
53 RELEASE_ACQUIRE_ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
54
55 void AccessorPair::SetComponents(Object getter, Object setter) {
56 if (!getter.IsNull()) set_getter(getter);
57 if (!setter.IsNull()) set_setter(setter);
58 }
59
Equals(Object getter_value,Object setter_value)60 bool AccessorPair::Equals(Object getter_value, Object setter_value) {
61 return (getter() == getter_value) && (setter() == setter_value);
62 }
63
64 } // namespace internal
65 } // namespace v8
66
67 #include "src/objects/object-macros-undef.h"
68
69 #endif // V8_OBJECTS_STRUCT_INL_H_
70