Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: src/ast/ast-value-factory.cc

Issue 2485423002: Adding smi cache (Closed)
Patch Set: Changed signature to uint Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast/ast-value-factory.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/ast/ast-value-factory.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698