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_HEAP_NUMBER_INL_H_
6#define V8_OBJECTS_HEAP_NUMBER_INL_H_
7
8#include "src/objects/heap-number.h"
9
10#include "src/objects-inl.h"
11#include "src/objects/heap-object-inl.h"
12
13// Has to be the last include (doesn't have include guards):
14#include "src/objects/object-macros.h"
15
16namespace v8 {
17namespace internal {
18
19OBJECT_CONSTRUCTORS_IMPL(HeapNumberBase, HeapObject)
20OBJECT_CONSTRUCTORS_IMPL(HeapNumber, HeapNumberBase)
21OBJECT_CONSTRUCTORS_IMPL(MutableHeapNumber, HeapNumberBase)
22
23CAST_ACCESSOR(HeapNumber)
24CAST_ACCESSOR(MutableHeapNumber)
25
26double HeapNumberBase::value() const {
27 return READ_DOUBLE_FIELD(*this, kValueOffset);
28}
29
30void HeapNumberBase::set_value(double value) {
31 WRITE_DOUBLE_FIELD(*this, kValueOffset, value);
32}
33
34uint64_t HeapNumberBase::value_as_bits() const {
35 return READ_UINT64_FIELD(*this, kValueOffset);
36}
37
38void HeapNumberBase::set_value_as_bits(uint64_t bits) {
39 WRITE_UINT64_FIELD(*this, kValueOffset, bits);
40}
41
42int HeapNumberBase::get_exponent() {
43 return ((READ_INT_FIELD(*this, kExponentOffset) & kExponentMask) >>
44 kExponentShift) -
45 kExponentBias;
46}
47
48int HeapNumberBase::get_sign() {
49 return READ_INT_FIELD(*this, kExponentOffset) & kSignMask;
50}
51
52} // namespace internal
53} // namespace v8
54
55#include "src/objects/object-macros-undef.h"
56
57#endif // V8_OBJECTS_HEAP_NUMBER_INL_H_
58