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