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