OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3337 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), | 3337 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), |
3338 elements_kind)) { | 3338 elements_kind)) { |
3339 __ SmiUntag(ToRegister(key)); | 3339 __ SmiUntag(ToRegister(key)); |
3340 } | 3340 } |
3341 Operand operand(BuildFastArrayOperand( | 3341 Operand operand(BuildFastArrayOperand( |
3342 instr->elements(), | 3342 instr->elements(), |
3343 key, | 3343 key, |
3344 instr->hydrogen()->key()->representation(), | 3344 instr->hydrogen()->key()->representation(), |
3345 elements_kind, | 3345 elements_kind, |
3346 instr->base_offset())); | 3346 instr->base_offset())); |
3347 if (elements_kind == FLOAT32_ELEMENTS) { | 3347 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || |
| 3348 elements_kind == FLOAT32_ELEMENTS) { |
3348 X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); | 3349 X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); |
3349 } else if (elements_kind == FLOAT64_ELEMENTS) { | 3350 } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || |
| 3351 elements_kind == FLOAT64_ELEMENTS) { |
3350 X87Mov(ToX87Register(instr->result()), operand); | 3352 X87Mov(ToX87Register(instr->result()), operand); |
3351 } else { | 3353 } else { |
3352 Register result(ToRegister(instr->result())); | 3354 Register result(ToRegister(instr->result())); |
3353 switch (elements_kind) { | 3355 switch (elements_kind) { |
| 3356 case EXTERNAL_INT8_ELEMENTS: |
3354 case INT8_ELEMENTS: | 3357 case INT8_ELEMENTS: |
3355 __ movsx_b(result, operand); | 3358 __ movsx_b(result, operand); |
3356 break; | 3359 break; |
| 3360 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: |
| 3361 case EXTERNAL_UINT8_ELEMENTS: |
3357 case UINT8_ELEMENTS: | 3362 case UINT8_ELEMENTS: |
3358 case UINT8_CLAMPED_ELEMENTS: | 3363 case UINT8_CLAMPED_ELEMENTS: |
3359 __ movzx_b(result, operand); | 3364 __ movzx_b(result, operand); |
3360 break; | 3365 break; |
| 3366 case EXTERNAL_INT16_ELEMENTS: |
3361 case INT16_ELEMENTS: | 3367 case INT16_ELEMENTS: |
3362 __ movsx_w(result, operand); | 3368 __ movsx_w(result, operand); |
3363 break; | 3369 break; |
| 3370 case EXTERNAL_UINT16_ELEMENTS: |
3364 case UINT16_ELEMENTS: | 3371 case UINT16_ELEMENTS: |
3365 __ movzx_w(result, operand); | 3372 __ movzx_w(result, operand); |
3366 break; | 3373 break; |
| 3374 case EXTERNAL_INT32_ELEMENTS: |
3367 case INT32_ELEMENTS: | 3375 case INT32_ELEMENTS: |
3368 __ mov(result, operand); | 3376 __ mov(result, operand); |
3369 break; | 3377 break; |
| 3378 case EXTERNAL_UINT32_ELEMENTS: |
3370 case UINT32_ELEMENTS: | 3379 case UINT32_ELEMENTS: |
3371 __ mov(result, operand); | 3380 __ mov(result, operand); |
3372 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { | 3381 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
3373 __ test(result, Operand(result)); | 3382 __ test(result, Operand(result)); |
3374 DeoptimizeIf(negative, instr, Deoptimizer::kNegativeValue); | 3383 DeoptimizeIf(negative, instr, Deoptimizer::kNegativeValue); |
3375 } | 3384 } |
3376 break; | 3385 break; |
| 3386 case EXTERNAL_FLOAT32_ELEMENTS: |
| 3387 case EXTERNAL_FLOAT64_ELEMENTS: |
3377 case FLOAT32_ELEMENTS: | 3388 case FLOAT32_ELEMENTS: |
3378 case FLOAT64_ELEMENTS: | 3389 case FLOAT64_ELEMENTS: |
3379 case FAST_SMI_ELEMENTS: | 3390 case FAST_SMI_ELEMENTS: |
3380 case FAST_ELEMENTS: | 3391 case FAST_ELEMENTS: |
3381 case FAST_DOUBLE_ELEMENTS: | 3392 case FAST_DOUBLE_ELEMENTS: |
3382 case FAST_HOLEY_SMI_ELEMENTS: | 3393 case FAST_HOLEY_SMI_ELEMENTS: |
3383 case FAST_HOLEY_ELEMENTS: | 3394 case FAST_HOLEY_ELEMENTS: |
3384 case FAST_HOLEY_DOUBLE_ELEMENTS: | 3395 case FAST_HOLEY_DOUBLE_ELEMENTS: |
3385 case DICTIONARY_ELEMENTS: | 3396 case DICTIONARY_ELEMENTS: |
3386 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 3397 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3445 Immediate(Smi::FromInt(Isolate::kArrayProtectorValid))); | 3456 Immediate(Smi::FromInt(Isolate::kArrayProtectorValid))); |
3446 DeoptimizeIf(not_equal, instr, Deoptimizer::kHole); | 3457 DeoptimizeIf(not_equal, instr, Deoptimizer::kHole); |
3447 } | 3458 } |
3448 __ mov(result, isolate()->factory()->undefined_value()); | 3459 __ mov(result, isolate()->factory()->undefined_value()); |
3449 __ bind(&done); | 3460 __ bind(&done); |
3450 } | 3461 } |
3451 } | 3462 } |
3452 | 3463 |
3453 | 3464 |
3454 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { | 3465 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
3455 if (instr->is_fixed_typed_array()) { | 3466 if (instr->is_typed_elements()) { |
3456 DoLoadKeyedExternalArray(instr); | 3467 DoLoadKeyedExternalArray(instr); |
3457 } else if (instr->hydrogen()->representation().IsDouble()) { | 3468 } else if (instr->hydrogen()->representation().IsDouble()) { |
3458 DoLoadKeyedFixedDoubleArray(instr); | 3469 DoLoadKeyedFixedDoubleArray(instr); |
3459 } else { | 3470 } else { |
3460 DoLoadKeyedFixedArray(instr); | 3471 DoLoadKeyedFixedArray(instr); |
3461 } | 3472 } |
3462 } | 3473 } |
3463 | 3474 |
3464 | 3475 |
3465 Operand LCodeGen::BuildFastArrayOperand( | 3476 Operand LCodeGen::BuildFastArrayOperand( |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4592 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), | 4603 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), |
4593 elements_kind)) { | 4604 elements_kind)) { |
4594 __ SmiUntag(ToRegister(key)); | 4605 __ SmiUntag(ToRegister(key)); |
4595 } | 4606 } |
4596 Operand operand(BuildFastArrayOperand( | 4607 Operand operand(BuildFastArrayOperand( |
4597 instr->elements(), | 4608 instr->elements(), |
4598 key, | 4609 key, |
4599 instr->hydrogen()->key()->representation(), | 4610 instr->hydrogen()->key()->representation(), |
4600 elements_kind, | 4611 elements_kind, |
4601 instr->base_offset())); | 4612 instr->base_offset())); |
4602 if (elements_kind == FLOAT32_ELEMENTS) { | 4613 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || |
| 4614 elements_kind == FLOAT32_ELEMENTS) { |
4603 X87Mov(operand, ToX87Register(instr->value()), kX87FloatOperand); | 4615 X87Mov(operand, ToX87Register(instr->value()), kX87FloatOperand); |
4604 } else if (elements_kind == FLOAT64_ELEMENTS) { | 4616 } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || |
| 4617 elements_kind == FLOAT64_ELEMENTS) { |
4605 uint64_t int_val = kHoleNanInt64; | 4618 uint64_t int_val = kHoleNanInt64; |
4606 int32_t lower = static_cast<int32_t>(int_val); | 4619 int32_t lower = static_cast<int32_t>(int_val); |
4607 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | 4620 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); |
4608 Operand operand2 = BuildFastArrayOperand( | 4621 Operand operand2 = BuildFastArrayOperand( |
4609 instr->elements(), instr->key(), | 4622 instr->elements(), instr->key(), |
4610 instr->hydrogen()->key()->representation(), elements_kind, | 4623 instr->hydrogen()->key()->representation(), elements_kind, |
4611 instr->base_offset() + kPointerSize); | 4624 instr->base_offset() + kPointerSize); |
4612 | 4625 |
4613 Label no_special_nan_handling, done; | 4626 Label no_special_nan_handling, done; |
4614 X87Register value = ToX87Register(instr->value()); | 4627 X87Register value = ToX87Register(instr->value()); |
4615 X87Fxch(value); | 4628 X87Fxch(value); |
4616 __ lea(esp, Operand(esp, -kDoubleSize)); | 4629 __ lea(esp, Operand(esp, -kDoubleSize)); |
4617 __ fst_d(MemOperand(esp, 0)); | 4630 __ fst_d(MemOperand(esp, 0)); |
4618 __ lea(esp, Operand(esp, kDoubleSize)); | 4631 __ lea(esp, Operand(esp, kDoubleSize)); |
4619 int offset = sizeof(kHoleNanUpper32); | 4632 int offset = sizeof(kHoleNanUpper32); |
4620 // x87 converts sNaN(0xfff7fffffff7ffff) to QNaN(0xfffffffffff7ffff), | 4633 // x87 converts sNaN(0xfff7fffffff7ffff) to QNaN(0xfffffffffff7ffff), |
4621 // so we check the upper with 0xffffffff for hole as a temporary fix. | 4634 // so we check the upper with 0xffffffff for hole as a temporary fix. |
4622 __ cmp(MemOperand(esp, -offset), Immediate(0xffffffff)); | 4635 __ cmp(MemOperand(esp, -offset), Immediate(0xffffffff)); |
4623 __ j(not_equal, &no_special_nan_handling, Label::kNear); | 4636 __ j(not_equal, &no_special_nan_handling, Label::kNear); |
4624 __ mov(operand, Immediate(lower)); | 4637 __ mov(operand, Immediate(lower)); |
4625 __ mov(operand2, Immediate(upper)); | 4638 __ mov(operand2, Immediate(upper)); |
4626 __ jmp(&done, Label::kNear); | 4639 __ jmp(&done, Label::kNear); |
4627 | 4640 |
4628 __ bind(&no_special_nan_handling); | 4641 __ bind(&no_special_nan_handling); |
4629 __ fst_d(operand); | 4642 __ fst_d(operand); |
4630 __ bind(&done); | 4643 __ bind(&done); |
4631 } else { | 4644 } else { |
4632 Register value = ToRegister(instr->value()); | 4645 Register value = ToRegister(instr->value()); |
4633 switch (elements_kind) { | 4646 switch (elements_kind) { |
| 4647 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: |
| 4648 case EXTERNAL_UINT8_ELEMENTS: |
| 4649 case EXTERNAL_INT8_ELEMENTS: |
4634 case UINT8_ELEMENTS: | 4650 case UINT8_ELEMENTS: |
4635 case INT8_ELEMENTS: | 4651 case INT8_ELEMENTS: |
4636 case UINT8_CLAMPED_ELEMENTS: | 4652 case UINT8_CLAMPED_ELEMENTS: |
4637 __ mov_b(operand, value); | 4653 __ mov_b(operand, value); |
4638 break; | 4654 break; |
| 4655 case EXTERNAL_INT16_ELEMENTS: |
| 4656 case EXTERNAL_UINT16_ELEMENTS: |
4639 case UINT16_ELEMENTS: | 4657 case UINT16_ELEMENTS: |
4640 case INT16_ELEMENTS: | 4658 case INT16_ELEMENTS: |
4641 __ mov_w(operand, value); | 4659 __ mov_w(operand, value); |
4642 break; | 4660 break; |
| 4661 case EXTERNAL_INT32_ELEMENTS: |
| 4662 case EXTERNAL_UINT32_ELEMENTS: |
4643 case UINT32_ELEMENTS: | 4663 case UINT32_ELEMENTS: |
4644 case INT32_ELEMENTS: | 4664 case INT32_ELEMENTS: |
4645 __ mov(operand, value); | 4665 __ mov(operand, value); |
4646 break; | 4666 break; |
| 4667 case EXTERNAL_FLOAT32_ELEMENTS: |
| 4668 case EXTERNAL_FLOAT64_ELEMENTS: |
4647 case FLOAT32_ELEMENTS: | 4669 case FLOAT32_ELEMENTS: |
4648 case FLOAT64_ELEMENTS: | 4670 case FLOAT64_ELEMENTS: |
4649 case FAST_SMI_ELEMENTS: | 4671 case FAST_SMI_ELEMENTS: |
4650 case FAST_ELEMENTS: | 4672 case FAST_ELEMENTS: |
4651 case FAST_DOUBLE_ELEMENTS: | 4673 case FAST_DOUBLE_ELEMENTS: |
4652 case FAST_HOLEY_SMI_ELEMENTS: | 4674 case FAST_HOLEY_SMI_ELEMENTS: |
4653 case FAST_HOLEY_ELEMENTS: | 4675 case FAST_HOLEY_ELEMENTS: |
4654 case FAST_HOLEY_DOUBLE_ELEMENTS: | 4676 case FAST_HOLEY_DOUBLE_ELEMENTS: |
4655 case DICTIONARY_ELEMENTS: | 4677 case DICTIONARY_ELEMENTS: |
4656 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 4678 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4752 __ lea(key, operand); | 4774 __ lea(key, operand); |
4753 __ RecordWrite(elements, key, value, kSaveFPRegs, EMIT_REMEMBERED_SET, | 4775 __ RecordWrite(elements, key, value, kSaveFPRegs, EMIT_REMEMBERED_SET, |
4754 check_needed, | 4776 check_needed, |
4755 instr->hydrogen()->PointersToHereCheckForValue()); | 4777 instr->hydrogen()->PointersToHereCheckForValue()); |
4756 } | 4778 } |
4757 } | 4779 } |
4758 | 4780 |
4759 | 4781 |
4760 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { | 4782 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
4761 // By cases...external, fast-double, fast | 4783 // By cases...external, fast-double, fast |
4762 if (instr->is_fixed_typed_array()) { | 4784 if (instr->is_typed_elements()) { |
4763 DoStoreKeyedExternalArray(instr); | 4785 DoStoreKeyedExternalArray(instr); |
4764 } else if (instr->hydrogen()->value()->representation().IsDouble()) { | 4786 } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
4765 DoStoreKeyedFixedDoubleArray(instr); | 4787 DoStoreKeyedFixedDoubleArray(instr); |
4766 } else { | 4788 } else { |
4767 DoStoreKeyedFixedArray(instr); | 4789 DoStoreKeyedFixedArray(instr); |
4768 } | 4790 } |
4769 } | 4791 } |
4770 | 4792 |
4771 | 4793 |
4772 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 4794 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6461 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6483 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6462 } | 6484 } |
6463 | 6485 |
6464 | 6486 |
6465 #undef __ | 6487 #undef __ |
6466 | 6488 |
6467 } // namespace internal | 6489 } // namespace internal |
6468 } // namespace v8 | 6490 } // namespace v8 |
6469 | 6491 |
6470 #endif // V8_TARGET_ARCH_X87 | 6492 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |