| 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 8264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8275 HConstant* right_const = HConstant::cast(right); | 8275 HConstant* right_const = HConstant::cast(right); |
| 8276 if (right_const->HasInteger32Value() && | 8276 if (right_const->HasInteger32Value() && |
| 8277 (right_const->Integer32Value() & 0x1f) != 0) { | 8277 (right_const->Integer32Value() & 0x1f) != 0) { |
| 8278 return false; | 8278 return false; |
| 8279 } | 8279 } |
| 8280 } | 8280 } |
| 8281 return true; | 8281 return true; |
| 8282 } | 8282 } |
| 8283 | 8283 |
| 8284 | 8284 |
| 8285 bool HGraphBuilder::MatchMultiplyAdd(HValue* left, HValue* right, HValue** a, |
| 8286 HValue** b, HValue** c) { |
| 8287 if (right->IsMul()) { |
| 8288 HValue *tmp = left; |
| 8289 left = right; |
| 8290 right = tmp; |
| 8291 } |
| 8292 if (!left->IsMul()) |
| 8293 return false; |
| 8294 |
| 8295 HMul* mul = HMul::cast(left); |
| 8296 *a = mul->left(); |
| 8297 *b = mul->right(); |
| 8298 *c = right; |
| 8299 return true; |
| 8300 } |
| 8301 |
| 8302 |
| 8285 HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, | 8303 HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, |
| 8286 HValue* left, | 8304 HValue* left, |
| 8287 HValue* right) { | 8305 HValue* right) { |
| 8288 HValue* context = environment()->LookupContext(); | 8306 HValue* context = environment()->LookupContext(); |
| 8289 TypeInfo info = oracle()->BinaryType(expr); | 8307 TypeInfo info = oracle()->BinaryType(expr); |
| 8290 if (info.IsUninitialized()) { | 8308 if (info.IsUninitialized()) { |
| 8291 AddInstruction(new(zone()) HSoftDeoptimize); | 8309 AddInstruction(new(zone()) HSoftDeoptimize); |
| 8292 current_block()->MarkAsDeoptimizing(); | 8310 current_block()->MarkAsDeoptimizing(); |
| 8293 info = TypeInfo::Unknown(); | 8311 info = TypeInfo::Unknown(); |
| 8294 } | 8312 } |
| 8295 HInstruction* instr = NULL; | 8313 HInstruction* instr = NULL; |
| 8296 switch (expr->op()) { | 8314 switch (expr->op()) { |
| 8297 case Token::ADD: | 8315 case Token::ADD: { |
| 8316 HValue* a, *b, *c; |
| 8298 if (info.IsString()) { | 8317 if (info.IsString()) { |
| 8299 AddInstruction(new(zone()) HCheckNonSmi(left)); | 8318 AddInstruction(new(zone()) HCheckNonSmi(left)); |
| 8300 AddInstruction(HCheckInstanceType::NewIsString(left, zone())); | 8319 AddInstruction(HCheckInstanceType::NewIsString(left, zone())); |
| 8301 AddInstruction(new(zone()) HCheckNonSmi(right)); | 8320 AddInstruction(new(zone()) HCheckNonSmi(right)); |
| 8302 AddInstruction(HCheckInstanceType::NewIsString(right, zone())); | 8321 AddInstruction(HCheckInstanceType::NewIsString(right, zone())); |
| 8303 instr = new(zone()) HStringAdd(context, left, right); | 8322 instr = new(zone()) HStringAdd(context, left, right); |
| 8323 } else if (info.IsDouble() && MatchMultiplyAdd(left, right, &a, &b, &c)) { |
| 8324 instr = new(zone()) HMultiplyAddD(context, a, b, c); |
| 8304 } else { | 8325 } else { |
| 8305 instr = HAdd::NewHAdd(zone(), context, left, right); | 8326 instr = HAdd::NewHAdd(zone(), context, left, right); |
| 8306 } | 8327 } |
| 8307 break; | 8328 break; |
| 8329 } |
| 8308 case Token::SUB: | 8330 case Token::SUB: |
| 8309 instr = HSub::NewHSub(zone(), context, left, right); | 8331 instr = HSub::NewHSub(zone(), context, left, right); |
| 8310 break; | 8332 break; |
| 8311 case Token::MUL: | 8333 case Token::MUL: |
| 8312 instr = HMul::NewHMul(zone(), context, left, right); | 8334 instr = HMul::NewHMul(zone(), context, left, right); |
| 8313 break; | 8335 break; |
| 8314 case Token::MOD: | 8336 case Token::MOD: |
| 8315 instr = HMod::NewHMod(zone(), context, left, right); | 8337 instr = HMod::NewHMod(zone(), context, left, right); |
| 8316 break; | 8338 break; |
| 8317 case Token::DIV: | 8339 case Token::DIV: |
| (...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10011 } | 10033 } |
| 10012 } | 10034 } |
| 10013 | 10035 |
| 10014 #ifdef DEBUG | 10036 #ifdef DEBUG |
| 10015 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10037 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 10016 if (allocator_ != NULL) allocator_->Verify(); | 10038 if (allocator_ != NULL) allocator_->Verify(); |
| 10017 #endif | 10039 #endif |
| 10018 } | 10040 } |
| 10019 | 10041 |
| 10020 } } // namespace v8::internal | 10042 } } // namespace v8::internal |
| OLD | NEW |