• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/objects-inl.h"
11 #include "src/objects/primitive-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 
16 namespace v8 {
17 namespace internal {
18 
19 #include "torque-generated/src/objects/heap-number-tq-inl.inc"
20 
TQ_OBJECT_CONSTRUCTORS_IMPL(HeapNumber)21 TQ_OBJECT_CONSTRUCTORS_IMPL(HeapNumber)
22 
23 uint64_t HeapNumber::value_as_bits() const {
24   // Bug(v8:8875): HeapNumber's double may be unaligned.
25   return base::ReadUnalignedValue<uint64_t>(field_address(kValueOffset));
26 }
27 
set_value_as_bits(uint64_t bits)28 void HeapNumber::set_value_as_bits(uint64_t bits) {
29   base::WriteUnalignedValue<uint64_t>(field_address(kValueOffset), bits);
30 }
31 
get_exponent()32 int HeapNumber::get_exponent() {
33   return ((ReadField<int>(kExponentOffset) & kExponentMask) >> kExponentShift) -
34          kExponentBias;
35 }
36 
get_sign()37 int HeapNumber::get_sign() {
38   return ReadField<int>(kExponentOffset) & kSignMask;
39 }
40 
41 }  // namespace internal
42 }  // namespace v8
43 
44 #include "src/objects/object-macros-undef.h"
45 
46 #endif  // V8_OBJECTS_HEAP_NUMBER_INL_H_
47