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 4516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4527 AllocateRawOneByteString(string.length(), pretenure); | 4527 AllocateRawOneByteString(string.length(), pretenure); |
4528 if (!maybe_result->ToObject(&result)) return maybe_result; | 4528 if (!maybe_result->ToObject(&result)) return maybe_result; |
4529 } | 4529 } |
4530 | 4530 |
4531 // Copy the characters into the new object. | 4531 // Copy the characters into the new object. |
4532 CopyChars(SeqOneByteString::cast(result)->GetChars(), string.start(), length); | 4532 CopyChars(SeqOneByteString::cast(result)->GetChars(), string.start(), length); |
4533 return result; | 4533 return result; |
4534 } | 4534 } |
4535 | 4535 |
4536 | 4536 |
4537 MaybeObject* Heap::AllocateStringFromAsciiSafe(Vector<const char> string, | |
4538 PretenureFlag pretenure) { | |
4539 if (string.length() == 1) { | |
4540 return Heap::LookupSingleCharacterStringFromCode(string | |
4541 [0] & String::kMaxAsciiCharCodeU); | |
4542 } | |
4543 Object* result; | |
4544 { MaybeObject* maybe_result = | |
4545 AllocateRawAsciiString(string.length(), pretenure); | |
4546 if (!maybe_result->ToObject(&result)) return maybe_result; | |
4547 } | |
4548 | |
4549 // Copy the characters into the new object. | |
4550 SeqAsciiString* string_result = SeqAsciiString::cast(result); | |
4551 for (int i = 0; i < string.length(); i++) { | |
4552 string_result->SeqAsciiStringSet(i, | |
bnoordhuis1
2012/12/07 04:54:47
AllocateRawAsciiString and SeqAsciiString don't ex
| |
4553 string[i] & String::kMaxAsciiCharCodeU); | |
4554 } | |
4555 return result; | |
4556 } | |
4557 | |
4558 | |
4537 MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, | 4559 MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, |
4538 int non_ascii_start, | 4560 int non_ascii_start, |
4539 PretenureFlag pretenure) { | 4561 PretenureFlag pretenure) { |
4540 // Continue counting the number of characters in the UTF-8 string, starting | 4562 // Continue counting the number of characters in the UTF-8 string, starting |
4541 // from the first non-ascii character or word. | 4563 // from the first non-ascii character or word. |
4542 int chars = non_ascii_start; | 4564 int chars = non_ascii_start; |
4543 Access<UnicodeCache::Utf8Decoder> | 4565 Access<UnicodeCache::Utf8Decoder> |
4544 decoder(isolate_->unicode_cache()->utf8_decoder()); | 4566 decoder(isolate_->unicode_cache()->utf8_decoder()); |
4545 decoder->Reset(string.start() + non_ascii_start, string.length() - chars); | 4567 decoder->Reset(string.start() + non_ascii_start, string.length() - chars); |
4546 while (decoder->has_more()) { | 4568 while (decoder->has_more()) { |
(...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7286 static_cast<int>(object_sizes_last_time_[index])); | 7308 static_cast<int>(object_sizes_last_time_[index])); |
7287 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7309 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7288 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7310 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7289 | 7311 |
7290 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7312 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7291 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7313 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7292 ClearObjectStats(); | 7314 ClearObjectStats(); |
7293 } | 7315 } |
7294 | 7316 |
7295 } } // namespace v8::internal | 7317 } } // namespace v8::internal |
OLD | NEW |