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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 353 |
354 #undef GENERATE_VALUE_GETTER | 354 #undef GENERATE_VALUE_GETTER |
355 | 355 |
356 AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte, | 356 AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte, |
357 Vector<const byte> literal_bytes) { | 357 Vector<const byte> literal_bytes) { |
358 // literal_bytes here points to whatever the user passed, and this is OK | 358 // literal_bytes here points to whatever the user passed, and this is OK |
359 // because we use vector_compare (which checks the contents) to compare | 359 // because we use vector_compare (which checks the contents) to compare |
360 // against the AstRawStrings which are in the string_table_. We should not | 360 // against the AstRawStrings which are in the string_table_. We should not |
361 // return this AstRawString. | 361 // return this AstRawString. |
362 AstRawString key(is_one_byte, literal_bytes, hash); | 362 AstRawString key(is_one_byte, literal_bytes, hash); |
363 HashMap::Entry* entry = string_table_.LookupOrInsert(&key, hash); | 363 base::HashMap::Entry* entry = string_table_.LookupOrInsert(&key, hash); |
364 if (entry->value == NULL) { | 364 if (entry->value == NULL) { |
365 // Copy literal contents for later comparison. | 365 // Copy literal contents for later comparison. |
366 int length = literal_bytes.length(); | 366 int length = literal_bytes.length(); |
367 byte* new_literal_bytes = zone_->NewArray<byte>(length); | 367 byte* new_literal_bytes = zone_->NewArray<byte>(length); |
368 memcpy(new_literal_bytes, literal_bytes.start(), length); | 368 memcpy(new_literal_bytes, literal_bytes.start(), length); |
369 AstRawString* new_string = new (zone_) AstRawString( | 369 AstRawString* new_string = new (zone_) AstRawString( |
370 is_one_byte, Vector<const byte>(new_literal_bytes, length), hash); | 370 is_one_byte, Vector<const byte>(new_literal_bytes, length), hash); |
371 entry->key = new_string; | 371 entry->key = new_string; |
372 strings_.Add(new_string); | 372 strings_.Add(new_string); |
373 if (isolate_) { | 373 if (isolate_) { |
(...skipping 30 matching lines...) Expand all Loading... |
404 length) == 0; | 404 length) == 0; |
405 } else { | 405 } else { |
406 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 406 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
407 reinterpret_cast<const uint16_t*>(r), | 407 reinterpret_cast<const uint16_t*>(r), |
408 length) == 0; | 408 length) == 0; |
409 } | 409 } |
410 } | 410 } |
411 } | 411 } |
412 } // namespace internal | 412 } // namespace internal |
413 } // namespace v8 | 413 } // namespace v8 |
OLD | NEW |