OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 9142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9153 | 9153 |
9154 | 9154 |
9155 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { | 9155 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
9156 ASSERT(!HasStackOverflow()); | 9156 ASSERT(!HasStackOverflow()); |
9157 ASSERT(current_block() != NULL); | 9157 ASSERT(current_block() != NULL); |
9158 ASSERT(current_block()->HasPredecessor()); | 9158 ASSERT(current_block()->HasPredecessor()); |
9159 switch (expr->op()) { | 9159 switch (expr->op()) { |
9160 case Token::DELETE: return VisitDelete(expr); | 9160 case Token::DELETE: return VisitDelete(expr); |
9161 case Token::VOID: return VisitVoid(expr); | 9161 case Token::VOID: return VisitVoid(expr); |
9162 case Token::TYPEOF: return VisitTypeof(expr); | 9162 case Token::TYPEOF: return VisitTypeof(expr); |
9163 case Token::ADD: return VisitAdd(expr); | |
9164 case Token::SUB: return VisitSub(expr); | 9163 case Token::SUB: return VisitSub(expr); |
9165 case Token::BIT_NOT: return VisitBitNot(expr); | 9164 case Token::BIT_NOT: return VisitBitNot(expr); |
9166 case Token::NOT: return VisitNot(expr); | 9165 case Token::NOT: return VisitNot(expr); |
9167 default: UNREACHABLE(); | 9166 default: UNREACHABLE(); |
9168 } | 9167 } |
9169 } | 9168 } |
9170 | 9169 |
9171 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { | 9170 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { |
9172 Property* prop = expr->expression()->AsProperty(); | 9171 Property* prop = expr->expression()->AsProperty(); |
9173 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 9172 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9211 | 9210 |
9212 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { | 9211 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { |
9213 CHECK_ALIVE(VisitForTypeOf(expr->expression())); | 9212 CHECK_ALIVE(VisitForTypeOf(expr->expression())); |
9214 HValue* value = Pop(); | 9213 HValue* value = Pop(); |
9215 HValue* context = environment()->LookupContext(); | 9214 HValue* context = environment()->LookupContext(); |
9216 HInstruction* instr = new(zone()) HTypeof(context, value); | 9215 HInstruction* instr = new(zone()) HTypeof(context, value); |
9217 return ast_context()->ReturnInstruction(instr, expr->id()); | 9216 return ast_context()->ReturnInstruction(instr, expr->id()); |
9218 } | 9217 } |
9219 | 9218 |
9220 | 9219 |
9221 void HOptimizedGraphBuilder::VisitAdd(UnaryOperation* expr) { | |
9222 CHECK_ALIVE(VisitForValue(expr->expression())); | |
9223 HValue* value = Pop(); | |
9224 HValue* context = environment()->LookupContext(); | |
9225 HInstruction* instr = | |
9226 HMul::New(zone(), context, value, graph()->GetConstant1()); | |
9227 if (instr->IsBinaryOperation()) { | |
9228 // Since we don't have type feedback, we must be cautious/pessimistic. | |
9229 HBinaryOperation::cast(instr)->set_observed_input_representation( | |
9230 Representation::Tagged(), Representation::Tagged()); | |
9231 } | |
9232 return ast_context()->ReturnInstruction(instr, expr->id()); | |
9233 } | |
9234 | |
9235 | |
9236 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) { | 9220 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) { |
9237 CHECK_ALIVE(VisitForValue(expr->expression())); | 9221 CHECK_ALIVE(VisitForValue(expr->expression())); |
9238 HValue* value = Pop(); | 9222 HValue* value = Pop(); |
9239 HValue* context = environment()->LookupContext(); | 9223 HValue* context = environment()->LookupContext(); |
9240 HInstruction* instr = | 9224 HInstruction* instr = |
9241 HMul::New(zone(), context, value, graph()->GetConstantMinus1()); | 9225 HMul::New(zone(), context, value, graph()->GetConstantMinus1()); |
9242 TypeInfo info = oracle()->UnaryType(expr); | 9226 TypeInfo info = oracle()->UnaryType(expr); |
9243 Representation rep = ToRepresentation(info); | 9227 Representation rep = ToRepresentation(info); |
9244 if (info.IsUninitialized()) { | 9228 if (info.IsUninitialized()) { |
9245 AddSoftDeoptimize(); | 9229 AddSoftDeoptimize(); |
(...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11691 } | 11675 } |
11692 } | 11676 } |
11693 | 11677 |
11694 #ifdef DEBUG | 11678 #ifdef DEBUG |
11695 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11679 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
11696 if (allocator_ != NULL) allocator_->Verify(); | 11680 if (allocator_ != NULL) allocator_->Verify(); |
11697 #endif | 11681 #endif |
11698 } | 11682 } |
11699 | 11683 |
11700 } } // namespace v8::internal | 11684 } } // namespace v8::internal |
OLD | NEW |