Chromium Code Reviews| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 __ vldr(dbl_scratch, mem_op.rn(), mem_op.offset()); | 511 __ vldr(dbl_scratch, mem_op.rn(), mem_op.offset()); |
| 512 return dbl_scratch; | 512 return dbl_scratch; |
| 513 } | 513 } |
| 514 UNREACHABLE(); | 514 UNREACHABLE(); |
| 515 return dbl_scratch; | 515 return dbl_scratch; |
| 516 } | 516 } |
| 517 | 517 |
| 518 | 518 |
| 519 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { | 519 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { |
| 520 HConstant* constant = chunk_->LookupConstant(op); | 520 HConstant* constant = chunk_->LookupConstant(op); |
| 521 ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged()); | 521 ASSERT(chunk_->LookupLiteralRepresentation(op).IsSmiOrTagged()); |
| 522 return constant->handle(); | 522 return constant->handle(); |
| 523 } | 523 } |
| 524 | 524 |
| 525 | 525 |
| 526 bool LCodeGen::IsInteger32(LConstantOperand* op) const { | 526 bool LCodeGen::IsInteger32(LConstantOperand* op) const { |
| 527 return chunk_->LookupLiteralRepresentation(op).IsInteger32(); | 527 return chunk_->LookupLiteralRepresentation(op).IsInteger32(); |
| 528 } | 528 } |
| 529 | 529 |
| 530 | 530 |
| 531 bool LCodeGen::IsSmi(LConstantOperand* op) const { | |
| 532 return chunk_->LookupLiteralRepresentation(op).IsSmi(); | |
| 533 } | |
| 534 | |
| 535 | |
| 531 int LCodeGen::ToInteger32(LConstantOperand* op) const { | 536 int LCodeGen::ToInteger32(LConstantOperand* op) const { |
| 532 HConstant* constant = chunk_->LookupConstant(op); | 537 HConstant* constant = chunk_->LookupConstant(op); |
| 533 return constant->Integer32Value(); | 538 return constant->Integer32Value(); |
| 534 } | 539 } |
| 535 | 540 |
| 536 | 541 |
| 537 double LCodeGen::ToDouble(LConstantOperand* op) const { | 542 double LCodeGen::ToDouble(LConstantOperand* op) const { |
| 538 HConstant* constant = chunk_->LookupConstant(op); | 543 HConstant* constant = chunk_->LookupConstant(op); |
| 539 ASSERT(constant->HasDoubleValue()); | 544 ASSERT(constant->HasDoubleValue()); |
| 540 return constant->DoubleValue(); | 545 return constant->DoubleValue(); |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2201 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { | 2206 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { |
| 2202 __ stop("LBreak"); | 2207 __ stop("LBreak"); |
| 2203 } | 2208 } |
| 2204 | 2209 |
| 2205 | 2210 |
| 2206 void LCodeGen::DoBranch(LBranch* instr) { | 2211 void LCodeGen::DoBranch(LBranch* instr) { |
| 2207 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 2212 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 2208 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 2213 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 2209 | 2214 |
| 2210 Representation r = instr->hydrogen()->value()->representation(); | 2215 Representation r = instr->hydrogen()->value()->representation(); |
| 2211 if (r.IsInteger32()) { | 2216 if (r.IsInteger32() || r.IsSmi()) { |
| 2212 Register reg = ToRegister(instr->value()); | 2217 Register reg = ToRegister(instr->value()); |
| 2213 __ cmp(reg, Operand::Zero()); | 2218 __ cmp(reg, Operand::Zero()); |
| 2214 EmitBranch(true_block, false_block, ne); | 2219 EmitBranch(true_block, false_block, ne); |
| 2215 } else if (r.IsDouble()) { | 2220 } else if (r.IsDouble()) { |
| 2216 DwVfpRegister reg = ToDoubleRegister(instr->value()); | 2221 DwVfpRegister reg = ToDoubleRegister(instr->value()); |
| 2217 // Test the double value. Zero and NaN are false. | 2222 // Test the double value. Zero and NaN are false. |
| 2218 __ VFPCompareAndSetFlags(reg, 0.0); | 2223 __ VFPCompareAndSetFlags(reg, 0.0); |
| 2219 __ cmp(r0, r0, vs); // If NaN, set the Z flag. | 2224 __ cmp(r0, r0, vs); // If NaN, set the Z flag. |
| 2220 EmitBranch(true_block, false_block, ne); | 2225 EmitBranch(true_block, false_block, ne); |
| 2221 } else { | 2226 } else { |
| (...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4205 | 4210 |
| 4206 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { | 4211 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { |
| 4207 Representation representation = instr->representation(); | 4212 Representation representation = instr->representation(); |
| 4208 | 4213 |
| 4209 Register object = ToRegister(instr->object()); | 4214 Register object = ToRegister(instr->object()); |
| 4210 Register scratch = scratch0(); | 4215 Register scratch = scratch0(); |
| 4211 int offset = instr->offset(); | 4216 int offset = instr->offset(); |
| 4212 | 4217 |
| 4213 Handle<Map> transition = instr->transition(); | 4218 Handle<Map> transition = instr->transition(); |
| 4214 | 4219 |
| 4215 if (FLAG_track_fields && representation.IsSmi()) { | 4220 if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
| 4216 Register value = ToRegister(instr->value()); | |
| 4217 __ SmiTag(value, value, SetCC); | |
| 4218 if (!instr->hydrogen()->value()->range()->IsInSmiRange()) { | |
| 4219 DeoptimizeIf(vs, instr->environment()); | |
| 4220 } | |
| 4221 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | |
| 4222 Register value = ToRegister(instr->value()); | 4221 Register value = ToRegister(instr->value()); |
| 4223 if (!instr->hydrogen()->value()->type().IsHeapObject()) { | 4222 if (!instr->hydrogen()->value()->type().IsHeapObject()) { |
| 4224 __ tst(value, Operand(kSmiTagMask)); | 4223 __ tst(value, Operand(kSmiTagMask)); |
| 4225 DeoptimizeIf(eq, instr->environment()); | 4224 DeoptimizeIf(eq, instr->environment()); |
| 4226 } | 4225 } |
| 4227 } else if (FLAG_track_double_fields && representation.IsDouble()) { | 4226 } else if (FLAG_track_double_fields && representation.IsDouble()) { |
| 4228 ASSERT(transition.is_null()); | 4227 ASSERT(transition.is_null()); |
| 4229 ASSERT(instr->is_in_object()); | 4228 ASSERT(instr->is_in_object()); |
| 4230 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); | 4229 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); |
| 4231 DwVfpRegister value = ToDoubleRegister(instr->value()); | 4230 DwVfpRegister value = ToDoubleRegister(instr->value()); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4698 Register scratch = scratch0(); | 4697 Register scratch = scratch0(); |
| 4699 __ ldr(scratch, ToMemOperand(input)); | 4698 __ ldr(scratch, ToMemOperand(input)); |
| 4700 __ vmov(single_scratch, scratch); | 4699 __ vmov(single_scratch, scratch); |
| 4701 } else { | 4700 } else { |
| 4702 __ vmov(single_scratch, ToRegister(input)); | 4701 __ vmov(single_scratch, ToRegister(input)); |
| 4703 } | 4702 } |
| 4704 __ vcvt_f64_s32(ToDoubleRegister(output), single_scratch); | 4703 __ vcvt_f64_s32(ToDoubleRegister(output), single_scratch); |
| 4705 } | 4704 } |
| 4706 | 4705 |
| 4707 | 4706 |
| 4707 void LCodeGen::DoInteger32ToSmi(LInteger32ToSmi* instr) { | |
| 4708 LOperand* input = instr->value(); | |
| 4709 ASSERT(input->IsRegister()); | |
| 4710 LOperand* output = instr->result(); | |
| 4711 ASSERT(output->IsRegister()); | |
| 4712 __ SmiTag(ToRegister(output), ToRegister(input)); | |
|
Rodolph Perfetta
2013/05/18 17:54:53
SetCC
danno
2013/05/18 19:16:16
Done.
danno
2013/05/18 19:16:16
Done.
| |
| 4713 if (!instr->hydrogen()->value()->HasRange() || | |
| 4714 !instr->hydrogen()->value()->range()->IsInSmiRange()) { | |
| 4715 DeoptimizeIf(vs, instr->environment()); | |
| 4716 } | |
| 4717 } | |
| 4718 | |
| 4719 | |
| 4708 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { | 4720 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { |
| 4709 LOperand* input = instr->value(); | 4721 LOperand* input = instr->value(); |
| 4710 LOperand* output = instr->result(); | 4722 LOperand* output = instr->result(); |
| 4711 | 4723 |
| 4712 SwVfpRegister flt_scratch = double_scratch0().low(); | 4724 SwVfpRegister flt_scratch = double_scratch0().low(); |
| 4713 __ vmov(flt_scratch, ToRegister(input)); | 4725 __ vmov(flt_scratch, ToRegister(input)); |
| 4714 __ vcvt_f64_u32(ToDoubleRegister(output), flt_scratch); | 4726 __ vcvt_f64_u32(ToDoubleRegister(output), flt_scratch); |
| 4715 } | 4727 } |
| 4716 | 4728 |
| 4717 | 4729 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5135 scratch1, scratch2, scratch3, double_scratch); | 5147 scratch1, scratch2, scratch3, double_scratch); |
| 5136 } else { | 5148 } else { |
| 5137 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); | 5149 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); |
| 5138 // Deoptimize if the input wasn't a int32 (inside a double). | 5150 // Deoptimize if the input wasn't a int32 (inside a double). |
| 5139 DeoptimizeIf(ne, instr->environment()); | 5151 DeoptimizeIf(ne, instr->environment()); |
| 5140 } | 5152 } |
| 5141 __ bind(&done); | 5153 __ bind(&done); |
| 5142 } | 5154 } |
| 5143 | 5155 |
| 5144 | 5156 |
| 5157 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { | |
| 5158 Register result_reg = ToRegister(instr->result()); | |
| 5159 Register scratch1 = scratch0(); | |
| 5160 Register scratch2 = ToRegister(instr->temp()); | |
| 5161 DwVfpRegister double_input = ToDoubleRegister(instr->value()); | |
| 5162 DwVfpRegister double_scratch = double_scratch0(); | |
| 5163 | |
| 5164 Label done; | |
| 5165 | |
| 5166 if (instr->truncating()) { | |
| 5167 Register scratch3 = ToRegister(instr->temp2()); | |
| 5168 __ ECMAToInt32(result_reg, double_input, | |
| 5169 scratch1, scratch2, scratch3, double_scratch); | |
| 5170 } else { | |
| 5171 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); | |
| 5172 // Deoptimize if the input wasn't a int32 (inside a double). | |
| 5173 DeoptimizeIf(ne, instr->environment()); | |
|
Rodolph Perfetta
2013/05/18 17:54:53
This code doesn't handle -0.
danno
2013/05/18 19:16:16
Done.
| |
| 5174 } | |
| 5175 __ bind(&done); | |
|
Rodolph Perfetta
2013/05/18 17:54:53
Nothing branch to this label.
danno
2013/05/18 19:16:16
Done.
| |
| 5176 __ SmiTag(result_reg, SetCC); | |
| 5177 DeoptimizeIf(vs, instr->environment()); | |
| 5178 } | |
| 5179 | |
| 5180 | |
| 5145 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { | 5181 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { |
| 5146 LOperand* input = instr->value(); | 5182 LOperand* input = instr->value(); |
| 5147 __ tst(ToRegister(input), Operand(kSmiTagMask)); | 5183 __ tst(ToRegister(input), Operand(kSmiTagMask)); |
| 5148 DeoptimizeIf(ne, instr->environment()); | 5184 DeoptimizeIf(ne, instr->environment()); |
| 5149 } | 5185 } |
| 5150 | 5186 |
| 5151 | 5187 |
| 5152 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { | 5188 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { |
| 5153 LOperand* input = instr->value(); | 5189 LOperand* input = instr->value(); |
| 5154 __ tst(ToRegister(input), Operand(kSmiTagMask)); | 5190 __ tst(ToRegister(input), Operand(kSmiTagMask)); |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5910 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 5946 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 5911 __ ldr(result, FieldMemOperand(scratch, | 5947 __ ldr(result, FieldMemOperand(scratch, |
| 5912 FixedArray::kHeaderSize - kPointerSize)); | 5948 FixedArray::kHeaderSize - kPointerSize)); |
| 5913 __ bind(&done); | 5949 __ bind(&done); |
| 5914 } | 5950 } |
| 5915 | 5951 |
| 5916 | 5952 |
| 5917 #undef __ | 5953 #undef __ |
| 5918 | 5954 |
| 5919 } } // namespace v8::internal | 5955 } } // namespace v8::internal |
| OLD | NEW |