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); |
} |