Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: src/objects.h

Issue 882973002: [turbofan] Improve JSON output (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ASAN Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/allocation.h" 10 #include "src/allocation.h"
(...skipping 8829 matching lines...) Expand 10 before | Expand all | Expand 10 after
8840 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we 8840 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
8841 // could use a mask to test if the length of string is less than or equal to 8841 // could use a mask to test if the length of string is less than or equal to
8842 // kMaxCachedArrayIndexLength. 8842 // kMaxCachedArrayIndexLength.
8843 STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1)); 8843 STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1));
8844 8844
8845 static const unsigned int kContainsCachedArrayIndexMask = 8845 static const unsigned int kContainsCachedArrayIndexMask =
8846 (~static_cast<unsigned>(kMaxCachedArrayIndexLength) 8846 (~static_cast<unsigned>(kMaxCachedArrayIndexLength)
8847 << ArrayIndexLengthBits::kShift) | 8847 << ArrayIndexLengthBits::kShift) |
8848 kIsNotArrayIndexMask; 8848 kIsNotArrayIndexMask;
8849 8849
8850 class SubStringRange {
8851 public:
8852 explicit SubStringRange(String* string, int first = 0, int length = -1)
8853 : string_(string),
8854 first_(first),
8855 length_(length == -1 ? string->length() : length) {}
8856 class iterator;
8857 inline iterator begin();
8858 inline iterator end();
8859
8860 private:
8861 String* string_;
8862 int first_;
8863 int length_;
8864 };
8865
8850 // Representation of the flat content of a String. 8866 // Representation of the flat content of a String.
8851 // A non-flat string doesn't have flat content. 8867 // A non-flat string doesn't have flat content.
8852 // A flat string has content that's encoded as a sequence of either 8868 // A flat string has content that's encoded as a sequence of either
8853 // one-byte chars or two-byte UC16. 8869 // one-byte chars or two-byte UC16.
8854 // Returned by String::GetFlatContent(). 8870 // Returned by String::GetFlatContent().
8855 class FlatContent { 8871 class FlatContent {
8856 public: 8872 public:
8857 // Returns true if the string is flat and this structure contains content. 8873 // Returns true if the string is flat and this structure contains content.
8858 bool IsFlat() { return state_ != NON_FLAT; } 8874 bool IsFlat() { return state_ != NON_FLAT; }
8859 // Returns true if the structure contains one-byte content. 8875 // Returns true if the structure contains one-byte content.
(...skipping 14 matching lines...) Expand all
8874 return Vector<const uc16>(twobyte_start, length_); 8890 return Vector<const uc16>(twobyte_start, length_);
8875 } 8891 }
8876 8892
8877 uc16 Get(int i) { 8893 uc16 Get(int i) {
8878 DCHECK(i < length_); 8894 DCHECK(i < length_);
8879 DCHECK(state_ != NON_FLAT); 8895 DCHECK(state_ != NON_FLAT);
8880 if (state_ == ONE_BYTE) return onebyte_start[i]; 8896 if (state_ == ONE_BYTE) return onebyte_start[i];
8881 return twobyte_start[i]; 8897 return twobyte_start[i];
8882 } 8898 }
8883 8899
8900 bool UsesSameString(const FlatContent& other) const {
8901 return onebyte_start == other.onebyte_start;
8902 }
8903
8884 private: 8904 private:
8885 enum State { NON_FLAT, ONE_BYTE, TWO_BYTE }; 8905 enum State { NON_FLAT, ONE_BYTE, TWO_BYTE };
8886 8906
8887 // Constructors only used by String::GetFlatContent(). 8907 // Constructors only used by String::GetFlatContent().
8888 explicit FlatContent(const uint8_t* start, int length) 8908 explicit FlatContent(const uint8_t* start, int length)
8889 : onebyte_start(start), length_(length), state_(ONE_BYTE) {} 8909 : onebyte_start(start), length_(length), state_(ONE_BYTE) {}
8890 explicit FlatContent(const uc16* start, int length) 8910 explicit FlatContent(const uc16* start, int length)
8891 : twobyte_start(start), length_(length), state_(TWO_BYTE) { } 8911 : twobyte_start(start), length_(length), state_(TWO_BYTE) { }
8892 FlatContent() : onebyte_start(NULL), length_(0), state_(NON_FLAT) { } 8912 FlatContent() : onebyte_start(NULL), length_(0), state_(NON_FLAT) { }
8893 8913
8894 union { 8914 union {
8895 const uint8_t* onebyte_start; 8915 const uint8_t* onebyte_start;
8896 const uc16* twobyte_start; 8916 const uc16* twobyte_start;
8897 }; 8917 };
8898 int length_; 8918 int length_;
8899 State state_; 8919 State state_;
8900 8920
8901 friend class String; 8921 friend class String;
8922 friend class IterableSubString;
8902 }; 8923 };
8903 8924
8904 template <typename Char> 8925 template <typename Char>
8905 INLINE(Vector<const Char> GetCharVector()); 8926 INLINE(Vector<const Char> GetCharVector());
8906 8927
8907 // Get and set the length of the string. 8928 // Get and set the length of the string.
8908 inline int length() const; 8929 inline int length() const;
8909 inline void set_length(int value); 8930 inline void set_length(int value);
8910 8931
8911 // Get and set the length of the string using acquire loads and release 8932 // Get and set the length of the string using acquire loads and release
(...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after
10944 } else { 10965 } else {
10945 value &= ~(1 << bit_position); 10966 value &= ~(1 << bit_position);
10946 } 10967 }
10947 return value; 10968 return value;
10948 } 10969 }
10949 }; 10970 };
10950 10971
10951 } } // namespace v8::internal 10972 } } // namespace v8::internal
10952 10973
10953 #endif // V8_OBJECTS_H_ 10974 #endif // V8_OBJECTS_H_
OLDNEW
« src/compiler/pipeline.cc ('K') | « src/hydrogen.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698