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

Side by Side Diff: src/objects.h

Issue 11818025: Continues Latin-1 support. All tests pass with ENABLE_LATIN_1 flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ARM fix Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7070 matching lines...) Expand 10 before | Expand all | Expand 10 after
7081 // Returned by String::GetFlatContent(). 7081 // Returned by String::GetFlatContent().
7082 class FlatContent { 7082 class FlatContent {
7083 public: 7083 public:
7084 // Returns true if the string is flat and this structure contains content. 7084 // Returns true if the string is flat and this structure contains content.
7085 bool IsFlat() { return state_ != NON_FLAT; } 7085 bool IsFlat() { return state_ != NON_FLAT; }
7086 // Returns true if the structure contains ASCII content. 7086 // Returns true if the structure contains ASCII content.
7087 bool IsAscii() { return state_ == ASCII; } 7087 bool IsAscii() { return state_ == ASCII; }
7088 // Returns true if the structure contains two-byte content. 7088 // Returns true if the structure contains two-byte content.
7089 bool IsTwoByte() { return state_ == TWO_BYTE; } 7089 bool IsTwoByte() { return state_ == TWO_BYTE; }
7090 7090
7091 // TODO(dcarney): Remove this function.
7092 // Return the ASCII content of the string. Only use if IsAscii() returns
7093 // true.
7094 Vector<const char> ToAsciiVector() {
7095 ASSERT_EQ(ASCII, state_);
7096 return Vector<const char>::cast(buffer_);
7097 }
7098 // Return the one byte content of the string. Only use if IsAscii() returns 7091 // Return the one byte content of the string. Only use if IsAscii() returns
7099 // true. 7092 // true.
7100 Vector<const uint8_t> ToOneByteVector() { 7093 Vector<const uint8_t> ToOneByteVector() {
7101 ASSERT_EQ(ASCII, state_); 7094 ASSERT_EQ(ASCII, state_);
7102 return buffer_; 7095 return buffer_;
7103 } 7096 }
7104 // Return the two-byte content of the string. Only use if IsTwoByte() 7097 // Return the two-byte content of the string. Only use if IsTwoByte()
7105 // returns true. 7098 // returns true.
7106 Vector<const uc16> ToUC16Vector() { 7099 Vector<const uc16> ToUC16Vector() {
7107 ASSERT_EQ(TWO_BYTE, state_); 7100 ASSERT_EQ(TWO_BYTE, state_);
7108 return Vector<const uc16>::cast(buffer_); 7101 return Vector<const uc16>::cast(buffer_);
7109 } 7102 }
7110 7103
7111 private: 7104 private:
7112 enum State { NON_FLAT, ASCII, TWO_BYTE }; 7105 enum State { NON_FLAT, ASCII, TWO_BYTE };
7113 7106
7114 // Constructors only used by String::GetFlatContent(). 7107 // Constructors only used by String::GetFlatContent().
7115 explicit FlatContent(Vector<const char> chars) 7108 explicit FlatContent(Vector<const uint8_t> chars)
7116 : buffer_(Vector<const byte>::cast(chars)), 7109 : buffer_(chars),
7117 state_(ASCII) { } 7110 state_(ASCII) { }
7118 explicit FlatContent(Vector<const uc16> chars) 7111 explicit FlatContent(Vector<const uc16> chars)
7119 : buffer_(Vector<const byte>::cast(chars)), 7112 : buffer_(Vector<const byte>::cast(chars)),
7120 state_(TWO_BYTE) { } 7113 state_(TWO_BYTE) { }
7121 FlatContent() : buffer_(), state_(NON_FLAT) { } 7114 FlatContent() : buffer_(), state_(NON_FLAT) { }
7122 7115
7123 Vector<const byte> buffer_; 7116 Vector<const uint8_t> buffer_;
7124 State state_; 7117 State state_;
7125 7118
7126 friend class String; 7119 friend class String;
7127 }; 7120 };
7128 7121
7129 // Get and set the length of the string. 7122 // Get and set the length of the string.
7130 inline int length(); 7123 inline int length();
7131 inline void set_length(int value); 7124 inline void set_length(int value);
7132 7125
7133 // Get and set the hash field of the string. 7126 // Get and set the hash field of the string.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
7382 } 7375 }
7383 ++chars; 7376 ++chars;
7384 } 7377 }
7385 return static_cast<int>(chars - start); 7378 return static_cast<int>(chars - start);
7386 } 7379 }
7387 7380
7388 static inline bool IsAscii(const char* chars, int length) { 7381 static inline bool IsAscii(const char* chars, int length) {
7389 return NonAsciiStart(chars, length) >= length; 7382 return NonAsciiStart(chars, length) >= length;
7390 } 7383 }
7391 7384
7385 static inline bool IsAscii(const uint8_t* chars, int length) {
7386 return
7387 NonAsciiStart(reinterpret_cast<const char*>(chars), length) >= length;
Yang 2013/01/09 15:39:30 Could we also change NonAsciiStart to take const u
drcarney 2013/01/09 16:27:31 we need the char implementation for utf8 code patc
7388 }
7389
7392 static inline int NonOneByteStart(const uc16* chars, int length) { 7390 static inline int NonOneByteStart(const uc16* chars, int length) {
7393 const uc16* limit = chars + length; 7391 const uc16* limit = chars + length;
7394 const uc16* start = chars; 7392 const uc16* start = chars;
7395 while (chars < limit) { 7393 while (chars < limit) {
7396 if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start); 7394 if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start);
7397 ++chars; 7395 ++chars;
7398 } 7396 }
7399 return static_cast<int>(chars - start); 7397 return static_cast<int>(chars - start);
7400 } 7398 }
7401 7399
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
7458 public: 7456 public:
7459 static const bool kHasAsciiEncoding = true; 7457 static const bool kHasAsciiEncoding = true;
7460 7458
7461 // Dispatched behavior. 7459 // Dispatched behavior.
7462 inline uint16_t SeqOneByteStringGet(int index); 7460 inline uint16_t SeqOneByteStringGet(int index);
7463 inline void SeqOneByteStringSet(int index, uint16_t value); 7461 inline void SeqOneByteStringSet(int index, uint16_t value);
7464 7462
7465 // Get the address of the characters in this string. 7463 // Get the address of the characters in this string.
7466 inline Address GetCharsAddress(); 7464 inline Address GetCharsAddress();
7467 7465
7468 // TODO(dcarney): remove GetChars and rename GetCharsU to GetChars. 7466 inline uint8_t* GetChars();
7469 inline char* GetChars();
7470 inline uint8_t* GetCharsU();
7471 7467
7472 // Casting 7468 // Casting
7473 static inline SeqOneByteString* cast(Object* obj); 7469 static inline SeqOneByteString* cast(Object* obj);
7474 7470
7475 // Garbage collection support. This method is called by the 7471 // Garbage collection support. This method is called by the
7476 // garbage collector to compute the actual size of an AsciiString 7472 // garbage collector to compute the actual size of an AsciiString
7477 // instance. 7473 // instance.
7478 inline int SeqOneByteStringSize(InstanceType instance_type); 7474 inline int SeqOneByteStringSize(InstanceType instance_type);
7479 7475
7480 // Computes the size for an AsciiString instance of a given length. 7476 // Computes the size for an AsciiString instance of a given length.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
7673 // The underlying resource. 7669 // The underlying resource.
7674 inline const Resource* resource(); 7670 inline const Resource* resource();
7675 inline void set_resource(const Resource* buffer); 7671 inline void set_resource(const Resource* buffer);
7676 7672
7677 // Update the pointer cache to the external character array. 7673 // Update the pointer cache to the external character array.
7678 // The cached pointer is always valid, as the external character array does = 7674 // The cached pointer is always valid, as the external character array does =
7679 // not move during lifetime. Deserialization is the only exception, after 7675 // not move during lifetime. Deserialization is the only exception, after
7680 // which the pointer cache has to be refreshed. 7676 // which the pointer cache has to be refreshed.
7681 inline void update_data_cache(); 7677 inline void update_data_cache();
7682 7678
7683 inline const char* GetChars(); 7679 inline const uint8_t* GetChars();
7684 7680
7685 // Dispatched behavior. 7681 // Dispatched behavior.
7686 inline uint16_t ExternalAsciiStringGet(int index); 7682 inline uint16_t ExternalAsciiStringGet(int index);
7687 7683
7688 // Casting. 7684 // Casting.
7689 static inline ExternalAsciiString* cast(Object* obj); 7685 static inline ExternalAsciiString* cast(Object* obj);
7690 7686
7691 // Garbage collection support. 7687 // Garbage collection support.
7692 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v); 7688 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v);
7693 7689
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
8828 } else { 8824 } else {
8829 value &= ~(1 << bit_position); 8825 value &= ~(1 << bit_position);
8830 } 8826 }
8831 return value; 8827 return value;
8832 } 8828 }
8833 }; 8829 };
8834 8830
8835 } } // namespace v8::internal 8831 } } // namespace v8::internal
8836 8832
8837 #endif // V8_OBJECTS_H_ 8833 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698