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