| 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 5226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5237 __ mov(temp_reg, input_reg); | 5237 __ mov(temp_reg, input_reg); |
| 5238 __ SmiUntag(temp_reg); // Untag smi before converting to float. | 5238 __ SmiUntag(temp_reg); // Untag smi before converting to float. |
| 5239 __ Cvtsi2sd(result_reg, Operand(temp_reg)); | 5239 __ Cvtsi2sd(result_reg, Operand(temp_reg)); |
| 5240 __ bind(&done); | 5240 __ bind(&done); |
| 5241 } | 5241 } |
| 5242 | 5242 |
| 5243 | 5243 |
| 5244 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { | 5244 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
| 5245 Register input_reg = ToRegister(instr->value()); | 5245 Register input_reg = ToRegister(instr->value()); |
| 5246 | 5246 |
| 5247 // The input was optimistically untagged; revert it. |
| 5248 STATIC_ASSERT(kSmiTagSize == 1); |
| 5249 __ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); |
| 5250 |
| 5247 if (instr->truncating()) { | 5251 if (instr->truncating()) { |
| 5248 Label no_heap_number, check_bools, check_false; | 5252 Label no_heap_number, check_bools, check_false; |
| 5249 | 5253 |
| 5250 // Heap number map check. | 5254 // Heap number map check. |
| 5251 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 5255 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
| 5252 factory()->heap_number_map()); | 5256 factory()->heap_number_map()); |
| 5253 __ j(not_equal, &no_heap_number, Label::kNear); | 5257 __ j(not_equal, &no_heap_number, Label::kNear); |
| 5254 __ TruncateHeapNumberToI(input_reg, input_reg); | 5258 __ TruncateHeapNumberToI(input_reg, input_reg); |
| 5255 __ jmp(done); | 5259 __ jmp(done); |
| 5256 | 5260 |
| 5257 __ bind(&no_heap_number); | 5261 __ bind(&no_heap_number); |
| 5258 // Check for Oddballs. Undefined/False is converted to zero and True to one | 5262 // Check for Oddballs. Undefined/False is converted to zero and True to one |
| 5259 // for truncating conversions. | 5263 // for truncating conversions. |
| 5260 __ cmp(input_reg, factory()->undefined_value()); | 5264 __ cmp(input_reg, factory()->undefined_value()); |
| 5261 __ j(not_equal, &check_bools, Label::kNear); | 5265 __ j(not_equal, &check_bools, Label::kNear); |
| 5262 __ Set(input_reg, Immediate(0)); | 5266 __ Set(input_reg, Immediate(0)); |
| 5263 __ jmp(done); | 5267 __ jmp(done); |
| 5264 | 5268 |
| 5265 __ bind(&check_bools); | 5269 __ bind(&check_bools); |
| 5266 __ cmp(input_reg, factory()->true_value()); | 5270 __ cmp(input_reg, factory()->true_value()); |
| 5267 __ j(not_equal, &check_false, Label::kNear); | 5271 __ j(not_equal, &check_false, Label::kNear); |
| 5268 __ Set(input_reg, Immediate(1)); | 5272 __ Set(input_reg, Immediate(1)); |
| 5269 __ jmp(done); | 5273 __ jmp(done); |
| 5270 | 5274 |
| 5271 __ bind(&check_false); | 5275 __ bind(&check_false); |
| 5272 __ cmp(input_reg, factory()->false_value()); | 5276 __ cmp(input_reg, factory()->false_value()); |
| 5273 __ RecordComment("Deferred TaggedToI: cannot truncate"); | 5277 __ RecordComment("Deferred TaggedToI: cannot truncate"); |
| 5274 DeoptimizeIf(not_equal, instr->environment()); | 5278 DeoptimizeIf(not_equal, instr->environment()); |
| 5275 __ Set(input_reg, Immediate(0)); | 5279 __ Set(input_reg, Immediate(0)); |
| 5276 __ jmp(done); | |
| 5277 } else { | 5280 } else { |
| 5278 Label bailout; | 5281 Label bailout; |
| 5279 XMMRegister scratch = (instr->temp() != NULL) | 5282 XMMRegister scratch = (instr->temp() != NULL) |
| 5280 ? ToDoubleRegister(instr->temp()) | 5283 ? ToDoubleRegister(instr->temp()) |
| 5281 : no_xmm_reg; | 5284 : no_xmm_reg; |
| 5282 __ TaggedToI(input_reg, input_reg, scratch, | 5285 __ TaggedToI(input_reg, input_reg, scratch, |
| 5283 instr->hydrogen()->GetMinusZeroMode(), &bailout); | 5286 instr->hydrogen()->GetMinusZeroMode(), &bailout); |
| 5284 __ jmp(done); | 5287 __ jmp(done); |
| 5285 __ bind(&bailout); | 5288 __ bind(&bailout); |
| 5286 DeoptimizeIf(no_condition, instr->environment()); | 5289 DeoptimizeIf(no_condition, instr->environment()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5306 LOperand* input = instr->value(); | 5309 LOperand* input = instr->value(); |
| 5307 ASSERT(input->IsRegister()); | 5310 ASSERT(input->IsRegister()); |
| 5308 Register input_reg = ToRegister(input); | 5311 Register input_reg = ToRegister(input); |
| 5309 ASSERT(input_reg.is(ToRegister(instr->result()))); | 5312 ASSERT(input_reg.is(ToRegister(instr->result()))); |
| 5310 | 5313 |
| 5311 if (instr->hydrogen()->value()->representation().IsSmi()) { | 5314 if (instr->hydrogen()->value()->representation().IsSmi()) { |
| 5312 __ SmiUntag(input_reg); | 5315 __ SmiUntag(input_reg); |
| 5313 } else { | 5316 } else { |
| 5314 DeferredTaggedToI* deferred = | 5317 DeferredTaggedToI* deferred = |
| 5315 new(zone()) DeferredTaggedToI(this, instr, x87_stack_); | 5318 new(zone()) DeferredTaggedToI(this, instr, x87_stack_); |
| 5316 | 5319 // Optimistically untag the input. |
| 5317 __ JumpIfNotSmi(input_reg, deferred->entry()); | 5320 // If the input is a HeapObject, SmiUntag will set the carry flag. |
| 5321 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 5318 __ SmiUntag(input_reg); | 5322 __ SmiUntag(input_reg); |
| 5323 // Branch to deferred code if the input was tagged. |
| 5324 // The deferred code will take care of restoring the tag. |
| 5325 __ j(carry, deferred->entry()); |
| 5319 __ bind(deferred->exit()); | 5326 __ bind(deferred->exit()); |
| 5320 } | 5327 } |
| 5321 } | 5328 } |
| 5322 | 5329 |
| 5323 | 5330 |
| 5324 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 5331 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
| 5325 LOperand* input = instr->value(); | 5332 LOperand* input = instr->value(); |
| 5326 ASSERT(input->IsRegister()); | 5333 ASSERT(input->IsRegister()); |
| 5327 LOperand* temp = instr->temp(); | 5334 LOperand* temp = instr->temp(); |
| 5328 ASSERT(temp->IsRegister()); | 5335 ASSERT(temp->IsRegister()); |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6270 FixedArray::kHeaderSize - kPointerSize)); | 6277 FixedArray::kHeaderSize - kPointerSize)); |
| 6271 __ bind(&done); | 6278 __ bind(&done); |
| 6272 } | 6279 } |
| 6273 | 6280 |
| 6274 | 6281 |
| 6275 #undef __ | 6282 #undef __ |
| 6276 | 6283 |
| 6277 } } // namespace v8::internal | 6284 } } // namespace v8::internal |
| 6278 | 6285 |
| 6279 #endif // V8_TARGET_ARCH_IA32 | 6286 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |