| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/symbols.h" | 5 #include "vm/symbols.h" |
| 6 | 6 |
| 7 #include "vm/handles.h" | 7 #include "vm/handles.h" |
| 8 #include "vm/hash_table.h" | 8 #include "vm/hash_table.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 if (is_one_byte_string) { | 499 if (is_one_byte_string) { |
| 500 uint8_t* buffer = zone->Alloc<uint8_t>(len_sum); | 500 uint8_t* buffer = zone->Alloc<uint8_t>(len_sum); |
| 501 const uint8_t* const orig_buffer = buffer; | 501 const uint8_t* const orig_buffer = buffer; |
| 502 for (intptr_t i = 0; i < strs_length; i++) { | 502 for (intptr_t i = 0; i < strs_length; i++) { |
| 503 NoSafepointScope no_safepoint; | 503 NoSafepointScope no_safepoint; |
| 504 intptr_t str_len = lengths[i]; | 504 intptr_t str_len = lengths[i]; |
| 505 if (str_len > 0) { | 505 if (str_len > 0) { |
| 506 const String& str = strs[i]; | 506 const String& str = strs[i]; |
| 507 ASSERT(str.IsOneByteString() || str.IsExternalOneByteString()); | 507 ASSERT(str.IsOneByteString() || str.IsExternalOneByteString()); |
| 508 const uint8_t* src_p = str.IsOneByteString() | 508 const uint8_t* src_p = str.IsOneByteString() |
| 509 ? OneByteString::CharAddr(str, 0) | 509 ? OneByteString::DataStart(str) |
| 510 : ExternalOneByteString::CharAddr(str, 0); | 510 : ExternalOneByteString::DataStart(str); |
| 511 memmove(buffer, src_p, str_len); | 511 memmove(buffer, src_p, str_len); |
| 512 buffer += str_len; | 512 buffer += str_len; |
| 513 } | 513 } |
| 514 } | 514 } |
| 515 ASSERT(len_sum == buffer - orig_buffer); | 515 ASSERT(len_sum == buffer - orig_buffer); |
| 516 return Symbols::FromLatin1(thread, orig_buffer, len_sum); | 516 return Symbols::FromLatin1(thread, orig_buffer, len_sum); |
| 517 } else { | 517 } else { |
| 518 uint16_t* buffer = zone->Alloc<uint16_t>(len_sum); | 518 uint16_t* buffer = zone->Alloc<uint16_t>(len_sum); |
| 519 const uint16_t* const orig_buffer = buffer; | 519 const uint16_t* const orig_buffer = buffer; |
| 520 for (intptr_t i = 0; i < strs_length; i++) { | 520 for (intptr_t i = 0; i < strs_length; i++) { |
| 521 NoSafepointScope no_safepoint; | 521 NoSafepointScope no_safepoint; |
| 522 intptr_t str_len = lengths[i]; | 522 intptr_t str_len = lengths[i]; |
| 523 if (str_len > 0) { | 523 if (str_len > 0) { |
| 524 const String& str = strs[i]; | 524 const String& str = strs[i]; |
| 525 if (str.IsTwoByteString()) { | 525 if (str.IsTwoByteString()) { |
| 526 memmove(buffer, TwoByteString::CharAddr(str, 0), str_len * 2); | 526 memmove(buffer, TwoByteString::DataStart(str), str_len * 2); |
| 527 } else if (str.IsExternalTwoByteString()) { | 527 } else if (str.IsExternalTwoByteString()) { |
| 528 memmove(buffer, ExternalTwoByteString::CharAddr(str, 0), str_len * 2); | 528 memmove(buffer, ExternalTwoByteString::DataStart(str), str_len * 2); |
| 529 } else { | 529 } else { |
| 530 // One-byte to two-byte string copy. | 530 // One-byte to two-byte string copy. |
| 531 ASSERT(str.IsOneByteString() || str.IsExternalOneByteString()); | 531 ASSERT(str.IsOneByteString() || str.IsExternalOneByteString()); |
| 532 const uint8_t* src_p = str.IsOneByteString() | 532 const uint8_t* src_p = str.IsOneByteString() |
| 533 ? OneByteString::CharAddr(str, 0) | 533 ? OneByteString::DataStart(str) |
| 534 : ExternalOneByteString::CharAddr(str, 0); | 534 : ExternalOneByteString::DataStart(str); |
| 535 for (int n = 0; n < str_len; n++) { | 535 for (int n = 0; n < str_len; n++) { |
| 536 buffer[n] = src_p[n]; | 536 buffer[n] = src_p[n]; |
| 537 } | 537 } |
| 538 } | 538 } |
| 539 buffer += str_len; | 539 buffer += str_len; |
| 540 } | 540 } |
| 541 } | 541 } |
| 542 ASSERT(len_sum == buffer - orig_buffer); | 542 ASSERT(len_sum == buffer - orig_buffer); |
| 543 return Symbols::FromUTF16(thread, orig_buffer, len_sum); | 543 return Symbols::FromUTF16(thread, orig_buffer, len_sum); |
| 544 } | 544 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 RawObject* Symbols::GetPredefinedSymbol(intptr_t object_id) { | 699 RawObject* Symbols::GetPredefinedSymbol(intptr_t object_id) { |
| 700 ASSERT(IsPredefinedSymbolId(object_id)); | 700 ASSERT(IsPredefinedSymbolId(object_id)); |
| 701 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 701 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 702 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 702 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
| 703 return symbol_handles_[i]->raw(); | 703 return symbol_handles_[i]->raw(); |
| 704 } | 704 } |
| 705 return Object::null(); | 705 return Object::null(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 } // namespace dart | 708 } // namespace dart |
| OLD | NEW |