diff options
Diffstat (limited to 'src/3rdparty/v8/src/utils.h')
-rw-r--r-- | src/3rdparty/v8/src/utils.h | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/src/3rdparty/v8/src/utils.h b/src/3rdparty/v8/src/utils.h index f116c14..e03f96f 100644 --- a/src/3rdparty/v8/src/utils.h +++ b/src/3rdparty/v8/src/utils.h @@ -248,6 +248,7 @@ class BitField { // bitfield without compiler warnings we have to compute 2^32 without // using a shift count of 32. static const uint32_t kMask = ((1U << shift) << size) - (1U << shift); + static const uint32_t kShift = shift; // Value for the field with all bits set. static const T kMax = static_cast<T>((1U << size) - 1); @@ -861,7 +862,11 @@ class EmbeddedContainer { public: EmbeddedContainer() : elems_() { } - int length() { return NumElements; } + int length() const { return NumElements; } + const ElementType& operator[](int i) const { + ASSERT(i < length()); + return elems_[i]; + } ElementType& operator[](int i) { ASSERT(i < length()); return elems_[i]; @@ -875,7 +880,12 @@ class EmbeddedContainer { template<typename ElementType> class EmbeddedContainer<ElementType, 0> { public: - int length() { return 0; } + int length() const { return 0; } + const ElementType& operator[](int i) const { + UNREACHABLE(); + static ElementType t = 0; + return t; + } ElementType& operator[](int i) { UNREACHABLE(); static ElementType t = 0; @@ -973,13 +983,59 @@ class EnumSet { T Mask(E element) const { // The strange typing in ASSERT is necessary to avoid stupid warnings, see: // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43680 - ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); + ASSERT(static_cast<int>(element) < static_cast<int>(sizeof(T) * CHAR_BIT)); return 1 << element; } T bits_; }; + +class TypeFeedbackId { + public: + explicit TypeFeedbackId(int id) : id_(id) { } + int ToInt() const { return id_; } + + static TypeFeedbackId None() { return TypeFeedbackId(kNoneId); } + bool IsNone() const { return id_ == kNoneId; } + + private: + static const int kNoneId = -1; + + int id_; +}; + + +class BailoutId { + public: + explicit BailoutId(int id) : id_(id) { } + int ToInt() const { return id_; } + + static BailoutId None() { return BailoutId(kNoneId); } + static BailoutId FunctionEntry() { return BailoutId(kFunctionEntryId); } + static BailoutId Declarations() { return BailoutId(kDeclarationsId); } + static BailoutId FirstUsable() { return BailoutId(kFirstUsableId); } + + bool IsNone() const { return id_ == kNoneId; } + bool operator==(const BailoutId& other) const { return id_ == other.id_; } + + private: + static const int kNoneId = -1; + + // Using 0 could disguise errors. + static const int kFunctionEntryId = 2; + + // This AST id identifies the point after the declarations have been visited. + // We need it to capture the environment effects of declarations that emit + // code (function declarations). + static const int kDeclarationsId = 3; + + // Ever FunctionState starts with this id. + static const int kFirstUsableId = 4; + + int id_; +}; + } } // namespace v8::internal #endif // V8_UTILS_H_ |