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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 F(false_value) \ | 326 F(false_value) \ |
327 F(null_value) \ | 327 F(null_value) \ |
328 F(undefined_value) \ | 328 F(undefined_value) \ |
329 F(the_hole_value) | 329 F(the_hole_value) |
330 | 330 |
331 class AstValueFactory { | 331 class AstValueFactory { |
332 public: | 332 public: |
333 AstValueFactory(Zone* zone, uint32_t hash_seed) | 333 AstValueFactory(Zone* zone, uint32_t hash_seed) |
334 : string_table_(AstRawStringCompare), | 334 : string_table_(AstRawStringCompare), |
335 values_(nullptr), | 335 values_(nullptr), |
336 smis_(), | |
337 strings_(nullptr), | 336 strings_(nullptr), |
338 strings_end_(&strings_), | 337 strings_end_(&strings_), |
339 zone_(zone), | 338 zone_(zone), |
340 hash_seed_(hash_seed) { | 339 hash_seed_(hash_seed) { |
341 #define F(name, str) name##_string_ = NULL; | 340 #define F(name, str) name##_string_ = NULL; |
342 STRING_CONSTANTS(F) | 341 STRING_CONSTANTS(F) |
343 #undef F | 342 #undef F |
344 #define F(name) name##_ = NULL; | 343 #define F(name) name##_ = NULL; |
345 OTHER_CONSTANTS(F) | 344 OTHER_CONSTANTS(F) |
346 #undef F | 345 #undef F |
347 std::fill(smis_, smis_ + arraysize(smis_), nullptr); | 346 std::fill(smis_, smis_ + arraysize(smis_), nullptr); |
| 347 std::fill(one_character_strings_, |
| 348 one_character_strings_ + arraysize(one_character_strings_), |
| 349 nullptr); |
348 } | 350 } |
349 | 351 |
350 Zone* zone() const { return zone_; } | 352 Zone* zone() const { return zone_; } |
351 | 353 |
352 const AstRawString* GetOneByteString(Vector<const uint8_t> literal) { | 354 const AstRawString* GetOneByteString(Vector<const uint8_t> literal) { |
353 return GetOneByteStringInternal(literal); | 355 return GetOneByteStringInternal(literal); |
354 } | 356 } |
355 const AstRawString* GetOneByteString(const char* string) { | 357 const AstRawString* GetOneByteString(const char* string) { |
356 return GetOneByteString(Vector<const uint8_t>( | 358 return GetOneByteString(Vector<const uint8_t>( |
357 reinterpret_cast<const uint8_t*>(string), StrLength(string))); | 359 reinterpret_cast<const uint8_t*>(string), StrLength(string))); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 Vector<const byte> literal_bytes); | 417 Vector<const byte> literal_bytes); |
416 | 418 |
417 static bool AstRawStringCompare(void* a, void* b); | 419 static bool AstRawStringCompare(void* a, void* b); |
418 | 420 |
419 // All strings are copied here, one after another (no NULLs inbetween). | 421 // All strings are copied here, one after another (no NULLs inbetween). |
420 base::CustomMatcherHashMap string_table_; | 422 base::CustomMatcherHashMap string_table_; |
421 // For keeping track of all AstValues and AstRawStrings we've created (so that | 423 // For keeping track of all AstValues and AstRawStrings we've created (so that |
422 // they can be internalized later). | 424 // they can be internalized later). |
423 AstValue* values_; | 425 AstValue* values_; |
424 | 426 |
425 AstValue* smis_[kMaxCachedSmi + 1]; | |
426 // We need to keep track of strings_ in order since cons strings require their | 427 // We need to keep track of strings_ in order since cons strings require their |
427 // members to be internalized first. | 428 // members to be internalized first. |
428 AstString* strings_; | 429 AstString* strings_; |
429 AstString** strings_end_; | 430 AstString** strings_end_; |
| 431 |
| 432 // Caches for faster access: small numbers, one character lowercase strings |
| 433 // (for minified code). |
| 434 AstValue* smis_[kMaxCachedSmi + 1]; |
| 435 AstRawString* one_character_strings_[26]; |
| 436 |
430 Zone* zone_; | 437 Zone* zone_; |
431 | 438 |
432 uint32_t hash_seed_; | 439 uint32_t hash_seed_; |
433 | 440 |
434 #define F(name, str) const AstRawString* name##_string_; | 441 #define F(name, str) const AstRawString* name##_string_; |
435 STRING_CONSTANTS(F) | 442 STRING_CONSTANTS(F) |
436 #undef F | 443 #undef F |
437 | 444 |
438 #define F(name) AstValue* name##_; | 445 #define F(name) AstValue* name##_; |
439 OTHER_CONSTANTS(F) | 446 OTHER_CONSTANTS(F) |
440 #undef F | 447 #undef F |
441 }; | 448 }; |
442 } // namespace internal | 449 } // namespace internal |
443 } // namespace v8 | 450 } // namespace v8 |
444 | 451 |
445 #undef STRING_CONSTANTS | 452 #undef STRING_CONSTANTS |
446 #undef OTHER_CONSTANTS | 453 #undef OTHER_CONSTANTS |
447 | 454 |
448 #endif // V8_AST_AST_VALUE_FACTORY_H_ | 455 #endif // V8_AST_AST_VALUE_FACTORY_H_ |
OLD | NEW |