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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 697473006: Properly handle stack overflows in the AST graph builder. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Harden test case. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) { 333 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) {
334 for (int i = 0; i < exprs->length(); ++i) { 334 for (int i = 0; i < exprs->length(); ++i) {
335 VisitForValue(exprs->at(i)); 335 VisitForValue(exprs->at(i));
336 } 336 }
337 } 337 }
338 338
339 339
340 void AstGraphBuilder::VisitForValue(Expression* expr) { 340 void AstGraphBuilder::VisitForValue(Expression* expr) {
341 AstValueContext for_value(this); 341 AstValueContext for_value(this);
342 if (!HasStackOverflow()) { 342 if (!CheckStackOverflow()) {
343 expr->Accept(this); 343 expr->Accept(this);
344 } else {
345 ast_context()->ProduceValue(jsgraph()->UndefinedConstant());
344 } 346 }
345 } 347 }
346 348
347 349
348 void AstGraphBuilder::VisitForEffect(Expression* expr) { 350 void AstGraphBuilder::VisitForEffect(Expression* expr) {
349 AstEffectContext for_effect(this); 351 AstEffectContext for_effect(this);
350 if (!HasStackOverflow()) { 352 if (!CheckStackOverflow()) {
351 expr->Accept(this); 353 expr->Accept(this);
354 } else {
355 ast_context()->ProduceValue(jsgraph()->UndefinedConstant());
352 } 356 }
353 } 357 }
354 358
355 359
356 void AstGraphBuilder::VisitForTest(Expression* expr) { 360 void AstGraphBuilder::VisitForTest(Expression* expr) {
357 AstTestContext for_condition(this); 361 AstTestContext for_condition(this);
358 if (!HasStackOverflow()) { 362 if (!CheckStackOverflow()) {
359 expr->Accept(this); 363 expr->Accept(this);
364 } else {
365 ast_context()->ProduceValue(jsgraph()->UndefinedConstant());
360 } 366 }
361 } 367 }
362 368
369
370 void AstGraphBuilder::Visit(Expression* expr) {
371 // Reuses enclosing AstContext.
372 if (!CheckStackOverflow()) {
373 expr->Accept(this);
374 } else {
375 ast_context()->ProduceValue(jsgraph()->UndefinedConstant());
376 }
377 }
378
363 379
364 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { 380 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) {
365 Variable* variable = decl->proxy()->var(); 381 Variable* variable = decl->proxy()->var();
366 VariableMode mode = decl->mode(); 382 VariableMode mode = decl->mode();
367 bool hole_init = mode == CONST || mode == CONST_LEGACY || mode == LET; 383 bool hole_init = mode == CONST || mode == CONST_LEGACY || mode == LET;
368 switch (variable->location()) { 384 switch (variable->location()) {
369 case Variable::UNALLOCATED: { 385 case Variable::UNALLOCATED: {
370 Handle<Oddball> value = variable->binding_needs_init() 386 Handle<Oddball> value = variable->binding_needs_init()
371 ? isolate()->factory()->the_hole_value() 387 ? isolate()->factory()->the_hole_value()
372 : isolate()->factory()->undefined_value(); 388 : isolate()->factory()->undefined_value();
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 2182
2167 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( 2183 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop(
2168 IterationStatement* stmt) { 2184 IterationStatement* stmt) {
2169 if (loop_assignment_analysis_ == NULL) return NULL; 2185 if (loop_assignment_analysis_ == NULL) return NULL;
2170 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); 2186 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt);
2171 } 2187 }
2172 2188
2173 } // namespace compiler 2189 } // namespace compiler
2174 } // namespace internal 2190 } // namespace internal
2175 } // namespace v8 2191 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698