| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 if (fun->scope()->arguments() != NULL) { | 69 if (fun->scope()->arguments() != NULL) { |
| 70 BAILOUT("function uses .arguments"); | 70 BAILOUT("function uses .arguments"); |
| 71 } | 71 } |
| 72 | 72 |
| 73 ZoneList<Statement*>* body = fun->body(); | 73 ZoneList<Statement*>* body = fun->body(); |
| 74 if (body->is_empty()) { | 74 if (body->is_empty()) { |
| 75 BAILOUT("empty function body"); | 75 BAILOUT("empty function body"); |
| 76 } | 76 } |
| 77 | 77 |
| 78 StatementBuilder builder; | 78 StatementCfgBuilder builder; |
| 79 builder.VisitStatements(body); | 79 builder.VisitStatements(body); |
| 80 Cfg* graph = builder.graph(); | 80 Cfg* graph = builder.graph(); |
| 81 if (graph == NULL) { | 81 if (graph == NULL) { |
| 82 BAILOUT("unsupported statement type"); | 82 BAILOUT("unsupported statement type"); |
| 83 } | 83 } |
| 84 if (graph->is_empty()) { | 84 if (graph->is_empty()) { |
| 85 BAILOUT("function body produces empty cfg"); | 85 BAILOUT("function body produces empty cfg"); |
| 86 } | 86 } |
| 87 if (graph->has_exit()) { | 87 if (graph->has_exit()) { |
| 88 BAILOUT("control path without explicit return"); | 88 BAILOUT("control path without explicit return"); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); | 224 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); |
| 225 if (temp == value_) { | 225 if (temp == value_) { |
| 226 temp->set_where(TempLocation::ACCUMULATOR); | 226 temp->set_where(TempLocation::ACCUMULATOR); |
| 227 } else { | 227 } else { |
| 228 temp->set_where(TempLocation::STACK); | 228 temp->set_where(TempLocation::STACK); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 // The expression builder should not be used for declarations or statements. | 233 // The expression builder should not be used for declarations or statements. |
| 234 void ExpressionBuilder::VisitDeclaration(Declaration* decl) { UNREACHABLE(); } | 234 void ExpressionCfgBuilder::VisitDeclaration(Declaration* decl) { |
| 235 UNREACHABLE(); |
| 236 } |
| 235 | 237 |
| 236 #define DEFINE_VISIT(type) \ | 238 #define DEFINE_VISIT(type) \ |
| 237 void ExpressionBuilder::Visit##type(type* stmt) { UNREACHABLE(); } | 239 void ExpressionCfgBuilder::Visit##type(type* stmt) { UNREACHABLE(); } |
| 238 STATEMENT_NODE_LIST(DEFINE_VISIT) | 240 STATEMENT_NODE_LIST(DEFINE_VISIT) |
| 239 #undef DEFINE_VISIT | 241 #undef DEFINE_VISIT |
| 240 | 242 |
| 241 | 243 |
| 242 // Macros (temporarily) handling unsupported expression types. | 244 // Macros (temporarily) handling unsupported expression types. |
| 243 #define BAILOUT(reason) \ | 245 #define BAILOUT(reason) \ |
| 244 do { \ | 246 do { \ |
| 245 graph_ = NULL; \ | 247 graph_ = NULL; \ |
| 246 return; \ | 248 return; \ |
| 247 } while (false) | 249 } while (false) |
| 248 | 250 |
| 249 void ExpressionBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { | 251 void ExpressionCfgBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { |
| 250 BAILOUT("FunctionLiteral"); | 252 BAILOUT("FunctionLiteral"); |
| 251 } | 253 } |
| 252 | 254 |
| 253 | 255 |
| 254 void ExpressionBuilder::VisitFunctionBoilerplateLiteral( | 256 void ExpressionCfgBuilder::VisitFunctionBoilerplateLiteral( |
| 255 FunctionBoilerplateLiteral* expr) { | 257 FunctionBoilerplateLiteral* expr) { |
| 256 BAILOUT("FunctionBoilerplateLiteral"); | 258 BAILOUT("FunctionBoilerplateLiteral"); |
| 257 } | 259 } |
| 258 | 260 |
| 259 | 261 |
| 260 void ExpressionBuilder::VisitConditional(Conditional* expr) { | 262 void ExpressionCfgBuilder::VisitConditional(Conditional* expr) { |
| 261 BAILOUT("Conditional"); | 263 BAILOUT("Conditional"); |
| 262 } | 264 } |
| 263 | 265 |
| 264 | 266 |
| 265 void ExpressionBuilder::VisitSlot(Slot* expr) { | 267 void ExpressionCfgBuilder::VisitSlot(Slot* expr) { |
| 266 BAILOUT("Slot"); | 268 BAILOUT("Slot"); |
| 267 } | 269 } |
| 268 | 270 |
| 269 | 271 |
| 270 void ExpressionBuilder::VisitVariableProxy(VariableProxy* expr) { | 272 void ExpressionCfgBuilder::VisitVariableProxy(VariableProxy* expr) { |
| 271 Expression* rewrite = expr->var()->rewrite(); | 273 Expression* rewrite = expr->var()->rewrite(); |
| 272 if (rewrite == NULL || rewrite->AsSlot() == NULL) { | 274 if (rewrite == NULL || rewrite->AsSlot() == NULL) { |
| 273 BAILOUT("unsupported variable (not a slot)"); | 275 BAILOUT("unsupported variable (not a slot)"); |
| 274 } | 276 } |
| 275 Slot* slot = rewrite->AsSlot(); | 277 Slot* slot = rewrite->AsSlot(); |
| 276 if (slot->type() != Slot::PARAMETER && slot->type() != Slot::LOCAL) { | 278 if (slot->type() != Slot::PARAMETER && slot->type() != Slot::LOCAL) { |
| 277 BAILOUT("unsupported slot type (not a parameter or local)"); | 279 BAILOUT("unsupported slot type (not a parameter or local)"); |
| 278 } | 280 } |
| 279 // Ignore the passed destination. | 281 // Ignore the passed destination. |
| 280 value_ = new SlotLocation(slot->type(), slot->index()); | 282 value_ = new SlotLocation(slot->type(), slot->index()); |
| 281 } | 283 } |
| 282 | 284 |
| 283 | 285 |
| 284 void ExpressionBuilder::VisitLiteral(Literal* expr) { | 286 void ExpressionCfgBuilder::VisitLiteral(Literal* expr) { |
| 285 // Ignore the passed destination. | 287 // Ignore the passed destination. |
| 286 value_ = new Constant(expr->handle()); | 288 value_ = new Constant(expr->handle()); |
| 287 } | 289 } |
| 288 | 290 |
| 289 | 291 |
| 290 void ExpressionBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { | 292 void ExpressionCfgBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 291 BAILOUT("RegExpLiteral"); | 293 BAILOUT("RegExpLiteral"); |
| 292 } | 294 } |
| 293 | 295 |
| 294 | 296 |
| 295 void ExpressionBuilder::VisitObjectLiteral(ObjectLiteral* expr) { | 297 void ExpressionCfgBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
| 296 BAILOUT("ObjectLiteral"); | 298 BAILOUT("ObjectLiteral"); |
| 297 } | 299 } |
| 298 | 300 |
| 299 | 301 |
| 300 void ExpressionBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 302 void ExpressionCfgBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
| 301 BAILOUT("ArrayLiteral"); | 303 BAILOUT("ArrayLiteral"); |
| 302 } | 304 } |
| 303 | 305 |
| 304 | 306 |
| 305 void ExpressionBuilder::VisitCatchExtensionObject(CatchExtensionObject* expr) { | 307 void ExpressionCfgBuilder::VisitCatchExtensionObject( |
| 308 CatchExtensionObject* expr) { |
| 306 BAILOUT("CatchExtensionObject"); | 309 BAILOUT("CatchExtensionObject"); |
| 307 } | 310 } |
| 308 | 311 |
| 309 | 312 |
| 310 void ExpressionBuilder::VisitAssignment(Assignment* expr) { | 313 void ExpressionCfgBuilder::VisitAssignment(Assignment* expr) { |
| 311 if (expr->op() != Token::ASSIGN && expr->op() != Token::INIT_VAR) { | 314 if (expr->op() != Token::ASSIGN && expr->op() != Token::INIT_VAR) { |
| 312 BAILOUT("unsupported compound assignment"); | 315 BAILOUT("unsupported compound assignment"); |
| 313 } | 316 } |
| 314 Expression* lhs = expr->target(); | 317 Expression* lhs = expr->target(); |
| 315 if (lhs->AsProperty() != NULL) { | 318 if (lhs->AsProperty() != NULL) { |
| 316 BAILOUT("unsupported property assignment"); | 319 BAILOUT("unsupported property assignment"); |
| 317 } | 320 } |
| 318 Variable* var = lhs->AsVariableProxy()->AsVariable(); | 321 Variable* var = lhs->AsVariableProxy()->AsVariable(); |
| 319 if (var == NULL) { | 322 if (var == NULL) { |
| 320 BAILOUT("unsupported invalid left-hand side"); | 323 BAILOUT("unsupported invalid left-hand side"); |
| 321 } | 324 } |
| 322 if (var->is_global()) { | 325 if (var->is_global()) { |
| 323 BAILOUT("unsupported global variable"); | 326 BAILOUT("unsupported global variable"); |
| 324 } | 327 } |
| 325 Slot* slot = var->slot(); | 328 Slot* slot = var->slot(); |
| 326 ASSERT(slot != NULL); | 329 ASSERT(slot != NULL); |
| 327 if (slot->type() != Slot::PARAMETER && slot->type() != Slot::LOCAL) { | 330 if (slot->type() != Slot::PARAMETER && slot->type() != Slot::LOCAL) { |
| 328 BAILOUT("unsupported slot lhs (not a parameter or local)"); | 331 BAILOUT("unsupported slot lhs (not a parameter or local)"); |
| 329 } | 332 } |
| 330 | 333 |
| 331 ExpressionBuilder builder; | 334 ExpressionCfgBuilder builder; |
| 332 SlotLocation* loc = new SlotLocation(slot->type(), slot->index()); | 335 SlotLocation* loc = new SlotLocation(slot->type(), slot->index()); |
| 333 builder.Build(expr->value(), loc); | 336 builder.Build(expr->value(), loc); |
| 334 if (builder.graph() == NULL) { | 337 if (builder.graph() == NULL) { |
| 335 BAILOUT("unsupported expression in assignment"); | 338 BAILOUT("unsupported expression in assignment"); |
| 336 } | 339 } |
| 337 // If the expression did not come back in the slot location, append | 340 // If the expression did not come back in the slot location, append |
| 338 // a move to the CFG. | 341 // a move to the CFG. |
| 339 graph_ = builder.graph(); | 342 graph_ = builder.graph(); |
| 340 if (builder.value() != loc) { | 343 if (builder.value() != loc) { |
| 341 graph()->Append(new MoveInstr(loc, builder.value())); | 344 graph()->Append(new MoveInstr(loc, builder.value())); |
| 342 } | 345 } |
| 343 // Record the assignment. | 346 // Record the assignment. |
| 344 assigned_vars_.AddElement(loc); | 347 assigned_vars_.AddElement(loc); |
| 345 // Ignore the destination passed to us. | 348 // Ignore the destination passed to us. |
| 346 value_ = loc; | 349 value_ = loc; |
| 347 } | 350 } |
| 348 | 351 |
| 349 | 352 |
| 350 void ExpressionBuilder::VisitThrow(Throw* expr) { | 353 void ExpressionCfgBuilder::VisitThrow(Throw* expr) { |
| 351 BAILOUT("Throw"); | 354 BAILOUT("Throw"); |
| 352 } | 355 } |
| 353 | 356 |
| 354 | 357 |
| 355 void ExpressionBuilder::VisitProperty(Property* expr) { | 358 void ExpressionCfgBuilder::VisitProperty(Property* expr) { |
| 356 BAILOUT("Property"); | 359 BAILOUT("Property"); |
| 357 } | 360 } |
| 358 | 361 |
| 359 | 362 |
| 360 void ExpressionBuilder::VisitCall(Call* expr) { | 363 void ExpressionCfgBuilder::VisitCall(Call* expr) { |
| 361 BAILOUT("Call"); | 364 BAILOUT("Call"); |
| 362 } | 365 } |
| 363 | 366 |
| 364 | 367 |
| 365 void ExpressionBuilder::VisitCallEval(CallEval* expr) { | 368 void ExpressionCfgBuilder::VisitCallEval(CallEval* expr) { |
| 366 BAILOUT("CallEval"); | 369 BAILOUT("CallEval"); |
| 367 } | 370 } |
| 368 | 371 |
| 369 | 372 |
| 370 void ExpressionBuilder::VisitCallNew(CallNew* expr) { | 373 void ExpressionCfgBuilder::VisitCallNew(CallNew* expr) { |
| 371 BAILOUT("CallNew"); | 374 BAILOUT("CallNew"); |
| 372 } | 375 } |
| 373 | 376 |
| 374 | 377 |
| 375 void ExpressionBuilder::VisitCallRuntime(CallRuntime* expr) { | 378 void ExpressionCfgBuilder::VisitCallRuntime(CallRuntime* expr) { |
| 376 BAILOUT("CallRuntime"); | 379 BAILOUT("CallRuntime"); |
| 377 } | 380 } |
| 378 | 381 |
| 379 | 382 |
| 380 void ExpressionBuilder::VisitUnaryOperation(UnaryOperation* expr) { | 383 void ExpressionCfgBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
| 381 BAILOUT("UnaryOperation"); | 384 BAILOUT("UnaryOperation"); |
| 382 } | 385 } |
| 383 | 386 |
| 384 | 387 |
| 385 void ExpressionBuilder::VisitCountOperation(CountOperation* expr) { | 388 void ExpressionCfgBuilder::VisitCountOperation(CountOperation* expr) { |
| 386 BAILOUT("CountOperation"); | 389 BAILOUT("CountOperation"); |
| 387 } | 390 } |
| 388 | 391 |
| 389 | 392 |
| 390 void ExpressionBuilder::VisitBinaryOperation(BinaryOperation* expr) { | 393 void ExpressionCfgBuilder::VisitBinaryOperation(BinaryOperation* expr) { |
| 391 Token::Value op = expr->op(); | 394 Token::Value op = expr->op(); |
| 392 switch (op) { | 395 switch (op) { |
| 393 case Token::COMMA: | 396 case Token::COMMA: |
| 394 case Token::OR: | 397 case Token::OR: |
| 395 case Token::AND: | 398 case Token::AND: |
| 396 BAILOUT("unsupported binary operation"); | 399 BAILOUT("unsupported binary operation"); |
| 397 | 400 |
| 398 case Token::BIT_OR: | 401 case Token::BIT_OR: |
| 399 case Token::BIT_XOR: | 402 case Token::BIT_XOR: |
| 400 case Token::BIT_AND: | 403 case Token::BIT_AND: |
| 401 case Token::SHL: | 404 case Token::SHL: |
| 402 case Token::SAR: | 405 case Token::SAR: |
| 403 case Token::SHR: | 406 case Token::SHR: |
| 404 case Token::ADD: | 407 case Token::ADD: |
| 405 case Token::SUB: | 408 case Token::SUB: |
| 406 case Token::MUL: | 409 case Token::MUL: |
| 407 case Token::DIV: | 410 case Token::DIV: |
| 408 case Token::MOD: { | 411 case Token::MOD: { |
| 409 ExpressionBuilder left, right; | 412 ExpressionCfgBuilder left, right; |
| 410 left.Build(expr->left(), NULL); | 413 left.Build(expr->left(), NULL); |
| 411 if (left.graph() == NULL) { | 414 if (left.graph() == NULL) { |
| 412 BAILOUT("unsupported left subexpression in binop"); | 415 BAILOUT("unsupported left subexpression in binop"); |
| 413 } | 416 } |
| 414 right.Build(expr->right(), NULL); | 417 right.Build(expr->right(), NULL); |
| 415 if (right.graph() == NULL) { | 418 if (right.graph() == NULL) { |
| 416 BAILOUT("unsupported right subexpression in binop"); | 419 BAILOUT("unsupported right subexpression in binop"); |
| 417 } | 420 } |
| 418 | 421 |
| 419 if (destination_ == NULL) destination_ = new TempLocation(); | 422 if (destination_ == NULL) destination_ = new TempLocation(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 438 value_ = destination_; | 441 value_ = destination_; |
| 439 return; | 442 return; |
| 440 } | 443 } |
| 441 | 444 |
| 442 default: | 445 default: |
| 443 UNREACHABLE(); | 446 UNREACHABLE(); |
| 444 } | 447 } |
| 445 } | 448 } |
| 446 | 449 |
| 447 | 450 |
| 448 void ExpressionBuilder::VisitCompareOperation(CompareOperation* expr) { | 451 void ExpressionCfgBuilder::VisitCompareOperation(CompareOperation* expr) { |
| 449 BAILOUT("CompareOperation"); | 452 BAILOUT("CompareOperation"); |
| 450 } | 453 } |
| 451 | 454 |
| 452 | 455 |
| 453 void ExpressionBuilder::VisitThisFunction(ThisFunction* expr) { | 456 void ExpressionCfgBuilder::VisitThisFunction(ThisFunction* expr) { |
| 454 BAILOUT("ThisFunction"); | 457 BAILOUT("ThisFunction"); |
| 455 } | 458 } |
| 456 | 459 |
| 457 #undef BAILOUT | 460 #undef BAILOUT |
| 458 | 461 |
| 459 | 462 |
| 460 // Macros (temporarily) handling unsupported statement types. | 463 // Macros (temporarily) handling unsupported statement types. |
| 461 #define BAILOUT(reason) \ | 464 #define BAILOUT(reason) \ |
| 462 do { \ | 465 do { \ |
| 463 graph_ = NULL; \ | 466 graph_ = NULL; \ |
| 464 return; \ | 467 return; \ |
| 465 } while (false) | 468 } while (false) |
| 466 | 469 |
| 467 #define CHECK_BAILOUT() \ | 470 #define CHECK_BAILOUT() \ |
| 468 if (graph() == NULL) { return; } else {} | 471 if (graph() == NULL) { return; } else {} |
| 469 | 472 |
| 470 void StatementBuilder::VisitStatements(ZoneList<Statement*>* stmts) { | 473 void StatementCfgBuilder::VisitStatements(ZoneList<Statement*>* stmts) { |
| 471 for (int i = 0, len = stmts->length(); i < len; i++) { | 474 for (int i = 0, len = stmts->length(); i < len; i++) { |
| 472 Visit(stmts->at(i)); | 475 Visit(stmts->at(i)); |
| 473 CHECK_BAILOUT(); | 476 CHECK_BAILOUT(); |
| 474 if (!graph()->has_exit()) return; | 477 if (!graph()->has_exit()) return; |
| 475 } | 478 } |
| 476 } | 479 } |
| 477 | 480 |
| 478 | 481 |
| 479 // The statement builder should not be used for declarations or expressions. | 482 // The statement builder should not be used for declarations or expressions. |
| 480 void StatementBuilder::VisitDeclaration(Declaration* decl) { UNREACHABLE(); } | 483 void StatementCfgBuilder::VisitDeclaration(Declaration* decl) { UNREACHABLE(); } |
| 481 | 484 |
| 482 #define DEFINE_VISIT(type) \ | 485 #define DEFINE_VISIT(type) \ |
| 483 void StatementBuilder::Visit##type(type* expr) { UNREACHABLE(); } | 486 void StatementCfgBuilder::Visit##type(type* expr) { UNREACHABLE(); } |
| 484 EXPRESSION_NODE_LIST(DEFINE_VISIT) | 487 EXPRESSION_NODE_LIST(DEFINE_VISIT) |
| 485 #undef DEFINE_VISIT | 488 #undef DEFINE_VISIT |
| 486 | 489 |
| 487 | 490 |
| 488 void StatementBuilder::VisitBlock(Block* stmt) { | 491 void StatementCfgBuilder::VisitBlock(Block* stmt) { |
| 489 VisitStatements(stmt->statements()); | 492 VisitStatements(stmt->statements()); |
| 490 } | 493 } |
| 491 | 494 |
| 492 | 495 |
| 493 void StatementBuilder::VisitExpressionStatement(ExpressionStatement* stmt) { | 496 void StatementCfgBuilder::VisitExpressionStatement(ExpressionStatement* stmt) { |
| 494 ExpressionBuilder builder; | 497 ExpressionCfgBuilder builder; |
| 495 builder.Build(stmt->expression(), CfgGlobals::current()->nowhere()); | 498 builder.Build(stmt->expression(), CfgGlobals::current()->nowhere()); |
| 496 if (builder.graph() == NULL) { | 499 if (builder.graph() == NULL) { |
| 497 BAILOUT("unsupported expression in expression statement"); | 500 BAILOUT("unsupported expression in expression statement"); |
| 498 } | 501 } |
| 499 graph()->Append(new PositionInstr(stmt->statement_pos())); | 502 graph()->Append(new PositionInstr(stmt->statement_pos())); |
| 500 graph()->Concatenate(builder.graph()); | 503 graph()->Concatenate(builder.graph()); |
| 501 } | 504 } |
| 502 | 505 |
| 503 | 506 |
| 504 void StatementBuilder::VisitEmptyStatement(EmptyStatement* stmt) { | 507 void StatementCfgBuilder::VisitEmptyStatement(EmptyStatement* stmt) { |
| 505 // Nothing to do. | 508 // Nothing to do. |
| 506 } | 509 } |
| 507 | 510 |
| 508 | 511 |
| 509 void StatementBuilder::VisitIfStatement(IfStatement* stmt) { | 512 void StatementCfgBuilder::VisitIfStatement(IfStatement* stmt) { |
| 510 BAILOUT("IfStatement"); | 513 BAILOUT("IfStatement"); |
| 511 } | 514 } |
| 512 | 515 |
| 513 | 516 |
| 514 void StatementBuilder::VisitContinueStatement(ContinueStatement* stmt) { | 517 void StatementCfgBuilder::VisitContinueStatement(ContinueStatement* stmt) { |
| 515 BAILOUT("ContinueStatement"); | 518 BAILOUT("ContinueStatement"); |
| 516 } | 519 } |
| 517 | 520 |
| 518 | 521 |
| 519 void StatementBuilder::VisitBreakStatement(BreakStatement* stmt) { | 522 void StatementCfgBuilder::VisitBreakStatement(BreakStatement* stmt) { |
| 520 BAILOUT("BreakStatement"); | 523 BAILOUT("BreakStatement"); |
| 521 } | 524 } |
| 522 | 525 |
| 523 | 526 |
| 524 void StatementBuilder::VisitReturnStatement(ReturnStatement* stmt) { | 527 void StatementCfgBuilder::VisitReturnStatement(ReturnStatement* stmt) { |
| 525 ExpressionBuilder builder; | 528 ExpressionCfgBuilder builder; |
| 526 builder.Build(stmt->expression(), NULL); | 529 builder.Build(stmt->expression(), NULL); |
| 527 if (builder.graph() == NULL) { | 530 if (builder.graph() == NULL) { |
| 528 BAILOUT("unsupported expression in return statement"); | 531 BAILOUT("unsupported expression in return statement"); |
| 529 } | 532 } |
| 530 | 533 |
| 531 graph()->Append(new PositionInstr(stmt->statement_pos())); | 534 graph()->Append(new PositionInstr(stmt->statement_pos())); |
| 532 graph()->Concatenate(builder.graph()); | 535 graph()->Concatenate(builder.graph()); |
| 533 graph()->AppendReturnInstruction(builder.value()); | 536 graph()->AppendReturnInstruction(builder.value()); |
| 534 } | 537 } |
| 535 | 538 |
| 536 | 539 |
| 537 void StatementBuilder::VisitWithEnterStatement(WithEnterStatement* stmt) { | 540 void StatementCfgBuilder::VisitWithEnterStatement(WithEnterStatement* stmt) { |
| 538 BAILOUT("WithEnterStatement"); | 541 BAILOUT("WithEnterStatement"); |
| 539 } | 542 } |
| 540 | 543 |
| 541 | 544 |
| 542 void StatementBuilder::VisitWithExitStatement(WithExitStatement* stmt) { | 545 void StatementCfgBuilder::VisitWithExitStatement(WithExitStatement* stmt) { |
| 543 BAILOUT("WithExitStatement"); | 546 BAILOUT("WithExitStatement"); |
| 544 } | 547 } |
| 545 | 548 |
| 546 | 549 |
| 547 void StatementBuilder::VisitSwitchStatement(SwitchStatement* stmt) { | 550 void StatementCfgBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
| 548 BAILOUT("SwitchStatement"); | 551 BAILOUT("SwitchStatement"); |
| 549 } | 552 } |
| 550 | 553 |
| 551 | 554 |
| 552 void StatementBuilder::VisitLoopStatement(LoopStatement* stmt) { | 555 void StatementCfgBuilder::VisitLoopStatement(LoopStatement* stmt) { |
| 553 BAILOUT("LoopStatement"); | 556 BAILOUT("LoopStatement"); |
| 554 } | 557 } |
| 555 | 558 |
| 556 | 559 |
| 557 void StatementBuilder::VisitForInStatement(ForInStatement* stmt) { | 560 void StatementCfgBuilder::VisitForInStatement(ForInStatement* stmt) { |
| 558 BAILOUT("ForInStatement"); | 561 BAILOUT("ForInStatement"); |
| 559 } | 562 } |
| 560 | 563 |
| 561 | 564 |
| 562 void StatementBuilder::VisitTryCatch(TryCatch* stmt) { | 565 void StatementCfgBuilder::VisitTryCatch(TryCatch* stmt) { |
| 563 BAILOUT("TryCatch"); | 566 BAILOUT("TryCatch"); |
| 564 } | 567 } |
| 565 | 568 |
| 566 | 569 |
| 567 void StatementBuilder::VisitTryFinally(TryFinally* stmt) { | 570 void StatementCfgBuilder::VisitTryFinally(TryFinally* stmt) { |
| 568 BAILOUT("TryFinally"); | 571 BAILOUT("TryFinally"); |
| 569 } | 572 } |
| 570 | 573 |
| 571 | 574 |
| 572 void StatementBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { | 575 void StatementCfgBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { |
| 573 BAILOUT("DebuggerStatement"); | 576 BAILOUT("DebuggerStatement"); |
| 574 } | 577 } |
| 575 | 578 |
| 576 | 579 |
| 577 #ifdef DEBUG | 580 #ifdef DEBUG |
| 578 // CFG printing support (via depth-first, preorder block traversal). | 581 // CFG printing support (via depth-first, preorder block traversal). |
| 579 | 582 |
| 580 void Cfg::Print() { | 583 void Cfg::Print() { |
| 581 entry_->Print(); | 584 entry_->Print(); |
| 582 entry_->Unmark(); | 585 entry_->Unmark(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 void ExitNode::Print() { | 669 void ExitNode::Print() { |
| 667 if (!is_marked_) { | 670 if (!is_marked_) { |
| 668 is_marked_ = true; | 671 is_marked_ = true; |
| 669 PrintF("L%d:\nExit\n\n", number()); | 672 PrintF("L%d:\nExit\n\n", number()); |
| 670 } | 673 } |
| 671 } | 674 } |
| 672 | 675 |
| 673 #endif // DEBUG | 676 #endif // DEBUG |
| 674 | 677 |
| 675 } } // namespace v8::internal | 678 } } // namespace v8::internal |
| OLD | NEW |