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

Side by Side Diff: src/heap.cc

Issue 11194053: Keep track of the first non-ascii word/char to avoid redoing the work. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 2 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
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4410 matching lines...) Expand 10 before | Expand all | Expand 10 after
4421 if (!maybe_result->ToObject(&result)) return maybe_result; 4421 if (!maybe_result->ToObject(&result)) return maybe_result;
4422 } 4422 }
4423 4423
4424 // Copy the characters into the new object. 4424 // Copy the characters into the new object.
4425 CopyChars(SeqAsciiString::cast(result)->GetChars(), string.start(), length); 4425 CopyChars(SeqAsciiString::cast(result)->GetChars(), string.start(), length);
4426 return result; 4426 return result;
4427 } 4427 }
4428 4428
4429 4429
4430 MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, 4430 MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string,
4431 int non_ascii_start,
4431 PretenureFlag pretenure) { 4432 PretenureFlag pretenure) {
4432 // Count the number of characters in the UTF-8 string and check if 4433 // Continue counting the number of characters in the UTF-8 string, starting
4433 // it is an ASCII string. 4434 // from the first non-ascii character or word.
4435 int chars = non_ascii_start;
4434 Access<UnicodeCache::Utf8Decoder> 4436 Access<UnicodeCache::Utf8Decoder>
4435 decoder(isolate_->unicode_cache()->utf8_decoder()); 4437 decoder(isolate_->unicode_cache()->utf8_decoder());
4436 decoder->Reset(string.start(), string.length()); 4438 decoder->Reset(string.start() + non_ascii_start, string.length() - chars);
4437 int chars = 0;
4438 while (decoder->has_more()) { 4439 while (decoder->has_more()) {
4439 uint32_t r = decoder->GetNext(); 4440 uint32_t r = decoder->GetNext();
4440 if (r <= unibrow::Utf16::kMaxNonSurrogateCharCode) { 4441 if (r <= unibrow::Utf16::kMaxNonSurrogateCharCode) {
4441 chars++; 4442 chars++;
4442 } else { 4443 } else {
4443 chars += 2; 4444 chars += 2;
4444 } 4445 }
4445 } 4446 }
4446 4447
4447 Object* result; 4448 Object* result;
(...skipping 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after
7337 static_cast<int>(object_sizes_last_time_[index])); 7338 static_cast<int>(object_sizes_last_time_[index]));
7338 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7339 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7339 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7340 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7340 7341
7341 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7342 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7342 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7343 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7343 ClearObjectStats(); 7344 ClearObjectStats();
7344 } 7345 }
7345 7346
7346 } } // namespace v8::internal 7347 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698