v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-temporal-objects-inl.h
Go to the documentation of this file.
1// Copyright 2021 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_JS_TEMPORAL_OBJECTS_INL_H_
6#define V8_OBJECTS_JS_TEMPORAL_OBJECTS_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11#include "src/api/api-inl.h"
13
14// Has to be the last include (doesn't have include guards):
16
17namespace v8 {
18namespace internal {
19
20#include "torque-generated/src/objects/js-temporal-objects-tq-inl.inc"
21
22#define TEMPORAL_INLINE_GETTER_SETTER(T, data, field, lower, upper, B) \
23 inline void T::set_##field(int32_t field) { \
24 DCHECK_GE(upper, field); \
25 DCHECK_LE(lower, field); \
26 int hints = data(); \
27 hints = B##Bits::update(hints, field); \
28 set_##data(hints); \
29 } \
30 inline int32_t T::field() const { \
31 int32_t v = B##Bits::decode(data()); \
32 DCHECK_GE(upper, v); \
33 DCHECK_LE(lower, v); \
34 return v; \
35 }
36
37#define TEMPORAL_INLINE_SIGNED_GETTER_SETTER(T, data, field, lower, upper, B) \
38 inline void T::set_##field(int32_t field) { \
39 DCHECK_GE(upper, field); \
40 DCHECK_LE(lower, field); \
41 int hints = data(); \
42 /* Mask out unrelated bits */ \
43 field &= (static_cast<uint32_t>(int32_t{-1})) ^ \
44 (static_cast<uint32_t>(int32_t{-1}) << B##Bits::kSize); \
45 hints = B##Bits::update(hints, field); \
46 set_##data(hints); \
47 } \
48 inline int32_t T::field() const { \
49 int32_t v = B##Bits::decode(data()); \
50 /* Restore bits for negative values based on the MSB in that field */ \
51 v |= ((int32_t{1} << (B##Bits::kSize - 1) & v) \
52 ? (static_cast<uint32_t>(int32_t{-1}) << B##Bits::kSize) \
53 : 0); \
54 DCHECK_GE(upper, v); \
55 DCHECK_LE(lower, v); \
56 return v; \
57 }
58
59#define TEMPORAL_DATE_INLINE_GETTER_SETTER(T, data) \
60 TEMPORAL_INLINE_SIGNED_GETTER_SETTER(T, data, iso_year, -271821, 275760, \
61 IsoYear) \
62 TEMPORAL_INLINE_GETTER_SETTER(T, data, iso_month, 1, 12, IsoMonth) \
63 TEMPORAL_INLINE_GETTER_SETTER(T, data, iso_day, 1, 31, IsoDay)
64
65#define TEMPORAL_TIME_INLINE_GETTER_SETTER(T, data1, data2) \
66 TEMPORAL_INLINE_GETTER_SETTER(T, data1, iso_hour, 0, 23, IsoHour) \
67 TEMPORAL_INLINE_GETTER_SETTER(T, data1, iso_minute, 0, 59, IsoMinute) \
68 TEMPORAL_INLINE_GETTER_SETTER(T, data1, iso_second, 0, 59, IsoSecond) \
69 TEMPORAL_INLINE_GETTER_SETTER(T, data2, iso_millisecond, 0, 999, \
70 IsoMillisecond) \
71 TEMPORAL_INLINE_GETTER_SETTER(T, data2, iso_microsecond, 0, 999, \
72 IsoMicrosecond) \
73 TEMPORAL_INLINE_GETTER_SETTER(T, data2, iso_nanosecond, 0, 999, IsoNanosecond)
74
75TEMPORAL_DATE_INLINE_GETTER_SETTER(JSTemporalPlainDate, year_month_day)
76TEMPORAL_DATE_INLINE_GETTER_SETTER(JSTemporalPlainDateTime, year_month_day)
78 second_parts)
81 second_parts)
83
94
96 JSTemporalCalendar::CalendarIndexBits)
97
98BOOL_ACCESSORS(JSTemporalTimeZone, flags, is_offset, IsOffsetBit::kShift)
99
100// Special handling of sign
102 offset_milliseconds, -24 * 60 * 60 * 1000,
103 24 * 60 * 60 * 1000,
104 OffsetMillisecondsOrTimeZoneIndex)
105
107 offset_sub_milliseconds, -1000000, 1000000,
108 OffsetSubMilliseconds)
109
112 JSTemporalTimeZone::OffsetMillisecondsOrTimeZoneIndexBits)
113
114} // namespace internal
115} // namespace v8
116
117#include "src/objects/object-macros-undef.h"
118
119#endif // V8_OBJECTS_JS_TEMPORAL_OBJECTS_INL_H_
#define TEMPORAL_INLINE_SIGNED_GETTER_SETTER(T, data, field, lower, upper, B)
#define TEMPORAL_TIME_INLINE_GETTER_SETTER(T, data1, data2)
#define TEMPORAL_DATE_INLINE_GETTER_SETTER(T, data)
second_parts OffsetMillisecondsOrTimeZoneIndex offset_milliseconds_or_time_zone_index
second_parts offset_milliseconds
#define BOOL_ACCESSORS(holder, field, name, offset)
#define TQ_OBJECT_CONSTRUCTORS_IMPL(Type)
#define BIT_FIELD_ACCESSORS(holder, field, name, BitField)