OLD | NEW |
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 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 size_t length = resource->length(); | 2545 size_t length = resource->length(); |
2546 if (length > static_cast<size_t>(String::kMaxLength)) { | 2546 if (length > static_cast<size_t>(String::kMaxLength)) { |
2547 Top::context()->mark_out_of_memory(); | 2547 Top::context()->mark_out_of_memory(); |
2548 return Failure::OutOfMemoryException(); | 2548 return Failure::OutOfMemoryException(); |
2549 } | 2549 } |
2550 | 2550 |
2551 // For small strings we check whether the resource contains only | 2551 // For small strings we check whether the resource contains only |
2552 // ASCII characters. If yes, we use a different string map. | 2552 // ASCII characters. If yes, we use a different string map. |
2553 static const size_t kAsciiCheckLengthLimit = 32; | 2553 static const size_t kAsciiCheckLengthLimit = 32; |
2554 bool is_ascii = length <= kAsciiCheckLengthLimit && | 2554 bool is_ascii = length <= kAsciiCheckLengthLimit && |
2555 String::IsAscii(resource->data(), length); | 2555 String::IsAscii(resource->data(), static_cast<int>(length)); |
2556 Map* map = is_ascii ? | 2556 Map* map = is_ascii ? |
2557 Heap::external_string_with_ascii_data_map() : Heap::external_string_map(); | 2557 Heap::external_string_with_ascii_data_map() : Heap::external_string_map(); |
2558 Object* result; | 2558 Object* result; |
2559 { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 2559 { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
2560 if (!maybe_result->ToObject(&result)) return maybe_result; | 2560 if (!maybe_result->ToObject(&result)) return maybe_result; |
2561 } | 2561 } |
2562 | 2562 |
2563 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); | 2563 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); |
2564 external_string->set_length(static_cast<int>(length)); | 2564 external_string->set_length(static_cast<int>(length)); |
2565 external_string->set_hash_field(String::kEmptyHashField); | 2565 external_string->set_hash_field(String::kEmptyHashField); |
(...skipping 2934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5500 void ExternalStringTable::TearDown() { | 5500 void ExternalStringTable::TearDown() { |
5501 new_space_strings_.Free(); | 5501 new_space_strings_.Free(); |
5502 old_space_strings_.Free(); | 5502 old_space_strings_.Free(); |
5503 } | 5503 } |
5504 | 5504 |
5505 | 5505 |
5506 List<Object*> ExternalStringTable::new_space_strings_; | 5506 List<Object*> ExternalStringTable::new_space_strings_; |
5507 List<Object*> ExternalStringTable::old_space_strings_; | 5507 List<Object*> ExternalStringTable::old_space_strings_; |
5508 | 5508 |
5509 } } // namespace v8::internal | 5509 } } // namespace v8::internal |
OLD | NEW |