LCOV - code coverage report
Current view: top level - src/objects - oddball.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2019-02-19 Functions: 1 1 100.0 %

          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_ODDBALL_H_
       6             : #define V8_OBJECTS_ODDBALL_H_
       7             : 
       8             : #include "src/objects/heap-object.h"
       9             : 
      10             : // Has to be the last include (doesn't have include guards):
      11             : #include "src/objects/object-macros.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // The Oddball describes objects null, undefined, true, and false.
      17             : class Oddball : public HeapObject {
      18             :  public:
      19             :   // [to_number_raw]: Cached raw to_number computed at startup.
      20             :   inline double to_number_raw() const;
      21             :   inline void set_to_number_raw(double value);
      22             :   inline void set_to_number_raw_as_bits(uint64_t bits);
      23             : 
      24             :   // [to_string]: Cached to_string computed at startup.
      25             :   DECL_ACCESSORS(to_string, String)
      26             : 
      27             :   // [to_number]: Cached to_number computed at startup.
      28             :   DECL_ACCESSORS(to_number, Object)
      29             : 
      30             :   // [typeof]: Cached type_of computed at startup.
      31             :   DECL_ACCESSORS(type_of, String)
      32             : 
      33             :   inline byte kind() const;
      34             :   inline void set_kind(byte kind);
      35             : 
      36             :   // ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined.
      37             :   V8_WARN_UNUSED_RESULT static inline Handle<Object> ToNumber(
      38             :       Isolate* isolate, Handle<Oddball> input);
      39             : 
      40             :   DECL_CAST(Oddball)
      41             : 
      42             :   // Dispatched behavior.
      43             :   DECL_VERIFIER(Oddball)
      44             : 
      45             :   // Initialize the fields.
      46             :   static void Initialize(Isolate* isolate, Handle<Oddball> oddball,
      47             :                          const char* to_string, Handle<Object> to_number,
      48             :                          const char* type_of, byte kind);
      49             : 
      50             :   // Layout description.
      51             : #define ODDBALL_FIELDS(V)                  \
      52             :   V(kToNumberRawOffset, kDoubleSize)       \
      53             :   /* Tagged fields. */                     \
      54             :   V(kTaggedFieldsStartOffset, 0)           \
      55             :   V(kToStringOffset, kTaggedSize)          \
      56             :   V(kToNumberOffset, kTaggedSize)          \
      57             :   V(kTypeOfOffset, kTaggedSize)            \
      58             :   V(kTaggedFieldsEndOffset, 0)             \
      59             :   /* Raw data but still encoded as Smi. */ \
      60             :   V(kKindOffset, kTaggedSize)              \
      61             :   /* Total size. */                        \
      62             :   V(kSize, 0)
      63             : 
      64             :   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, ODDBALL_FIELDS)
      65             : #undef ODDBALL_FIELDS
      66             : 
      67             :   static const byte kFalse = 0;
      68             :   static const byte kTrue = 1;
      69             :   static const byte kNotBooleanMask = static_cast<byte>(~1);
      70             :   static const byte kTheHole = 2;
      71             :   static const byte kNull = 3;
      72             :   static const byte kArgumentsMarker = 4;
      73             :   static const byte kUndefined = 5;
      74             :   static const byte kUninitialized = 6;
      75             :   static const byte kOther = 7;
      76             :   static const byte kException = 8;
      77             :   static const byte kOptimizedOut = 9;
      78             :   static const byte kStaleRegister = 10;
      79             :   static const byte kSelfReferenceMarker = 10;
      80             : 
      81             :   typedef FixedBodyDescriptor<kTaggedFieldsStartOffset, kTaggedFieldsEndOffset,
      82             :                               kSize>
      83             :       BodyDescriptor;
      84             : 
      85             :   STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset);
      86             :   STATIC_ASSERT(kNull == Internals::kNullOddballKind);
      87             :   STATIC_ASSERT(kUndefined == Internals::kUndefinedOddballKind);
      88             : 
      89     3775856 :   OBJECT_CONSTRUCTORS(Oddball, HeapObject);
      90             : };
      91             : 
      92             : }  // namespace internal
      93             : }  // namespace v8
      94             : 
      95             : #include "src/objects/object-macros-undef.h"
      96             : 
      97             : #endif  // V8_OBJECTS_ODDBALL_H_

Generated by: LCOV version 1.10