OLD | NEW |
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 4667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4678 __ SmiUntag(result, input); | 4678 __ SmiUntag(result, input); |
4679 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); | 4679 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg)); |
4680 } else { | 4680 } else { |
4681 __ SmiUntag(result, input); | 4681 __ SmiUntag(result, input); |
4682 } | 4682 } |
4683 } | 4683 } |
4684 | 4684 |
4685 | 4685 |
4686 void LCodeGen::EmitNumberUntagD(Register input_reg, | 4686 void LCodeGen::EmitNumberUntagD(Register input_reg, |
4687 DoubleRegister result_reg, | 4687 DoubleRegister result_reg, |
4688 bool deoptimize_on_undefined, | 4688 bool allow_undefined_as_nan, |
4689 bool deoptimize_on_minus_zero, | 4689 bool deoptimize_on_minus_zero, |
4690 LEnvironment* env, | 4690 LEnvironment* env, |
4691 NumberUntagDMode mode) { | 4691 NumberUntagDMode mode) { |
4692 Register scratch = scratch0(); | 4692 Register scratch = scratch0(); |
4693 | 4693 |
4694 Label load_smi, heap_number, done; | 4694 Label load_smi, heap_number, done; |
4695 | 4695 |
4696 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE > | 4696 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE > |
4697 NUMBER_CANDIDATE_IS_ANY_TAGGED); | 4697 NUMBER_CANDIDATE_IS_ANY_TAGGED); |
4698 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) { | 4698 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
4699 // Smi check. | 4699 // Smi check. |
4700 __ UntagAndJumpIfSmi(scratch, input_reg, &load_smi); | 4700 __ UntagAndJumpIfSmi(scratch, input_reg, &load_smi); |
4701 | 4701 |
4702 // Heap number map check. | 4702 // Heap number map check. |
4703 __ lw(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 4703 __ lw(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); |
4704 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | 4704 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
4705 if (deoptimize_on_undefined) { | 4705 if (!allow_undefined_as_nan) { |
4706 DeoptimizeIf(ne, env, scratch, Operand(at)); | 4706 DeoptimizeIf(ne, env, scratch, Operand(at)); |
4707 } else { | 4707 } else { |
4708 Label heap_number, convert; | 4708 Label heap_number, convert; |
4709 __ Branch(&heap_number, eq, scratch, Operand(at)); | 4709 __ Branch(&heap_number, eq, scratch, Operand(at)); |
4710 | 4710 |
4711 // Convert undefined (and hole) to NaN. | 4711 // Convert undefined (and hole) to NaN. |
4712 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 4712 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
4713 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) { | 4713 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) { |
4714 __ Branch(&convert, eq, input_reg, Operand(at)); | 4714 __ Branch(&convert, eq, input_reg, Operand(at)); |
4715 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 4715 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4868 } else if (value->IsLoadKeyed()) { | 4868 } else if (value->IsLoadKeyed()) { |
4869 HLoadKeyed* load = HLoadKeyed::cast(value); | 4869 HLoadKeyed* load = HLoadKeyed::cast(value); |
4870 if (load->UsesMustHandleHole()) { | 4870 if (load->UsesMustHandleHole()) { |
4871 if (load->hole_mode() == ALLOW_RETURN_HOLE) { | 4871 if (load->hole_mode() == ALLOW_RETURN_HOLE) { |
4872 mode = NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE; | 4872 mode = NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE; |
4873 } | 4873 } |
4874 } | 4874 } |
4875 } | 4875 } |
4876 | 4876 |
4877 EmitNumberUntagD(input_reg, result_reg, | 4877 EmitNumberUntagD(input_reg, result_reg, |
4878 instr->hydrogen()->deoptimize_on_undefined(), | 4878 instr->hydrogen()->allow_undefined_as_nan(), |
4879 instr->hydrogen()->deoptimize_on_minus_zero(), | 4879 instr->hydrogen()->deoptimize_on_minus_zero(), |
4880 instr->environment(), | 4880 instr->environment(), |
4881 mode); | 4881 mode); |
4882 } | 4882 } |
4883 | 4883 |
4884 | 4884 |
4885 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 4885 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
4886 Register result_reg = ToRegister(instr->result()); | 4886 Register result_reg = ToRegister(instr->result()); |
4887 Register scratch1 = scratch0(); | 4887 Register scratch1 = scratch0(); |
4888 Register scratch2 = ToRegister(instr->temp()); | 4888 Register scratch2 = ToRegister(instr->temp()); |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5768 __ Subu(scratch, result, scratch); | 5768 __ Subu(scratch, result, scratch); |
5769 __ lw(result, FieldMemOperand(scratch, | 5769 __ lw(result, FieldMemOperand(scratch, |
5770 FixedArray::kHeaderSize - kPointerSize)); | 5770 FixedArray::kHeaderSize - kPointerSize)); |
5771 __ bind(&done); | 5771 __ bind(&done); |
5772 } | 5772 } |
5773 | 5773 |
5774 | 5774 |
5775 #undef __ | 5775 #undef __ |
5776 | 5776 |
5777 } } // namespace v8::internal | 5777 } } // namespace v8::internal |
OLD | NEW |