Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: src/codegen-ia32.cc

Issue 21539: Simplify non-smi bit operation optimization. The explicit range... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_smi_result, skip_allocation, operands_too_large; 4485 Label non_smi_result, skip_allocation, operands_failed_conversion;
4486
4487 // Make sure that the operands can be truncated into 64-bit
4488 // integers. Otherwise, the fistt instruction will signal an IA
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);
4509 __ fucompp();
4510 __ fnstsw_ax();
4511 __ sahf();
4512 __ j(above, &operands_too_large);
4513 4486
4514 // Reserve space for converted numbers. 4487 // Reserve space for converted numbers.
4515 __ sub(Operand(esp), Immediate(4 * kPointerSize)); 4488 __ sub(Operand(esp), Immediate(4 * kPointerSize));
4516 4489
4517 // Convert right operand to int32. 4490 // Convert right operand to int32.
4518 Label done_right;
4519 __ fnclex(); 4491 __ fnclex();
4520 __ fisttp_d(Operand(esp, 2 * kPointerSize)); 4492 __ fisttp_d(Operand(esp, 2 * kPointerSize));
4521 __ fnstsw_ax(); 4493 __ fnstsw_ax();
4522 __ test(eax, Immediate(1)); 4494 __ test(eax, Immediate(1));
4523 __ j(zero, &done_right); 4495 __ j(not_zero, &operands_failed_conversion);
4524 __ fnclex();
4525 __ mov(Operand(esp, 2 * kPointerSize), Immediate(0));
4526 __ bind(&done_right);
4527 4496
4528 // Convert left operand to int32. 4497 // Convert left operand to int32.
4529 Label done_left;
4530 __ fisttp_d(Operand(esp, 0 * kPointerSize)); 4498 __ fisttp_d(Operand(esp, 0 * kPointerSize));
4531 __ fnstsw_ax(); 4499 __ fnstsw_ax();
4532 __ test(eax, Immediate(1)); 4500 __ test(eax, Immediate(1));
4533 __ j(zero, &done_left); 4501 __ j(not_zero, &operands_failed_conversion);
4534 __ mov(Operand(esp, 0 * kPointerSize), Immediate(0));
4535 __ bind(&done_left);
4536 4502
4537 // Get int32 operands and perform bitop. 4503 // Get int32 operands and perform bitop.
4538 __ pop(eax); 4504 __ pop(eax);
4539 __ add(Operand(esp), Immediate(kPointerSize)); 4505 __ add(Operand(esp), Immediate(kPointerSize));
4540 __ pop(ecx); 4506 __ pop(ecx);
4541 __ add(Operand(esp), Immediate(kPointerSize)); 4507 __ add(Operand(esp), Immediate(kPointerSize));
4542 switch (op_) { 4508 switch (op_) {
4543 case Token::BIT_OR: __ or_(eax, Operand(ecx)); break; 4509 case Token::BIT_OR: __ or_(eax, Operand(ecx)); break;
4544 case Token::BIT_AND: __ and_(eax, Operand(ecx)); break; 4510 case Token::BIT_AND: __ and_(eax, Operand(ecx)); break;
4545 case Token::BIT_XOR: __ xor_(eax, Operand(ecx)); break; 4511 case Token::BIT_XOR: __ xor_(eax, Operand(ecx)); break;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 break; 4546 break;
4581 default: UNREACHABLE(); 4547 default: UNREACHABLE();
4582 } 4548 }
4583 // Store the result in the HeapNumber and return. 4549 // Store the result in the HeapNumber and return.
4584 __ mov(Operand(esp, 1 * kPointerSize), ebx); 4550 __ mov(Operand(esp, 1 * kPointerSize), ebx);
4585 __ fild_s(Operand(esp, 1 * kPointerSize)); 4551 __ fild_s(Operand(esp, 1 * kPointerSize));
4586 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); 4552 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
4587 __ ret(2 * kPointerSize); 4553 __ ret(2 * kPointerSize);
4588 } 4554 }
4589 4555
4590 // Free ST(0) and ST(1) before calling runtime. 4556 // Free ST(0) before calling runtime.
4591 __ bind(&operands_too_large); 4557 __ bind(&operands_failed_conversion);
4558 __ add(Operand(esp), Immediate(4 * kPointerSize));
4592 __ ffree(0); 4559 __ ffree(0);
4593 __ ffree(1);
4594 4560
4595 // SHR should return uint32 - go to runtime for non-smi/negative result. 4561 // SHR should return uint32 - go to runtime for non-smi/negative result.
4596 if (op_ == Token::SHR) __ bind(&non_smi_result); 4562 if (op_ == Token::SHR) __ bind(&non_smi_result);
4597 __ mov(eax, Operand(esp, 1 * kPointerSize)); 4563 __ mov(eax, Operand(esp, 1 * kPointerSize));
4598 __ mov(edx, Operand(esp, 2 * kPointerSize)); 4564 __ mov(edx, Operand(esp, 2 * kPointerSize));
4599 break; 4565 break;
4600 } 4566 }
4601 default: UNREACHABLE(); break; 4567 default: UNREACHABLE(); break;
4602 } 4568 }
4603 4569
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
5455 5421
5456 // Slow-case: Go through the JavaScript implementation. 5422 // Slow-case: Go through the JavaScript implementation.
5457 __ bind(&slow); 5423 __ bind(&slow);
5458 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 5424 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
5459 } 5425 }
5460 5426
5461 5427
5462 #undef __ 5428 #undef __
5463 5429
5464 } } // namespace v8::internal 5430 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698