Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 23694014: MIPS: Support for DoubleToIStub (truncating). (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // Compute lower part of fraction (last 12 bits). 514 // Compute lower part of fraction (last 12 bits).
515 __ sll(mantissa, source_, HeapNumber::kMantissaBitsInTopWord); 515 __ sll(mantissa, source_, HeapNumber::kMantissaBitsInTopWord);
516 // And the top (top 20 bits). 516 // And the top (top 20 bits).
517 __ srl(source_, source_, 32 - HeapNumber::kMantissaBitsInTopWord); 517 __ srl(source_, source_, 32 - HeapNumber::kMantissaBitsInTopWord);
518 518
519 __ Ret(USE_DELAY_SLOT); 519 __ Ret(USE_DELAY_SLOT);
520 __ or_(exponent, exponent, source_); 520 __ or_(exponent, exponent, source_);
521 } 521 }
522 522
523 523
524 void DoubleToIStub::Generate(MacroAssembler* masm) {
525 Label out_of_range, only_low, negate, done;
526 Register input_reg = source();
527 Register result_reg = destination();
528
529 int double_offset = offset();
530 // Account for saved regs if input is sp.
531 if (input_reg.is(sp)) double_offset += 3 * kPointerSize;
532
533 Register scratch =
534 GetRegisterThatIsNotOneOf(input_reg, result_reg);
535 Register scratch2 =
536 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch);
537 Register scratch3 =
538 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch, scratch2);
539 DoubleRegister double_scratch = kLithiumScratchDouble.low();
540 DoubleRegister double_input = f12;
541
542 __ Push(scratch, scratch2, scratch3);
543
544 __ ldc1(double_input, MemOperand(input_reg, double_offset));
545
546 if (!skip_fastpath()) {
547 // Clear cumulative exception flags and save the FCSR.
548 __ cfc1(scratch2, FCSR);
549 __ ctc1(zero_reg, FCSR);
550 // Try a conversion to a signed integer.
551 __ trunc_w_d(double_scratch, double_input);
552 __ mfc1(result_reg, double_scratch);
553 // Retrieve and restore the FCSR.
554 __ cfc1(scratch, FCSR);
555 __ ctc1(scratch2, FCSR);
556 // Check for overflow and NaNs.
557 __ And(
558 scratch, scratch,
559 kFCSROverflowFlagMask | kFCSRUnderflowFlagMask
560 | kFCSRInvalidOpFlagMask);
561 // If we had no exceptions we are done.
562 __ Branch(&done, eq, scratch, Operand(zero_reg));
563 }
564
565 // Load the double value and perform a manual truncation.
566 Register input_high = scratch2;
567 Register input_low = scratch3;
568 __ Move(input_low, input_high, double_input);
569
570 __ EmitOutOfInt32RangeTruncate(result_reg,
571 input_high,
572 input_low,
573 scratch);
574
575 __ bind(&done);
576
577 __ Pop(scratch, scratch2, scratch3);
578 __ Ret();
579 }
580
581
524 bool WriteInt32ToHeapNumberStub::IsPregenerated() { 582 bool WriteInt32ToHeapNumberStub::IsPregenerated() {
525 // These variants are compiled ahead of time. See next method. 583 // These variants are compiled ahead of time. See next method.
526 if (the_int_.is(a1) && 584 if (the_int_.is(a1) &&
527 the_heap_number_.is(v0) && 585 the_heap_number_.is(v0) &&
528 scratch_.is(a2) && 586 scratch_.is(a2) &&
529 sign_.is(a3)) { 587 sign_.is(a3)) {
530 return true; 588 return true;
531 } 589 }
532 if (the_int_.is(a2) && 590 if (the_int_.is(a2) &&
533 the_heap_number_.is(v0) && 591 the_heap_number_.is(v0) &&
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 case Token::BIT_XOR: 1583 case Token::BIT_XOR:
1526 case Token::BIT_AND: 1584 case Token::BIT_AND:
1527 case Token::SAR: 1585 case Token::SAR:
1528 case Token::SHR: 1586 case Token::SHR:
1529 case Token::SHL: { 1587 case Token::SHL: {
1530 if (smi_operands) { 1588 if (smi_operands) {
1531 __ SmiUntag(a3, left); 1589 __ SmiUntag(a3, left);
1532 __ SmiUntag(a2, right); 1590 __ SmiUntag(a2, right);
1533 } else { 1591 } else {
1534 // Convert operands to 32-bit integers. Right in a2 and left in a3. 1592 // Convert operands to 32-bit integers. Right in a2 and left in a3.
1535 __ ConvertNumberToInt32( 1593 __ TruncateNumberToI(
1536 left, a3, heap_number_map, 1594 left, a3, heap_number_map,
1537 scratch1, scratch2, scratch3, f0, not_numbers); 1595 scratch1, scratch2, scratch3, not_numbers);
1538 __ ConvertNumberToInt32( 1596 __ TruncateNumberToI(
1539 right, a2, heap_number_map, 1597 right, a2, heap_number_map,
1540 scratch1, scratch2, scratch3, f0, not_numbers); 1598 scratch1, scratch2, scratch3, not_numbers);
1541 } 1599 }
1542 Label result_not_a_smi; 1600 Label result_not_a_smi;
1543 switch (op) { 1601 switch (op) {
1544 case Token::BIT_OR: 1602 case Token::BIT_OR:
1545 __ Or(a2, a3, Operand(a2)); 1603 __ Or(a2, a3, Operand(a2));
1546 break; 1604 break;
1547 case Token::BIT_XOR: 1605 case Token::BIT_XOR:
1548 __ Xor(a2, a3, Operand(a2)); 1606 __ Xor(a2, a3, Operand(a2));
1549 break; 1607 break;
1550 case Token::BIT_AND: 1608 case Token::BIT_AND:
(...skipping 5581 matching lines...) Expand 10 before | Expand all | Expand 10 after
7132 __ bind(&fast_elements_case); 7190 __ bind(&fast_elements_case);
7133 GenerateCase(masm, FAST_ELEMENTS); 7191 GenerateCase(masm, FAST_ELEMENTS);
7134 } 7192 }
7135 7193
7136 7194
7137 #undef __ 7195 #undef __
7138 7196
7139 } } // namespace v8::internal 7197 } } // namespace v8::internal
7140 7198
7141 #endif // V8_TARGET_ARCH_MIPS 7199 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698