OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 9528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9539 | 9539 |
9540 // The Oddball describes objects null, undefined, true, and false. | 9540 // The Oddball describes objects null, undefined, true, and false. |
9541 class Oddball: public HeapObject { | 9541 class Oddball: public HeapObject { |
9542 public: | 9542 public: |
9543 // [to_string]: Cached to_string computed at startup. | 9543 // [to_string]: Cached to_string computed at startup. |
9544 DECL_ACCESSORS(to_string, String) | 9544 DECL_ACCESSORS(to_string, String) |
9545 | 9545 |
9546 // [to_number]: Cached to_number computed at startup. | 9546 // [to_number]: Cached to_number computed at startup. |
9547 DECL_ACCESSORS(to_number, Object) | 9547 DECL_ACCESSORS(to_number, Object) |
9548 | 9548 |
| 9549 // [to_number]: Cached to_boolean computed at startup. |
| 9550 DECL_ACCESSORS(to_boolean, Oddball) |
| 9551 |
9549 // [typeof]: Cached type_of computed at startup. | 9552 // [typeof]: Cached type_of computed at startup. |
9550 DECL_ACCESSORS(type_of, String) | 9553 DECL_ACCESSORS(type_of, String) |
9551 | 9554 |
9552 inline byte kind() const; | 9555 inline byte kind() const; |
9553 inline void set_kind(byte kind); | 9556 inline void set_kind(byte kind); |
9554 | 9557 |
9555 // ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined. | 9558 // ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined. |
9556 MUST_USE_RESULT static inline Handle<Object> ToNumber(Handle<Oddball> input); | 9559 MUST_USE_RESULT static inline Handle<Object> ToNumber(Handle<Oddball> input); |
9557 | 9560 |
9558 DECLARE_CAST(Oddball) | 9561 DECLARE_CAST(Oddball) |
9559 | 9562 |
9560 // Dispatched behavior. | 9563 // Dispatched behavior. |
9561 DECLARE_VERIFIER(Oddball) | 9564 DECLARE_VERIFIER(Oddball) |
9562 | 9565 |
9563 // Initialize the fields. | 9566 // Initialize the fields. |
9564 static void Initialize(Isolate* isolate, Handle<Oddball> oddball, | 9567 static void Initialize(Isolate* isolate, Handle<Oddball> oddball, |
9565 const char* to_string, Handle<Object> to_number, | 9568 const char* to_string, Handle<Object> to_number, |
9566 const char* type_of, byte kind); | 9569 bool to_boolean, const char* type_of, byte kind); |
9567 | 9570 |
9568 // Layout description. | 9571 // Layout description. |
9569 static const int kToStringOffset = HeapObject::kHeaderSize; | 9572 static const int kToStringOffset = HeapObject::kHeaderSize; |
9570 static const int kToNumberOffset = kToStringOffset + kPointerSize; | 9573 static const int kToNumberOffset = kToStringOffset + kPointerSize; |
9571 static const int kTypeOfOffset = kToNumberOffset + kPointerSize; | 9574 static const int kToBooleanOffset = kToNumberOffset + kPointerSize; |
| 9575 static const int kTypeOfOffset = kToBooleanOffset + kPointerSize; |
9572 static const int kKindOffset = kTypeOfOffset + kPointerSize; | 9576 static const int kKindOffset = kTypeOfOffset + kPointerSize; |
9573 static const int kSize = kKindOffset + kPointerSize; | 9577 static const int kSize = kKindOffset + kPointerSize; |
9574 | 9578 |
9575 static const byte kFalse = 0; | 9579 static const byte kFalse = 0; |
9576 static const byte kTrue = 1; | 9580 static const byte kTrue = 1; |
9577 static const byte kNotBooleanMask = ~1; | 9581 static const byte kNotBooleanMask = ~1; |
9578 static const byte kTheHole = 2; | 9582 static const byte kTheHole = 2; |
9579 static const byte kNull = 3; | 9583 static const byte kNull = 3; |
9580 static const byte kArgumentsMarker = 4; | 9584 static const byte kArgumentsMarker = 4; |
9581 static const byte kUndefined = 5; | 9585 static const byte kUndefined = 5; |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10871 } | 10875 } |
10872 return value; | 10876 return value; |
10873 } | 10877 } |
10874 }; | 10878 }; |
10875 | 10879 |
10876 | 10880 |
10877 } // NOLINT, false-positive due to second-order macros. | 10881 } // NOLINT, false-positive due to second-order macros. |
10878 } // NOLINT, false-positive due to second-order macros. | 10882 } // NOLINT, false-positive due to second-order macros. |
10879 | 10883 |
10880 #endif // V8_OBJECTS_H_ | 10884 #endif // V8_OBJECTS_H_ |
OLD | NEW |