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 6554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6565 | 6565 |
6566 __ bind(&miss); | 6566 __ bind(&miss); |
6567 GenerateMiss(masm); | 6567 GenerateMiss(masm); |
6568 } | 6568 } |
6569 | 6569 |
6570 | 6570 |
6571 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { | 6571 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { |
6572 ASSERT(state_ == CompareIC::HEAP_NUMBERS); | 6572 ASSERT(state_ == CompareIC::HEAP_NUMBERS); |
6573 | 6573 |
6574 Label generic_stub; | 6574 Label generic_stub; |
6575 Label unordered; | 6575 Label unordered, maybe_undefined1, maybe_undefined2; |
6576 Label miss; | 6576 Label miss; |
6577 __ mov(ecx, edx); | 6577 __ mov(ecx, edx); |
6578 __ and_(ecx, eax); | 6578 __ and_(ecx, eax); |
6579 __ JumpIfSmi(ecx, &generic_stub, Label::kNear); | 6579 __ JumpIfSmi(ecx, &generic_stub, Label::kNear); |
6580 | 6580 |
6581 __ CmpObjectType(eax, HEAP_NUMBER_TYPE, ecx); | 6581 __ CmpObjectType(eax, HEAP_NUMBER_TYPE, ecx); |
6582 __ j(not_equal, &miss, Label::kNear); | 6582 __ j(not_equal, &maybe_undefined1, Label::kNear); |
6583 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); | 6583 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); |
6584 __ j(not_equal, &miss, Label::kNear); | 6584 __ j(not_equal, &maybe_undefined2, Label::kNear); |
6585 | 6585 |
6586 // Inlining the double comparison and falling back to the general compare | 6586 // Inlining the double comparison and falling back to the general compare |
6587 // stub if NaN is involved or SS2 or CMOV is unsupported. | 6587 // stub if NaN is involved or SS2 or CMOV is unsupported. |
6588 if (CpuFeatures::IsSupported(SSE2) && CpuFeatures::IsSupported(CMOV)) { | 6588 if (CpuFeatures::IsSupported(SSE2) && CpuFeatures::IsSupported(CMOV)) { |
6589 CpuFeatures::Scope scope1(SSE2); | 6589 CpuFeatures::Scope scope1(SSE2); |
6590 CpuFeatures::Scope scope2(CMOV); | 6590 CpuFeatures::Scope scope2(CMOV); |
6591 | 6591 |
6592 // Load left and right operand | 6592 // Load left and right operand |
6593 __ movdbl(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); | 6593 __ movdbl(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); |
6594 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); | 6594 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); |
6595 | 6595 |
6596 // Compare operands | 6596 // Compare operands |
6597 __ ucomisd(xmm0, xmm1); | 6597 __ ucomisd(xmm0, xmm1); |
6598 | 6598 |
6599 // Don't base result on EFLAGS when a NaN is involved. | 6599 // Don't base result on EFLAGS when a NaN is involved. |
6600 __ j(parity_even, &unordered, Label::kNear); | 6600 __ j(parity_even, &unordered, Label::kNear); |
6601 | 6601 |
6602 // Return a result of -1, 0, or 1, based on EFLAGS. | 6602 // Return a result of -1, 0, or 1, based on EFLAGS. |
6603 // Performing mov, because xor would destroy the flag register. | 6603 // Performing mov, because xor would destroy the flag register. |
6604 __ mov(eax, 0); // equal | 6604 __ mov(eax, 0); // equal |
6605 __ mov(ecx, Immediate(Smi::FromInt(1))); | 6605 __ mov(ecx, Immediate(Smi::FromInt(1))); |
6606 __ cmov(above, eax, ecx); | 6606 __ cmov(above, eax, ecx); |
6607 __ mov(ecx, Immediate(Smi::FromInt(-1))); | 6607 __ mov(ecx, Immediate(Smi::FromInt(-1))); |
6608 __ cmov(below, eax, ecx); | 6608 __ cmov(below, eax, ecx); |
6609 __ ret(0); | 6609 __ ret(0); |
6610 | |
6611 __ bind(&unordered); | |
6612 } | 6610 } |
6613 | 6611 |
| 6612 __ bind(&unordered); |
6614 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); | 6613 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); |
6615 __ bind(&generic_stub); | 6614 __ bind(&generic_stub); |
6616 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); | 6615 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
6617 | 6616 |
| 6617 __ bind(&maybe_undefined1); |
| 6618 if (Token::IsOrderedRelationalCompareOp(op_)) { |
| 6619 __ cmp(eax, Immediate(masm->isolate()->factory()->undefined_value())); |
| 6620 __ j(not_equal, &miss); |
| 6621 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); |
| 6622 __ j(not_equal, &maybe_undefined2, Label::kNear); |
| 6623 __ jmp(&unordered); |
| 6624 } |
| 6625 |
| 6626 __ bind(&maybe_undefined2); |
| 6627 if (Token::IsOrderedRelationalCompareOp(op_)) { |
| 6628 __ cmp(edx, Immediate(masm->isolate()->factory()->undefined_value())); |
| 6629 __ j(equal, &unordered); |
| 6630 } |
| 6631 |
6618 __ bind(&miss); | 6632 __ bind(&miss); |
6619 GenerateMiss(masm); | 6633 GenerateMiss(masm); |
6620 } | 6634 } |
6621 | 6635 |
6622 | 6636 |
6623 void ICCompareStub::GenerateSymbols(MacroAssembler* masm) { | 6637 void ICCompareStub::GenerateSymbols(MacroAssembler* masm) { |
6624 ASSERT(state_ == CompareIC::SYMBOLS); | 6638 ASSERT(state_ == CompareIC::SYMBOLS); |
6625 ASSERT(GetCondition() == equal); | 6639 ASSERT(GetCondition() == equal); |
6626 | 6640 |
6627 // Registers containing left and right operands respectively. | 6641 // Registers containing left and right operands respectively. |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7385 false); | 7399 false); |
7386 __ pop(edx); | 7400 __ pop(edx); |
7387 __ ret(0); | 7401 __ ret(0); |
7388 } | 7402 } |
7389 | 7403 |
7390 #undef __ | 7404 #undef __ |
7391 | 7405 |
7392 } } // namespace v8::internal | 7406 } } // namespace v8::internal |
7393 | 7407 |
7394 #endif // V8_TARGET_ARCH_IA32 | 7408 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |