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

Unified Diff: src/ast/ast-value-factory.h

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.h ('k') | src/ast/ast-value-factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.h
diff --git a/src/ast/ast-value-factory.h b/src/ast/ast-value-factory.h
index 51c0df7a807416ad69e3361c338eef356e75a105..4ce480fe570b94b6fda45492592985afaeb137cb 100644
--- a/src/ast/ast-value-factory.h
+++ b/src/ast/ast-value-factory.h
@@ -332,6 +332,7 @@ class AstValueFactory {
AstValueFactory(Zone* zone, uint32_t hash_seed)
: string_table_(AstRawStringCompare),
values_(nullptr),
+ smis_(),
strings_(nullptr),
strings_end_(&strings_),
zone_(zone),
@@ -342,6 +343,7 @@ class AstValueFactory {
#define F(name) name##_ = NULL;
OTHER_CONSTANTS(F)
#undef F
+ std::fill(smis_, smis_ + arraysize(smis_), nullptr);
}
Zone* zone() const { return zone_; }
@@ -381,7 +383,7 @@ class AstValueFactory {
// A JavaScript symbol (ECMA-262 edition 6).
const AstValue* NewSymbol(const char* name);
const AstValue* NewNumber(double number, bool with_dot = false);
- const AstValue* NewSmi(int number);
+ const AstValue* NewSmi(uint32_t number);
const AstValue* NewBoolean(bool b);
const AstValue* NewStringList(ZoneList<const AstRawString*>* strings);
const AstValue* NewNull();
@@ -389,6 +391,10 @@ class AstValueFactory {
const AstValue* NewTheHole();
private:
+ static const uint32_t kMaxCachedSmi = 1 << 10;
+
+ STATIC_ASSERT(kMaxCachedSmi <= Smi::kMaxValue);
+
AstValue* AddValue(AstValue* value) {
value->set_next(values_);
values_ = value;
@@ -416,6 +422,8 @@ class AstValueFactory {
// For keeping track of all AstValues and AstRawStrings we've created (so that
// they can be internalized later).
AstValue* values_;
+
+ AstValue* smis_[kMaxCachedSmi + 1];
// We need to keep track of strings_ in order since cons strings require their
// members to be internalized first.
AstString* strings_;
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-value-factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698