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 9415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9426 bool has_more() { return index_ < data_.length(); } | 9426 bool has_more() { return index_ < data_.length(); } |
9427 private: | 9427 private: |
9428 Vector<const T> data_; | 9428 Vector<const T> data_; |
9429 int index_; | 9429 int index_; |
9430 }; | 9430 }; |
9431 | 9431 |
9432 | 9432 |
9433 // The Oddball describes objects null, undefined, true, and false. | 9433 // The Oddball describes objects null, undefined, true, and false. |
9434 class Oddball: public HeapObject { | 9434 class Oddball: public HeapObject { |
9435 public: | 9435 public: |
| 9436 // [to_number_raw]: Cached raw to_number computed at startup. |
| 9437 inline double to_number_raw() const; |
| 9438 inline void set_to_number_raw(double value); |
| 9439 |
9436 // [to_string]: Cached to_string computed at startup. | 9440 // [to_string]: Cached to_string computed at startup. |
9437 DECL_ACCESSORS(to_string, String) | 9441 DECL_ACCESSORS(to_string, String) |
9438 | 9442 |
9439 // [to_number]: Cached to_number computed at startup. | 9443 // [to_number]: Cached to_number computed at startup. |
9440 DECL_ACCESSORS(to_number, Object) | 9444 DECL_ACCESSORS(to_number, Object) |
9441 | 9445 |
9442 // [to_number]: Cached to_boolean computed at startup. | 9446 // [to_number]: Cached to_boolean computed at startup. |
9443 DECL_ACCESSORS(to_boolean, Oddball) | 9447 DECL_ACCESSORS(to_boolean, Oddball) |
9444 | 9448 |
9445 // [typeof]: Cached type_of computed at startup. | 9449 // [typeof]: Cached type_of computed at startup. |
9446 DECL_ACCESSORS(type_of, String) | 9450 DECL_ACCESSORS(type_of, String) |
9447 | 9451 |
9448 inline byte kind() const; | 9452 inline byte kind() const; |
9449 inline void set_kind(byte kind); | 9453 inline void set_kind(byte kind); |
9450 | 9454 |
9451 // ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined. | 9455 // ES6 section 7.1.3 ToNumber for Boolean, Null, Undefined. |
9452 MUST_USE_RESULT static inline Handle<Object> ToNumber(Handle<Oddball> input); | 9456 MUST_USE_RESULT static inline Handle<Object> ToNumber(Handle<Oddball> input); |
9453 | 9457 |
9454 DECLARE_CAST(Oddball) | 9458 DECLARE_CAST(Oddball) |
9455 | 9459 |
9456 // Dispatched behavior. | 9460 // Dispatched behavior. |
9457 DECLARE_VERIFIER(Oddball) | 9461 DECLARE_VERIFIER(Oddball) |
9458 | 9462 |
9459 // Initialize the fields. | 9463 // Initialize the fields. |
9460 static void Initialize(Isolate* isolate, Handle<Oddball> oddball, | 9464 static void Initialize(Isolate* isolate, Handle<Oddball> oddball, |
9461 const char* to_string, Handle<Object> to_number, | 9465 const char* to_string, Handle<Object> to_number, |
9462 bool to_boolean, const char* type_of, byte kind); | 9466 bool to_boolean, const char* type_of, byte kind); |
9463 | 9467 |
9464 // Layout description. | 9468 // Layout description. |
9465 static const int kToStringOffset = HeapObject::kHeaderSize; | 9469 static const int kToNumberRawOffset = HeapObject::kHeaderSize; |
| 9470 static const int kToStringOffset = kToNumberRawOffset + kDoubleSize; |
9466 static const int kToNumberOffset = kToStringOffset + kPointerSize; | 9471 static const int kToNumberOffset = kToStringOffset + kPointerSize; |
9467 static const int kToBooleanOffset = kToNumberOffset + kPointerSize; | 9472 static const int kToBooleanOffset = kToNumberOffset + kPointerSize; |
9468 static const int kTypeOfOffset = kToBooleanOffset + kPointerSize; | 9473 static const int kTypeOfOffset = kToBooleanOffset + kPointerSize; |
9469 static const int kKindOffset = kTypeOfOffset + kPointerSize; | 9474 static const int kKindOffset = kTypeOfOffset + kPointerSize; |
9470 static const int kSize = kKindOffset + kPointerSize; | 9475 static const int kSize = kKindOffset + kPointerSize; |
9471 | 9476 |
9472 static const byte kFalse = 0; | 9477 static const byte kFalse = 0; |
9473 static const byte kTrue = 1; | 9478 static const byte kTrue = 1; |
9474 static const byte kNotBooleanMask = ~1; | 9479 static const byte kNotBooleanMask = ~1; |
9475 static const byte kTheHole = 2; | 9480 static const byte kTheHole = 2; |
9476 static const byte kNull = 3; | 9481 static const byte kNull = 3; |
9477 static const byte kArgumentsMarker = 4; | 9482 static const byte kArgumentsMarker = 4; |
9478 static const byte kUndefined = 5; | 9483 static const byte kUndefined = 5; |
9479 static const byte kUninitialized = 6; | 9484 static const byte kUninitialized = 6; |
9480 static const byte kOther = 7; | 9485 static const byte kOther = 7; |
9481 static const byte kException = 8; | 9486 static const byte kException = 8; |
9482 static const byte kOptimizedOut = 9; | 9487 static const byte kOptimizedOut = 9; |
9483 | 9488 |
9484 typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize, | 9489 typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize, |
9485 kSize> BodyDescriptor; | 9490 kSize> BodyDescriptor; |
9486 | 9491 |
| 9492 STATIC_ASSERT(kToNumberRawOffset == HeapNumber::kValueOffset); |
9487 STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset); | 9493 STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset); |
9488 STATIC_ASSERT(kNull == Internals::kNullOddballKind); | 9494 STATIC_ASSERT(kNull == Internals::kNullOddballKind); |
9489 STATIC_ASSERT(kUndefined == Internals::kUndefinedOddballKind); | 9495 STATIC_ASSERT(kUndefined == Internals::kUndefinedOddballKind); |
9490 | 9496 |
9491 private: | 9497 private: |
9492 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); | 9498 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); |
9493 }; | 9499 }; |
9494 | 9500 |
9495 | 9501 |
9496 class Cell: public HeapObject { | 9502 class Cell: public HeapObject { |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10776 } | 10782 } |
10777 return value; | 10783 return value; |
10778 } | 10784 } |
10779 }; | 10785 }; |
10780 | 10786 |
10781 | 10787 |
10782 } // NOLINT, false-positive due to second-order macros. | 10788 } // NOLINT, false-positive due to second-order macros. |
10783 } // NOLINT, false-positive due to second-order macros. | 10789 } // NOLINT, false-positive due to second-order macros. |
10784 | 10790 |
10785 #endif // V8_OBJECTS_H_ | 10791 #endif // V8_OBJECTS_H_ |
OLD | NEW |