Chromium Code Reviews| 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 4464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4475 } | 4475 } |
| 4476 case Token::BIT_OR: | 4476 case Token::BIT_OR: |
| 4477 case Token::BIT_AND: | 4477 case Token::BIT_AND: |
| 4478 case Token::BIT_XOR: | 4478 case Token::BIT_XOR: |
| 4479 case Token::SAR: | 4479 case Token::SAR: |
| 4480 case Token::SHL: | 4480 case Token::SHL: |
| 4481 case Token::SHR: { | 4481 case Token::SHR: { |
| 4482 FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx); | 4482 FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx); |
| 4483 FloatingPointHelper::LoadFloatOperands(masm, ecx); | 4483 FloatingPointHelper::LoadFloatOperands(masm, ecx); |
| 4484 | 4484 |
| 4485 Label non_int32_operands, non_smi_result, skip_allocation; | 4485 Label non_smi_result, skip_allocation, operands_too_large; |
| 4486 // Reserve space for converted numbers. | |
| 4487 __ sub(Operand(esp), Immediate(2 * kPointerSize)); | |
| 4488 | 4486 |
| 4489 // Check if right operand is int32. | 4487 // Make sure that the operands can be truncated into 64-bit |
| 4490 __ fist_s(Operand(esp, 1 * kPointerSize)); | 4488 // integers. Otherwise, the fistt instruction will signal an IA |
| 4491 __ fild_s(Operand(esp, 1 * kPointerSize)); | 4489 // exception which will cause us to overwrite the operand with |
| 4490 // zero. | |
| 4491 __ push(Immediate(0x7fffffff)); | |
| 4492 __ push(Immediate(-1)); | |
| 4493 __ fild_d(Operand(esp, 0)); | |
| 4494 __ add(Operand(esp), Immediate(2 * kPointerSize)); | |
| 4495 | |
| 4496 // Convert the operands to absolute values before comparing | |
| 4497 // against the limit. | |
| 4498 __ fld(2); | |
| 4499 __ fabs(); | |
| 4500 __ fld(2); | |
| 4501 __ fabs(); | |
| 4502 | |
| 4503 // Do the comparison. If the operands are too large we go | |
| 4504 // slow-case through the runtime system. | |
| 4505 __ fucomp(2); | |
| 4506 __ fnstsw_ax(); | |
| 4507 __ sahf(); | |
| 4508 __ j(above, &operands_too_large); | |
| 4492 __ fucompp(); | 4509 __ fucompp(); |
| 4493 __ fnstsw_ax(); | 4510 __ fnstsw_ax(); |
| 4494 __ sahf(); | 4511 __ sahf(); |
| 4495 __ j(not_zero, &non_int32_operands); | 4512 __ j(above, &operands_too_large); |
| 4496 __ j(parity_even, &non_int32_operands); | |
| 4497 | 4513 |
| 4498 // Check if left operand is int32. | 4514 // Reserve space for converted numbers. |
| 4499 __ fist_s(Operand(esp, 0 * kPointerSize)); | 4515 __ sub(Operand(esp), Immediate(4 * kPointerSize)); |
| 4500 __ fild_s(Operand(esp, 0 * kPointerSize)); | 4516 |
| 4501 __ fucompp(); | 4517 // Convert right operand to int32. |
| 4518 Label done_right; | |
| 4519 __ fnclex(); | |
| 4520 __ fisttp_d(Operand(esp, 2 * kPointerSize)); | |
|
Erik Corry
2009/02/20 16:40:41
This is an SSE3 instruction :-(. I guess we can s
| |
| 4502 __ fnstsw_ax(); | 4521 __ fnstsw_ax(); |
| 4503 __ sahf(); | 4522 __ test(eax, Immediate(1)); |
| 4504 __ j(not_zero, &non_int32_operands); | 4523 __ j(zero, &done_right); |
| 4505 __ j(parity_even, &non_int32_operands); | 4524 __ fnclex(); |
| 4525 __ mov(Operand(esp, 2 * kPointerSize), Immediate(0)); | |
| 4526 __ bind(&done_right); | |
| 4527 | |
| 4528 // Convert left operand to int32. | |
| 4529 Label done_left; | |
| 4530 __ fisttp_d(Operand(esp, 0 * kPointerSize)); | |
| 4531 __ fnstsw_ax(); | |
| 4532 __ test(eax, Immediate(1)); | |
| 4533 __ j(zero, &done_left); | |
| 4534 __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); | |
| 4535 __ bind(&done_left); | |
| 4506 | 4536 |
| 4507 // Get int32 operands and perform bitop. | 4537 // Get int32 operands and perform bitop. |
| 4508 __ pop(eax); | 4538 __ pop(eax); |
| 4539 __ add(Operand(esp), Immediate(kPointerSize)); | |
| 4509 __ pop(ecx); | 4540 __ pop(ecx); |
| 4541 __ add(Operand(esp), Immediate(kPointerSize)); | |
| 4510 switch (op_) { | 4542 switch (op_) { |
| 4511 case Token::BIT_OR: __ or_(eax, Operand(ecx)); break; | 4543 case Token::BIT_OR: __ or_(eax, Operand(ecx)); break; |
| 4512 case Token::BIT_AND: __ and_(eax, Operand(ecx)); break; | 4544 case Token::BIT_AND: __ and_(eax, Operand(ecx)); break; |
| 4513 case Token::BIT_XOR: __ xor_(eax, Operand(ecx)); break; | 4545 case Token::BIT_XOR: __ xor_(eax, Operand(ecx)); break; |
| 4514 case Token::SAR: __ sar(eax); break; | 4546 case Token::SAR: __ sar(eax); break; |
| 4515 case Token::SHL: __ shl(eax); break; | 4547 case Token::SHL: __ shl(eax); break; |
| 4516 case Token::SHR: __ shr(eax); break; | 4548 case Token::SHR: __ shr(eax); break; |
| 4517 default: UNREACHABLE(); | 4549 default: UNREACHABLE(); |
| 4518 } | 4550 } |
| 4519 | 4551 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 4547 __ bind(&skip_allocation); | 4579 __ bind(&skip_allocation); |
| 4548 break; | 4580 break; |
| 4549 default: UNREACHABLE(); | 4581 default: UNREACHABLE(); |
| 4550 } | 4582 } |
| 4551 // Store the result in the HeapNumber and return. | 4583 // Store the result in the HeapNumber and return. |
| 4552 __ mov(Operand(esp, 1 * kPointerSize), ebx); | 4584 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
| 4553 __ fild_s(Operand(esp, 1 * kPointerSize)); | 4585 __ fild_s(Operand(esp, 1 * kPointerSize)); |
| 4554 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 4586 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 4555 __ ret(2 * kPointerSize); | 4587 __ ret(2 * kPointerSize); |
| 4556 } | 4588 } |
| 4557 __ bind(&non_int32_operands); | 4589 |
| 4558 // Restore stacks and operands before calling runtime. | 4590 // Free ST(0) and ST(1) before calling runtime. |
| 4591 __ bind(&operands_too_large); | |
| 4559 __ ffree(0); | 4592 __ ffree(0); |
| 4560 __ add(Operand(esp), Immediate(2 * kPointerSize)); | 4593 __ ffree(1); |
| 4561 | 4594 |
| 4562 // SHR should return uint32 - go to runtime for non-smi/negative result. | 4595 // SHR should return uint32 - go to runtime for non-smi/negative result. |
| 4563 if (op_ == Token::SHR) __ bind(&non_smi_result); | 4596 if (op_ == Token::SHR) __ bind(&non_smi_result); |
| 4564 __ mov(eax, Operand(esp, 1 * kPointerSize)); | 4597 __ mov(eax, Operand(esp, 1 * kPointerSize)); |
| 4565 __ mov(edx, Operand(esp, 2 * kPointerSize)); | 4598 __ mov(edx, Operand(esp, 2 * kPointerSize)); |
| 4566 break; | 4599 break; |
| 4567 } | 4600 } |
| 4568 default: UNREACHABLE(); break; | 4601 default: UNREACHABLE(); break; |
| 4569 } | 4602 } |
| 4570 | 4603 |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5422 | 5455 |
| 5423 // Slow-case: Go through the JavaScript implementation. | 5456 // Slow-case: Go through the JavaScript implementation. |
| 5424 __ bind(&slow); | 5457 __ bind(&slow); |
| 5425 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 5458 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 5426 } | 5459 } |
| 5427 | 5460 |
| 5428 | 5461 |
| 5429 #undef __ | 5462 #undef __ |
| 5430 | 5463 |
| 5431 } } // namespace v8::internal | 5464 } } // namespace v8::internal |
| OLD | NEW |