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

Side by Side Diff: src/objects.h

Issue 5963003: Clean up is-ASCII checks. (Closed)
Patch Set: Created 10 years 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 5227 matching lines...) Expand 10 before | Expand all | Expand 10 after
5238 unsigned* remaining, 5238 unsigned* remaining,
5239 unsigned* offset); 5239 unsigned* offset);
5240 5240
5241 // Helper function for flattening strings. 5241 // Helper function for flattening strings.
5242 template <typename sinkchar> 5242 template <typename sinkchar>
5243 static void WriteToFlat(String* source, 5243 static void WriteToFlat(String* source,
5244 sinkchar* sink, 5244 sinkchar* sink,
5245 int from, 5245 int from,
5246 int to); 5246 int to);
5247 5247
5248 static inline bool IsAscii(const char* chars, int length) {
5249 const char* limit = chars + length;
5250 #ifdef V8_HOST_CAN_READ_UNALIGNED
5251 ASSERT(kMaxAsciiCharCode == 0x7F);
5252 const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80;
5253 while (chars <= limit - sizeof(uintptr_t)) {
5254 if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) {
5255 return false;
5256 }
5257 chars += sizeof(uintptr_t);
5258 }
5259 #endif
5260 while (chars < limit) {
5261 if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return false;
5262 ++chars;
5263 }
5264 return true;
5265 }
5266
5267 static inline bool IsAscii(const uc16* chars, int length) {
5268 const uc16* limit = chars + length;
5269 while (chars < limit) {
5270 if (*chars > kMaxAsciiCharCodeU) return false;
5271 ++chars;
5272 }
5273 return true;
5274 }
5275
5248 protected: 5276 protected:
5249 class ReadBlockBuffer { 5277 class ReadBlockBuffer {
5250 public: 5278 public:
5251 ReadBlockBuffer(unibrow::byte* util_buffer_, 5279 ReadBlockBuffer(unibrow::byte* util_buffer_,
5252 unsigned cursor_, 5280 unsigned cursor_,
5253 unsigned capacity_, 5281 unsigned capacity_,
5254 unsigned remaining_) : 5282 unsigned remaining_) :
5255 util_buffer(util_buffer_), 5283 util_buffer(util_buffer_),
5256 cursor(cursor_), 5284 cursor(cursor_),
5257 capacity(capacity_), 5285 capacity(capacity_),
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
6348 } else { 6376 } else {
6349 value &= ~(1 << bit_position); 6377 value &= ~(1 << bit_position);
6350 } 6378 }
6351 return value; 6379 return value;
6352 } 6380 }
6353 }; 6381 };
6354 6382
6355 } } // namespace v8::internal 6383 } } // namespace v8::internal
6356 6384
6357 #endif // V8_OBJECTS_H_ 6385 #endif // V8_OBJECTS_H_
OLDNEW
« src/heap.cc ('K') | « src/ia32/regexp-macro-assembler-ia32.cc ('k') | src/string-search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698