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 3403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3414 elements_kind)) { | 3414 elements_kind)) { |
3415 __ SmiUntag(ToRegister(key)); | 3415 __ SmiUntag(ToRegister(key)); |
3416 } | 3416 } |
3417 Operand operand(BuildFastArrayOperand( | 3417 Operand operand(BuildFastArrayOperand( |
3418 instr->elements(), | 3418 instr->elements(), |
3419 key, | 3419 key, |
3420 instr->hydrogen()->key()->representation(), | 3420 instr->hydrogen()->key()->representation(), |
3421 elements_kind, | 3421 elements_kind, |
3422 0, | 3422 0, |
3423 instr->additional_index())); | 3423 instr->additional_index())); |
3424 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | 3424 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
3425 elements_kind == FLOAT32_ELEMENTS) { | |
3426 if (CpuFeatures::IsSupported(SSE2)) { | 3425 if (CpuFeatures::IsSupported(SSE2)) { |
3427 CpuFeatureScope scope(masm(), SSE2); | 3426 CpuFeatureScope scope(masm(), SSE2); |
3428 XMMRegister result(ToDoubleRegister(instr->result())); | 3427 XMMRegister result(ToDoubleRegister(instr->result())); |
3429 __ movss(result, operand); | 3428 __ movss(result, operand); |
3430 __ cvtss2sd(result, result); | 3429 __ cvtss2sd(result, result); |
3431 } else { | 3430 } else { |
3432 X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); | 3431 X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); |
3433 } | 3432 } |
3434 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS || | 3433 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
3435 elements_kind == FLOAT64_ELEMENTS) { | |
3436 if (CpuFeatures::IsSupported(SSE2)) { | 3434 if (CpuFeatures::IsSupported(SSE2)) { |
3437 CpuFeatureScope scope(masm(), SSE2); | 3435 CpuFeatureScope scope(masm(), SSE2); |
3438 __ movsd(ToDoubleRegister(instr->result()), operand); | 3436 __ movsd(ToDoubleRegister(instr->result()), operand); |
3439 } else { | 3437 } else { |
3440 X87Mov(ToX87Register(instr->result()), operand); | 3438 X87Mov(ToX87Register(instr->result()), operand); |
3441 } | 3439 } |
3442 } else { | 3440 } else { |
3443 Register result(ToRegister(instr->result())); | 3441 Register result(ToRegister(instr->result())); |
3444 switch (elements_kind) { | 3442 switch (elements_kind) { |
3445 case EXTERNAL_BYTE_ELEMENTS: | 3443 case EXTERNAL_BYTE_ELEMENTS: |
3446 case INT8_ELEMENTS: | |
3447 __ movsx_b(result, operand); | 3444 __ movsx_b(result, operand); |
3448 break; | 3445 break; |
3449 case EXTERNAL_PIXEL_ELEMENTS: | 3446 case EXTERNAL_PIXEL_ELEMENTS: |
3450 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3447 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3451 case UINT8_ELEMENTS: | |
3452 case UINT8_CLAMPED_ELEMENTS: | |
3453 __ movzx_b(result, operand); | 3448 __ movzx_b(result, operand); |
3454 break; | 3449 break; |
3455 case EXTERNAL_SHORT_ELEMENTS: | 3450 case EXTERNAL_SHORT_ELEMENTS: |
3456 case INT16_ELEMENTS: | |
3457 __ movsx_w(result, operand); | 3451 __ movsx_w(result, operand); |
3458 break; | 3452 break; |
3459 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3453 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
3460 case UINT16_ELEMENTS: | |
3461 __ movzx_w(result, operand); | 3454 __ movzx_w(result, operand); |
3462 break; | 3455 break; |
3463 case EXTERNAL_INT_ELEMENTS: | 3456 case EXTERNAL_INT_ELEMENTS: |
3464 case INT32_ELEMENTS: | |
3465 __ mov(result, operand); | 3457 __ mov(result, operand); |
3466 break; | 3458 break; |
3467 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3459 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3468 case UINT32_ELEMENTS: | |
3469 __ mov(result, operand); | 3460 __ mov(result, operand); |
3470 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { | 3461 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
3471 __ test(result, Operand(result)); | 3462 __ test(result, Operand(result)); |
3472 DeoptimizeIf(negative, instr->environment()); | 3463 DeoptimizeIf(negative, instr->environment()); |
3473 } | 3464 } |
3474 break; | 3465 break; |
3475 case EXTERNAL_FLOAT_ELEMENTS: | 3466 case EXTERNAL_FLOAT_ELEMENTS: |
3476 case EXTERNAL_DOUBLE_ELEMENTS: | 3467 case EXTERNAL_DOUBLE_ELEMENTS: |
3477 case FLOAT32_ELEMENTS: | |
3478 case FLOAT64_ELEMENTS: | |
3479 case FAST_SMI_ELEMENTS: | 3468 case FAST_SMI_ELEMENTS: |
3480 case FAST_ELEMENTS: | 3469 case FAST_ELEMENTS: |
3481 case FAST_DOUBLE_ELEMENTS: | 3470 case FAST_DOUBLE_ELEMENTS: |
3482 case FAST_HOLEY_SMI_ELEMENTS: | 3471 case FAST_HOLEY_SMI_ELEMENTS: |
3483 case FAST_HOLEY_ELEMENTS: | 3472 case FAST_HOLEY_ELEMENTS: |
3484 case FAST_HOLEY_DOUBLE_ELEMENTS: | 3473 case FAST_HOLEY_DOUBLE_ELEMENTS: |
3485 case DICTIONARY_ELEMENTS: | 3474 case DICTIONARY_ELEMENTS: |
3486 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3475 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3487 UNREACHABLE(); | 3476 UNREACHABLE(); |
3488 break; | 3477 break; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3541 DeoptimizeIf(not_equal, instr->environment()); | 3530 DeoptimizeIf(not_equal, instr->environment()); |
3542 } else { | 3531 } else { |
3543 __ cmp(result, factory()->the_hole_value()); | 3532 __ cmp(result, factory()->the_hole_value()); |
3544 DeoptimizeIf(equal, instr->environment()); | 3533 DeoptimizeIf(equal, instr->environment()); |
3545 } | 3534 } |
3546 } | 3535 } |
3547 } | 3536 } |
3548 | 3537 |
3549 | 3538 |
3550 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { | 3539 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
3551 if (instr->is_typed_elements()) { | 3540 if (instr->is_external()) { |
3552 DoLoadKeyedExternalArray(instr); | 3541 DoLoadKeyedExternalArray(instr); |
3553 } else if (instr->hydrogen()->representation().IsDouble()) { | 3542 } else if (instr->hydrogen()->representation().IsDouble()) { |
3554 DoLoadKeyedFixedDoubleArray(instr); | 3543 DoLoadKeyedFixedDoubleArray(instr); |
3555 } else { | 3544 } else { |
3556 DoLoadKeyedFixedArray(instr); | 3545 DoLoadKeyedFixedArray(instr); |
3557 } | 3546 } |
3558 } | 3547 } |
3559 | 3548 |
3560 | 3549 |
3561 Operand LCodeGen::BuildFastArrayOperand( | 3550 Operand LCodeGen::BuildFastArrayOperand( |
3562 LOperand* elements_pointer, | 3551 LOperand* elements_pointer, |
3563 LOperand* key, | 3552 LOperand* key, |
3564 Representation key_representation, | 3553 Representation key_representation, |
3565 ElementsKind elements_kind, | 3554 ElementsKind elements_kind, |
3566 uint32_t offset, | 3555 uint32_t offset, |
3567 uint32_t additional_index) { | 3556 uint32_t additional_index) { |
3568 Register elements_pointer_reg = ToRegister(elements_pointer); | 3557 Register elements_pointer_reg = ToRegister(elements_pointer); |
3569 int element_shift_size = ElementsKindToShiftSize(elements_kind); | 3558 int element_shift_size = ElementsKindToShiftSize(elements_kind); |
3570 if (IsFixedTypedArrayElementsKind(elements_kind)) { | |
3571 offset += FixedTypedArrayBase::kDataOffset - kHeapObjectTag; | |
3572 } | |
3573 int shift_size = element_shift_size; | 3559 int shift_size = element_shift_size; |
3574 if (key->IsConstantOperand()) { | 3560 if (key->IsConstantOperand()) { |
3575 int constant_value = ToInteger32(LConstantOperand::cast(key)); | 3561 int constant_value = ToInteger32(LConstantOperand::cast(key)); |
3576 if (constant_value & 0xF0000000) { | 3562 if (constant_value & 0xF0000000) { |
3577 Abort(kArrayIndexConstantValueTooBig); | 3563 Abort(kArrayIndexConstantValueTooBig); |
3578 } | 3564 } |
3579 return Operand(elements_pointer_reg, | 3565 return Operand(elements_pointer_reg, |
3580 ((constant_value + additional_index) << shift_size) | 3566 ((constant_value + additional_index) << shift_size) |
3581 + offset); | 3567 + offset); |
3582 } else { | 3568 } else { |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4545 elements_kind)) { | 4531 elements_kind)) { |
4546 __ SmiUntag(ToRegister(key)); | 4532 __ SmiUntag(ToRegister(key)); |
4547 } | 4533 } |
4548 Operand operand(BuildFastArrayOperand( | 4534 Operand operand(BuildFastArrayOperand( |
4549 instr->elements(), | 4535 instr->elements(), |
4550 key, | 4536 key, |
4551 instr->hydrogen()->key()->representation(), | 4537 instr->hydrogen()->key()->representation(), |
4552 elements_kind, | 4538 elements_kind, |
4553 0, | 4539 0, |
4554 instr->additional_index())); | 4540 instr->additional_index())); |
4555 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || | 4541 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
4556 elements_kind == FLOAT32_ELEMENTS) { | |
4557 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { | 4542 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { |
4558 CpuFeatureScope scope(masm(), SSE2); | 4543 CpuFeatureScope scope(masm(), SSE2); |
4559 XMMRegister xmm_scratch = double_scratch0(); | 4544 XMMRegister xmm_scratch = double_scratch0(); |
4560 __ cvtsd2ss(xmm_scratch, ToDoubleRegister(instr->value())); | 4545 __ cvtsd2ss(xmm_scratch, ToDoubleRegister(instr->value())); |
4561 __ movss(operand, xmm_scratch); | 4546 __ movss(operand, xmm_scratch); |
4562 } else { | 4547 } else { |
4563 __ fld(0); | 4548 __ fld(0); |
4564 __ fstp_s(operand); | 4549 __ fstp_s(operand); |
4565 } | 4550 } |
4566 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS || | 4551 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
4567 elements_kind == FLOAT64_ELEMENTS) { | |
4568 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { | 4552 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { |
4569 CpuFeatureScope scope(masm(), SSE2); | 4553 CpuFeatureScope scope(masm(), SSE2); |
4570 __ movsd(operand, ToDoubleRegister(instr->value())); | 4554 __ movsd(operand, ToDoubleRegister(instr->value())); |
4571 } else { | 4555 } else { |
4572 X87Mov(operand, ToX87Register(instr->value())); | 4556 X87Mov(operand, ToX87Register(instr->value())); |
4573 } | 4557 } |
4574 } else { | 4558 } else { |
4575 Register value = ToRegister(instr->value()); | 4559 Register value = ToRegister(instr->value()); |
4576 switch (elements_kind) { | 4560 switch (elements_kind) { |
4577 case EXTERNAL_PIXEL_ELEMENTS: | 4561 case EXTERNAL_PIXEL_ELEMENTS: |
4578 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 4562 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
4579 case EXTERNAL_BYTE_ELEMENTS: | 4563 case EXTERNAL_BYTE_ELEMENTS: |
4580 case UINT8_ELEMENTS: | |
4581 case INT8_ELEMENTS: | |
4582 case UINT8_CLAMPED_ELEMENTS: | |
4583 __ mov_b(operand, value); | 4564 __ mov_b(operand, value); |
4584 break; | 4565 break; |
4585 case EXTERNAL_SHORT_ELEMENTS: | 4566 case EXTERNAL_SHORT_ELEMENTS: |
4586 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 4567 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
4587 case UINT16_ELEMENTS: | |
4588 case INT16_ELEMENTS: | |
4589 __ mov_w(operand, value); | 4568 __ mov_w(operand, value); |
4590 break; | 4569 break; |
4591 case EXTERNAL_INT_ELEMENTS: | 4570 case EXTERNAL_INT_ELEMENTS: |
4592 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 4571 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
4593 case UINT32_ELEMENTS: | |
4594 case INT32_ELEMENTS: | |
4595 __ mov(operand, value); | 4572 __ mov(operand, value); |
4596 break; | 4573 break; |
4597 case EXTERNAL_FLOAT_ELEMENTS: | 4574 case EXTERNAL_FLOAT_ELEMENTS: |
4598 case EXTERNAL_DOUBLE_ELEMENTS: | 4575 case EXTERNAL_DOUBLE_ELEMENTS: |
4599 case FLOAT32_ELEMENTS: | |
4600 case FLOAT64_ELEMENTS: | |
4601 case FAST_SMI_ELEMENTS: | 4576 case FAST_SMI_ELEMENTS: |
4602 case FAST_ELEMENTS: | 4577 case FAST_ELEMENTS: |
4603 case FAST_DOUBLE_ELEMENTS: | 4578 case FAST_DOUBLE_ELEMENTS: |
4604 case FAST_HOLEY_SMI_ELEMENTS: | 4579 case FAST_HOLEY_SMI_ELEMENTS: |
4605 case FAST_HOLEY_ELEMENTS: | 4580 case FAST_HOLEY_ELEMENTS: |
4606 case FAST_HOLEY_DOUBLE_ELEMENTS: | 4581 case FAST_HOLEY_DOUBLE_ELEMENTS: |
4607 case DICTIONARY_ELEMENTS: | 4582 case DICTIONARY_ELEMENTS: |
4608 case NON_STRICT_ARGUMENTS_ELEMENTS: | 4583 case NON_STRICT_ARGUMENTS_ELEMENTS: |
4609 UNREACHABLE(); | 4584 UNREACHABLE(); |
4610 break; | 4585 break; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4728 value, | 4703 value, |
4729 GetSaveFPRegsMode(), | 4704 GetSaveFPRegsMode(), |
4730 EMIT_REMEMBERED_SET, | 4705 EMIT_REMEMBERED_SET, |
4731 check_needed); | 4706 check_needed); |
4732 } | 4707 } |
4733 } | 4708 } |
4734 | 4709 |
4735 | 4710 |
4736 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { | 4711 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
4737 // By cases...external, fast-double, fast | 4712 // By cases...external, fast-double, fast |
4738 if (instr->is_typed_elements()) { | 4713 if (instr->is_external()) { |
4739 DoStoreKeyedExternalArray(instr); | 4714 DoStoreKeyedExternalArray(instr); |
4740 } else if (instr->hydrogen()->value()->representation().IsDouble()) { | 4715 } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
4741 DoStoreKeyedFixedDoubleArray(instr); | 4716 DoStoreKeyedFixedDoubleArray(instr); |
4742 } else { | 4717 } else { |
4743 DoStoreKeyedFixedArray(instr); | 4718 DoStoreKeyedFixedArray(instr); |
4744 } | 4719 } |
4745 } | 4720 } |
4746 | 4721 |
4747 | 4722 |
4748 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 4723 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6376 FixedArray::kHeaderSize - kPointerSize)); | 6351 FixedArray::kHeaderSize - kPointerSize)); |
6377 __ bind(&done); | 6352 __ bind(&done); |
6378 } | 6353 } |
6379 | 6354 |
6380 | 6355 |
6381 #undef __ | 6356 #undef __ |
6382 | 6357 |
6383 } } // namespace v8::internal | 6358 } } // namespace v8::internal |
6384 | 6359 |
6385 #endif // V8_TARGET_ARCH_IA32 | 6360 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |