| OLD | NEW |
| 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 4285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4296 | 4296 |
| 4297 | 4297 |
| 4298 bool String::IsOneByte() const { | 4298 bool String::IsOneByte() const { |
| 4299 i::Handle<i::String> str = Utils::OpenHandle(this); | 4299 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 4300 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { | 4300 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { |
| 4301 return false; | 4301 return false; |
| 4302 } | 4302 } |
| 4303 return str->HasOnlyOneByteChars(); | 4303 return str->HasOnlyOneByteChars(); |
| 4304 } | 4304 } |
| 4305 | 4305 |
| 4306 // Helpers for ContainsOnlyOneByteHelper |
| 4307 template<size_t size> struct OneByteMask; |
| 4308 template<> struct OneByteMask<4> { |
| 4309 static const uint32_t value = 0xFF00FF00; |
| 4310 }; |
| 4311 template<> struct OneByteMask<8> { |
| 4312 static const uint64_t value = 0xFF00FF00FF00FF00; |
| 4313 }; |
| 4314 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value; |
| 4315 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; |
| 4316 static inline bool Unaligned(const uint16_t* chars) { |
| 4317 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; |
| 4318 } |
| 4319 static inline const uint16_t* Align(const uint16_t* chars) { |
| 4320 return reinterpret_cast<uint16_t*>( |
| 4321 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); |
| 4322 } |
| 4306 | 4323 |
| 4307 class ContainsOnlyOneByteHelper { | 4324 class ContainsOnlyOneByteHelper { |
| 4308 public: | 4325 public: |
| 4309 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} | 4326 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} |
| 4310 bool Check(i::String* string) { | 4327 bool Check(i::String* string) { |
| 4311 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); | 4328 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); |
| 4312 if (cons_string == NULL) return is_one_byte_; | 4329 if (cons_string == NULL) return is_one_byte_; |
| 4313 return CheckCons(cons_string); | 4330 return CheckCons(cons_string); |
| 4314 } | 4331 } |
| 4315 void VisitOneByteString(const uint8_t* chars, int length) { | 4332 void VisitOneByteString(const uint8_t* chars, int length) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4341 } | 4358 } |
| 4342 // Read the rest. | 4359 // Read the rest. |
| 4343 while (chars != end) { | 4360 while (chars != end) { |
| 4344 acc |= *chars++; | 4361 acc |= *chars++; |
| 4345 } | 4362 } |
| 4346 // Check result. | 4363 // Check result. |
| 4347 if ((acc & kOneByteMask) != 0) is_one_byte_ = false; | 4364 if ((acc & kOneByteMask) != 0) is_one_byte_ = false; |
| 4348 } | 4365 } |
| 4349 | 4366 |
| 4350 private: | 4367 private: |
| 4351 static const uintptr_t kOneByteMask = | |
| 4352 static_cast<uintptr_t>(0xFF00FF00FF00FF00ULL); | |
| 4353 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; | |
| 4354 static inline bool Unaligned(const uint16_t* chars) { | |
| 4355 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; | |
| 4356 } | |
| 4357 static inline const uint16_t* Align(const uint16_t* chars) { | |
| 4358 return reinterpret_cast<uint16_t*>( | |
| 4359 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); | |
| 4360 } | |
| 4361 bool CheckCons(i::ConsString* cons_string) { | 4368 bool CheckCons(i::ConsString* cons_string) { |
| 4362 while (true) { | 4369 while (true) { |
| 4363 // Check left side if flat. | 4370 // Check left side if flat. |
| 4364 i::String* left = cons_string->first(); | 4371 i::String* left = cons_string->first(); |
| 4365 i::ConsString* left_as_cons = | 4372 i::ConsString* left_as_cons = |
| 4366 i::String::VisitFlat(this, left, 0); | 4373 i::String::VisitFlat(this, left, 0); |
| 4367 if (!is_one_byte_) return false; | 4374 if (!is_one_byte_) return false; |
| 4368 // Check right side if flat. | 4375 // Check right side if flat. |
| 4369 i::String* right = cons_string->second(); | 4376 i::String* right = cons_string->second(); |
| 4370 i::ConsString* right_as_cons = | 4377 i::ConsString* right_as_cons = |
| (...skipping 3617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7988 | 7995 |
| 7989 v->VisitPointers(blocks_.first(), first_block_limit_); | 7996 v->VisitPointers(blocks_.first(), first_block_limit_); |
| 7990 | 7997 |
| 7991 for (int i = 1; i < blocks_.length(); i++) { | 7998 for (int i = 1; i < blocks_.length(); i++) { |
| 7992 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7999 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
| 7993 } | 8000 } |
| 7994 } | 8001 } |
| 7995 | 8002 |
| 7996 | 8003 |
| 7997 } } // namespace v8::internal | 8004 } } // namespace v8::internal |
| OLD | NEW |