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 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 case Token::MUL: | 2481 case Token::MUL: |
2482 __ mul_d(f10, f12, f14); | 2482 __ mul_d(f10, f12, f14); |
2483 break; | 2483 break; |
2484 case Token::DIV: | 2484 case Token::DIV: |
2485 __ div_d(f10, f12, f14); | 2485 __ div_d(f10, f12, f14); |
2486 break; | 2486 break; |
2487 default: | 2487 default: |
2488 UNREACHABLE(); | 2488 UNREACHABLE(); |
2489 } | 2489 } |
2490 | 2490 |
2491 if (op_ != Token::DIV) { | 2491 if (result_type_ <= BinaryOpIC::INT32) { |
2492 // These operations produce an integer result. | |
2493 // Try to return a smi if we can. | |
2494 // Otherwise return a heap number if allowed, or jump to type | |
2495 // transition. | |
2496 | |
2497 Register except_flag = scratch2; | 2492 Register except_flag = scratch2; |
2498 __ EmitFPUTruncate(kRoundToZero, | 2493 const FPURoundingMode kRoundingMode = op_ == Token::DIV ? |
| 2494 kRoundToMinusInf : kRoundToZero; |
| 2495 const CheckForInexactConversion kConversion = op_ == Token::DIV ? |
| 2496 kCheckForInexactConversion : kDontCheckForInexactConversion; |
| 2497 __ EmitFPUTruncate(kRoundingMode, |
2499 scratch1, | 2498 scratch1, |
2500 f10, | 2499 f10, |
2501 at, | 2500 at, |
2502 f16, | 2501 f16, |
2503 except_flag); | 2502 except_flag, |
2504 | 2503 kConversion); |
2505 if (result_type_ <= BinaryOpIC::INT32) { | 2504 // If except_flag != 0, result does not fit in a 32-bit integer. |
2506 // If except_flag != 0, result does not fit in a 32-bit integer. | 2505 __ Branch(&transition, ne, except_flag, Operand(zero_reg)); |
2507 __ Branch(&transition, ne, except_flag, Operand(zero_reg)); | 2506 // Try to tag the result as a Smi, return heap number on overflow. |
2508 } | 2507 __ SmiTagCheckOverflow(scratch1, scratch1, scratch2); |
2509 | |
2510 // Check if the result fits in a smi. | |
2511 __ Addu(scratch2, scratch1, Operand(0x40000000)); | |
2512 // If not try to return a heap number. | |
2513 __ Branch(&return_heap_number, lt, scratch2, Operand(zero_reg)); | 2508 __ Branch(&return_heap_number, lt, scratch2, Operand(zero_reg)); |
2514 // Check for minus zero. Return heap number for minus zero if | 2509 // Check for minus zero, transition in that case (because we need |
2515 // double results are allowed; otherwise transition. | 2510 // to return a heap number). |
2516 Label not_zero; | 2511 Label not_zero; |
| 2512 ASSERT(kSmiTag == 0); |
2517 __ Branch(¬_zero, ne, scratch1, Operand(zero_reg)); | 2513 __ Branch(¬_zero, ne, scratch1, Operand(zero_reg)); |
2518 __ mfc1(scratch2, f11); | 2514 __ mfc1(scratch2, f11); |
2519 __ And(scratch2, scratch2, HeapNumber::kSignMask); | 2515 __ And(scratch2, scratch2, HeapNumber::kSignMask); |
2520 __ Branch(result_type_ <= BinaryOpIC::INT32 ? &transition | 2516 __ Branch(&transition, ne, scratch2, Operand(zero_reg)); |
2521 : &return_heap_number, | |
2522 ne, | |
2523 scratch2, | |
2524 Operand(zero_reg)); | |
2525 __ bind(¬_zero); | 2517 __ bind(¬_zero); |
2526 | 2518 |
2527 // Tag the result and return. | |
2528 __ Ret(USE_DELAY_SLOT); | 2519 __ Ret(USE_DELAY_SLOT); |
2529 __ SmiTag(v0, scratch1); // SmiTag emits one instruction. | 2520 __ mov(v0, scratch1); |
2530 } else { | |
2531 // DIV just falls through to allocating a heap number. | |
2532 } | 2521 } |
2533 | 2522 |
2534 __ bind(&return_heap_number); | 2523 __ bind(&return_heap_number); |
2535 // Return a heap number, or fall through to type transition or runtime | 2524 // Return a heap number, or fall through to type transition or runtime |
2536 // call if we can't. | 2525 // call if we can't. |
2537 // We are using FPU registers so s0 is available. | 2526 // We are using FPU registers so s0 is available. |
2538 heap_number_result = s0; | 2527 heap_number_result = s0; |
2539 BinaryOpStub_GenerateHeapResultAllocation(masm, | 2528 BinaryOpStub_GenerateHeapResultAllocation(masm, |
2540 heap_number_result, | 2529 heap_number_result, |
2541 heap_number_map, | 2530 heap_number_map, |
(...skipping 5386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7928 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 7917 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
7929 } | 7918 } |
7930 } | 7919 } |
7931 | 7920 |
7932 | 7921 |
7933 #undef __ | 7922 #undef __ |
7934 | 7923 |
7935 } } // namespace v8::internal | 7924 } } // namespace v8::internal |
7936 | 7925 |
7937 #endif // V8_TARGET_ARCH_MIPS | 7926 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |