OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 4489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4500 } | 4500 } |
4501 case Token::BIT_OR: | 4501 case Token::BIT_OR: |
4502 case Token::BIT_AND: | 4502 case Token::BIT_AND: |
4503 case Token::BIT_XOR: | 4503 case Token::BIT_XOR: |
4504 case Token::SAR: | 4504 case Token::SAR: |
4505 case Token::SHL: | 4505 case Token::SHL: |
4506 case Token::SHR: { | 4506 case Token::SHR: { |
4507 FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx); | 4507 FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx); |
4508 FloatingPointHelper::LoadFloatOperands(masm, ecx); | 4508 FloatingPointHelper::LoadFloatOperands(masm, ecx); |
4509 | 4509 |
4510 Label non_int32_operands, non_smi_result, skip_allocation; | 4510 Label skip_allocation, non_smi_result, operand_conversion_failure; |
| 4511 |
4511 // Reserve space for converted numbers. | 4512 // Reserve space for converted numbers. |
4512 __ sub(Operand(esp), Immediate(2 * kPointerSize)); | 4513 __ sub(Operand(esp), Immediate(2 * kPointerSize)); |
4513 | 4514 |
4514 // Check if right operand is int32. | 4515 bool use_sse3 = CpuFeatures::IsSupported(CpuFeatures::SSE3); |
4515 __ fist_s(Operand(esp, 1 * kPointerSize)); | 4516 if (use_sse3) { |
4516 __ fild_s(Operand(esp, 1 * kPointerSize)); | 4517 // Truncate the operands to 32-bit integers and check for |
4517 __ fucompp(); | 4518 // exceptions in doing so. |
4518 __ fnstsw_ax(); | 4519 CpuFeatures::Scope scope(CpuFeatures::SSE3); |
4519 __ sahf(); | 4520 __ fisttp_s(Operand(esp, 0 * kPointerSize)); |
4520 __ j(not_zero, &non_int32_operands); | 4521 __ fisttp_s(Operand(esp, 1 * kPointerSize)); |
4521 __ j(parity_even, &non_int32_operands); | 4522 __ fnstsw_ax(); |
| 4523 __ test(eax, Immediate(1)); |
| 4524 __ j(not_zero, &operand_conversion_failure); |
| 4525 } else { |
| 4526 // Check if right operand is int32. |
| 4527 __ fist_s(Operand(esp, 0 * kPointerSize)); |
| 4528 __ fild_s(Operand(esp, 0 * kPointerSize)); |
| 4529 __ fucompp(); |
| 4530 __ fnstsw_ax(); |
| 4531 __ sahf(); |
| 4532 __ j(not_zero, &operand_conversion_failure); |
| 4533 __ j(parity_even, &operand_conversion_failure); |
4522 | 4534 |
4523 // Check if left operand is int32. | 4535 // Check if left operand is int32. |
4524 __ fist_s(Operand(esp, 0 * kPointerSize)); | 4536 __ fist_s(Operand(esp, 1 * kPointerSize)); |
4525 __ fild_s(Operand(esp, 0 * kPointerSize)); | 4537 __ fild_s(Operand(esp, 1 * kPointerSize)); |
4526 __ fucompp(); | 4538 __ fucompp(); |
4527 __ fnstsw_ax(); | 4539 __ fnstsw_ax(); |
4528 __ sahf(); | 4540 __ sahf(); |
4529 __ j(not_zero, &non_int32_operands); | 4541 __ j(not_zero, &operand_conversion_failure); |
4530 __ j(parity_even, &non_int32_operands); | 4542 __ j(parity_even, &operand_conversion_failure); |
| 4543 } |
4531 | 4544 |
4532 // Get int32 operands and perform bitop. | 4545 // Get int32 operands and perform bitop. |
| 4546 __ pop(ecx); |
4533 __ pop(eax); | 4547 __ pop(eax); |
4534 __ pop(ecx); | |
4535 switch (op_) { | 4548 switch (op_) { |
4536 case Token::BIT_OR: __ or_(eax, Operand(ecx)); break; | 4549 case Token::BIT_OR: __ or_(eax, Operand(ecx)); break; |
4537 case Token::BIT_AND: __ and_(eax, Operand(ecx)); break; | 4550 case Token::BIT_AND: __ and_(eax, Operand(ecx)); break; |
4538 case Token::BIT_XOR: __ xor_(eax, Operand(ecx)); break; | 4551 case Token::BIT_XOR: __ xor_(eax, Operand(ecx)); break; |
4539 case Token::SAR: __ sar(eax); break; | 4552 case Token::SAR: __ sar(eax); break; |
4540 case Token::SHL: __ shl(eax); break; | 4553 case Token::SHL: __ shl(eax); break; |
4541 case Token::SHR: __ shr(eax); break; | 4554 case Token::SHR: __ shr(eax); break; |
4542 default: UNREACHABLE(); | 4555 default: UNREACHABLE(); |
4543 } | 4556 } |
4544 | 4557 |
(...skipping 27 matching lines...) Expand all Loading... |
4572 __ bind(&skip_allocation); | 4585 __ bind(&skip_allocation); |
4573 break; | 4586 break; |
4574 default: UNREACHABLE(); | 4587 default: UNREACHABLE(); |
4575 } | 4588 } |
4576 // Store the result in the HeapNumber and return. | 4589 // Store the result in the HeapNumber and return. |
4577 __ mov(Operand(esp, 1 * kPointerSize), ebx); | 4590 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
4578 __ fild_s(Operand(esp, 1 * kPointerSize)); | 4591 __ fild_s(Operand(esp, 1 * kPointerSize)); |
4579 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 4592 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
4580 __ ret(2 * kPointerSize); | 4593 __ ret(2 * kPointerSize); |
4581 } | 4594 } |
4582 __ bind(&non_int32_operands); | 4595 |
4583 // Restore stacks and operands before calling runtime. | 4596 // Clear the FPU exception flag and reset the stack before calling |
4584 __ ffree(0); | 4597 // the runtime system. |
| 4598 __ bind(&operand_conversion_failure); |
4585 __ add(Operand(esp), Immediate(2 * kPointerSize)); | 4599 __ add(Operand(esp), Immediate(2 * kPointerSize)); |
| 4600 if (use_sse3) { |
| 4601 // If we've used the SSE3 instructions for truncating the |
| 4602 // floating point values to integers and it failed, we have a |
| 4603 // pending #IA exception. Clear it. |
| 4604 __ fnclex(); |
| 4605 } else { |
| 4606 // The non-SSE3 variant does early bailout if the right |
| 4607 // operand isn't a 32-bit integer, so we may have a single |
| 4608 // value on the FPU stack we need to get rid of. |
| 4609 __ ffree(0); |
| 4610 } |
4586 | 4611 |
4587 // SHR should return uint32 - go to runtime for non-smi/negative result. | 4612 // SHR should return uint32 - go to runtime for non-smi/negative result. |
4588 if (op_ == Token::SHR) __ bind(&non_smi_result); | 4613 if (op_ == Token::SHR) __ bind(&non_smi_result); |
4589 __ mov(eax, Operand(esp, 1 * kPointerSize)); | 4614 __ mov(eax, Operand(esp, 1 * kPointerSize)); |
4590 __ mov(edx, Operand(esp, 2 * kPointerSize)); | 4615 __ mov(edx, Operand(esp, 2 * kPointerSize)); |
4591 break; | 4616 break; |
4592 } | 4617 } |
4593 default: UNREACHABLE(); break; | 4618 default: UNREACHABLE(); break; |
4594 } | 4619 } |
4595 | 4620 |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5447 | 5472 |
5448 // Slow-case: Go through the JavaScript implementation. | 5473 // Slow-case: Go through the JavaScript implementation. |
5449 __ bind(&slow); | 5474 __ bind(&slow); |
5450 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 5475 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
5451 } | 5476 } |
5452 | 5477 |
5453 | 5478 |
5454 #undef __ | 5479 #undef __ |
5455 | 5480 |
5456 } } // namespace v8::internal | 5481 } } // namespace v8::internal |
OLD | NEW |