OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 5075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5086 ASSERT(call->arguments()->length() == 1); | 5086 ASSERT(call->arguments()->length() == 1); |
5087 return true; | 5087 return true; |
5088 } | 5088 } |
5089 | 5089 |
5090 | 5090 |
5091 void HGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { | 5091 void HGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { |
5092 ASSERT(!HasStackOverflow()); | 5092 ASSERT(!HasStackOverflow()); |
5093 ASSERT(current_block() != NULL); | 5093 ASSERT(current_block() != NULL); |
5094 ASSERT(current_block()->HasPredecessor()); | 5094 ASSERT(current_block()->HasPredecessor()); |
5095 switch (expr->op()) { | 5095 switch (expr->op()) { |
5096 case Token::COMMA: return VisitComma(expr); | 5096 case Token::COMMA: |
5097 case Token::OR: return VisitAndOr(expr, false); | 5097 return VisitComma(expr); |
5098 case Token::AND: return VisitAndOr(expr, true); | 5098 case Token::OR: |
5099 default: return VisitCommon(expr); | 5099 case Token::AND: |
| 5100 return VisitLogicalExpression(expr); |
| 5101 default: |
| 5102 return VisitArithmeticExpression(expr); |
5100 } | 5103 } |
5101 } | 5104 } |
5102 | 5105 |
5103 | 5106 |
5104 void HGraphBuilder::VisitComma(BinaryOperation* expr) { | 5107 void HGraphBuilder::VisitComma(BinaryOperation* expr) { |
5105 CHECK_ALIVE(VisitForEffect(expr->left())); | 5108 CHECK_ALIVE(VisitForEffect(expr->left())); |
5106 // Visit the right subexpression in the same AST context as the entire | 5109 // Visit the right subexpression in the same AST context as the entire |
5107 // expression. | 5110 // expression. |
5108 Visit(expr->right()); | 5111 Visit(expr->right()); |
5109 } | 5112 } |
5110 | 5113 |
5111 | 5114 |
5112 void HGraphBuilder::VisitAndOr(BinaryOperation* expr, bool is_logical_and) { | 5115 void HGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) { |
| 5116 bool is_logical_and = expr->op() == Token::AND; |
5113 if (ast_context()->IsTest()) { | 5117 if (ast_context()->IsTest()) { |
5114 TestContext* context = TestContext::cast(ast_context()); | 5118 TestContext* context = TestContext::cast(ast_context()); |
5115 // Translate left subexpression. | 5119 // Translate left subexpression. |
5116 HBasicBlock* eval_right = graph()->CreateBasicBlock(); | 5120 HBasicBlock* eval_right = graph()->CreateBasicBlock(); |
5117 if (is_logical_and) { | 5121 if (is_logical_and) { |
5118 CHECK_BAILOUT(VisitForControl(expr->left(), | 5122 CHECK_BAILOUT(VisitForControl(expr->left(), |
5119 eval_right, | 5123 eval_right, |
5120 context->if_false())); | 5124 context->if_false())); |
5121 } else { | 5125 } else { |
5122 CHECK_BAILOUT(VisitForControl(expr->left(), | 5126 CHECK_BAILOUT(VisitForControl(expr->left(), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5189 | 5193 |
5190 HBasicBlock* join_block = | 5194 HBasicBlock* join_block = |
5191 CreateJoin(empty_block, right_block, expr->id()); | 5195 CreateJoin(empty_block, right_block, expr->id()); |
5192 set_current_block(join_block); | 5196 set_current_block(join_block); |
5193 // We did not materialize any value in the predecessor environments, | 5197 // We did not materialize any value in the predecessor environments, |
5194 // so there is no need to handle it here. | 5198 // so there is no need to handle it here. |
5195 } | 5199 } |
5196 } | 5200 } |
5197 | 5201 |
5198 | 5202 |
5199 void HGraphBuilder::VisitCommon(BinaryOperation* expr) { | 5203 void HGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { |
5200 CHECK_ALIVE(VisitForValue(expr->left())); | 5204 CHECK_ALIVE(VisitForValue(expr->left())); |
5201 CHECK_ALIVE(VisitForValue(expr->right())); | 5205 CHECK_ALIVE(VisitForValue(expr->right())); |
5202 HValue* right = Pop(); | 5206 HValue* right = Pop(); |
5203 HValue* left = Pop(); | 5207 HValue* left = Pop(); |
5204 HInstruction* instr = BuildBinaryOperation(expr, left, right); | 5208 HInstruction* instr = BuildBinaryOperation(expr, left, right); |
5205 instr->set_position(expr->position()); | 5209 instr->set_position(expr->position()); |
5206 ast_context()->ReturnInstruction(instr, expr->id()); | 5210 ast_context()->ReturnInstruction(instr, expr->id()); |
5207 } | 5211 } |
5208 | 5212 |
5209 | 5213 |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6306 } | 6310 } |
6307 } | 6311 } |
6308 | 6312 |
6309 #ifdef DEBUG | 6313 #ifdef DEBUG |
6310 if (graph_ != NULL) graph_->Verify(); | 6314 if (graph_ != NULL) graph_->Verify(); |
6311 if (allocator_ != NULL) allocator_->Verify(); | 6315 if (allocator_ != NULL) allocator_->Verify(); |
6312 #endif | 6316 #endif |
6313 } | 6317 } |
6314 | 6318 |
6315 } } // namespace v8::internal | 6319 } } // namespace v8::internal |
OLD | NEW |