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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 for (current_instruction_ = 0; | 286 for (current_instruction_ = 0; |
287 !is_aborted() && current_instruction_ < instructions_->length(); | 287 !is_aborted() && current_instruction_ < instructions_->length(); |
288 current_instruction_++) { | 288 current_instruction_++) { |
289 LInstruction* instr = instructions_->at(current_instruction_); | 289 LInstruction* instr = instructions_->at(current_instruction_); |
290 if (instr->IsLabel()) { | 290 if (instr->IsLabel()) { |
291 LLabel* label = LLabel::cast(instr); | 291 LLabel* label = LLabel::cast(instr); |
292 emit_instructions = !label->HasReplacement(); | 292 emit_instructions = !label->HasReplacement(); |
293 } | 293 } |
294 | 294 |
295 if (emit_instructions) { | 295 if (emit_instructions) { |
296 Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic()); | 296 if (FLAG_code_comments) { |
| 297 HValue* hydrogen = instr->hydrogen_value(); |
| 298 if (hydrogen != NULL) { |
| 299 if (hydrogen->IsChange()) { |
| 300 HValue* changed_value = HChange::cast(hydrogen)->value(); |
| 301 int use_id = 0; |
| 302 const char* use_mnemo = "dead"; |
| 303 if (hydrogen->UseCount() >= 1) { |
| 304 HValue* use_value = hydrogen->uses().value(); |
| 305 use_id = use_value->id(); |
| 306 use_mnemo = use_value->Mnemonic(); |
| 307 } |
| 308 Comment(";;; @%d: %s. <of #%d %s for #%d %s>", |
| 309 current_instruction_, instr->Mnemonic(), |
| 310 changed_value->id(), changed_value->Mnemonic(), |
| 311 use_id, use_mnemo); |
| 312 } else { |
| 313 Comment(";;; @%d: %s. <#%d>", current_instruction_, |
| 314 instr->Mnemonic(), hydrogen->id()); |
| 315 } |
| 316 } else { |
| 317 Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic()); |
| 318 } |
| 319 } |
297 instr->CompileToNative(this); | 320 instr->CompileToNative(this); |
298 } | 321 } |
299 } | 322 } |
300 EnsureSpaceForLazyDeopt(); | 323 EnsureSpaceForLazyDeopt(); |
301 return !is_aborted(); | 324 return !is_aborted(); |
302 } | 325 } |
303 | 326 |
304 | 327 |
305 bool LCodeGen::GenerateDeferredCode() { | 328 bool LCodeGen::GenerateDeferredCode() { |
306 ASSERT(is_generating()); | 329 ASSERT(is_generating()); |
(...skipping 4073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4380 | 4403 |
4381 // Heap number map check. | 4404 // Heap number map check. |
4382 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 4405 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
4383 factory()->heap_number_map()); | 4406 factory()->heap_number_map()); |
4384 | 4407 |
4385 if (instr->truncating()) { | 4408 if (instr->truncating()) { |
4386 __ j(equal, &heap_number, Label::kNear); | 4409 __ j(equal, &heap_number, Label::kNear); |
4387 // Check for undefined. Undefined is converted to zero for truncating | 4410 // Check for undefined. Undefined is converted to zero for truncating |
4388 // conversions. | 4411 // conversions. |
4389 __ cmp(input_reg, factory()->undefined_value()); | 4412 __ cmp(input_reg, factory()->undefined_value()); |
| 4413 __ RecordComment("Deferred TaggedToI: cannot truncate"); |
4390 DeoptimizeIf(not_equal, instr->environment()); | 4414 DeoptimizeIf(not_equal, instr->environment()); |
4391 __ mov(input_reg, 0); | 4415 __ mov(input_reg, 0); |
4392 __ jmp(&done, Label::kNear); | 4416 __ jmp(&done, Label::kNear); |
4393 | 4417 |
4394 __ bind(&heap_number); | 4418 __ bind(&heap_number); |
4395 if (CpuFeatures::IsSupported(SSE3)) { | 4419 if (CpuFeatures::IsSupported(SSE3)) { |
4396 CpuFeatures::Scope scope(SSE3); | 4420 CpuFeatures::Scope scope(SSE3); |
4397 Label convert; | 4421 Label convert; |
4398 // Use more powerful conversion when sse3 is available. | 4422 // Use more powerful conversion when sse3 is available. |
4399 // Load x87 register with heap number. | 4423 // Load x87 register with heap number. |
4400 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4424 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4401 // Get exponent alone and check for too-big exponent. | 4425 // Get exponent alone and check for too-big exponent. |
4402 __ mov(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset)); | 4426 __ mov(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset)); |
4403 __ and_(input_reg, HeapNumber::kExponentMask); | 4427 __ and_(input_reg, HeapNumber::kExponentMask); |
4404 const uint32_t kTooBigExponent = | 4428 const uint32_t kTooBigExponent = |
4405 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; | 4429 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; |
4406 __ cmp(Operand(input_reg), Immediate(kTooBigExponent)); | 4430 __ cmp(Operand(input_reg), Immediate(kTooBigExponent)); |
4407 __ j(less, &convert, Label::kNear); | 4431 __ j(less, &convert, Label::kNear); |
4408 // Pop FPU stack before deoptimizing. | 4432 // Pop FPU stack before deoptimizing. |
4409 __ fstp(0); | 4433 __ fstp(0); |
| 4434 __ RecordComment("Deferred TaggedToI: exponent too big"); |
4410 DeoptimizeIf(no_condition, instr->environment()); | 4435 DeoptimizeIf(no_condition, instr->environment()); |
4411 | 4436 |
4412 // Reserve space for 64 bit answer. | 4437 // Reserve space for 64 bit answer. |
4413 __ bind(&convert); | 4438 __ bind(&convert); |
4414 __ sub(Operand(esp), Immediate(kDoubleSize)); | 4439 __ sub(Operand(esp), Immediate(kDoubleSize)); |
4415 // Do conversion, which cannot fail because we checked the exponent. | 4440 // Do conversion, which cannot fail because we checked the exponent. |
4416 __ fisttp_d(Operand(esp, 0)); | 4441 __ fisttp_d(Operand(esp, 0)); |
4417 __ mov(input_reg, Operand(esp, 0)); // Low word of answer is the result. | 4442 __ mov(input_reg, Operand(esp, 0)); // Low word of answer is the result. |
4418 __ add(Operand(esp), Immediate(kDoubleSize)); | 4443 __ add(Operand(esp), Immediate(kDoubleSize)); |
4419 } else { | 4444 } else { |
4420 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); | 4445 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); |
4421 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4446 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4422 __ cvttsd2si(input_reg, Operand(xmm0)); | 4447 __ cvttsd2si(input_reg, Operand(xmm0)); |
4423 __ cmp(input_reg, 0x80000000u); | 4448 __ cmp(input_reg, 0x80000000u); |
4424 __ j(not_equal, &done); | 4449 __ j(not_equal, &done); |
4425 // Check if the input was 0x8000000 (kMinInt). | 4450 // Check if the input was 0x8000000 (kMinInt). |
4426 // If no, then we got an overflow and we deoptimize. | 4451 // If no, then we got an overflow and we deoptimize. |
4427 ExternalReference min_int = ExternalReference::address_of_min_int(); | 4452 ExternalReference min_int = ExternalReference::address_of_min_int(); |
4428 __ movdbl(xmm_temp, Operand::StaticVariable(min_int)); | 4453 __ movdbl(xmm_temp, Operand::StaticVariable(min_int)); |
4429 __ ucomisd(xmm_temp, xmm0); | 4454 __ ucomisd(xmm_temp, xmm0); |
4430 DeoptimizeIf(not_equal, instr->environment()); | 4455 DeoptimizeIf(not_equal, instr->environment()); |
4431 DeoptimizeIf(parity_even, instr->environment()); // NaN. | 4456 DeoptimizeIf(parity_even, instr->environment()); // NaN. |
4432 } | 4457 } |
4433 } else { | 4458 } else { |
4434 // Deoptimize if we don't have a heap number. | 4459 // Deoptimize if we don't have a heap number. |
| 4460 __ RecordComment("Deferred TaggedToI: not a heap number"); |
4435 DeoptimizeIf(not_equal, instr->environment()); | 4461 DeoptimizeIf(not_equal, instr->environment()); |
4436 | 4462 |
4437 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); | 4463 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); |
4438 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4464 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4439 __ cvttsd2si(input_reg, Operand(xmm0)); | 4465 __ cvttsd2si(input_reg, Operand(xmm0)); |
4440 __ cvtsi2sd(xmm_temp, Operand(input_reg)); | 4466 __ cvtsi2sd(xmm_temp, Operand(input_reg)); |
4441 __ ucomisd(xmm0, xmm_temp); | 4467 __ ucomisd(xmm0, xmm_temp); |
| 4468 __ RecordComment("Deferred TaggedToI: lost precision"); |
4442 DeoptimizeIf(not_equal, instr->environment()); | 4469 DeoptimizeIf(not_equal, instr->environment()); |
| 4470 __ RecordComment("Deferred TaggedToI: NaN"); |
4443 DeoptimizeIf(parity_even, instr->environment()); // NaN. | 4471 DeoptimizeIf(parity_even, instr->environment()); // NaN. |
4444 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 4472 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
4445 __ test(input_reg, Operand(input_reg)); | 4473 __ test(input_reg, Operand(input_reg)); |
4446 __ j(not_zero, &done); | 4474 __ j(not_zero, &done); |
4447 __ movmskpd(input_reg, xmm0); | 4475 __ movmskpd(input_reg, xmm0); |
4448 __ and_(input_reg, 1); | 4476 __ and_(input_reg, 1); |
| 4477 __ RecordComment("Deferred TaggedToI: minus zero"); |
4449 DeoptimizeIf(not_zero, instr->environment()); | 4478 DeoptimizeIf(not_zero, instr->environment()); |
4450 } | 4479 } |
4451 } | 4480 } |
4452 __ bind(&done); | 4481 __ bind(&done); |
4453 } | 4482 } |
4454 | 4483 |
4455 | 4484 |
4456 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 4485 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
4457 class DeferredTaggedToI: public LDeferredCode { | 4486 class DeferredTaggedToI: public LDeferredCode { |
4458 public: | 4487 public: |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5557 FixedArray::kHeaderSize - kPointerSize)); | 5586 FixedArray::kHeaderSize - kPointerSize)); |
5558 __ bind(&done); | 5587 __ bind(&done); |
5559 } | 5588 } |
5560 | 5589 |
5561 | 5590 |
5562 #undef __ | 5591 #undef __ |
5563 | 5592 |
5564 } } // namespace v8::internal | 5593 } } // namespace v8::internal |
5565 | 5594 |
5566 #endif // V8_TARGET_ARCH_IA32 | 5595 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |