Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 UNIMPLEMENTED(); | 107 UNIMPLEMENTED(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 void BytecodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { | 111 void BytecodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { |
| 112 Visit(stmt->expression()); | 112 Visit(stmt->expression()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 void BytecodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { | 116 void BytecodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { |
| 117 UNIMPLEMENTED(); | 117 // For control-flow it could be useful to signal empty paths here. |
| 118 } | 118 } |
| 119 | 119 |
| 120 | 120 |
| 121 void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) { UNIMPLEMENTED(); } | 121 void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) { |
| 122 // TODO(oth): spot easy cases if (true/1/false/0)? | |
| 123 BytecodeLabel else_start, else_end; | |
| 124 Visit(stmt->condition()); | |
| 125 // TODO(oth) This cast may need to be pushed down the evaluation stack | |
| 126 // when logical connectives are implemented, e.g. &&, ||, etc. Optimization | |
|
Michael Starzinger
2015/09/23 08:46:24
I am not sure what this TODO refers to exactly, bu
oth
2015/09/23 10:46:56
Sorry about the wording here.
Basically, the goal
| |
| 127 // opportunities too in bytecode-array-builder.cc. | |
| 128 builder().CastAccumulatorToBoolean(); | |
| 129 builder().JumpIfFalse(&else_start); | |
| 130 Visit(stmt->then_statement()); | |
| 131 builder().Jump(&else_end); | |
| 132 builder().Bind(&else_start); | |
| 133 Visit(stmt->else_statement()); | |
| 134 builder().Bind(&else_end); | |
| 135 } | |
| 122 | 136 |
| 123 | 137 |
| 124 void BytecodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { | 138 void BytecodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { |
| 125 UNIMPLEMENTED(); | 139 UNIMPLEMENTED(); |
| 126 } | 140 } |
| 127 | 141 |
| 128 | 142 |
| 129 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { | 143 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { |
| 130 UNIMPLEMENTED(); | 144 UNIMPLEMENTED(); |
| 131 } | 145 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 UNIMPLEMENTED(); | 459 UNIMPLEMENTED(); |
| 446 break; | 460 break; |
| 447 default: | 461 default: |
| 448 VisitArithmeticExpression(binop); | 462 VisitArithmeticExpression(binop); |
| 449 break; | 463 break; |
| 450 } | 464 } |
| 451 } | 465 } |
| 452 | 466 |
| 453 | 467 |
| 454 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 468 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 455 UNIMPLEMENTED(); | 469 Token::Value op = expr->op(); |
| 470 Expression* left = expr->left(); | |
| 471 Expression* right = expr->right(); | |
| 472 | |
| 473 TemporaryRegisterScope temporary_register_scope(&builder_); | |
| 474 Register temporary = temporary_register_scope.NewRegister(); | |
| 475 | |
| 476 Visit(left); | |
| 477 builder().StoreAccumulatorInRegister(temporary); | |
| 478 Visit(right); | |
| 479 builder().CompareOperation(op, temporary, language_mode()); | |
| 456 } | 480 } |
| 457 | 481 |
| 458 | 482 |
| 459 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } | 483 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } |
| 460 | 484 |
| 461 | 485 |
| 462 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { | 486 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
| 463 UNREACHABLE(); | 487 UNREACHABLE(); |
| 464 } | 488 } |
| 465 | 489 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 } | 524 } |
| 501 | 525 |
| 502 | 526 |
| 503 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { | 527 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { |
| 504 return info()->feedback_vector()->GetIndex(slot); | 528 return info()->feedback_vector()->GetIndex(slot); |
| 505 } | 529 } |
| 506 | 530 |
| 507 } // namespace interpreter | 531 } // namespace interpreter |
| 508 } // namespace internal | 532 } // namespace internal |
| 509 } // namespace v8 | 533 } // namespace v8 |
| OLD | NEW |