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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 AstValue* value = new (zone_) AstValue(name); | 323 AstValue* value = new (zone_) AstValue(name); |
324 return AddValue(value); | 324 return AddValue(value); |
325 } | 325 } |
326 | 326 |
327 | 327 |
328 const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) { | 328 const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) { |
329 AstValue* value = new (zone_) AstValue(number, with_dot); | 329 AstValue* value = new (zone_) AstValue(number, with_dot); |
330 return AddValue(value); | 330 return AddValue(value); |
331 } | 331 } |
332 | 332 |
| 333 const AstValue* AstValueFactory::NewSmi(uint32_t number) { |
| 334 bool cacheable_smi = number <= kMaxCachedSmi; |
| 335 if (cacheable_smi && smis_[number] != nullptr) return smis_[number]; |
333 | 336 |
334 const AstValue* AstValueFactory::NewSmi(int number) { | 337 AstValue* value = new (zone_) AstValue(AstValue::SMI, number); |
335 AstValue* value = | 338 if (cacheable_smi) smis_[number] = value; |
336 new (zone_) AstValue(AstValue::SMI, number); | |
337 return AddValue(value); | 339 return AddValue(value); |
338 } | 340 } |
339 | 341 |
340 #define GENERATE_VALUE_GETTER(value, initializer) \ | 342 #define GENERATE_VALUE_GETTER(value, initializer) \ |
341 if (!value) { \ | 343 if (!value) { \ |
342 value = AddValue(new (zone_) AstValue(initializer)); \ | 344 value = AddValue(new (zone_) AstValue(initializer)); \ |
343 } \ | 345 } \ |
344 return value; | 346 return value; |
345 | 347 |
346 const AstValue* AstValueFactory::NewBoolean(bool b) { | 348 const AstValue* AstValueFactory::NewBoolean(bool b) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 length) == 0; | 420 length) == 0; |
419 } else { | 421 } else { |
420 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 422 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
421 reinterpret_cast<const uint16_t*>(r), | 423 reinterpret_cast<const uint16_t*>(r), |
422 length) == 0; | 424 length) == 0; |
423 } | 425 } |
424 } | 426 } |
425 } | 427 } |
426 } // namespace internal | 428 } // namespace internal |
427 } // namespace v8 | 429 } // namespace v8 |
OLD | NEW |