OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 4958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4969 // Sign extend eax into edx:eax. | 4969 // Sign extend eax into edx:eax. |
4970 __ cdq(); | 4970 __ cdq(); |
4971 // Check for 0 divisor. | 4971 // Check for 0 divisor. |
4972 __ testl(right->reg(), right->reg()); | 4972 __ testl(right->reg(), right->reg()); |
4973 deferred->Branch(zero); | 4973 deferred->Branch(zero); |
4974 // Divide rdx:rax by the right operand. | 4974 // Divide rdx:rax by the right operand. |
4975 __ idivl(right->reg()); | 4975 __ idivl(right->reg()); |
4976 | 4976 |
4977 // Complete the operation. | 4977 // Complete the operation. |
4978 if (op == Token::DIV) { | 4978 if (op == Token::DIV) { |
4979 // Check for negative zero result. If result is zero, and divisor | 4979 // Check for negative zero result. If the result is zero, and the |
4980 // is negative, return a floating point negative zero. The jump | 4980 // divisor is negative, return a floating point negative zero. |
4981 // to non_zero_result is safe w.r.t. the frame. | |
4982 Label non_zero_result; | 4981 Label non_zero_result; |
4983 __ testl(left->reg(), left->reg()); | 4982 __ testl(left->reg(), left->reg()); |
4984 __ j(not_zero, &non_zero_result); | 4983 __ j(not_zero, &non_zero_result); |
4985 __ testl(right->reg(), right->reg()); | 4984 __ testl(right->reg(), right->reg()); |
4986 deferred->Branch(negative); | 4985 deferred->Branch(negative); |
| 4986 // The frame is identical on all paths reaching this label. |
4987 __ bind(&non_zero_result); | 4987 __ bind(&non_zero_result); |
4988 // Check for the corner case of dividing the most negative smi by | 4988 // Check for the corner case of dividing the most negative smi by |
4989 // -1. We cannot use the overflow flag, since it is not set by | 4989 // -1. We cannot use the overflow flag, since it is not set by |
4990 // idiv instruction. | 4990 // idiv instruction. |
4991 ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | 4991 ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
4992 __ cmpl(rax, Immediate(0x40000000)); | 4992 __ cmpl(rax, Immediate(0x40000000)); |
4993 deferred->Branch(equal); | 4993 deferred->Branch(equal); |
4994 // Check that the remainder is zero. | 4994 // Check that the remainder is zero. |
4995 __ testl(rdx, rdx); | 4995 __ testl(rdx, rdx); |
4996 deferred->Branch(not_zero); | 4996 deferred->Branch(not_zero); |
4997 // Tag the result and store it in the quotient register. | 4997 // Tag the result and store it in the quotient register. |
4998 ASSERT(kSmiTagSize == times_2); // adjust code if not the case | 4998 ASSERT(kSmiTagSize == times_2); // adjust code if not the case |
4999 __ lea(rax, Operand(rax, rax, times_1, kSmiTag)); | 4999 __ lea(rax, Operand(rax, rax, times_1, kSmiTag)); |
5000 deferred->BindExit(); | 5000 deferred->BindExit(); |
5001 left->Unuse(); | 5001 left->Unuse(); |
5002 right->Unuse(); | 5002 right->Unuse(); |
5003 frame_->Push("ient); | 5003 frame_->Push("ient); |
5004 } else { | 5004 } else { |
5005 ASSERT(op == Token::MOD); | 5005 ASSERT(op == Token::MOD); |
5006 // Check for a negative zero result. If the result is zero, and | 5006 // Check for a negative zero result. If the result is zero, and the |
5007 // the dividend is negative, return a floating point negative | 5007 // dividend is negative, return a floating point negative zero. |
5008 // zero. The frame is unchanged between the jump to &non_zero_result | |
5009 // and the target, so a Label can be used. | |
5010 Label non_zero_result; | 5008 Label non_zero_result; |
5011 __ testl(rdx, rdx); | 5009 __ testl(rdx, rdx); |
5012 __ j(not_zero, &non_zero_result); | 5010 __ j(not_zero, &non_zero_result); |
5013 __ testl(left->reg(), left->reg()); | 5011 __ testl(left->reg(), left->reg()); |
5014 deferred->Branch(negative); | 5012 deferred->Branch(negative); |
| 5013 // The frame is identical on all paths reaching this label. |
5015 __ bind(&non_zero_result); | 5014 __ bind(&non_zero_result); |
5016 deferred->BindExit(); | 5015 deferred->BindExit(); |
5017 left->Unuse(); | 5016 left->Unuse(); |
5018 right->Unuse(); | 5017 right->Unuse(); |
5019 frame_->Push(&remainder); | 5018 frame_->Push(&remainder); |
5020 } | 5019 } |
5021 return; | 5020 return; |
5022 } | 5021 } |
5023 | 5022 |
5024 // Special handling of shift operations because they use fixed | 5023 // Special handling of shift operations because they use fixed |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6937 int CompareStub::MinorKey() { | 6936 int CompareStub::MinorKey() { |
6938 // Encode the two parameters in a unique 16 bit value. | 6937 // Encode the two parameters in a unique 16 bit value. |
6939 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); | 6938 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); |
6940 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); | 6939 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); |
6941 } | 6940 } |
6942 | 6941 |
6943 | 6942 |
6944 #undef __ | 6943 #undef __ |
6945 | 6944 |
6946 } } // namespace v8::internal | 6945 } } // namespace v8::internal |
OLD | NEW |