| Index: src/ast-value-factory.cc
|
| diff --git a/src/ast-value-factory.cc b/src/ast-value-factory.cc
|
| index 4df6ac01a03a7ddef1fa401c6b0707677bc1950b..0a1949a69cc2b05756aa1939e1d947ebffae2b12 100644
|
| --- a/src/ast-value-factory.cc
|
| +++ b/src/ast-value-factory.cc
|
| @@ -330,13 +330,23 @@ const AstValue* AstValueFactory::NewSmi(int number) {
|
| }
|
|
|
|
|
| +#define GENERATE_VALUE_GETTER(value, initializer) \
|
| + if (!value) { \
|
| + value = new (zone_) AstValue(initializer); \
|
| + if (isolate_) { \
|
| + value->Internalize(isolate_); \
|
| + } \
|
| + values_.Add(value); \
|
| + } \
|
| + return value;
|
| +
|
| +
|
| const AstValue* AstValueFactory::NewBoolean(bool b) {
|
| - AstValue* value = new (zone_) AstValue(b);
|
| - if (isolate_) {
|
| - value->Internalize(isolate_);
|
| + if (b) {
|
| + GENERATE_VALUE_GETTER(true_value_, true);
|
| + } else {
|
| + GENERATE_VALUE_GETTER(false_value_, false);
|
| }
|
| - values_.Add(value);
|
| - return value;
|
| }
|
|
|
|
|
| @@ -352,35 +362,22 @@ const AstValue* AstValueFactory::NewStringList(
|
|
|
|
|
| const AstValue* AstValueFactory::NewNull() {
|
| - AstValue* value = new (zone_) AstValue(AstValue::NULL_TYPE);
|
| - if (isolate_) {
|
| - value->Internalize(isolate_);
|
| - }
|
| - values_.Add(value);
|
| - return value;
|
| + GENERATE_VALUE_GETTER(null_value_, AstValue::NULL_TYPE);
|
| }
|
|
|
|
|
| const AstValue* AstValueFactory::NewUndefined() {
|
| - AstValue* value = new (zone_) AstValue(AstValue::UNDEFINED);
|
| - if (isolate_) {
|
| - value->Internalize(isolate_);
|
| - }
|
| - values_.Add(value);
|
| - return value;
|
| + GENERATE_VALUE_GETTER(undefined_value_, AstValue::UNDEFINED);
|
| }
|
|
|
|
|
| const AstValue* AstValueFactory::NewTheHole() {
|
| - AstValue* value = new (zone_) AstValue(AstValue::THE_HOLE);
|
| - if (isolate_) {
|
| - value->Internalize(isolate_);
|
| - }
|
| - values_.Add(value);
|
| - return value;
|
| + GENERATE_VALUE_GETTER(the_hole_value_, AstValue::THE_HOLE);
|
| }
|
|
|
|
|
| +#undef GENERATE_VALUE_GETTER
|
| +
|
| const AstRawString* AstValueFactory::GetString(
|
| uint32_t hash, bool is_one_byte, Vector<const byte> literal_bytes) {
|
| // literal_bytes here points to whatever the user passed, and this is OK
|
|
|