1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
|
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Note 1: Any file that includes this one should include object-macros-undef.h
// at the bottom.
// Note 2: This file is deliberately missing the include guards (the undeffing
// approach wouldn't work otherwise).
//
// PRESUBMIT_INTENTIONALLY_MISSING_INCLUDE_GUARD
// The accessors with RELAXED_, ACQUIRE_, and RELEASE_ prefixes should be used
// for fields that can be written to and read from multiple threads at the same
// time. See comments in src/base/atomicops.h for the memory ordering sematics.
#include "src/base/memory.h"
// Since this changes visibility, it should always be last in a class
// definition.
#define OBJECT_CONSTRUCTORS(Type, ...) \
public: \
constexpr Type() : __VA_ARGS__() {} \
\
protected: \
template <typename TFieldType, int kFieldOffset> \
friend class TaggedField; \
\
explicit inline Type(Address ptr)
#define OBJECT_CONSTRUCTORS_IMPL(Type, Super) \
inline Type::Type(Address ptr) : Super(ptr) { SLOW_DCHECK(Is##Type()); }
// In these cases, we don't have our own instance type to check, so check the
// supertype instead. This happens for types denoting a NativeContext-dependent
// set of maps.
#define OBJECT_CONSTRUCTORS_IMPL_CHECK_SUPER(Type, Super) \
inline Type::Type(Address ptr) : Super(ptr) { SLOW_DCHECK(Is##Super()); }
#define NEVER_READ_ONLY_SPACE \
inline Heap* GetHeap() const; \
inline Isolate* GetIsolate() const;
// TODO(leszeks): Add checks in the factory that we never allocate these
// objects in RO space.
#define NEVER_READ_ONLY_SPACE_IMPL(Type) \
Heap* Type::GetHeap() const { return GetHeapFromWritableObject(*this); } \
Isolate* Type::GetIsolate() const { \
return GetIsolateFromWritableObject(*this); \
}
#define DECL_PRIMITIVE_GETTER(name, type) inline type name() const;
#define DECL_PRIMITIVE_SETTER(name, type) inline void set_##name(type value);
#define DECL_PRIMITIVE_ACCESSORS(name, type) \
DECL_PRIMITIVE_GETTER(name, type) \
DECL_PRIMITIVE_SETTER(name, type)
#define DECL_BOOLEAN_ACCESSORS(name) DECL_PRIMITIVE_ACCESSORS(name, bool)
#define DECL_INT_ACCESSORS(name) DECL_PRIMITIVE_ACCESSORS(name, int)
#define DECL_INT32_ACCESSORS(name) DECL_PRIMITIVE_ACCESSORS(name, int32_t)
#define DECL_UINT16_ACCESSORS(name) \
inline uint16_t name() const; \
inline void set_##name(int value);
#define DECL_INT16_ACCESSORS(name) \
inline int16_t name() const; \
inline void set_##name(int16_t value);
#define DECL_UINT8_ACCESSORS(name) \
inline uint8_t name() const; \
inline void set_##name(int value);
// TODO(ishell): eventually isolate-less getters should not be used anymore.
// For full pointer-mode the C++ compiler should optimize away unused isolate
// parameter.
#define DECL_GETTER(name, type) \
inline type name() const; \
inline type name(PtrComprCageBase cage_base) const;
#define DEF_GETTER(holder, name, type) \
type holder::name() const { \
PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \
return holder::name(cage_base); \
} \
type holder::name(PtrComprCageBase cage_base) const
#define DECL_SETTER(name, type) \
inline void set_##name(type value, \
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
#define DECL_ACCESSORS(name, type) \
DECL_GETTER(name, type) \
DECL_SETTER(name, type)
#define DECL_ACCESSORS_LOAD_TAG(name, type, tag_type) \
inline type name(tag_type tag) const; \
inline type name(PtrComprCageBase cage_base, tag_type) const;
#define DECL_ACCESSORS_STORE_TAG(name, type, tag_type) \
inline void set_##name(type value, tag_type, \
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
#define DECL_RELAXED_GETTER(name, type) \
DECL_ACCESSORS_LOAD_TAG(name, type, RelaxedLoadTag)
#define DECL_RELAXED_SETTER(name, type) \
DECL_ACCESSORS_STORE_TAG(name, type, RelaxedStoreTag)
#define DECL_RELAXED_ACCESSORS(name, type) \
DECL_RELAXED_GETTER(name, type) \
DECL_RELAXED_SETTER(name, type)
#define DECL_ACQUIRE_GETTER(name, type) \
DECL_ACCESSORS_LOAD_TAG(name, type, AcquireLoadTag)
#define DECL_RELEASE_SETTER(name, type) \
DECL_ACCESSORS_STORE_TAG(name, type, ReleaseStoreTag)
#define DECL_RELEASE_ACQUIRE_ACCESSORS(name, type) \
DECL_ACQUIRE_GETTER(name, type) \
DECL_RELEASE_SETTER(name, type)
#define DECL_RELEASE_ACQUIRE_WEAK_ACCESSORS(name) \
DECL_ACQUIRE_GETTER(name, MaybeObject) \
DECL_RELEASE_SETTER(name, MaybeObject)
#define DECL_CAST(Type) \
V8_INLINE static Type cast(Object object); \
V8_INLINE static Type unchecked_cast(Object object) { \
return bit_cast<Type>(object); \
}
#define CAST_ACCESSOR(Type) \
Type Type::cast(Object object) { return Type(object.ptr()); }
#define INT_ACCESSORS(holder, name, offset) \
int holder::name() const { return ReadField<int>(offset); } \
void holder::set_##name(int value) { WriteField<int>(offset, value); }
#define INT32_ACCESSORS(holder, name, offset) \
int32_t holder::name() const { return ReadField<int32_t>(offset); } \
void holder::set_##name(int32_t value) { WriteField<int32_t>(offset, value); }
#define RELAXED_INT32_ACCESSORS(holder, name, offset) \
int32_t holder::name() const { \
return RELAXED_READ_INT32_FIELD(*this, offset); \
} \
void holder::set_##name(int32_t value) { \
RELAXED_WRITE_INT32_FIELD(*this, offset, value); \
}
#define UINT16_ACCESSORS(holder, name, offset) \
uint16_t holder::name() const { return ReadField<uint16_t>(offset); } \
void holder::set_##name(int value) { \
DCHECK_GE(value, 0); \
DCHECK_LE(value, static_cast<uint16_t>(-1)); \
WriteField<uint16_t>(offset, value); \
}
#define UINT8_ACCESSORS(holder, name, offset) \
uint8_t holder::name() const { return ReadField<uint8_t>(offset); } \
void holder::set_##name(int value) { \
DCHECK_GE(value, 0); \
DCHECK_LE(value, static_cast<uint8_t>(-1)); \
WriteField<uint8_t>(offset, value); \
}
#define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
set_condition) \
DEF_GETTER(holder, name, type) { \
type value = TaggedField<type, offset>::load(cage_base, *this); \
DCHECK(get_condition); \
return value; \
} \
void holder::set_##name(type value, WriteBarrierMode mode) { \
DCHECK(set_condition); \
TaggedField<type, offset>::store(*this, value); \
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
}
#define ACCESSORS_CHECKED(holder, name, type, offset, condition) \
ACCESSORS_CHECKED2(holder, name, type, offset, condition, condition)
#define ACCESSORS(holder, name, type, offset) \
ACCESSORS_CHECKED(holder, name, type, offset, true)
#define RENAME_TORQUE_ACCESSORS(holder, name, torque_name, type) \
inline type holder::name() const { \
return TorqueGeneratedClass::torque_name(); \
} \
inline void holder::set_##name(type value, WriteBarrierMode mode) { \
TorqueGeneratedClass::set_##torque_name(value, mode); \
}
#define RENAME_UINT16_TORQUE_ACCESSORS(holder, name, torque_name) \
uint16_t holder::name() const { \
return TorqueGeneratedClass::torque_name(); \
} \
void holder::set_##name(int value) { \
DCHECK_EQ(value, static_cast<uint16_t>(value)); \
TorqueGeneratedClass::set_##torque_name(value); \
}
#define RELAXED_ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
set_condition) \
type holder::name(RelaxedLoadTag tag) const { \
PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \
return holder::name(cage_base, tag); \
} \
type holder::name(PtrComprCageBase cage_base, RelaxedLoadTag) const { \
type value = TaggedField<type, offset>::Relaxed_Load(cage_base, *this); \
DCHECK(get_condition); \
return value; \
} \
void holder::set_##name(type value, RelaxedStoreTag, \
WriteBarrierMode mode) { \
DCHECK(set_condition); \
TaggedField<type, offset>::Relaxed_Store(*this, value); \
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
}
#define RELAXED_ACCESSORS_CHECKED(holder, name, type, offset, condition) \
RELAXED_ACCESSORS_CHECKED2(holder, name, type, offset, condition, condition)
#define RELAXED_ACCESSORS(holder, name, type, offset) \
RELAXED_ACCESSORS_CHECKED(holder, name, type, offset, true)
#define RELEASE_ACQUIRE_ACCESSORS_CHECKED2(holder, name, type, offset, \
get_condition, set_condition) \
type holder::name(AcquireLoadTag tag) const { \
PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \
return holder::name(cage_base, tag); \
} \
type holder::name(PtrComprCageBase cage_base, AcquireLoadTag) const { \
type value = TaggedField<type, offset>::Acquire_Load(cage_base, *this); \
DCHECK(get_condition); \
return value; \
} \
void holder::set_##name(type value, ReleaseStoreTag, \
WriteBarrierMode mode) { \
DCHECK(set_condition); \
TaggedField<type, offset>::Release_Store(*this, value); \
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode); \
}
#define RELEASE_ACQUIRE_ACCESSORS_CHECKED(holder, name, type, offset, \
condition) \
RELEASE_ACQUIRE_ACCESSORS_CHECKED2(holder, name, type, offset, condition, \
condition)
#define RELEASE_ACQUIRE_ACCESSORS(holder, name, type, offset) \
RELEASE_ACQUIRE_ACCESSORS_CHECKED(holder, name, type, offset, true)
#define WEAK_ACCESSORS_CHECKED2(holder, name, offset, get_condition, \
set_condition) \
DEF_GETTER(holder, name, MaybeObject) { \
MaybeObject value = \
TaggedField<MaybeObject, offset>::load(cage_base, *this); \
DCHECK(get_condition); \
return value; \
} \
void holder::set_##name(MaybeObject value, WriteBarrierMode mode) { \
DCHECK(set_condition); \
TaggedField<MaybeObject, offset>::store(*this, value); \
CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); \
}
#define WEAK_ACCESSORS_CHECKED(holder, name, offset, condition) \
WEAK_ACCESSORS_CHECKED2(holder, name, offset, condition, condition)
#define WEAK_ACCESSORS(holder, name, offset) \
WEAK_ACCESSORS_CHECKED(holder, name, offset, true)
#define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED2(holder, name, offset, \
get_condition, set_condition) \
MaybeObject holder::name(AcquireLoadTag tag) const { \
PtrComprCageBase cage_base = GetPtrComprCageBase(*this); \
return holder::name(cage_base, tag); \
} \
MaybeObject holder::name(PtrComprCageBase cage_base, AcquireLoadTag) const { \
MaybeObject value = \
TaggedField<MaybeObject, offset>::Acquire_Load(cage_base, *this); \
DCHECK(get_condition); \
return value; \
} \
void holder::set_##name(MaybeObject value, ReleaseStoreTag, \
WriteBarrierMode mode) { \
DCHECK(set_condition); \
TaggedField<MaybeObject, offset>::Release_Store(*this, value); \
CONDITIONAL_WEAK_WRITE_BARRIER(*this, offset, value, mode); \
}
#define RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED(holder, name, offset, \
condition) \
RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED2(holder, name, offset, condition, \
condition)
#define RELEASE_ACQUIRE_WEAK_ACCESSORS(holder, name, offset) \
RELEASE_ACQUIRE_WEAK_ACCESSORS_CHECKED(holder, name, offset, true)
// Getter that returns a Smi as an int and writes an int as a Smi.
#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
int holder::name() const { \
DCHECK(condition); \
Smi value = TaggedField<Smi, offset>::load(*this); \
return value.value(); \
} \
void holder::set_##name(int value) { \
DCHECK(condition); \
TaggedField<Smi, offset>::store(*this, Smi::FromInt(value)); \
}
#define SMI_ACCESSORS(holder, name, offset) \
SMI_ACCESSORS_CHECKED(holder, name, offset, true)
#define DECL_RELEASE_ACQUIRE_INT_ACCESSORS(name) \
inline int name(AcquireLoadTag) const; \
inline void set_##name(int value, ReleaseStoreTag);
#define RELEASE_ACQUIRE_SMI_ACCESSORS(holder, name, offset) \
int holder::name(AcquireLoadTag) const { \
Smi value = TaggedField<Smi, offset>::Acquire_Load(*this); \
return value.value(); \
} \
void holder::set_##name(int value, ReleaseStoreTag) { \
TaggedField<Smi, offset>::Release_Store(*this, Smi::FromInt(value)); \
}
#define DECL_RELAXED_SMI_ACCESSORS(name) \
inline int name(RelaxedLoadTag) const; \
inline void set_##name(int value, RelaxedStoreTag);
#define RELAXED_SMI_ACCESSORS(holder, name, offset) \
int holder::name(RelaxedLoadTag) const { \
Smi value = TaggedField<Smi, offset>::Relaxed_Load(*this); \
return value.value(); \
} \
void holder::set_##name(int value, RelaxedStoreTag) { \
TaggedField<Smi, offset>::Relaxed_Store(*this, Smi::FromInt(value)); \
}
#define BOOL_GETTER(holder, field, name, offset) \
bool holder::name() const { return BooleanBit::get(field(), offset); }
#define BOOL_ACCESSORS(holder, field, name, offset) \
bool holder::name() const { return BooleanBit::get(field(), offset); } \
void holder::set_##name(bool value) { \
set_##field(BooleanBit::set(field(), offset, value)); \
}
#define DECL_RELAXED_BOOL_ACCESSORS(name) \
inline bool name(RelaxedLoadTag) const; \
inline void set_##name(bool value, RelaxedStoreTag);
#define RELAXED_BOOL_ACCESSORS(holder, field, name, offset) \
bool holder::name(RelaxedLoadTag) const { \
return BooleanBit::get(field(kRelaxedLoad), offset); \
} \
void holder::set_##name(bool value, RelaxedStoreTag) { \
set_##field(BooleanBit::set(field(kRelaxedLoad), offset, value), \
kRelaxedStore); \
}
#define BIT_FIELD_ACCESSORS2(holder, get_field, set_field, name, BitField) \
typename BitField::FieldType holder::name() const { \
return BitField::decode(get_field()); \
} \
void holder::set_##name(typename BitField::FieldType value) { \
set_##set_field(BitField::update(set_field(), value)); \
}
#define BIT_FIELD_ACCESSORS(holder, field, name, BitField) \
BIT_FIELD_ACCESSORS2(holder, field, field, name, BitField)
#define INSTANCE_TYPE_CHECKER(type, forinstancetype) \
V8_INLINE bool Is##type(InstanceType instance_type) { \
return instance_type == forinstancetype; \
}
#define TYPE_CHECKER(type, ...) \
DEF_GETTER(HeapObject, Is##type, bool) { \
return InstanceTypeChecker::Is##type(map(cage_base).instance_type()); \
}
#define RELAXED_INT16_ACCESSORS(holder, name, offset) \
int16_t holder::name() const { \
return RELAXED_READ_INT16_FIELD(*this, offset); \
} \
void holder::set_##name(int16_t value) { \
RELAXED_WRITE_INT16_FIELD(*this, offset, value); \
}
#define FIELD_ADDR(p, offset) ((p).ptr() + offset - kHeapObjectTag)
#define ACQUIRE_READ_FIELD(p, offset) \
TaggedField<Object>::Acquire_Load(p, offset)
#define RELAXED_READ_FIELD(p, offset) \
TaggedField<Object>::Relaxed_Load(p, offset)
#define RELAXED_READ_WEAK_FIELD(p, offset) \
TaggedField<MaybeObject>::Relaxed_Load(p, offset)
#define WRITE_FIELD(p, offset, value) \
TaggedField<Object>::store(p, offset, value)
#define RELEASE_WRITE_FIELD(p, offset, value) \
TaggedField<Object>::Release_Store(p, offset, value)
#define RELAXED_WRITE_FIELD(p, offset, value) \
TaggedField<Object>::Relaxed_Store(p, offset, value)
#define RELAXED_WRITE_WEAK_FIELD(p, offset, value) \
TaggedField<MaybeObject>::Relaxed_Store(p, offset, value)
#ifdef V8_DISABLE_WRITE_BARRIERS
#define WRITE_BARRIER(object, offset, value)
#else
#define WRITE_BARRIER(object, offset, value) \
do { \
DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \
WriteBarrier::Marking(object, (object).RawField(offset), value); \
GenerationalBarrier(object, (object).RawField(offset), value); \
} while (false)
#endif
#ifdef V8_DISABLE_WRITE_BARRIERS
#define WEAK_WRITE_BARRIER(object, offset, value)
#else
#define WEAK_WRITE_BARRIER(object, offset, value) \
do { \
DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \
WriteBarrier::Marking(object, (object).RawMaybeWeakField(offset), value); \
GenerationalBarrier(object, (object).RawMaybeWeakField(offset), value); \
} while (false)
#endif
#ifdef V8_DISABLE_WRITE_BARRIERS
#define EPHEMERON_KEY_WRITE_BARRIER(object, offset, value)
#elif V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
#define EPHEMERON_KEY_WRITE_BARRIER(object, offset, value) \
WRITE_BARRIER(object, offset, value)
#else
#define EPHEMERON_KEY_WRITE_BARRIER(object, offset, value) \
do { \
DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \
EphemeronHashTable table = EphemeronHashTable::cast(object); \
WriteBarrier::Marking(object, (object).RawField(offset), value); \
GenerationalEphemeronKeyBarrier(table, (object).RawField(offset), value); \
} while (false)
#endif
#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_WRITE_BARRIER(object, offset, value, mode)
#elif V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
#define CONDITIONAL_WRITE_BARRIER(object, offset, value, mode) \
WRITE_BARRIER(object, offset, value)
#else
#define CONDITIONAL_WRITE_BARRIER(object, offset, value, mode) \
do { \
DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \
DCHECK_NE(mode, UPDATE_EPHEMERON_KEY_WRITE_BARRIER); \
if (mode != SKIP_WRITE_BARRIER) { \
if (mode == UPDATE_WRITE_BARRIER) { \
WriteBarrier::Marking(object, (object).RawField(offset), value); \
} \
GenerationalBarrier(object, (object).RawField(offset), value); \
} \
} while (false)
#endif
#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_WEAK_WRITE_BARRIER(object, offset, value, mode)
#elif V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
#define CONDITIONAL_WEAK_WRITE_BARRIER(object, offset, value, mode) \
WRITE_BARRIER(object, offset, value)
#else
#define CONDITIONAL_WEAK_WRITE_BARRIER(object, offset, value, mode) \
do { \
DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \
DCHECK_NE(mode, UPDATE_EPHEMERON_KEY_WRITE_BARRIER); \
if (mode != SKIP_WRITE_BARRIER) { \
if (mode == UPDATE_WRITE_BARRIER) { \
WriteBarrier::Marking(object, (object).RawMaybeWeakField(offset), \
value); \
} \
GenerationalBarrier(object, (object).RawMaybeWeakField(offset), value); \
} \
} while (false)
#endif
#ifdef V8_DISABLE_WRITE_BARRIERS
#define CONDITIONAL_EPHEMERON_KEY_WRITE_BARRIER(object, offset, value, mode)
#else
#define CONDITIONAL_EPHEMERON_KEY_WRITE_BARRIER(object, offset, value, mode) \
do { \
DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \
DCHECK_NE(mode, UPDATE_EPHEMERON_KEY_WRITE_BARRIER); \
EphemeronHashTable table = EphemeronHashTable::cast(object); \
if (mode != SKIP_WRITE_BARRIER) { \
if (mode == UPDATE_WRITE_BARRIER) { \
WriteBarrier::Marking(object, (object).RawField(offset), value); \
} \
GenerationalEphemeronKeyBarrier(table, (object).RawField(offset), \
value); \
} \
} while (false)
#endif
#define ACQUIRE_READ_INT32_FIELD(p, offset) \
static_cast<int32_t>(base::Acquire_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
#define RELAXED_WRITE_INT8_FIELD(p, offset, value) \
base::Relaxed_Store(reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic8>(value));
#define RELAXED_READ_INT8_FIELD(p, offset) \
static_cast<int8_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset))))
#define RELAXED_READ_UINT16_FIELD(p, offset) \
static_cast<uint16_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic16*>(FIELD_ADDR(p, offset))))
#define RELAXED_WRITE_UINT16_FIELD(p, offset, value) \
base::Relaxed_Store( \
reinterpret_cast<base::Atomic16*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic16>(value));
#define RELAXED_READ_INT16_FIELD(p, offset) \
static_cast<int16_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic16*>(FIELD_ADDR(p, offset))))
#define RELAXED_WRITE_INT16_FIELD(p, offset, value) \
base::Relaxed_Store( \
reinterpret_cast<base::Atomic16*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic16>(value));
#define RELAXED_READ_UINT32_FIELD(p, offset) \
static_cast<uint32_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
#define ACQUIRE_READ_UINT32_FIELD(p, offset) \
static_cast<uint32_t>(base::Acquire_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
#define RELAXED_WRITE_UINT32_FIELD(p, offset, value) \
base::Relaxed_Store( \
reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic32>(value));
#define RELEASE_WRITE_UINT32_FIELD(p, offset, value) \
base::Release_Store( \
reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic32>(value));
#define RELAXED_READ_INT32_FIELD(p, offset) \
static_cast<int32_t>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic32*>(FIELD_ADDR(p, offset))))
#define RELEASE_WRITE_INT32_FIELD(p, offset, value) \
base::Release_Store( \
reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic32>(value))
#define RELAXED_WRITE_INT32_FIELD(p, offset, value) \
base::Relaxed_Store( \
reinterpret_cast<base::Atomic32*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic32>(value))
static_assert(sizeof(int) == sizeof(int32_t),
"sizeof int must match sizeof int32_t");
#define RELAXED_READ_INT_FIELD(p, offset) RELAXED_READ_INT32_FIELD(p, offset)
#define RELAXED_WRITE_INT_FIELD(p, offset, value) \
RELAXED_WRITE_INT32_FIELD(p, offset, value)
static_assert(sizeof(unsigned) == sizeof(uint32_t),
"sizeof unsigned must match sizeof uint32_t");
#define RELAXED_READ_UINT_FIELD(p, offset) RELAXED_READ_UINT32_FIELD(p, offset)
#define RELAXED_WRITE_UINT_FIELD(p, offset, value) \
RELAXED_WRITE_UINT32_FIELD(p, offset, value)
#define RELAXED_READ_BYTE_FIELD(p, offset) \
static_cast<byte>(base::Relaxed_Load( \
reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset))))
#define ACQUIRE_READ_BYTE_FIELD(p, offset) \
static_cast<byte>(base::Acquire_Load( \
reinterpret_cast<const base::Atomic8*>(FIELD_ADDR(p, offset))))
#define RELAXED_WRITE_BYTE_FIELD(p, offset, value) \
base::Relaxed_Store(reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic8>(value));
#define RELEASE_WRITE_BYTE_FIELD(p, offset, value) \
base::Release_Store(reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \
static_cast<base::Atomic8>(value));
#ifdef OBJECT_PRINT
#define DECL_PRINTER(Name) void Name##Print(std::ostream& os);
#else
#define DECL_PRINTER(Name)
#endif
#ifdef VERIFY_HEAP
#define DECL_VERIFIER(Name) void Name##Verify(Isolate* isolate);
#define EXPORT_DECL_VERIFIER(Name) \
V8_EXPORT_PRIVATE void Name##Verify(Isolate* isolate);
#else
#define DECL_VERIFIER(Name)
#define EXPORT_DECL_VERIFIER(Name)
#endif
#define DEFINE_DEOPT_ELEMENT_ACCESSORS(name, type) \
type DeoptimizationData::name() const { \
return type::cast(get(k##name##Index)); \
} \
void DeoptimizationData::Set##name(type value) { set(k##name##Index, value); }
#define DEFINE_DEOPT_ENTRY_ACCESSORS(name, type) \
type DeoptimizationData::name(int i) const { \
return type::cast(get(IndexForEntry(i) + k##name##Offset)); \
} \
void DeoptimizationData::Set##name(int i, type value) { \
set(IndexForEntry(i) + k##name##Offset, value); \
}
#define TQ_OBJECT_CONSTRUCTORS(Type) \
public: \
constexpr Type() = default; \
\
protected: \
template <typename TFieldType, int kFieldOffset> \
friend class TaggedField; \
\
inline explicit Type(Address ptr); \
friend class TorqueGenerated##Type<Type, Super>;
#define TQ_OBJECT_CONSTRUCTORS_IMPL(Type) \
inline Type::Type(Address ptr) \
: TorqueGenerated##Type<Type, Type::Super>(ptr) {}
|