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 5504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5515 | 5515 |
5516 __ bind(&miss); | 5516 __ bind(&miss); |
5517 GenerateMiss(masm); | 5517 GenerateMiss(masm); |
5518 } | 5518 } |
5519 | 5519 |
5520 | 5520 |
5521 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { | 5521 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { |
5522 ASSERT(state_ == CompareIC::HEAP_NUMBERS); | 5522 ASSERT(state_ == CompareIC::HEAP_NUMBERS); |
5523 | 5523 |
5524 Label generic_stub; | 5524 Label generic_stub; |
5525 Label unordered; | 5525 Label unordered, maybe_undefined1, maybe_undefined2; |
5526 Label miss; | 5526 Label miss; |
5527 Condition either_smi = masm->CheckEitherSmi(rax, rdx); | 5527 Condition either_smi = masm->CheckEitherSmi(rax, rdx); |
5528 __ j(either_smi, &generic_stub, Label::kNear); | 5528 __ j(either_smi, &generic_stub, Label::kNear); |
5529 | 5529 |
5530 __ CmpObjectType(rax, HEAP_NUMBER_TYPE, rcx); | 5530 __ CmpObjectType(rax, HEAP_NUMBER_TYPE, rcx); |
5531 __ j(not_equal, &miss, Label::kNear); | 5531 __ j(not_equal, &maybe_undefined1, Label::kNear); |
5532 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rcx); | 5532 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rcx); |
5533 __ j(not_equal, &miss, Label::kNear); | 5533 __ j(not_equal, &maybe_undefined2, Label::kNear); |
5534 | 5534 |
5535 // Load left and right operand | 5535 // Load left and right operand |
5536 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); | 5536 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); |
5537 __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); | 5537 __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); |
5538 | 5538 |
5539 // Compare operands | 5539 // Compare operands |
5540 __ ucomisd(xmm0, xmm1); | 5540 __ ucomisd(xmm0, xmm1); |
5541 | 5541 |
5542 // Don't base result on EFLAGS when a NaN is involved. | 5542 // Don't base result on EFLAGS when a NaN is involved. |
5543 __ j(parity_even, &unordered, Label::kNear); | 5543 __ j(parity_even, &unordered, Label::kNear); |
5544 | 5544 |
5545 // Return a result of -1, 0, or 1, based on EFLAGS. | 5545 // Return a result of -1, 0, or 1, based on EFLAGS. |
5546 // Performing mov, because xor would destroy the flag register. | 5546 // Performing mov, because xor would destroy the flag register. |
5547 __ movl(rax, Immediate(0)); | 5547 __ movl(rax, Immediate(0)); |
5548 __ movl(rcx, Immediate(0)); | 5548 __ movl(rcx, Immediate(0)); |
5549 __ setcc(above, rax); // Add one to zero if carry clear and not equal. | 5549 __ setcc(above, rax); // Add one to zero if carry clear and not equal. |
5550 __ sbbq(rax, rcx); // Subtract one if below (aka. carry set). | 5550 __ sbbq(rax, rcx); // Subtract one if below (aka. carry set). |
5551 __ ret(0); | 5551 __ ret(0); |
5552 | 5552 |
5553 __ bind(&unordered); | 5553 __ bind(&unordered); |
5554 | |
5555 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); | 5554 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); |
5556 __ bind(&generic_stub); | 5555 __ bind(&generic_stub); |
5557 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); | 5556 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
5558 | 5557 |
| 5558 __ bind(&maybe_undefined1); |
| 5559 if (Token::IsOrderedRelationalCompareOp(op_)) { |
| 5560 __ Cmp(rax, masm->isolate()->factory()->undefined_value()); |
| 5561 __ j(not_equal, &miss); |
| 5562 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rcx); |
| 5563 __ j(not_equal, &maybe_undefined2, Label::kNear); |
| 5564 __ jmp(&unordered); |
| 5565 } |
| 5566 |
| 5567 __ bind(&maybe_undefined2); |
| 5568 if (Token::IsOrderedRelationalCompareOp(op_)) { |
| 5569 __ Cmp(rdx, masm->isolate()->factory()->undefined_value()); |
| 5570 __ j(equal, &unordered); |
| 5571 } |
| 5572 |
5559 __ bind(&miss); | 5573 __ bind(&miss); |
5560 GenerateMiss(masm); | 5574 GenerateMiss(masm); |
5561 } | 5575 } |
5562 | 5576 |
5563 | 5577 |
5564 void ICCompareStub::GenerateSymbols(MacroAssembler* masm) { | 5578 void ICCompareStub::GenerateSymbols(MacroAssembler* masm) { |
5565 ASSERT(state_ == CompareIC::SYMBOLS); | 5579 ASSERT(state_ == CompareIC::SYMBOLS); |
5566 ASSERT(GetCondition() == equal); | 5580 ASSERT(GetCondition() == equal); |
5567 | 5581 |
5568 // Registers containing left and right operands respectively. | 5582 // Registers containing left and right operands respectively. |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6312 xmm0, | 6326 xmm0, |
6313 &slow_elements); | 6327 &slow_elements); |
6314 __ ret(0); | 6328 __ ret(0); |
6315 } | 6329 } |
6316 | 6330 |
6317 #undef __ | 6331 #undef __ |
6318 | 6332 |
6319 } } // namespace v8::internal | 6333 } } // namespace v8::internal |
6320 | 6334 |
6321 #endif // V8_TARGET_ARCH_X64 | 6335 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |