OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 void MacroAssembler::CheckFastSmiOnlyElements(Register map, | 399 void MacroAssembler::CheckFastSmiOnlyElements(Register map, |
400 Label* fail, | 400 Label* fail, |
401 Label::Distance distance) { | 401 Label::Distance distance) { |
402 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); | 402 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); |
403 cmpb(FieldOperand(map, Map::kBitField2Offset), | 403 cmpb(FieldOperand(map, Map::kBitField2Offset), |
404 Map::kMaximumBitField2FastSmiOnlyElementValue); | 404 Map::kMaximumBitField2FastSmiOnlyElementValue); |
405 j(above, fail, distance); | 405 j(above, fail, distance); |
406 } | 406 } |
407 | 407 |
408 | 408 |
| 409 void MacroAssembler::StoreNumberToDoubleElements( |
| 410 Register maybe_number, |
| 411 Register elements, |
| 412 Register key, |
| 413 Register scratch1, |
| 414 XMMRegister scratch2, |
| 415 Label* fail, |
| 416 bool specialize_for_processor) { |
| 417 Label smi_value, done, maybe_nan, not_nan, is_nan, have_double_value; |
| 418 JumpIfSmi(maybe_number, &smi_value, Label::kNear); |
| 419 |
| 420 CheckMap(maybe_number, |
| 421 isolate()->factory()->heap_number_map(), |
| 422 fail, |
| 423 DONT_DO_SMI_CHECK); |
| 424 |
| 425 // Double value, canonicalize NaN. |
| 426 uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32); |
| 427 cmp(FieldOperand(maybe_number, offset), |
| 428 Immediate(kNaNOrInfinityLowerBoundUpper32)); |
| 429 j(greater_equal, &maybe_nan, Label::kNear); |
| 430 |
| 431 bind(¬_nan); |
| 432 ExternalReference canonical_nan_reference = |
| 433 ExternalReference::address_of_canonical_non_hole_nan(); |
| 434 if (CpuFeatures::IsSupported(SSE2) && specialize_for_processor) { |
| 435 CpuFeatures::Scope use_sse2(SSE2); |
| 436 movdbl(scratch2, FieldOperand(maybe_number, HeapNumber::kValueOffset)); |
| 437 bind(&have_double_value); |
| 438 movdbl(FieldOperand(elements, key, times_4, FixedDoubleArray::kHeaderSize), |
| 439 scratch2); |
| 440 } else { |
| 441 fld_d(FieldOperand(maybe_number, HeapNumber::kValueOffset)); |
| 442 bind(&have_double_value); |
| 443 fstp_d(FieldOperand(elements, key, times_4, FixedDoubleArray::kHeaderSize)); |
| 444 } |
| 445 jmp(&done); |
| 446 |
| 447 bind(&maybe_nan); |
| 448 // Could be NaN or Infinity. If fraction is not zero, it's NaN, otherwise |
| 449 // it's an Infinity, and the non-NaN code path applies. |
| 450 j(greater, &is_nan, Label::kNear); |
| 451 cmp(FieldOperand(maybe_number, HeapNumber::kValueOffset), Immediate(0)); |
| 452 j(zero, ¬_nan); |
| 453 bind(&is_nan); |
| 454 if (CpuFeatures::IsSupported(SSE2) && specialize_for_processor) { |
| 455 CpuFeatures::Scope use_sse2(SSE2); |
| 456 movdbl(scratch2, Operand::StaticVariable(canonical_nan_reference)); |
| 457 } else { |
| 458 fld_d(Operand::StaticVariable(canonical_nan_reference)); |
| 459 } |
| 460 jmp(&have_double_value, Label::kNear); |
| 461 |
| 462 bind(&smi_value); |
| 463 // Value is a smi. Convert to a double and store. |
| 464 // Preserve original value. |
| 465 mov(scratch1, maybe_number); |
| 466 SmiUntag(scratch1); |
| 467 if (CpuFeatures::IsSupported(SSE2) && specialize_for_processor) { |
| 468 CpuFeatures::Scope fscope(SSE2); |
| 469 cvtsi2sd(scratch2, Operand(scratch1)); |
| 470 movdbl(FieldOperand(elements, key, times_4, FixedDoubleArray::kHeaderSize), |
| 471 scratch2); |
| 472 } else { |
| 473 push(scratch1); |
| 474 fild_s(Operand(esp, 0)); |
| 475 pop(scratch1); |
| 476 fstp_d(FieldOperand(elements, key, times_4, FixedDoubleArray::kHeaderSize)); |
| 477 } |
| 478 bind(&done); |
| 479 } |
| 480 |
| 481 |
409 void MacroAssembler::CheckMap(Register obj, | 482 void MacroAssembler::CheckMap(Register obj, |
410 Handle<Map> map, | 483 Handle<Map> map, |
411 Label* fail, | 484 Label* fail, |
412 SmiCheckType smi_check_type) { | 485 SmiCheckType smi_check_type) { |
413 if (smi_check_type == DO_SMI_CHECK) { | 486 if (smi_check_type == DO_SMI_CHECK) { |
414 JumpIfSmi(obj, fail); | 487 JumpIfSmi(obj, fail); |
415 } | 488 } |
416 cmp(FieldOperand(obj, HeapObject::kMapOffset), Immediate(map)); | 489 cmp(FieldOperand(obj, HeapObject::kMapOffset), Immediate(map)); |
417 j(not_equal, fail); | 490 j(not_equal, fail); |
418 } | 491 } |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset)); | 2713 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset)); |
2641 Check(less_equal, "Live Bytes Count overflow chunk size"); | 2714 Check(less_equal, "Live Bytes Count overflow chunk size"); |
2642 } | 2715 } |
2643 | 2716 |
2644 bind(&done); | 2717 bind(&done); |
2645 } | 2718 } |
2646 | 2719 |
2647 } } // namespace v8::internal | 2720 } } // namespace v8::internal |
2648 | 2721 |
2649 #endif // V8_TARGET_ARCH_IA32 | 2722 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |