| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, | 1712 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, |
| 1713 static_cast<HValue*>(NULL), kind); | 1713 static_cast<HValue*>(NULL), kind); |
| 1714 Add<HStoreKeyed>(object_elements, key_constant, value, kind); | 1714 Add<HStoreKeyed>(object_elements, key_constant, value, kind); |
| 1715 } | 1715 } |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 return object; | 1718 return object; |
| 1719 } | 1719 } |
| 1720 | 1720 |
| 1721 | 1721 |
| 1722 HInstruction* HGraphBuilder::BuildUnaryMathOp( | |
| 1723 HValue* input, Handle<Type> type, Token::Value operation) { | |
| 1724 ASSERT_EQ(Token::BIT_NOT, operation); | |
| 1725 // We only handle the numeric cases here | |
| 1726 type = handle( | |
| 1727 Type::Intersect(type, handle(Type::Number(), isolate())), isolate()); | |
| 1728 if (type->Is(Type::None())) { | |
| 1729 Add<HDeoptimize>(Deoptimizer::SOFT); | |
| 1730 } | |
| 1731 return New<HBitNot>(input); | |
| 1732 } | |
| 1733 | |
| 1734 | |
| 1735 void HGraphBuilder::BuildCompareNil( | 1722 void HGraphBuilder::BuildCompareNil( |
| 1736 HValue* value, | 1723 HValue* value, |
| 1737 Handle<Type> type, | 1724 Handle<Type> type, |
| 1738 int position, | 1725 int position, |
| 1739 HIfContinuation* continuation) { | 1726 HIfContinuation* continuation) { |
| 1740 IfBuilder if_nil(this, position); | 1727 IfBuilder if_nil(this, position); |
| 1741 bool needs_or = false; | 1728 bool needs_or = false; |
| 1742 if (type->Maybe(Type::Null())) { | 1729 if (type->Maybe(Type::Null())) { |
| 1743 if (needs_or) if_nil.Or(); | 1730 if (needs_or) if_nil.Or(); |
| 1744 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); | 1731 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); |
| (...skipping 5477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7222 | 7209 |
| 7223 | 7210 |
| 7224 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { | 7211 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
| 7225 ASSERT(!HasStackOverflow()); | 7212 ASSERT(!HasStackOverflow()); |
| 7226 ASSERT(current_block() != NULL); | 7213 ASSERT(current_block() != NULL); |
| 7227 ASSERT(current_block()->HasPredecessor()); | 7214 ASSERT(current_block()->HasPredecessor()); |
| 7228 switch (expr->op()) { | 7215 switch (expr->op()) { |
| 7229 case Token::DELETE: return VisitDelete(expr); | 7216 case Token::DELETE: return VisitDelete(expr); |
| 7230 case Token::VOID: return VisitVoid(expr); | 7217 case Token::VOID: return VisitVoid(expr); |
| 7231 case Token::TYPEOF: return VisitTypeof(expr); | 7218 case Token::TYPEOF: return VisitTypeof(expr); |
| 7232 case Token::BIT_NOT: return VisitBitNot(expr); | |
| 7233 case Token::NOT: return VisitNot(expr); | 7219 case Token::NOT: return VisitNot(expr); |
| 7234 default: UNREACHABLE(); | 7220 default: UNREACHABLE(); |
| 7235 } | 7221 } |
| 7236 } | 7222 } |
| 7237 | 7223 |
| 7238 | 7224 |
| 7239 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { | 7225 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { |
| 7240 Property* prop = expr->expression()->AsProperty(); | 7226 Property* prop = expr->expression()->AsProperty(); |
| 7241 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 7227 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 7242 if (prop != NULL) { | 7228 if (prop != NULL) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7284 | 7270 |
| 7285 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { | 7271 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { |
| 7286 CHECK_ALIVE(VisitForTypeOf(expr->expression())); | 7272 CHECK_ALIVE(VisitForTypeOf(expr->expression())); |
| 7287 HValue* value = Pop(); | 7273 HValue* value = Pop(); |
| 7288 HValue* context = environment()->context(); | 7274 HValue* context = environment()->context(); |
| 7289 HInstruction* instr = new(zone()) HTypeof(context, value); | 7275 HInstruction* instr = new(zone()) HTypeof(context, value); |
| 7290 return ast_context()->ReturnInstruction(instr, expr->id()); | 7276 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 7291 } | 7277 } |
| 7292 | 7278 |
| 7293 | 7279 |
| 7294 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) { | |
| 7295 CHECK_ALIVE(VisitForValue(expr->expression())); | |
| 7296 Handle<Type> operand_type = expr->expression()->bounds().lower; | |
| 7297 HValue* value = TruncateToNumber(Pop(), &operand_type); | |
| 7298 HInstruction* instr = BuildUnaryMathOp(value, operand_type, Token::BIT_NOT); | |
| 7299 return ast_context()->ReturnInstruction(instr, expr->id()); | |
| 7300 } | |
| 7301 | |
| 7302 | |
| 7303 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { | 7280 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { |
| 7304 if (ast_context()->IsTest()) { | 7281 if (ast_context()->IsTest()) { |
| 7305 TestContext* context = TestContext::cast(ast_context()); | 7282 TestContext* context = TestContext::cast(ast_context()); |
| 7306 VisitForControl(expr->expression(), | 7283 VisitForControl(expr->expression(), |
| 7307 context->if_false(), | 7284 context->if_false(), |
| 7308 context->if_true()); | 7285 context->if_true()); |
| 7309 return; | 7286 return; |
| 7310 } | 7287 } |
| 7311 | 7288 |
| 7312 if (ast_context()->IsEffect()) { | 7289 if (ast_context()->IsEffect()) { |
| (...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9729 if (ShouldProduceTraceOutput()) { | 9706 if (ShouldProduceTraceOutput()) { |
| 9730 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9707 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 9731 } | 9708 } |
| 9732 | 9709 |
| 9733 #ifdef DEBUG | 9710 #ifdef DEBUG |
| 9734 graph_->Verify(false); // No full verify. | 9711 graph_->Verify(false); // No full verify. |
| 9735 #endif | 9712 #endif |
| 9736 } | 9713 } |
| 9737 | 9714 |
| 9738 } } // namespace v8::internal | 9715 } } // namespace v8::internal |
| OLD | NEW |