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 4856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4867 Register input_reg = ToRegister(input); | 4867 Register input_reg = ToRegister(input); |
4868 __ push(input_reg); | 4868 __ push(input_reg); |
4869 X87Mov(ToX87Register(output), Operand(esp, 0), kX87IntOperand); | 4869 X87Mov(ToX87Register(output), Operand(esp, 0), kX87IntOperand); |
4870 __ pop(input_reg); | 4870 __ pop(input_reg); |
4871 } else { | 4871 } else { |
4872 X87Mov(ToX87Register(output), ToOperand(input), kX87IntOperand); | 4872 X87Mov(ToX87Register(output), ToOperand(input), kX87IntOperand); |
4873 } | 4873 } |
4874 } | 4874 } |
4875 | 4875 |
4876 | 4876 |
4877 void LCodeGen::DoInteger32ToSmi(LInteger32ToSmi* instr) { | |
4878 Register input = ToRegister(instr->value()); | |
4879 __ SmiTag(input); | |
4880 if (!instr->hydrogen()->value()->HasRange() || | |
4881 !instr->hydrogen()->value()->range()->IsInSmiRange()) { | |
4882 DeoptimizeIf(overflow, instr->environment()); | |
4883 } | |
4884 } | |
4885 | |
4886 | |
4887 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { | 4877 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { |
4888 LOperand* input = instr->value(); | 4878 LOperand* input = instr->value(); |
4889 LOperand* output = instr->result(); | 4879 LOperand* output = instr->result(); |
4890 if (CpuFeatures::IsSupported(SSE2)) { | 4880 if (CpuFeatures::IsSupported(SSE2)) { |
4891 CpuFeatureScope scope(masm(), SSE2); | 4881 CpuFeatureScope scope(masm(), SSE2); |
4892 LOperand* temp = instr->temp(); | 4882 LOperand* temp = instr->temp(); |
4893 | 4883 |
4894 __ LoadUint32(ToDoubleRegister(output), | 4884 __ LoadUint32(ToDoubleRegister(output), |
4895 ToRegister(input), | 4885 ToRegister(input), |
4896 ToDoubleRegister(temp)); | 4886 ToDoubleRegister(temp)); |
4897 } else { | 4887 } else { |
4898 X87Register res = ToX87Register(output); | 4888 X87Register res = ToX87Register(output); |
4899 X87PrepareToWrite(res); | 4889 X87PrepareToWrite(res); |
4900 __ LoadUint32NoSSE2(ToRegister(input)); | 4890 __ LoadUint32NoSSE2(ToRegister(input)); |
4901 X87CommitWrite(res); | 4891 X87CommitWrite(res); |
4902 } | 4892 } |
4903 } | 4893 } |
4904 | 4894 |
4905 | 4895 |
4906 void LCodeGen::DoUint32ToSmi(LUint32ToSmi* instr) { | |
4907 Register input = ToRegister(instr->value()); | |
4908 if (!instr->hydrogen()->value()->HasRange() || | |
4909 !instr->hydrogen()->value()->range()->IsInSmiRange()) { | |
4910 __ test(input, Immediate(0xc0000000)); | |
4911 DeoptimizeIf(not_zero, instr->environment()); | |
4912 } | |
4913 __ SmiTag(input); | |
4914 } | |
4915 | |
4916 | |
4917 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 4896 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
4918 class DeferredNumberTagI V8_FINAL : public LDeferredCode { | 4897 class DeferredNumberTagI V8_FINAL : public LDeferredCode { |
4919 public: | 4898 public: |
4920 DeferredNumberTagI(LCodeGen* codegen, | 4899 DeferredNumberTagI(LCodeGen* codegen, |
4921 LNumberTagI* instr, | 4900 LNumberTagI* instr, |
4922 const X87Stack& x87_stack) | 4901 const X87Stack& x87_stack) |
4923 : LDeferredCode(codegen, x87_stack), instr_(instr) { } | 4902 : LDeferredCode(codegen, x87_stack), instr_(instr) { } |
4924 virtual void Generate() V8_OVERRIDE { | 4903 virtual void Generate() V8_OVERRIDE { |
4925 codegen()->DoDeferredNumberTagIU(instr_, instr_->value(), instr_->temp(), | 4904 codegen()->DoDeferredNumberTagIU(instr_, instr_->value(), instr_->temp(), |
4926 NULL, SIGNED_INT32); | 4905 NULL, SIGNED_INT32); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5108 // not have easy access to the local context. | 5087 // not have easy access to the local context. |
5109 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 5088 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
5110 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | 5089 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
5111 RecordSafepointWithRegisters( | 5090 RecordSafepointWithRegisters( |
5112 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); | 5091 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); |
5113 __ StoreToSafepointRegisterSlot(reg, eax); | 5092 __ StoreToSafepointRegisterSlot(reg, eax); |
5114 } | 5093 } |
5115 | 5094 |
5116 | 5095 |
5117 void LCodeGen::DoSmiTag(LSmiTag* instr) { | 5096 void LCodeGen::DoSmiTag(LSmiTag* instr) { |
5118 LOperand* input = instr->value(); | 5097 HChange* hchange = instr->hydrogen(); |
5119 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 5098 Register input = ToRegister(instr->value()); |
5120 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); | 5099 if (hchange->CheckFlag(HValue::kCanOverflow) && |
5121 __ SmiTag(ToRegister(input)); | 5100 hchange->value()->CheckFlag(HValue::kUint32)) { |
| 5101 __ test(input, Immediate(0xc0000000)); |
| 5102 DeoptimizeIf(not_zero, instr->environment()); |
| 5103 } |
| 5104 __ SmiTag(input); |
| 5105 if (hchange->CheckFlag(HValue::kCanOverflow) && |
| 5106 !hchange->value()->CheckFlag(HValue::kUint32)) { |
| 5107 DeoptimizeIf(overflow, instr->environment()); |
| 5108 } |
5122 } | 5109 } |
5123 | 5110 |
5124 | 5111 |
5125 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { | 5112 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { |
5126 LOperand* input = instr->value(); | 5113 LOperand* input = instr->value(); |
5127 Register result = ToRegister(input); | 5114 Register result = ToRegister(input); |
5128 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 5115 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
5129 if (instr->needs_check()) { | 5116 if (instr->needs_check()) { |
5130 __ test(result, Immediate(kSmiTagMask)); | 5117 __ test(result, Immediate(kSmiTagMask)); |
5131 DeoptimizeIf(not_zero, instr->environment()); | 5118 DeoptimizeIf(not_zero, instr->environment()); |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6343 FixedArray::kHeaderSize - kPointerSize)); | 6330 FixedArray::kHeaderSize - kPointerSize)); |
6344 __ bind(&done); | 6331 __ bind(&done); |
6345 } | 6332 } |
6346 | 6333 |
6347 | 6334 |
6348 #undef __ | 6335 #undef __ |
6349 | 6336 |
6350 } } // namespace v8::internal | 6337 } } // namespace v8::internal |
6351 | 6338 |
6352 #endif // V8_TARGET_ARCH_IA32 | 6339 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |