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 6361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6372 __ j(equal, &heap_number); | 6372 __ j(equal, &heap_number); |
6373 __ bind(&return_equal); | 6373 __ bind(&return_equal); |
6374 __ xor_(rax, rax); | 6374 __ xor_(rax, rax); |
6375 __ ret(0); | 6375 __ ret(0); |
6376 | 6376 |
6377 __ bind(&heap_number); | 6377 __ bind(&heap_number); |
6378 // It is a heap number, so return non-equal if it's NaN and equal if it's | 6378 // It is a heap number, so return non-equal if it's NaN and equal if it's |
6379 // not NaN. | 6379 // not NaN. |
6380 // The representation of NaN values has all exponent bits (52..62) set, | 6380 // The representation of NaN values has all exponent bits (52..62) set, |
6381 // and not all mantissa bits (0..51) clear. | 6381 // and not all mantissa bits (0..51) clear. |
6382 // Read double representation into rax. | 6382 // We only allow QNaNs, which have bit 51 set (which also rules out |
6383 __ movq(rbx, V8_UINT64_C(0x7ff0000000000000), RelocInfo::NONE); | 6383 // the value being Infinity). |
6384 __ movq(rax, FieldOperand(rdx, HeapNumber::kValueOffset)); | 6384 |
6385 // Test that exponent bits are all set. | 6385 // Value is a QNaN if value & kQuietNaNMask == kQuietNaNMask, i.e., |
6386 __ or_(rbx, rax); | 6386 // all bits in the mask are set. We only need to check the word |
6387 __ cmpq(rbx, rax); | 6387 // that contains the exponent and high bit of the mantissa. |
6388 __ j(not_equal, &return_equal); | 6388 ASSERT_NE(0, (kQuietNaNHighBitsMask << 1) & 0x80000000u); |
6389 // Shift out flag and all exponent bits, retaining only mantissa. | 6389 __ movl(rdx, FieldOperand(rdx, HeapNumber::kExponentOffset)); |
6390 __ shl(rax, Immediate(12)); | 6390 __ xorl(rax, rax); |
6391 // If all bits in the mantissa are zero the number is Infinity, and | 6391 __ addl(rdx, rdx); // Shift value and mask so mask applies to top bits. |
6392 // we return zero. Otherwise it is a NaN, and we return non-zero. | 6392 __ cmpl(rdx, Immediate(kQuietNaNHighBitsMask << 1)); |
6393 // We cannot just return rax because only eax is tested on return. | 6393 __ setcc(above_equal, rax); |
6394 __ setcc(not_zero, rax); | |
6395 __ ret(0); | 6394 __ ret(0); |
6396 | 6395 |
6397 __ bind(¬_identical); | 6396 __ bind(¬_identical); |
6398 } | 6397 } |
6399 | 6398 |
6400 // If we're doing a strict equality comparison, we don't have to do | 6399 // If we're doing a strict equality comparison, we don't have to do |
6401 // type conversion, so we generate code to do fast comparison for objects | 6400 // type conversion, so we generate code to do fast comparison for objects |
6402 // and oddballs. Non-smi numbers and strings still go through the usual | 6401 // and oddballs. Non-smi numbers and strings still go through the usual |
6403 // slow-case code. | 6402 // slow-case code. |
6404 if (strict_) { | 6403 if (strict_) { |
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7729 masm.GetCode(&desc); | 7728 masm.GetCode(&desc); |
7730 // Call the function from C++. | 7729 // Call the function from C++. |
7731 return FUNCTION_CAST<ModuloFunction>(buffer); | 7730 return FUNCTION_CAST<ModuloFunction>(buffer); |
7732 } | 7731 } |
7733 | 7732 |
7734 #endif | 7733 #endif |
7735 | 7734 |
7736 #undef __ | 7735 #undef __ |
7737 | 7736 |
7738 } } // namespace v8::internal | 7737 } } // namespace v8::internal |
OLD | NEW |