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

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

Issue 16099006: Fix the hole loading optimization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | « src/lithium.h ('k') | test/mjsunit/regress/regress-convert-hole.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 4645 matching lines...) Expand 10 before | Expand all | Expand 10 after
4656 4656
4657 4657
4658 void LCodeGen::EmitNumberUntagD(Register input_reg, 4658 void LCodeGen::EmitNumberUntagD(Register input_reg,
4659 XMMRegister result_reg, 4659 XMMRegister result_reg,
4660 bool deoptimize_on_undefined, 4660 bool deoptimize_on_undefined,
4661 bool deoptimize_on_minus_zero, 4661 bool deoptimize_on_minus_zero,
4662 LEnvironment* env, 4662 LEnvironment* env,
4663 NumberUntagDMode mode) { 4663 NumberUntagDMode mode) {
4664 Label load_smi, done; 4664 Label load_smi, done;
4665 4665
4666 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { 4666 STATIC_ASSERT(NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE >
4667 NUMBER_CANDIDATE_IS_ANY_TAGGED);
4668 if (mode >= NUMBER_CANDIDATE_IS_ANY_TAGGED) {
4667 // Smi check. 4669 // Smi check.
4668 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); 4670 __ JumpIfSmi(input_reg, &load_smi, Label::kNear);
4669 4671
4670 // Heap number map check. 4672 // Heap number map check.
4671 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), 4673 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
4672 Heap::kHeapNumberMapRootIndex); 4674 Heap::kHeapNumberMapRootIndex);
4673 if (deoptimize_on_undefined) { 4675 if (deoptimize_on_undefined) {
4674 DeoptimizeIf(not_equal, env); 4676 DeoptimizeIf(not_equal, env);
4675 } else { 4677 } else {
4676 Label heap_number; 4678 Label heap_number, convert;
4677 __ j(equal, &heap_number, Label::kNear); 4679 __ j(equal, &heap_number, Label::kNear);
4678 4680
4681 // Convert undefined (and hole) to NaN. Compute NaN as 0/0.
4679 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); 4682 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
4683 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE) {
4684 __ j(equal, &convert, Label::kNear);
4685 __ CompareRoot(input_reg, Heap::kTheHoleValueRootIndex);
4686 }
4680 DeoptimizeIf(not_equal, env); 4687 DeoptimizeIf(not_equal, env);
4681 4688
4682 // Convert undefined to NaN. Compute NaN as 0/0. 4689 __ bind(&convert);
4683 __ xorps(result_reg, result_reg); 4690 __ xorps(result_reg, result_reg);
4684 __ divsd(result_reg, result_reg); 4691 __ divsd(result_reg, result_reg);
4685 __ jmp(&done, Label::kNear); 4692 __ jmp(&done, Label::kNear);
4686 4693
4687 __ bind(&heap_number); 4694 __ bind(&heap_number);
4688 } 4695 }
4689 // Heap number to XMM conversion. 4696 // Heap number to XMM conversion.
4690 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); 4697 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
4691 if (deoptimize_on_minus_zero) { 4698 if (deoptimize_on_minus_zero) {
4692 XMMRegister xmm_scratch = xmm0; 4699 XMMRegister xmm_scratch = xmm0;
4693 __ xorps(xmm_scratch, xmm_scratch); 4700 __ xorps(xmm_scratch, xmm_scratch);
4694 __ ucomisd(xmm_scratch, result_reg); 4701 __ ucomisd(xmm_scratch, result_reg);
4695 __ j(not_equal, &done, Label::kNear); 4702 __ j(not_equal, &done, Label::kNear);
4696 __ movmskpd(kScratchRegister, result_reg); 4703 __ movmskpd(kScratchRegister, result_reg);
4697 __ testq(kScratchRegister, Immediate(1)); 4704 __ testq(kScratchRegister, Immediate(1));
4698 DeoptimizeIf(not_zero, env); 4705 DeoptimizeIf(not_zero, env);
4699 } 4706 }
4700 __ jmp(&done, Label::kNear); 4707 __ jmp(&done, Label::kNear);
4701 } else if (mode == NUMBER_CANDIDATE_IS_SMI_OR_HOLE) {
4702 __ testq(input_reg, Immediate(kSmiTagMask));
4703 DeoptimizeIf(not_equal, env);
4704 } else if (mode == NUMBER_CANDIDATE_IS_SMI_CONVERT_HOLE) {
4705 __ testq(input_reg, Immediate(kSmiTagMask));
4706 __ j(zero, &load_smi);
4707 __ Set(kScratchRegister, BitCast<uint64_t>(
4708 FixedDoubleArray::hole_nan_as_double()));
4709 __ movq(result_reg, kScratchRegister);
4710 __ jmp(&done, Label::kNear);
4711 } else { 4708 } else {
4712 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); 4709 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI);
4713 } 4710 }
4714 4711
4715 // Smi to XMM conversion 4712 // Smi to XMM conversion
4716 __ bind(&load_smi); 4713 __ bind(&load_smi);
4717 __ SmiToInteger32(kScratchRegister, input_reg); 4714 __ SmiToInteger32(kScratchRegister, input_reg);
4718 __ cvtlsi2sd(result_reg, kScratchRegister); 4715 __ cvtlsi2sd(result_reg, kScratchRegister);
4719 __ bind(&done); 4716 __ bind(&done);
4720 } 4717 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4795 ASSERT(input->IsRegister()); 4792 ASSERT(input->IsRegister());
4796 LOperand* result = instr->result(); 4793 LOperand* result = instr->result();
4797 ASSERT(result->IsDoubleRegister()); 4794 ASSERT(result->IsDoubleRegister());
4798 4795
4799 Register input_reg = ToRegister(input); 4796 Register input_reg = ToRegister(input);
4800 XMMRegister result_reg = ToDoubleRegister(result); 4797 XMMRegister result_reg = ToDoubleRegister(result);
4801 4798
4802 NumberUntagDMode mode = NUMBER_CANDIDATE_IS_ANY_TAGGED; 4799 NumberUntagDMode mode = NUMBER_CANDIDATE_IS_ANY_TAGGED;
4803 HValue* value = instr->hydrogen()->value(); 4800 HValue* value = instr->hydrogen()->value();
4804 if (value->type().IsSmi()) { 4801 if (value->type().IsSmi()) {
4805 if (value->IsLoadKeyed()) { 4802 mode = NUMBER_CANDIDATE_IS_SMI;
4806 HLoadKeyed* load = HLoadKeyed::cast(value); 4803 } else if (value->IsLoadKeyed()) {
4807 if (load->UsesMustHandleHole()) { 4804 HLoadKeyed* load = HLoadKeyed::cast(value);
4808 if (load->hole_mode() == ALLOW_RETURN_HOLE) { 4805 if (load->UsesMustHandleHole()) {
4809 mode = NUMBER_CANDIDATE_IS_SMI_CONVERT_HOLE; 4806 mode = NUMBER_CANDIDATE_IS_ANY_TAGGED_CONVERT_HOLE;
4810 } else {
4811 mode = NUMBER_CANDIDATE_IS_SMI_OR_HOLE;
4812 }
4813 } else {
4814 mode = NUMBER_CANDIDATE_IS_SMI;
4815 }
4816 } else {
4817 mode = NUMBER_CANDIDATE_IS_SMI;
4818 } 4807 }
4819 } 4808 }
4820 4809
4821 EmitNumberUntagD(input_reg, result_reg, 4810 EmitNumberUntagD(input_reg, result_reg,
4822 instr->hydrogen()->deoptimize_on_undefined(), 4811 instr->hydrogen()->deoptimize_on_undefined(),
4823 instr->hydrogen()->deoptimize_on_minus_zero(), 4812 instr->hydrogen()->deoptimize_on_minus_zero(),
4824 instr->environment(), 4813 instr->environment(),
4825 mode); 4814 mode);
4826 } 4815 }
4827 4816
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
5673 FixedArray::kHeaderSize - kPointerSize)); 5662 FixedArray::kHeaderSize - kPointerSize));
5674 __ bind(&done); 5663 __ bind(&done);
5675 } 5664 }
5676 5665
5677 5666
5678 #undef __ 5667 #undef __
5679 5668
5680 } } // namespace v8::internal 5669 } } // namespace v8::internal
5681 5670
5682 #endif // V8_TARGET_ARCH_X64 5671 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/lithium.h ('k') | test/mjsunit/regress/regress-convert-hole.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698