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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/ast-value-factory.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.cc
diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc
index 1e4ef7d37cd1ce5b4a0489b7938669e50c755c16..ed2976f52a98b15ef6872e9363bd272c6dd7e9e9 100644
--- a/src/ast/ast-value-factory.cc
+++ b/src/ast/ast-value-factory.cc
@@ -330,10 +330,12 @@ const AstValue* AstValueFactory::NewNumber(double number, bool with_dot) {
return AddValue(value);
}
+const AstValue* AstValueFactory::NewSmi(uint32_t number) {
+ bool cacheable_smi = number <= kMaxCachedSmi;
+ if (cacheable_smi && smis_[number] != nullptr) return smis_[number];
-const AstValue* AstValueFactory::NewSmi(int number) {
- AstValue* value =
- new (zone_) AstValue(AstValue::SMI, number);
+ AstValue* value = new (zone_) AstValue(AstValue::SMI, number);
+ if (cacheable_smi) smis_[number] = value;
return AddValue(value);
}
« 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