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/primitive-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 #include "torque-generated/src/objects/oddball-tq.inc" 17 18 // The Oddball describes objects null, undefined, true, and false. 19 class Oddball : public TorqueGeneratedOddball<Oddball, PrimitiveHeapObject> { 20 public: 21 // [to_number_raw]: Cached raw to_number computed at startup. 22 inline void set_to_number_raw_as_bits(uint64_t bits); 23 24 inline byte kind() const; 25 inline void set_kind(byte kind); 26 27 // Oddball has a custom verifier. 28 void OddballVerify(Isolate* isolate); 29 30 // ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined. 31 V8_WARN_UNUSED_RESULT static inline Handle<Object> ToNumber( 32 Isolate* isolate, Handle<Oddball> input); 33 34 // Initialize the fields. 35 static void Initialize(Isolate* isolate, Handle<Oddball> oddball, 36 const char* to_string, Handle<Object> to_number, 37 const char* type_of, byte kind); 38 39 static const byte kFalse = 0; 40 static const byte kTrue = 1; 41 static const byte kNotBooleanMask = static_cast<byte>(~1); 42 static const byte kTheHole = 2; 43 static const byte kNull = 3; 44 static const byte kArgumentsMarker = 4; 45 static const byte kUndefined = 5; 46 static const byte kUninitialized = 6; 47 static const byte kOther = 7; 48 static const byte kException = 8; 49 static const byte kOptimizedOut = 9; 50 static const byte kStaleRegister = 10; 51 static const byte kSelfReferenceMarker = 10; 52 static const byte kBasicBlockCountersMarker = 11; 53 54 class BodyDescriptor; 55 56 STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset); 57 STATIC_ASSERT(kNull == Internals::kNullOddballKind); 58 STATIC_ASSERT(kUndefined == Internals::kUndefinedOddballKind); 59 60 DECL_PRINTER(Oddball) 61 62 TQ_OBJECT_CONSTRUCTORS(Oddball) 63 }; 64 65 } // namespace internal 66 } // namespace v8 67 68 #include "src/objects/object-macros-undef.h" 69 70 #endif // V8_OBJECTS_ODDBALL_H_ 71