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

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

Issue 153773002: A64: Synchronize with r16679. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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 | « src/x64/lithium-codegen-x64.h ('k') | src/x64/macro-assembler-x64.h » ('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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 frame_is_built_ = true; 366 frame_is_built_ = true;
367 // Build the frame in such a way that esi isn't trashed. 367 // Build the frame in such a way that esi isn't trashed.
368 __ push(rbp); // Caller's frame pointer. 368 __ push(rbp); // Caller's frame pointer.
369 __ push(Operand(rbp, StandardFrameConstants::kContextOffset)); 369 __ push(Operand(rbp, StandardFrameConstants::kContextOffset));
370 __ Push(Smi::FromInt(StackFrame::STUB)); 370 __ Push(Smi::FromInt(StackFrame::STUB));
371 __ lea(rbp, Operand(rsp, 2 * kPointerSize)); 371 __ lea(rbp, Operand(rsp, 2 * kPointerSize));
372 Comment(";;; Deferred code"); 372 Comment(";;; Deferred code");
373 } 373 }
374 code->Generate(); 374 code->Generate();
375 if (NeedsDeferredFrame()) { 375 if (NeedsDeferredFrame()) {
376 __ bind(code->done());
376 Comment(";;; Destroy frame"); 377 Comment(";;; Destroy frame");
377 ASSERT(frame_is_built_); 378 ASSERT(frame_is_built_);
378 frame_is_built_ = false; 379 frame_is_built_ = false;
379 __ movq(rsp, rbp); 380 __ movq(rsp, rbp);
380 __ pop(rbp); 381 __ pop(rbp);
381 } 382 }
382 __ jmp(code->exit()); 383 __ jmp(code->exit());
383 } 384 }
384 } 385 }
385 386
(...skipping 4305 matching lines...) Expand 10 before | Expand all | Expand 10 after
4691 } 4692 }
4692 4693
4693 // Smi to XMM conversion 4694 // Smi to XMM conversion
4694 __ bind(&load_smi); 4695 __ bind(&load_smi);
4695 __ SmiToInteger32(kScratchRegister, input_reg); 4696 __ SmiToInteger32(kScratchRegister, input_reg);
4696 __ cvtlsi2sd(result_reg, kScratchRegister); 4697 __ cvtlsi2sd(result_reg, kScratchRegister);
4697 __ bind(&done); 4698 __ bind(&done);
4698 } 4699 }
4699 4700
4700 4701
4701 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { 4702 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) {
4702 Label done, heap_number; 4703 Label heap_number;
4703 Register input_reg = ToRegister(instr->value()); 4704 Register input_reg = ToRegister(instr->value());
4704 4705
4705 // Heap number map check.
4706 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
4707 Heap::kHeapNumberMapRootIndex);
4708 4706
4709 if (instr->truncating()) { 4707 if (instr->truncating()) {
4708 // Heap number map check.
4709 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
4710 Heap::kHeapNumberMapRootIndex);
4710 __ j(equal, &heap_number, Label::kNear); 4711 __ j(equal, &heap_number, Label::kNear);
4711 // Check for undefined. Undefined is converted to zero for truncating 4712 // Check for undefined. Undefined is converted to zero for truncating
4712 // conversions. 4713 // conversions.
4713 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); 4714 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
4714 DeoptimizeIf(not_equal, instr->environment()); 4715 DeoptimizeIf(not_equal, instr->environment());
4715 __ Set(input_reg, 0); 4716 __ Set(input_reg, 0);
4716 __ jmp(&done, Label::kNear); 4717 __ jmp(done);
4717 4718
4718 __ bind(&heap_number); 4719 __ bind(&heap_number);
4720 __ TruncateHeapNumberToI(input_reg, input_reg);
4721 } else {
4722 Label bailout;
4723 XMMRegister xmm_temp = ToDoubleRegister(instr->temp());
4724 __ TaggedToI(input_reg, input_reg, xmm_temp,
4725 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
4719 4726
4720 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); 4727 __ jmp(done);
4721 __ cvttsd2siq(input_reg, xmm0); 4728 __ bind(&bailout);
4722 __ Set(kScratchRegister, V8_UINT64_C(0x8000000000000000)); 4729 DeoptimizeIf(no_condition, instr->environment());
4723 __ cmpq(input_reg, kScratchRegister);
4724 DeoptimizeIf(equal, instr->environment());
4725 } else {
4726 // Deoptimize if we don't have a heap number.
4727 DeoptimizeIf(not_equal, instr->environment());
4728
4729 XMMRegister xmm_temp = ToDoubleRegister(instr->temp());
4730 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
4731 __ cvttsd2si(input_reg, xmm0);
4732 __ cvtlsi2sd(xmm_temp, input_reg);
4733 __ ucomisd(xmm0, xmm_temp);
4734 DeoptimizeIf(not_equal, instr->environment());
4735 DeoptimizeIf(parity_even, instr->environment()); // NaN.
4736 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
4737 __ testl(input_reg, input_reg);
4738 __ j(not_zero, &done);
4739 __ movmskpd(input_reg, xmm0);
4740 __ andl(input_reg, Immediate(1));
4741 DeoptimizeIf(not_zero, instr->environment());
4742 }
4743 } 4730 }
4744 __ bind(&done);
4745 } 4731 }
4746 4732
4747 4733
4748 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { 4734 void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
4749 class DeferredTaggedToI V8_FINAL : public LDeferredCode { 4735 class DeferredTaggedToI V8_FINAL : public LDeferredCode {
4750 public: 4736 public:
4751 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) 4737 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr)
4752 : LDeferredCode(codegen), instr_(instr) { } 4738 : LDeferredCode(codegen), instr_(instr) { }
4753 virtual void Generate() V8_OVERRIDE { 4739 virtual void Generate() V8_OVERRIDE {
4754 codegen()->DoDeferredTaggedToI(instr_); 4740 codegen()->DoDeferredTaggedToI(instr_, done());
4755 } 4741 }
4756 virtual LInstruction* instr() V8_OVERRIDE { return instr_; } 4742 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4757 private: 4743 private:
4758 LTaggedToI* instr_; 4744 LTaggedToI* instr_;
4759 }; 4745 };
4760 4746
4761 LOperand* input = instr->value(); 4747 LOperand* input = instr->value();
4762 ASSERT(input->IsRegister()); 4748 ASSERT(input->IsRegister());
4763 ASSERT(input->Equals(instr->result())); 4749 ASSERT(input->Equals(instr->result()));
4764 4750
(...skipping 29 matching lines...) Expand all
4794 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { 4780 void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
4795 LOperand* input = instr->value(); 4781 LOperand* input = instr->value();
4796 ASSERT(input->IsDoubleRegister()); 4782 ASSERT(input->IsDoubleRegister());
4797 LOperand* result = instr->result(); 4783 LOperand* result = instr->result();
4798 ASSERT(result->IsRegister()); 4784 ASSERT(result->IsRegister());
4799 4785
4800 XMMRegister input_reg = ToDoubleRegister(input); 4786 XMMRegister input_reg = ToDoubleRegister(input);
4801 Register result_reg = ToRegister(result); 4787 Register result_reg = ToRegister(result);
4802 4788
4803 if (instr->truncating()) { 4789 if (instr->truncating()) {
4804 // Performs a truncating conversion of a floating point number as used by 4790 __ TruncateDoubleToI(result_reg, input_reg);
4805 // the JS bitwise operations.
4806 __ cvttsd2siq(result_reg, input_reg);
4807 __ movq(kScratchRegister,
4808 V8_INT64_C(0x8000000000000000),
4809 RelocInfo::NONE64);
4810 __ cmpq(result_reg, kScratchRegister);
4811 DeoptimizeIf(equal, instr->environment());
4812 } else { 4791 } else {
4813 __ cvttsd2si(result_reg, input_reg); 4792 Label bailout, done;
4814 __ cvtlsi2sd(xmm0, result_reg); 4793 __ DoubleToI(result_reg, input_reg, xmm0,
4815 __ ucomisd(xmm0, input_reg); 4794 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
4816 DeoptimizeIf(not_equal, instr->environment()); 4795
4817 DeoptimizeIf(parity_even, instr->environment()); // NaN. 4796 __ jmp(&done, Label::kNear);
4818 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 4797 __ bind(&bailout);
4819 Label done; 4798 DeoptimizeIf(no_condition, instr->environment());
4820 // The integer converted back is equal to the original. We 4799 __ bind(&done);
4821 // only have to test if we got -0 as an input.
4822 __ testl(result_reg, result_reg);
4823 __ j(not_zero, &done, Label::kNear);
4824 __ movmskpd(result_reg, input_reg);
4825 // Bit 0 contains the sign of the double in input_reg.
4826 // If input was positive, we are ok and return 0, otherwise
4827 // deoptimize.
4828 __ andl(result_reg, Immediate(1));
4829 DeoptimizeIf(not_zero, instr->environment());
4830 __ bind(&done);
4831 }
4832 } 4800 }
4833 } 4801 }
4834 4802
4835 4803
4836 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { 4804 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
4837 LOperand* input = instr->value(); 4805 LOperand* input = instr->value();
4838 ASSERT(input->IsDoubleRegister()); 4806 ASSERT(input->IsDoubleRegister());
4839 LOperand* result = instr->result(); 4807 LOperand* result = instr->result();
4840 ASSERT(result->IsRegister()); 4808 ASSERT(result->IsRegister());
4841 CpuFeatureScope scope(masm(), SSE2);
4842 4809
4843 XMMRegister input_reg = ToDoubleRegister(input); 4810 XMMRegister input_reg = ToDoubleRegister(input);
4844 Register result_reg = ToRegister(result); 4811 Register result_reg = ToRegister(result);
4845 4812
4846 Label done; 4813 Label bailout, done;
4847 __ cvttsd2si(result_reg, input_reg); 4814 __ DoubleToI(result_reg, input_reg, xmm0,
4848 __ cvtlsi2sd(xmm0, result_reg); 4815 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
4849 __ ucomisd(xmm0, input_reg);
4850 DeoptimizeIf(not_equal, instr->environment());
4851 DeoptimizeIf(parity_even, instr->environment()); // NaN.
4852 4816
4853 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 4817 __ jmp(&done, Label::kNear);
4854 // The integer converted back is equal to the original. We 4818 __ bind(&bailout);
4855 // only have to test if we got -0 as an input. 4819 DeoptimizeIf(no_condition, instr->environment());
4856 __ testl(result_reg, result_reg); 4820 __ bind(&done);
4857 __ j(not_zero, &done, Label::kNear); 4821
4858 __ movmskpd(result_reg, input_reg);
4859 // Bit 0 contains the sign of the double in input_reg.
4860 // If input was positive, we are ok and return 0, otherwise
4861 // deoptimize.
4862 __ andl(result_reg, Immediate(1));
4863 DeoptimizeIf(not_zero, instr->environment());
4864 __ bind(&done);
4865 }
4866 __ Integer32ToSmi(result_reg, result_reg); 4822 __ Integer32ToSmi(result_reg, result_reg);
4867 DeoptimizeIf(overflow, instr->environment()); 4823 DeoptimizeIf(overflow, instr->environment());
4868 } 4824 }
4869 4825
4870 4826
4871 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { 4827 void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
4872 LOperand* input = instr->value(); 4828 LOperand* input = instr->value();
4873 Condition cc = masm()->CheckSmi(ToRegister(input)); 4829 Condition cc = masm()->CheckSmi(ToRegister(input));
4874 DeoptimizeIf(NegateCondition(cc), instr->environment()); 4830 DeoptimizeIf(NegateCondition(cc), instr->environment());
4875 } 4831 }
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5563 FixedArray::kHeaderSize - kPointerSize)); 5519 FixedArray::kHeaderSize - kPointerSize));
5564 __ bind(&done); 5520 __ bind(&done);
5565 } 5521 }
5566 5522
5567 5523
5568 #undef __ 5524 #undef __
5569 5525
5570 } } // namespace v8::internal 5526 } } // namespace v8::internal
5571 5527
5572 #endif // V8_TARGET_ARCH_X64 5528 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698