43 result_assigned_(
false),
47 InitializeAstVisitor(zone);
66 bool result_assigned_;
78 result_assigned_ =
true;
79 VariableProxy* result_proxy =
factory()->NewVariableProxy(result_);
80 return factory()->NewAssignment(
81 Token::ASSIGN, result_proxy, value, RelocInfo::kNoPosition);
85 #define DEF_VISIT(type) \
86 virtual void Visit##type(type* node);
90 void VisitIterationStatement(IterationStatement* stmt);
92 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
97 for (
int i = statements->length() - 1; i >= 0; --i) {
98 Visit(statements->
at(i));
103 void Processor::VisitBlock(
Block* node) {
112 if (!node->is_initializer_block())
Process(node->statements());
116 void Processor::VisitModuleStatement(ModuleStatement* node) {
117 bool set_after_body = is_set_;
119 is_set_ = is_set_ && set_after_body;
123 void Processor::VisitExpressionStatement(ExpressionStatement* node) {
125 if (!is_set_ && !node->expression()->IsThrow()) {
126 node->set_expression(SetResult(node->expression()));
127 if (!in_try_) is_set_ =
true;
132 void Processor::VisitIfStatement(IfStatement* node) {
135 Visit(node->else_statement());
136 bool set_after_then = is_set_;
138 Visit(node->then_statement());
139 is_set_ = is_set_ && set_after_then;
143 void Processor::VisitIterationStatement(IterationStatement* node) {
145 bool set_after_loop = is_set_;
147 is_set_ = is_set_ && set_after_loop;
151 void Processor::VisitDoWhileStatement(DoWhileStatement* node) {
152 VisitIterationStatement(node);
156 void Processor::VisitWhileStatement(WhileStatement* node) {
157 VisitIterationStatement(node);
161 void Processor::VisitForStatement(ForStatement* node) {
162 VisitIterationStatement(node);
166 void Processor::VisitForInStatement(ForInStatement* node) {
167 VisitIterationStatement(node);
171 void Processor::VisitForOfStatement(ForOfStatement* node) {
172 VisitIterationStatement(node);
176 void Processor::VisitTryCatchStatement(TryCatchStatement* node) {
178 bool set_after_catch = is_set_;
179 Visit(node->catch_block());
180 is_set_ = is_set_ && set_after_catch;
183 Visit(node->try_block());
188 void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
190 Visit(node->finally_block());
193 Visit(node->try_block());
198 void Processor::VisitSwitchStatement(SwitchStatement* node) {
200 ZoneList<CaseClause*>* clauses = node->cases();
201 bool set_after_switch = is_set_;
202 for (
int i = clauses->length() - 1; i >= 0; --i) {
203 CaseClause* clause = clauses->at(i);
206 is_set_ = is_set_ && set_after_switch;
210 void Processor::VisitContinueStatement(ContinueStatement* node) {
215 void Processor::VisitBreakStatement(BreakStatement* node) {
220 void Processor::VisitWithStatement(WithStatement* node) {
221 bool set_after_body = is_set_;
222 Visit(node->statement());
223 is_set_ = is_set_ && set_after_body;
228 void Processor::VisitVariableDeclaration(VariableDeclaration* node) {}
229 void Processor::VisitFunctionDeclaration(FunctionDeclaration* node) {}
230 void Processor::VisitModuleDeclaration(ModuleDeclaration* node) {}
231 void Processor::VisitImportDeclaration(ImportDeclaration* node) {}
232 void Processor::VisitExportDeclaration(ExportDeclaration* node) {}
233 void Processor::VisitModuleLiteral(ModuleLiteral* node) {}
234 void Processor::VisitModuleVariable(ModuleVariable* node) {}
235 void Processor::VisitModulePath(ModulePath* node) {}
236 void Processor::VisitModuleUrl(ModuleUrl* node) {}
237 void Processor::VisitEmptyStatement(EmptyStatement* node) {}
238 void Processor::VisitReturnStatement(ReturnStatement* node) {}
239 void Processor::VisitDebuggerStatement(DebuggerStatement* node) {}
243 #define DEF_VISIT(type) \
244 void Processor::Visit##type(type* expr) { UNREACHABLE(); }
252 FunctionLiteral*
function = info->
function();
254 Scope* scope =
function->scope();
259 if (!body->is_empty()) {
264 if (processor.HasStackOverflow())
return false;
266 if (processor.result_assigned()) {
267 ASSERT(function->end_position() != RelocInfo::kNoPosition);
274 int pos =
function->end_position();
275 VariableProxy* result_proxy = processor.factory()->NewVariableProxy(
277 result_proxy->BindTo(result);
279 processor.factory()->NewReturnStatement(result_proxy, pos);
280 body->
Add(result_statement, info->
zone());
bool is_global_scope() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
AstNodeFactory< AstNullVisitor > * factory()
Processor(Variable *result, Zone *zone)
Isolate * isolate() const
bool result_assigned() const
#define ASSERT(condition)
Variable * NewTemporary(Handle< String > name)
Interface * interface() const
void Process(ZoneList< Statement * > *statements)
Handle< String > name() const
bool is_eval_scope() const
FunctionLiteral * function() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
#define EXPRESSION_NODE_LIST(V)
static bool Rewrite(CompilationInfo *info)