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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 UNIMPLEMENTED(); |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) { UNIMPLEMENTED(); } | 121 void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) { |
122 // TODO(oth): condition may need a ToBoolean cast - not if a | |
123 // sequence of test operations. | |
rmcilroy
2015/09/18 10:42:23
Could you add the ToBoolean unconditionally for no
oth
2015/09/23 10:46:55
Done.
| |
124 // TODO(oth): spot easy cases if (true/1/false/0)? | |
125 BytecodeLabel else_start, else_end; | |
126 stmt->condition()->Accept(this); | |
127 builder().JumpIfFalse(&else_start); | |
Benedikt Meurer
2015/09/17 17:04:17
Oh thank god, this is so much better to just mater
| |
128 Visit(stmt->then_statement()); | |
129 builder().Jump(&else_end); | |
130 builder().Bind(&else_start); | |
131 Visit(stmt->else_statement()); | |
132 builder().Bind(&else_end); | |
133 } | |
122 | 134 |
123 | 135 |
124 void BytecodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { | 136 void BytecodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { |
125 UNIMPLEMENTED(); | 137 UNIMPLEMENTED(); |
126 } | 138 } |
127 | 139 |
128 | 140 |
129 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { | 141 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { |
130 UNIMPLEMENTED(); | 142 UNIMPLEMENTED(); |
131 } | 143 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 UNIMPLEMENTED(); | 457 UNIMPLEMENTED(); |
446 break; | 458 break; |
447 default: | 459 default: |
448 VisitArithmeticExpression(binop); | 460 VisitArithmeticExpression(binop); |
449 break; | 461 break; |
450 } | 462 } |
451 } | 463 } |
452 | 464 |
453 | 465 |
454 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 466 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
455 UNIMPLEMENTED(); | 467 Token::Value op = expr->op(); |
468 Expression* left = expr->left(); | |
469 Expression* right = expr->right(); | |
470 | |
471 TemporaryRegisterScope temporary_register_scope(&builder_); | |
472 Register temporary = temporary_register_scope.NewRegister(); | |
473 | |
474 Visit(left); | |
475 builder().StoreAccumulatorInRegister(temporary); | |
476 Visit(right); | |
477 // TODO(oth): ast-graph-builder has language_mode() option for LT/LE/etc. | |
rmcilroy
2015/09/18 10:42:23
Could you pass the language mode here and do UNIMP
oth
2015/09/23 10:46:55
Done.
| |
478 builder().CompareOperation(op, temporary); | |
456 } | 479 } |
457 | 480 |
458 | 481 |
459 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } | 482 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } |
460 | 483 |
461 | 484 |
462 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { | 485 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
463 UNREACHABLE(); | 486 UNREACHABLE(); |
464 } | 487 } |
465 | 488 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 } | 523 } |
501 | 524 |
502 | 525 |
503 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { | 526 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { |
504 return info()->feedback_vector()->GetIndex(slot); | 527 return info()->feedback_vector()->GetIndex(slot); |
505 } | 528 } |
506 | 529 |
507 } // namespace interpreter | 530 } // namespace interpreter |
508 } // namespace internal | 531 } // namespace internal |
509 } // namespace v8 | 532 } // namespace v8 |
OLD | NEW |