| 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 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, | 1709 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, |
| 1710 static_cast<HValue*>(NULL), kind); | 1710 static_cast<HValue*>(NULL), kind); |
| 1711 Add<HStoreKeyed>(object_elements, key_constant, value, kind); | 1711 Add<HStoreKeyed>(object_elements, key_constant, value, kind); |
| 1712 } | 1712 } |
| 1713 } | 1713 } |
| 1714 | 1714 |
| 1715 return object; | 1715 return object; |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 | 1718 |
| 1719 HInstruction* HGraphBuilder::BuildUnaryMathOp( | |
| 1720 HValue* input, Handle<Type> type, Token::Value operation) { | |
| 1721 ASSERT_EQ(Token::BIT_NOT, operation); | |
| 1722 // We only handle the numeric cases here | |
| 1723 type = handle( | |
| 1724 Type::Intersect(type, handle(Type::Number(), isolate())), isolate()); | |
| 1725 if (type->Is(Type::None())) { | |
| 1726 Add<HDeoptimize>(Deoptimizer::SOFT); | |
| 1727 } | |
| 1728 return New<HBitNot>(input); | |
| 1729 } | |
| 1730 | |
| 1731 | |
| 1732 void HGraphBuilder::BuildCompareNil( | 1719 void HGraphBuilder::BuildCompareNil( |
| 1733 HValue* value, | 1720 HValue* value, |
| 1734 Handle<Type> type, | 1721 Handle<Type> type, |
| 1735 int position, | 1722 int position, |
| 1736 HIfContinuation* continuation) { | 1723 HIfContinuation* continuation) { |
| 1737 IfBuilder if_nil(this, position); | 1724 IfBuilder if_nil(this, position); |
| 1738 bool needs_or = false; | 1725 bool needs_or = false; |
| 1739 if (type->Maybe(Type::Null())) { | 1726 if (type->Maybe(Type::Null())) { |
| 1740 if (needs_or) if_nil.Or(); | 1727 if (needs_or) if_nil.Or(); |
| 1741 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); | 1728 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); |
| (...skipping 5452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7194 | 7181 |
| 7195 | 7182 |
| 7196 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { | 7183 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
| 7197 ASSERT(!HasStackOverflow()); | 7184 ASSERT(!HasStackOverflow()); |
| 7198 ASSERT(current_block() != NULL); | 7185 ASSERT(current_block() != NULL); |
| 7199 ASSERT(current_block()->HasPredecessor()); | 7186 ASSERT(current_block()->HasPredecessor()); |
| 7200 switch (expr->op()) { | 7187 switch (expr->op()) { |
| 7201 case Token::DELETE: return VisitDelete(expr); | 7188 case Token::DELETE: return VisitDelete(expr); |
| 7202 case Token::VOID: return VisitVoid(expr); | 7189 case Token::VOID: return VisitVoid(expr); |
| 7203 case Token::TYPEOF: return VisitTypeof(expr); | 7190 case Token::TYPEOF: return VisitTypeof(expr); |
| 7204 case Token::BIT_NOT: return VisitBitNot(expr); | |
| 7205 case Token::NOT: return VisitNot(expr); | 7191 case Token::NOT: return VisitNot(expr); |
| 7206 default: UNREACHABLE(); | 7192 default: UNREACHABLE(); |
| 7207 } | 7193 } |
| 7208 } | 7194 } |
| 7209 | 7195 |
| 7210 | 7196 |
| 7211 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { | 7197 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { |
| 7212 Property* prop = expr->expression()->AsProperty(); | 7198 Property* prop = expr->expression()->AsProperty(); |
| 7213 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 7199 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 7214 if (prop != NULL) { | 7200 if (prop != NULL) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7256 | 7242 |
| 7257 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { | 7243 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { |
| 7258 CHECK_ALIVE(VisitForTypeOf(expr->expression())); | 7244 CHECK_ALIVE(VisitForTypeOf(expr->expression())); |
| 7259 HValue* value = Pop(); | 7245 HValue* value = Pop(); |
| 7260 HValue* context = environment()->context(); | 7246 HValue* context = environment()->context(); |
| 7261 HInstruction* instr = new(zone()) HTypeof(context, value); | 7247 HInstruction* instr = new(zone()) HTypeof(context, value); |
| 7262 return ast_context()->ReturnInstruction(instr, expr->id()); | 7248 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 7263 } | 7249 } |
| 7264 | 7250 |
| 7265 | 7251 |
| 7266 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) { | |
| 7267 CHECK_ALIVE(VisitForValue(expr->expression())); | |
| 7268 Handle<Type> operand_type = expr->expression()->bounds().lower; | |
| 7269 HValue* value = TruncateToNumber(Pop(), &operand_type); | |
| 7270 HInstruction* instr = BuildUnaryMathOp(value, operand_type, Token::BIT_NOT); | |
| 7271 return ast_context()->ReturnInstruction(instr, expr->id()); | |
| 7272 } | |
| 7273 | |
| 7274 | |
| 7275 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { | 7252 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { |
| 7276 if (ast_context()->IsTest()) { | 7253 if (ast_context()->IsTest()) { |
| 7277 TestContext* context = TestContext::cast(ast_context()); | 7254 TestContext* context = TestContext::cast(ast_context()); |
| 7278 VisitForControl(expr->expression(), | 7255 VisitForControl(expr->expression(), |
| 7279 context->if_false(), | 7256 context->if_false(), |
| 7280 context->if_true()); | 7257 context->if_true()); |
| 7281 return; | 7258 return; |
| 7282 } | 7259 } |
| 7283 | 7260 |
| 7284 if (ast_context()->IsEffect()) { | 7261 if (ast_context()->IsEffect()) { |
| (...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9701 if (ShouldProduceTraceOutput()) { | 9678 if (ShouldProduceTraceOutput()) { |
| 9702 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9679 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 9703 } | 9680 } |
| 9704 | 9681 |
| 9705 #ifdef DEBUG | 9682 #ifdef DEBUG |
| 9706 graph_->Verify(false); // No full verify. | 9683 graph_->Verify(false); // No full verify. |
| 9707 #endif | 9684 #endif |
| 9708 } | 9685 } |
| 9709 | 9686 |
| 9710 } } // namespace v8::internal | 9687 } } // namespace v8::internal |
| OLD | NEW |