| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "src/ast/ast-value-factory.h" | 28 #include "src/ast/ast-value-factory.h" |
| 29 | 29 |
| 30 #include "src/api.h" | 30 #include "src/api.h" |
| 31 #include "src/char-predicates-inl.h" |
| 31 #include "src/objects.h" | 32 #include "src/objects.h" |
| 32 #include "src/utils.h" | 33 #include "src/utils.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 // For using StringToArrayIndex. | 40 // For using StringToArrayIndex. |
| 40 class OneByteStringStream { | 41 class OneByteStringStream { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 break; | 216 break; |
| 216 case UNDEFINED: | 217 case UNDEFINED: |
| 217 set_value(isolate->factory()->undefined_value()); | 218 set_value(isolate->factory()->undefined_value()); |
| 218 break; | 219 break; |
| 219 } | 220 } |
| 220 } | 221 } |
| 221 | 222 |
| 222 | 223 |
| 223 AstRawString* AstValueFactory::GetOneByteStringInternal( | 224 AstRawString* AstValueFactory::GetOneByteStringInternal( |
| 224 Vector<const uint8_t> literal) { | 225 Vector<const uint8_t> literal) { |
| 226 if (literal.length() == 1 && IsInRange(literal[0], 'a', 'z')) { |
| 227 int key = literal[0] - 'a'; |
| 228 if (one_character_strings_[key] == nullptr) { |
| 229 uint32_t hash = StringHasher::HashSequentialString<uint8_t>( |
| 230 literal.start(), literal.length(), hash_seed_); |
| 231 one_character_strings_[key] = GetString(hash, true, literal); |
| 232 } |
| 233 return one_character_strings_[key]; |
| 234 } |
| 225 uint32_t hash = StringHasher::HashSequentialString<uint8_t>( | 235 uint32_t hash = StringHasher::HashSequentialString<uint8_t>( |
| 226 literal.start(), literal.length(), hash_seed_); | 236 literal.start(), literal.length(), hash_seed_); |
| 227 return GetString(hash, true, literal); | 237 return GetString(hash, true, literal); |
| 228 } | 238 } |
| 229 | 239 |
| 230 | 240 |
| 231 AstRawString* AstValueFactory::GetTwoByteStringInternal( | 241 AstRawString* AstValueFactory::GetTwoByteStringInternal( |
| 232 Vector<const uint16_t> literal) { | 242 Vector<const uint16_t> literal) { |
| 233 uint32_t hash = StringHasher::HashSequentialString<uint16_t>( | 243 uint32_t hash = StringHasher::HashSequentialString<uint16_t>( |
| 234 literal.start(), literal.length(), hash_seed_); | 244 literal.start(), literal.length(), hash_seed_); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 length) == 0; | 397 length) == 0; |
| 388 } else { | 398 } else { |
| 389 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 399 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
| 390 reinterpret_cast<const uint16_t*>(r), | 400 reinterpret_cast<const uint16_t*>(r), |
| 391 length) == 0; | 401 length) == 0; |
| 392 } | 402 } |
| 393 } | 403 } |
| 394 } | 404 } |
| 395 } // namespace internal | 405 } // namespace internal |
| 396 } // namespace v8 | 406 } // namespace v8 |
| OLD | NEW |