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

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

Issue 9147034: Inlining Math.min and Math.max in crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: bugfix (register allocation). Created 8 years, 11 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
OLDNEW
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 3658 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 ASSERT(input->IsRegister() && input->Equals(instr->result())); 3669 ASSERT(input->IsRegister() && input->Equals(instr->result()));
3670 if (instr->needs_check()) { 3670 if (instr->needs_check()) {
3671 __ test(ToRegister(input), Immediate(kSmiTagMask)); 3671 __ test(ToRegister(input), Immediate(kSmiTagMask));
3672 DeoptimizeIf(not_zero, instr->environment()); 3672 DeoptimizeIf(not_zero, instr->environment());
3673 } 3673 }
3674 __ SmiUntag(ToRegister(input)); 3674 __ SmiUntag(ToRegister(input));
3675 } 3675 }
3676 3676
3677 3677
3678 void LCodeGen::EmitNumberUntagD(Register input_reg, 3678 void LCodeGen::EmitNumberUntagD(Register input_reg,
3679 Register temp_reg,
3679 XMMRegister result_reg, 3680 XMMRegister result_reg,
3680 bool deoptimize_on_undefined, 3681 bool deoptimize_on_undefined,
3682 bool deoptimize_on_minus_zero,
3681 LEnvironment* env) { 3683 LEnvironment* env) {
3682 Label load_smi, done; 3684 Label load_smi, done;
3683 3685
3684 // Smi check. 3686 // Smi check.
3685 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); 3687 __ JumpIfSmi(input_reg, &load_smi, Label::kNear);
3686 3688
3687 // Heap number map check. 3689 // Heap number map check.
3688 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), 3690 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
3689 factory()->heap_number_map()); 3691 factory()->heap_number_map());
3690 if (deoptimize_on_undefined) { 3692 if (deoptimize_on_undefined) {
3691 DeoptimizeIf(not_equal, env); 3693 DeoptimizeIf(not_equal, env);
3692 } else { 3694 } else {
3693 Label heap_number; 3695 Label heap_number;
3694 __ j(equal, &heap_number, Label::kNear); 3696 __ j(equal, &heap_number, Label::kNear);
3695 3697
3696 __ cmp(input_reg, factory()->undefined_value()); 3698 __ cmp(input_reg, factory()->undefined_value());
3697 DeoptimizeIf(not_equal, env); 3699 DeoptimizeIf(not_equal, env);
3698 3700
3699 // Convert undefined to NaN. 3701 // Convert undefined to NaN.
3700 ExternalReference nan = 3702 ExternalReference nan =
3701 ExternalReference::address_of_canonical_non_hole_nan(); 3703 ExternalReference::address_of_canonical_non_hole_nan();
3702 __ movdbl(result_reg, Operand::StaticVariable(nan)); 3704 __ movdbl(result_reg, Operand::StaticVariable(nan));
3703 __ jmp(&done, Label::kNear); 3705 __ jmp(&done, Label::kNear);
3704 3706
3705 __ bind(&heap_number); 3707 __ bind(&heap_number);
3706 } 3708 }
3707 // Heap number to XMM conversion. 3709 // Heap number to XMM conversion.
3708 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); 3710 __ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
3711 if (deoptimize_on_minus_zero) {
3712 XMMRegister xmm_scratch = xmm0;
3713 __ xorps(xmm_scratch, xmm_scratch);
3714 __ ucomisd(result_reg, xmm_scratch);
3715 __ j(not_zero, &done, Label::kNear);
3716 __ movmskpd(temp_reg, result_reg);
3717 __ test_b(temp_reg, 1);
3718 DeoptimizeIf(not_zero, env);
3719 }
3709 __ jmp(&done, Label::kNear); 3720 __ jmp(&done, Label::kNear);
3710 3721
3711 // Smi to XMM conversion 3722 // Smi to XMM conversion
3712 __ bind(&load_smi); 3723 __ bind(&load_smi);
3713 __ SmiUntag(input_reg); // Untag smi before converting to float. 3724 __ SmiUntag(input_reg); // Untag smi before converting to float.
3714 __ cvtsi2sd(result_reg, Operand(input_reg)); 3725 __ cvtsi2sd(result_reg, Operand(input_reg));
3715 __ SmiTag(input_reg); // Retag smi. 3726 __ SmiTag(input_reg); // Retag smi.
3716 __ bind(&done); 3727 __ bind(&done);
3717 } 3728 }
3718 3729
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 // Smi to int32 conversion 3832 // Smi to int32 conversion
3822 __ SmiUntag(input_reg); // Untag smi. 3833 __ SmiUntag(input_reg); // Untag smi.
3823 3834
3824 __ bind(deferred->exit()); 3835 __ bind(deferred->exit());
3825 } 3836 }
3826 3837
3827 3838
3828 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { 3839 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) {
3829 LOperand* input = instr->InputAt(0); 3840 LOperand* input = instr->InputAt(0);
3830 ASSERT(input->IsRegister()); 3841 ASSERT(input->IsRegister());
3842 LOperand* temp = instr->TempAt(0);
3843 ASSERT(temp == NULL || temp->IsRegister());
3831 LOperand* result = instr->result(); 3844 LOperand* result = instr->result();
3832 ASSERT(result->IsDoubleRegister()); 3845 ASSERT(result->IsDoubleRegister());
3833 3846
3834 Register input_reg = ToRegister(input); 3847 Register input_reg = ToRegister(input);
3835 XMMRegister result_reg = ToDoubleRegister(result); 3848 XMMRegister result_reg = ToDoubleRegister(result);
3836 3849
3837 EmitNumberUntagD(input_reg, result_reg, 3850 bool deoptmize_on_minus_zero =
fschneider 2012/01/11 10:29:32 s/deoptmize/deoptimize/g
3851 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero);
3852 Register temp_reg = deoptmize_on_minus_zero ? ToRegister(temp) : no_reg;
3853
3854 EmitNumberUntagD(input_reg,
3855 temp_reg,
3856 result_reg,
3838 instr->hydrogen()->deoptimize_on_undefined(), 3857 instr->hydrogen()->deoptimize_on_undefined(),
3858 deoptmize_on_minus_zero,
3839 instr->environment()); 3859 instr->environment());
3840 } 3860 }
3841 3861
3842 3862
3843 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { 3863 void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
3844 LOperand* input = instr->InputAt(0); 3864 LOperand* input = instr->InputAt(0);
3845 ASSERT(input->IsDoubleRegister()); 3865 ASSERT(input->IsDoubleRegister());
3846 LOperand* result = instr->result(); 3866 LOperand* result = instr->result();
3847 ASSERT(result->IsRegister()); 3867 ASSERT(result->IsRegister());
3848 3868
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 this, pointers, Safepoint::kLazyDeopt); 4639 this, pointers, Safepoint::kLazyDeopt);
4620 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4640 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4621 } 4641 }
4622 4642
4623 4643
4624 #undef __ 4644 #undef __
4625 4645
4626 } } // namespace v8::internal 4646 } } // namespace v8::internal
4627 4647
4628 #endif // V8_TARGET_ARCH_IA32 4648 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/hydrogen.cc ('K') | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698