| 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 3379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3390 case kExternalUnsignedShortArray: | 3390 case kExternalUnsignedShortArray: |
| 3391 __ movzx_w(eax, Operand(ebx, ecx, times_2, 0)); | 3391 __ movzx_w(eax, Operand(ebx, ecx, times_2, 0)); |
| 3392 break; | 3392 break; |
| 3393 case kExternalIntArray: | 3393 case kExternalIntArray: |
| 3394 case kExternalUnsignedIntArray: | 3394 case kExternalUnsignedIntArray: |
| 3395 __ mov(ecx, Operand(ebx, ecx, times_4, 0)); | 3395 __ mov(ecx, Operand(ebx, ecx, times_4, 0)); |
| 3396 break; | 3396 break; |
| 3397 case kExternalFloatArray: | 3397 case kExternalFloatArray: |
| 3398 __ fld_s(Operand(ebx, ecx, times_4, 0)); | 3398 __ fld_s(Operand(ebx, ecx, times_4, 0)); |
| 3399 break; | 3399 break; |
| 3400 case kExternalDoubleArray: |
| 3401 __ fld_d(Operand(ebx, ecx, times_8, 0)); |
| 3402 break; |
| 3400 default: | 3403 default: |
| 3401 UNREACHABLE(); | 3404 UNREACHABLE(); |
| 3402 break; | 3405 break; |
| 3403 } | 3406 } |
| 3404 | 3407 |
| 3405 // For integer array types: | 3408 // For integer array types: |
| 3406 // ecx: value | 3409 // ecx: value |
| 3407 // For floating-point array type: | 3410 // For floating-point array type: |
| 3408 // FP(0): value | 3411 // FP(0): value |
| 3409 | 3412 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3447 __ fild_d(Operand(esp, 0)); | 3450 __ fild_d(Operand(esp, 0)); |
| 3448 __ pop(ecx); | 3451 __ pop(ecx); |
| 3449 __ pop(ecx); | 3452 __ pop(ecx); |
| 3450 } | 3453 } |
| 3451 // FP(0): value | 3454 // FP(0): value |
| 3452 __ AllocateHeapNumber(ecx, ebx, edi, &failed_allocation); | 3455 __ AllocateHeapNumber(ecx, ebx, edi, &failed_allocation); |
| 3453 // Set the value. | 3456 // Set the value. |
| 3454 __ mov(eax, ecx); | 3457 __ mov(eax, ecx); |
| 3455 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 3458 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3456 __ ret(0); | 3459 __ ret(0); |
| 3457 } else if (array_type == kExternalFloatArray) { | 3460 } else if (array_type == kExternalFloatArray || |
| 3461 array_type == kExternalDoubleArray) { |
| 3458 // For the floating-point array type, we need to always allocate a | 3462 // For the floating-point array type, we need to always allocate a |
| 3459 // HeapNumber. | 3463 // HeapNumber. |
| 3460 __ AllocateHeapNumber(ecx, ebx, edi, &failed_allocation); | 3464 __ AllocateHeapNumber(ecx, ebx, edi, &failed_allocation); |
| 3461 // Set the value. | 3465 // Set the value. |
| 3462 __ mov(eax, ecx); | 3466 __ mov(eax, ecx); |
| 3463 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 3467 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3464 __ ret(0); | 3468 __ ret(0); |
| 3465 } else { | 3469 } else { |
| 3466 __ SmiTag(eax); | 3470 __ SmiTag(eax); |
| 3467 __ ret(0); | 3471 __ ret(0); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3562 break; | 3566 break; |
| 3563 case kExternalShortArray: | 3567 case kExternalShortArray: |
| 3564 case kExternalUnsignedShortArray: | 3568 case kExternalUnsignedShortArray: |
| 3565 __ mov_w(Operand(edi, ebx, times_2, 0), ecx); | 3569 __ mov_w(Operand(edi, ebx, times_2, 0), ecx); |
| 3566 break; | 3570 break; |
| 3567 case kExternalIntArray: | 3571 case kExternalIntArray: |
| 3568 case kExternalUnsignedIntArray: | 3572 case kExternalUnsignedIntArray: |
| 3569 __ mov(Operand(edi, ebx, times_4, 0), ecx); | 3573 __ mov(Operand(edi, ebx, times_4, 0), ecx); |
| 3570 break; | 3574 break; |
| 3571 case kExternalFloatArray: | 3575 case kExternalFloatArray: |
| 3576 case kExternalDoubleArray: |
| 3572 // Need to perform int-to-float conversion. | 3577 // Need to perform int-to-float conversion. |
| 3573 __ push(ecx); | 3578 __ push(ecx); |
| 3574 __ fild_s(Operand(esp, 0)); | 3579 __ fild_s(Operand(esp, 0)); |
| 3575 __ pop(ecx); | 3580 __ pop(ecx); |
| 3576 __ fstp_s(Operand(edi, ebx, times_4, 0)); | 3581 if (array_type == kExternalFloatArray) { |
| 3582 __ fstp_s(Operand(edi, ebx, times_4, 0)); |
| 3583 } else { // array_type == kExternalDoubleArray. |
| 3584 __ fstp_d(Operand(edi, ebx, times_8, 0)); |
| 3585 } |
| 3577 break; | 3586 break; |
| 3578 default: | 3587 default: |
| 3579 UNREACHABLE(); | 3588 UNREACHABLE(); |
| 3580 break; | 3589 break; |
| 3581 } | 3590 } |
| 3582 __ ret(0); // Return the original value. | 3591 __ ret(0); // Return the original value. |
| 3583 | 3592 |
| 3584 // TODO(danno): handle heap number -> pixel array conversion | 3593 // TODO(danno): handle heap number -> pixel array conversion |
| 3585 if (array_type != kExternalPixelArray) { | 3594 if (array_type != kExternalPixelArray) { |
| 3586 __ bind(&check_heap_number); | 3595 __ bind(&check_heap_number); |
| 3587 // eax: value | 3596 // eax: value |
| 3588 // edx: receiver | 3597 // edx: receiver |
| 3589 // ecx: key | 3598 // ecx: key |
| 3590 // edi: elements array | 3599 // edi: elements array |
| 3591 // ebx: untagged index | 3600 // ebx: untagged index |
| 3592 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), | 3601 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), |
| 3593 Immediate(factory()->heap_number_map())); | 3602 Immediate(factory()->heap_number_map())); |
| 3594 __ j(not_equal, &slow); | 3603 __ j(not_equal, &slow); |
| 3595 | 3604 |
| 3596 // The WebGL specification leaves the behavior of storing NaN and | 3605 // The WebGL specification leaves the behavior of storing NaN and |
| 3597 // +/-Infinity into integer arrays basically undefined. For more | 3606 // +/-Infinity into integer arrays basically undefined. For more |
| 3598 // reproducible behavior, convert these to zero. | 3607 // reproducible behavior, convert these to zero. |
| 3599 __ mov(edi, FieldOperand(edi, ExternalArray::kExternalPointerOffset)); | 3608 __ mov(edi, FieldOperand(edi, ExternalArray::kExternalPointerOffset)); |
| 3600 // ebx: untagged index | 3609 // ebx: untagged index |
| 3601 // edi: base pointer of external storage | 3610 // edi: base pointer of external storage |
| 3602 if (array_type == kExternalFloatArray) { | 3611 if (array_type == kExternalFloatArray) { |
| 3603 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 3612 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3604 __ fstp_s(Operand(edi, ebx, times_4, 0)); | 3613 __ fstp_s(Operand(edi, ebx, times_4, 0)); |
| 3605 __ ret(0); | 3614 __ ret(0); |
| 3615 } else if (array_type == kExternalDoubleArray) { |
| 3616 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3617 __ fstp_d(Operand(edi, ebx, times_8, 0)); |
| 3618 __ ret(0); |
| 3606 } else { | 3619 } else { |
| 3607 // Perform float-to-int conversion with truncation (round-to-zero) | 3620 // Perform float-to-int conversion with truncation (round-to-zero) |
| 3608 // behavior. | 3621 // behavior. |
| 3609 | 3622 |
| 3610 // For the moment we make the slow call to the runtime on | 3623 // For the moment we make the slow call to the runtime on |
| 3611 // processors that don't support SSE2. The code in IntegerConvert | 3624 // processors that don't support SSE2. The code in IntegerConvert |
| 3612 // (code-stubs-ia32.cc) is roughly what is needed here though the | 3625 // (code-stubs-ia32.cc) is roughly what is needed here though the |
| 3613 // conversion failure case does not need to be handled. | 3626 // conversion failure case does not need to be handled. |
| 3614 if (CpuFeatures::IsSupported(SSE2)) { | 3627 if (CpuFeatures::IsSupported(SSE2)) { |
| 3615 if (array_type != kExternalIntArray && | 3628 if (array_type != kExternalIntArray && |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3702 | 3715 |
| 3703 return GetCode(flags); | 3716 return GetCode(flags); |
| 3704 } | 3717 } |
| 3705 | 3718 |
| 3706 | 3719 |
| 3707 #undef __ | 3720 #undef __ |
| 3708 | 3721 |
| 3709 } } // namespace v8::internal | 3722 } } // namespace v8::internal |
| 3710 | 3723 |
| 3711 #endif // V8_TARGET_ARCH_IA32 | 3724 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |