Index: src/ast.h |
diff --git a/src/ast.h b/src/ast.h |
index 0115d988272c44e64f326d6f7377619824f2ea41..3f227d8a7668d338f7b9fd6c435f0c636037cbe4 100644 |
--- a/src/ast.h |
+++ b/src/ast.h |
@@ -367,11 +367,14 @@ class Expression : public AstNode { |
protected: |
Expression(Zone* zone, int pos) |
: AstNode(pos), |
+ zone_(zone), |
bounds_(Bounds::Unbounded(zone)), |
id_(GetNextId(zone)), |
test_id_(GetNextId(zone)) {} |
void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
+ Zone* zone_; |
+ |
private: |
Bounds bounds_; |
byte to_boolean_types_; |
@@ -390,7 +393,7 @@ class BreakableStatement : public Statement { |
// The labels associated with this statement. May be NULL; |
// if it is != NULL, guaranteed to contain at least one entry. |
- ZoneStringList* labels() const { return labels_; } |
+ ZoneList<ParserSymbolTable::Symbol*>* labels() const { return labels_; } |
// Type testing & conversion. |
virtual BreakableStatement* AsBreakableStatement() V8_FINAL V8_OVERRIDE { |
@@ -410,7 +413,7 @@ class BreakableStatement : public Statement { |
protected: |
BreakableStatement( |
- Zone* zone, ZoneStringList* labels, |
+ Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, |
BreakableType breakable_type, int position) |
: Statement(zone, position), |
labels_(labels), |
@@ -422,7 +425,7 @@ class BreakableStatement : public Statement { |
private: |
- ZoneStringList* labels_; |
+ ZoneList<ParserSymbolTable::Symbol*>* labels_; |
BreakableType breakable_type_; |
Label break_target_; |
const BailoutId entry_id_; |
@@ -451,7 +454,7 @@ class Block V8_FINAL : public BreakableStatement { |
protected: |
Block(Zone* zone, |
- ZoneStringList* labels, |
+ ZoneList<ParserSymbolTable::Symbol*>* labels, |
int capacity, |
bool is_initializer_block, |
int pos) |
@@ -658,18 +661,16 @@ class ModulePath V8_FINAL : public Module { |
DECLARE_NODE_TYPE(ModulePath) |
Module* module() const { return module_; } |
- Handle<String> name() const { return name_; } |
+ Handle<String> name() const { return name_->string(); } |
protected: |
- ModulePath(Zone* zone, Module* module, Handle<String> name, int pos) |
- : Module(zone, pos), |
- module_(module), |
- name_(name) { |
- } |
+ ModulePath(Zone* zone, Module* module, ParserSymbolTable::Symbol* name, |
+ int pos) |
+ : Module(zone, pos), module_(module), name_(name) {} |
private: |
Module* module_; |
- Handle<String> name_; |
+ ParserSymbolTable::Symbol* name_; |
}; |
@@ -726,11 +727,11 @@ class IterationStatement : public BreakableStatement { |
Label* continue_target() { return &continue_target_; } |
protected: |
- IterationStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ IterationStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, |
+ int pos) |
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
body_(NULL), |
- osr_entry_id_(GetNextId(zone)) { |
- } |
+ osr_entry_id_(GetNextId(zone)) {} |
void Initialize(Statement* body) { |
body_ = body; |
@@ -760,12 +761,12 @@ class DoWhileStatement V8_FINAL : public IterationStatement { |
BailoutId BackEdgeId() const { return back_edge_id_; } |
protected: |
- DoWhileStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ DoWhileStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, |
+ int pos) |
: IterationStatement(zone, labels, pos), |
cond_(NULL), |
continue_id_(GetNextId(zone)), |
- back_edge_id_(GetNextId(zone)) { |
- } |
+ back_edge_id_(GetNextId(zone)) {} |
private: |
Expression* cond_; |
@@ -797,12 +798,12 @@ class WhileStatement V8_FINAL : public IterationStatement { |
BailoutId BodyId() const { return body_id_; } |
protected: |
- WhileStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ WhileStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, |
+ int pos) |
: IterationStatement(zone, labels, pos), |
cond_(NULL), |
may_have_function_literal_(true), |
- body_id_(GetNextId(zone)) { |
- } |
+ body_id_(GetNextId(zone)) {} |
private: |
Expression* cond_; |
@@ -848,7 +849,7 @@ class ForStatement V8_FINAL : public IterationStatement { |
void set_loop_variable(Variable* var) { loop_variable_ = var; } |
protected: |
- ForStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ ForStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, int pos) |
rossberg
2014/05/08 12:52:08
Nit: line length
marja
2014/06/03 08:48:20
Done.
|
: IterationStatement(zone, labels, pos), |
init_(NULL), |
cond_(NULL), |
@@ -890,7 +891,7 @@ class ForEachStatement : public IterationStatement { |
Expression* subject() const { return subject_; } |
protected: |
- ForEachStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ ForEachStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, int pos) |
rossberg
2014/05/08 12:52:08
Nit: line length
marja
2014/06/03 08:48:20
Done.
|
: IterationStatement(zone, labels, pos), |
each_(NULL), |
subject_(NULL) { |
@@ -930,7 +931,7 @@ class ForInStatement V8_FINAL : public ForEachStatement, |
virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } |
protected: |
- ForInStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ ForInStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, int pos) |
rossberg
2014/05/08 12:52:08
Nit: line length
marja
2014/06/03 08:48:20
Done.
|
: ForEachStatement(zone, labels, pos), |
for_in_type_(SLOW_FOR_IN), |
for_in_feedback_slot_(kInvalidFeedbackSlot), |
@@ -993,7 +994,7 @@ class ForOfStatement V8_FINAL : public ForEachStatement { |
BailoutId BackEdgeId() const { return back_edge_id_; } |
protected: |
- ForOfStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ ForOfStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, int pos) |
rossberg
2014/05/08 12:52:08
Nit: line length
marja
2014/06/03 08:48:20
Done.
|
: ForEachStatement(zone, labels, pos), |
assign_iterator_(NULL), |
next_result_(NULL), |
@@ -1153,7 +1154,7 @@ class SwitchStatement V8_FINAL : public BreakableStatement { |
ZoneList<CaseClause*>* cases() const { return cases_; } |
protected: |
- SwitchStatement(Zone* zone, ZoneStringList* labels, int pos) |
+ SwitchStatement(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* labels, int pos) |
rossberg
2014/05/08 12:52:08
Nit: line length
marja
2014/06/03 08:48:20
Done.
|
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
tag_(NULL), |
cases_(NULL) { } |
@@ -1333,18 +1334,23 @@ class Literal V8_FINAL : public Expression { |
DECLARE_NODE_TYPE(Literal) |
virtual bool IsPropertyName() const V8_OVERRIDE { |
- if (value_->IsInternalizedString()) { |
- uint32_t ignored; |
- return !String::cast(*value_)->AsArrayIndex(&ignored); |
+ if (string_) { |
+ return !ParserSymbolTable::IsArrayIndexSlow(string_); |
} |
return false; |
} |
Handle<String> AsPropertyName() { |
+ ASSERT(!value_.is_null()); |
ASSERT(IsPropertyName()); |
return Handle<String>::cast(value_); |
} |
+ ParserSymbolTable::Symbol* AsRawPropertyName() { |
+ ASSERT(IsPropertyName()); |
+ return string_; |
+ } |
+ |
virtual bool ToBooleanIsTrue() const V8_OVERRIDE { |
return value_->BooleanValue(); |
} |
@@ -1366,7 +1372,34 @@ class Literal V8_FINAL : public Expression { |
return value_->IsFalse(); |
} |
- Handle<Object> value() const { return value_; } |
+ // FIXME: this is temporary |
+ Handle<Object> valueIfNotString() const { |
+ return value_; |
+ } |
+ // FIXME: this function is called both before and after the internalization |
+ // point. Figure out how to. |
+ Handle<Object> value() const { |
+ if (!value_.is_null()) { |
rossberg
2014/05/08 12:52:08
Is it an invariant that at least one of value_, st
marja
2014/06/03 08:48:20
This is now refactored so that we have another Lit
|
+ return value_; |
+ } |
+ if (string_ != NULL) { |
+ value_ = string_->string(); |
+ } else if (strings_ != NULL) { |
+ // FIXME: get the isolate from somewhere else |
+ Factory* factory = Isolate::Current()->factory(); |
+ int len = strings_->length(); |
+ Handle<FixedArray> elements = factory->NewFixedArray(len, TENURED); |
+ for (int i = 0; i < len; i++) { |
+ Handle<Object> element = (*strings_)[i]->string(); |
+ elements->set(i, *element); |
+ } |
+ value_ = |
+ factory->NewJSArrayWithElements(elements, FAST_ELEMENTS, TENURED); |
+ } |
+ return value_; |
+ } |
+ |
+ ParserSymbolTable::Symbol* string() const { return string_; } |
rossberg
2014/05/08 12:52:08
Maybe call these symbol/symbol_?
marja
2014/06/03 08:48:20
This is also in the other class now, and I think i
|
// Support for using Literal as a HashMap key. NOTE: Currently, this works |
// only for string and number literals! |
@@ -1384,12 +1417,29 @@ class Literal V8_FINAL : public Expression { |
Literal(Zone* zone, Handle<Object> value, int position) |
: Expression(zone, position), |
value_(value), |
+ string_(NULL), |
+ strings_(NULL), |
isolate_(zone->isolate()) { } |
+ Literal(Zone* zone, ParserSymbolTable::Symbol* string, int position) |
+ : Expression(zone, position), |
+ string_(string), |
+ strings_(NULL), |
+ isolate_(zone->isolate()) { |
+ } |
+ Literal(Zone* zone, ZoneList<ParserSymbolTable::Symbol*>* strings, |
+ int position) |
+ : Expression(zone, position), |
+ string_(NULL), |
+ strings_(strings), |
+ isolate_(zone->isolate()) { |
+ } |
private: |
Handle<String> ToString(); |
- Handle<Object> value_; |
+ mutable Handle<Object> value_; |
+ ParserSymbolTable::Symbol* string_; |
+ ZoneList<ParserSymbolTable::Symbol*>* strings_; |
rossberg
2014/05/08 12:52:08
symbols_? Also, add a comment that this is to repr
marja
2014/06/03 08:48:20
Ditto (added comment about this to the literal cla
|
// TODO(dcarney): remove. this is only needed for Match and Hash. |
Isolate* isolate_; |
}; |
@@ -1559,13 +1609,13 @@ class RegExpLiteral V8_FINAL : public MaterializedLiteral { |
public: |
DECLARE_NODE_TYPE(RegExpLiteral) |
- Handle<String> pattern() const { return pattern_; } |
- Handle<String> flags() const { return flags_; } |
+ Handle<String> pattern() const { return pattern_->string(); } |
+ Handle<String> flags() const { return flags_->string(); } |
protected: |
RegExpLiteral(Zone* zone, |
- Handle<String> pattern, |
- Handle<String> flags, |
+ ParserSymbolTable::Symbol* pattern, |
+ ParserSymbolTable::Symbol* flags, |
int literal_index, |
int pos) |
: MaterializedLiteral(zone, literal_index, pos), |
@@ -1575,8 +1625,8 @@ class RegExpLiteral V8_FINAL : public MaterializedLiteral { |
} |
private: |
- Handle<String> pattern_; |
- Handle<String> flags_; |
+ ParserSymbolTable::Symbol* pattern_; |
+ ParserSymbolTable::Symbol* flags_; |
}; |
@@ -1635,7 +1685,8 @@ class VariableProxy V8_FINAL : public Expression { |
bool IsLValue() const { return is_lvalue_; } |
- Handle<String> name() const { return name_; } |
+ Handle<String> name() const { return raw_name_->string(); } |
+ ParserSymbolTable::Symbol* raw_name() const { return raw_name_; } |
Variable* var() const { return var_; } |
bool is_this() const { return is_this_; } |
Interface* interface() const { return interface_; } |
@@ -1651,12 +1702,12 @@ class VariableProxy V8_FINAL : public Expression { |
VariableProxy(Zone* zone, Variable* var, int position); |
VariableProxy(Zone* zone, |
- Handle<String> name, |
+ ParserSymbolTable::Symbol* raw_name, |
bool is_this, |
Interface* interface, |
int position); |
- Handle<String> name_; |
+ ParserSymbolTable::Symbol* raw_name_; |
Variable* var_; // resolved variable, or NULL |
bool is_this_; |
bool is_trivial_; |
@@ -1887,7 +1938,8 @@ class CallRuntime V8_FINAL : public Expression { |
public: |
DECLARE_NODE_TYPE(CallRuntime) |
- Handle<String> name() const { return name_; } |
+ Handle<String> name() const { return raw_name_->string(); } |
+ ParserSymbolTable::Symbol* raw_name() const { return raw_name_; } |
const Runtime::Function* function() const { return function_; } |
ZoneList<Expression*>* arguments() const { return arguments_; } |
bool is_jsruntime() const { return function_ == NULL; } |
@@ -1896,17 +1948,17 @@ class CallRuntime V8_FINAL : public Expression { |
protected: |
CallRuntime(Zone* zone, |
- Handle<String> name, |
+ ParserSymbolTable::Symbol* name, |
const Runtime::Function* function, |
ZoneList<Expression*>* arguments, |
int pos) |
: Expression(zone, pos), |
- name_(name), |
+ raw_name_(name), |
function_(function), |
arguments_(arguments) { } |
private: |
- Handle<String> name_; |
+ ParserSymbolTable::Symbol* raw_name_; |
const Runtime::Function* function_; |
ZoneList<Expression*>* arguments_; |
}; |
@@ -2294,7 +2346,8 @@ class FunctionLiteral V8_FINAL : public Expression { |
DECLARE_NODE_TYPE(FunctionLiteral) |
- Handle<String> name() const { return name_; } |
+ Handle<String> name() const { return raw_name_->string(); } |
+ ParserSymbolTable::Symbol* raw_name() const { return raw_name_; } |
Scope* scope() const { return scope_; } |
ZoneList<Statement*>* body() const { return body_; } |
void set_function_token_position(int pos) { function_token_position_ = pos; } |
@@ -2317,14 +2370,31 @@ class FunctionLiteral V8_FINAL : public Expression { |
void InitializeSharedInfo(Handle<Code> code); |
Handle<String> debug_name() const { |
- if (name_->length() > 0) return name_; |
+ if (raw_name_ != NULL) { |
+ return raw_name_->string(); |
+ } |
return inferred_name(); |
} |
- Handle<String> inferred_name() const { return inferred_name_; } |
void set_inferred_name(Handle<String> inferred_name) { |
inferred_name_ = inferred_name; |
} |
+ Handle<String> inferred_name() const { |
+ if (raw_inferred_name_ != NULL) { |
rossberg
2014/05/08 12:52:08
I'm surprised that inferred_name_ does not take pr
marja
2014/06/03 08:48:20
Doesn't matter, because only one of them will be s
|
+ return raw_inferred_name_->string(); |
+ } |
+ if (!inferred_name_.is_null()) { |
+ return inferred_name_; |
+ } |
+ // FIXME: here we'd need an empty string... |
+ return Isolate::Current()->factory()->empty_string(); |
+ } |
+ ParserSymbolTable::Symbol* raw_inferred_name() const { |
+ return raw_inferred_name_; |
+ } |
+ void set_raw_inferred_name(ParserSymbolTable::Symbol* raw_inferred_name) { |
+ raw_inferred_name_ = raw_inferred_name; |
+ } |
// shared_info may be null if it's not cached in full code. |
Handle<SharedFunctionInfo> shared_info() { return shared_info_; } |
@@ -2370,7 +2440,7 @@ class FunctionLiteral V8_FINAL : public Expression { |
protected: |
FunctionLiteral(Zone* zone, |
- Handle<String> name, |
+ ParserSymbolTable::Symbol* name, |
Scope* scope, |
ZoneList<Statement*>* body, |
int materialized_literal_count, |
@@ -2384,10 +2454,10 @@ class FunctionLiteral V8_FINAL : public Expression { |
IsGeneratorFlag is_generator, |
int position) |
: Expression(zone, position), |
- name_(name), |
+ raw_name_(name), |
scope_(scope), |
body_(body), |
- inferred_name_(zone->isolate()->factory()->empty_string()), |
+ raw_inferred_name_(NULL), |
dont_optimize_reason_(kNoReason), |
materialized_literal_count_(materialized_literal_count), |
expected_property_count_(expected_property_count), |
@@ -2405,10 +2475,12 @@ class FunctionLiteral V8_FINAL : public Expression { |
} |
private: |
+ ParserSymbolTable::Symbol* raw_name_; |
Handle<String> name_; |
Handle<SharedFunctionInfo> shared_info_; |
Scope* scope_; |
ZoneList<Statement*>* body_; |
+ ParserSymbolTable::Symbol* raw_inferred_name_; |
Handle<String> inferred_name_; |
AstProperties ast_properties_; |
BailoutReason dont_optimize_reason_; |
@@ -2434,16 +2506,16 @@ class NativeFunctionLiteral V8_FINAL : public Expression { |
public: |
DECLARE_NODE_TYPE(NativeFunctionLiteral) |
- Handle<String> name() const { return name_; } |
+ Handle<String> name() const { return raw_name_->string(); } |
v8::Extension* extension() const { return extension_; } |
protected: |
- NativeFunctionLiteral( |
- Zone* zone, Handle<String> name, v8::Extension* extension, int pos) |
- : Expression(zone, pos), name_(name), extension_(extension) {} |
+ NativeFunctionLiteral(Zone* zone, ParserSymbolTable::Symbol* name, |
+ v8::Extension* extension, int pos) |
+ : Expression(zone, pos), raw_name_(name), extension_(extension) {} |
private: |
- Handle<String> name_; |
+ ParserSymbolTable::Symbol* raw_name_; |
v8::Extension* extension_; |
}; |
@@ -2999,7 +3071,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
VISIT_AND_RETURN(ModuleVariable, module) |
} |
- ModulePath* NewModulePath(Module* origin, Handle<String> name, int pos) { |
+ ModulePath* NewModulePath(Module* origin, ParserSymbolTable::Symbol* name, |
+ int pos) { |
ModulePath* module = new(zone_) ModulePath(zone_, origin, name, pos); |
VISIT_AND_RETURN(ModulePath, module) |
} |
@@ -3009,7 +3082,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
VISIT_AND_RETURN(ModuleUrl, module) |
} |
- Block* NewBlock(ZoneStringList* labels, |
+ Block* NewBlock(ZoneList<ParserSymbolTable::Symbol*>* labels, |
int capacity, |
bool is_initializer_block, |
int pos) { |
@@ -3019,7 +3092,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
} |
#define STATEMENT_WITH_LABELS(NodeType) \ |
- NodeType* New##NodeType(ZoneStringList* labels, int pos) { \ |
+ NodeType* New##NodeType(ZoneList<ParserSymbolTable::Symbol*>* labels,\ |
+ int pos) { \ |
NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \ |
VISIT_AND_RETURN(NodeType, stmt); \ |
} |
@@ -3030,7 +3104,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
#undef STATEMENT_WITH_LABELS |
ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
- ZoneStringList* labels, |
+ ZoneList<ParserSymbolTable::Symbol*>* labels, |
int pos) { |
switch (visit_mode) { |
case ForEachStatement::ENUMERATE: { |
@@ -3132,6 +3206,16 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
VISIT_AND_RETURN(Literal, lit) |
} |
+ Literal* NewLiteral(ParserSymbolTable::Symbol* string, int pos) { |
+ Literal* lit = new(zone_) Literal(zone_, string, pos); |
+ VISIT_AND_RETURN(Literal, lit) |
+ } |
+ |
+ Literal* NewLiteral(ZoneList<ParserSymbolTable::Symbol*>* strings, int pos) { |
+ Literal* lit = new(zone_) Literal(zone_, strings, pos); |
+ VISIT_AND_RETURN(Literal, lit) |
+ } |
+ |
Literal* NewNumberLiteral(double number, int pos) { |
return NewLiteral( |
zone_->isolate()->factory()->NewNumber(number, TENURED), pos); |
@@ -3159,12 +3243,12 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
int pos) { |
ObjectLiteral::Property* prop = |
new(zone_) ObjectLiteral::Property(zone_, is_getter, value); |
- prop->set_key(NewLiteral(value->name(), pos)); |
+ prop->set_key(NewLiteral(value->raw_name(), pos)); |
return prop; // Not an AST node, will not be visited. |
} |
- RegExpLiteral* NewRegExpLiteral(Handle<String> pattern, |
- Handle<String> flags, |
+ RegExpLiteral* NewRegExpLiteral(ParserSymbolTable::Symbol* pattern, |
+ ParserSymbolTable::Symbol* flags, |
int literal_index, |
int pos) { |
RegExpLiteral* lit = |
@@ -3186,7 +3270,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
VISIT_AND_RETURN(VariableProxy, proxy) |
} |
- VariableProxy* NewVariableProxy(Handle<String> name, |
+ VariableProxy* NewVariableProxy(ParserSymbolTable::Symbol* name, |
bool is_this, |
Interface* interface = Interface::NewValue(), |
int position = RelocInfo::kNoPosition) { |
@@ -3214,7 +3298,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
VISIT_AND_RETURN(CallNew, call) |
} |
- CallRuntime* NewCallRuntime(Handle<String> name, |
+ CallRuntime* NewCallRuntime(ParserSymbolTable::Symbol* name, |
const Runtime::Function* function, |
ZoneList<Expression*>* arguments, |
int pos) { |
@@ -3292,7 +3376,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
} |
FunctionLiteral* NewFunctionLiteral( |
- Handle<String> name, |
+ ParserSymbolTable::Symbol* name, |
Scope* scope, |
ZoneList<Statement*>* body, |
int materialized_literal_count, |
@@ -3318,7 +3402,7 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
} |
NativeFunctionLiteral* NewNativeFunctionLiteral( |
- Handle<String> name, v8::Extension* extension, int pos) { |
+ ParserSymbolTable::Symbol* name, v8::Extension* extension, int pos) { |
NativeFunctionLiteral* lit = |
new(zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
VISIT_AND_RETURN(NativeFunctionLiteral, lit) |