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 3322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3333 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), | 3333 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), |
3334 elements_kind)) { | 3334 elements_kind)) { |
3335 __ SmiUntag(ToRegister(key)); | 3335 __ SmiUntag(ToRegister(key)); |
3336 } | 3336 } |
3337 Operand operand(BuildFastArrayOperand( | 3337 Operand operand(BuildFastArrayOperand( |
3338 instr->elements(), | 3338 instr->elements(), |
3339 key, | 3339 key, |
3340 instr->hydrogen()->key()->representation(), | 3340 instr->hydrogen()->key()->representation(), |
3341 elements_kind, | 3341 elements_kind, |
3342 instr->base_offset())); | 3342 instr->base_offset())); |
3343 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || | 3343 if (elements_kind == FLOAT32_ELEMENTS) { |
3344 elements_kind == FLOAT32_ELEMENTS) { | |
3345 X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); | 3344 X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); |
3346 } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || | 3345 } else if (elements_kind == FLOAT64_ELEMENTS) { |
3347 elements_kind == FLOAT64_ELEMENTS) { | |
3348 X87Mov(ToX87Register(instr->result()), operand); | 3346 X87Mov(ToX87Register(instr->result()), operand); |
3349 } else { | 3347 } else { |
3350 Register result(ToRegister(instr->result())); | 3348 Register result(ToRegister(instr->result())); |
3351 switch (elements_kind) { | 3349 switch (elements_kind) { |
3352 case EXTERNAL_INT8_ELEMENTS: | |
3353 case INT8_ELEMENTS: | 3350 case INT8_ELEMENTS: |
3354 __ movsx_b(result, operand); | 3351 __ movsx_b(result, operand); |
3355 break; | 3352 break; |
3356 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: | |
3357 case EXTERNAL_UINT8_ELEMENTS: | |
3358 case UINT8_ELEMENTS: | 3353 case UINT8_ELEMENTS: |
3359 case UINT8_CLAMPED_ELEMENTS: | 3354 case UINT8_CLAMPED_ELEMENTS: |
3360 __ movzx_b(result, operand); | 3355 __ movzx_b(result, operand); |
3361 break; | 3356 break; |
3362 case EXTERNAL_INT16_ELEMENTS: | |
3363 case INT16_ELEMENTS: | 3357 case INT16_ELEMENTS: |
3364 __ movsx_w(result, operand); | 3358 __ movsx_w(result, operand); |
3365 break; | 3359 break; |
3366 case EXTERNAL_UINT16_ELEMENTS: | |
3367 case UINT16_ELEMENTS: | 3360 case UINT16_ELEMENTS: |
3368 __ movzx_w(result, operand); | 3361 __ movzx_w(result, operand); |
3369 break; | 3362 break; |
3370 case EXTERNAL_INT32_ELEMENTS: | |
3371 case INT32_ELEMENTS: | 3363 case INT32_ELEMENTS: |
3372 __ mov(result, operand); | 3364 __ mov(result, operand); |
3373 break; | 3365 break; |
3374 case EXTERNAL_UINT32_ELEMENTS: | |
3375 case UINT32_ELEMENTS: | 3366 case UINT32_ELEMENTS: |
3376 __ mov(result, operand); | 3367 __ mov(result, operand); |
3377 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { | 3368 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
3378 __ test(result, Operand(result)); | 3369 __ test(result, Operand(result)); |
3379 DeoptimizeIf(negative, instr, Deoptimizer::kNegativeValue); | 3370 DeoptimizeIf(negative, instr, Deoptimizer::kNegativeValue); |
3380 } | 3371 } |
3381 break; | 3372 break; |
3382 case EXTERNAL_FLOAT32_ELEMENTS: | |
3383 case EXTERNAL_FLOAT64_ELEMENTS: | |
3384 case FLOAT32_ELEMENTS: | 3373 case FLOAT32_ELEMENTS: |
3385 case FLOAT64_ELEMENTS: | 3374 case FLOAT64_ELEMENTS: |
3386 case FAST_SMI_ELEMENTS: | 3375 case FAST_SMI_ELEMENTS: |
3387 case FAST_ELEMENTS: | 3376 case FAST_ELEMENTS: |
3388 case FAST_DOUBLE_ELEMENTS: | 3377 case FAST_DOUBLE_ELEMENTS: |
3389 case FAST_HOLEY_SMI_ELEMENTS: | 3378 case FAST_HOLEY_SMI_ELEMENTS: |
3390 case FAST_HOLEY_ELEMENTS: | 3379 case FAST_HOLEY_ELEMENTS: |
3391 case FAST_HOLEY_DOUBLE_ELEMENTS: | 3380 case FAST_HOLEY_DOUBLE_ELEMENTS: |
3392 case DICTIONARY_ELEMENTS: | 3381 case DICTIONARY_ELEMENTS: |
3393 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 3382 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3452 Immediate(Smi::FromInt(Isolate::kArrayProtectorValid))); | 3441 Immediate(Smi::FromInt(Isolate::kArrayProtectorValid))); |
3453 DeoptimizeIf(not_equal, instr, Deoptimizer::kHole); | 3442 DeoptimizeIf(not_equal, instr, Deoptimizer::kHole); |
3454 } | 3443 } |
3455 __ mov(result, isolate()->factory()->undefined_value()); | 3444 __ mov(result, isolate()->factory()->undefined_value()); |
3456 __ bind(&done); | 3445 __ bind(&done); |
3457 } | 3446 } |
3458 } | 3447 } |
3459 | 3448 |
3460 | 3449 |
3461 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { | 3450 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
3462 if (instr->is_typed_elements()) { | 3451 if (instr->is_fixed_typed_array()) { |
3463 DoLoadKeyedExternalArray(instr); | 3452 DoLoadKeyedExternalArray(instr); |
3464 } else if (instr->hydrogen()->representation().IsDouble()) { | 3453 } else if (instr->hydrogen()->representation().IsDouble()) { |
3465 DoLoadKeyedFixedDoubleArray(instr); | 3454 DoLoadKeyedFixedDoubleArray(instr); |
3466 } else { | 3455 } else { |
3467 DoLoadKeyedFixedArray(instr); | 3456 DoLoadKeyedFixedArray(instr); |
3468 } | 3457 } |
3469 } | 3458 } |
3470 | 3459 |
3471 | 3460 |
3472 Operand LCodeGen::BuildFastArrayOperand( | 3461 Operand LCodeGen::BuildFastArrayOperand( |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4591 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), | 4580 ExternalArrayOpRequiresTemp(instr->hydrogen()->key()->representation(), |
4592 elements_kind)) { | 4581 elements_kind)) { |
4593 __ SmiUntag(ToRegister(key)); | 4582 __ SmiUntag(ToRegister(key)); |
4594 } | 4583 } |
4595 Operand operand(BuildFastArrayOperand( | 4584 Operand operand(BuildFastArrayOperand( |
4596 instr->elements(), | 4585 instr->elements(), |
4597 key, | 4586 key, |
4598 instr->hydrogen()->key()->representation(), | 4587 instr->hydrogen()->key()->representation(), |
4599 elements_kind, | 4588 elements_kind, |
4600 instr->base_offset())); | 4589 instr->base_offset())); |
4601 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || | 4590 if (elements_kind == FLOAT32_ELEMENTS) { |
4602 elements_kind == FLOAT32_ELEMENTS) { | |
4603 X87Mov(operand, ToX87Register(instr->value()), kX87FloatOperand); | 4591 X87Mov(operand, ToX87Register(instr->value()), kX87FloatOperand); |
4604 } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || | 4592 } else if (elements_kind == FLOAT64_ELEMENTS) { |
4605 elements_kind == FLOAT64_ELEMENTS) { | |
4606 uint64_t int_val = kHoleNanInt64; | 4593 uint64_t int_val = kHoleNanInt64; |
4607 int32_t lower = static_cast<int32_t>(int_val); | 4594 int32_t lower = static_cast<int32_t>(int_val); |
4608 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | 4595 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); |
4609 Operand operand2 = BuildFastArrayOperand( | 4596 Operand operand2 = BuildFastArrayOperand( |
4610 instr->elements(), instr->key(), | 4597 instr->elements(), instr->key(), |
4611 instr->hydrogen()->key()->representation(), elements_kind, | 4598 instr->hydrogen()->key()->representation(), elements_kind, |
4612 instr->base_offset() + kPointerSize); | 4599 instr->base_offset() + kPointerSize); |
4613 | 4600 |
4614 Label no_special_nan_handling, done; | 4601 Label no_special_nan_handling, done; |
4615 X87Register value = ToX87Register(instr->value()); | 4602 X87Register value = ToX87Register(instr->value()); |
4616 X87Fxch(value); | 4603 X87Fxch(value); |
4617 __ lea(esp, Operand(esp, -kDoubleSize)); | 4604 __ lea(esp, Operand(esp, -kDoubleSize)); |
4618 __ fst_d(MemOperand(esp, 0)); | 4605 __ fst_d(MemOperand(esp, 0)); |
4619 __ lea(esp, Operand(esp, kDoubleSize)); | 4606 __ lea(esp, Operand(esp, kDoubleSize)); |
4620 int offset = sizeof(kHoleNanUpper32); | 4607 int offset = sizeof(kHoleNanUpper32); |
4621 // x87 converts sNaN(0xfff7fffffff7ffff) to QNaN(0xfffffffffff7ffff), | 4608 // x87 converts sNaN(0xfff7fffffff7ffff) to QNaN(0xfffffffffff7ffff), |
4622 // so we check the upper with 0xffffffff for hole as a temporary fix. | 4609 // so we check the upper with 0xffffffff for hole as a temporary fix. |
4623 __ cmp(MemOperand(esp, -offset), Immediate(0xffffffff)); | 4610 __ cmp(MemOperand(esp, -offset), Immediate(0xffffffff)); |
4624 __ j(not_equal, &no_special_nan_handling, Label::kNear); | 4611 __ j(not_equal, &no_special_nan_handling, Label::kNear); |
4625 __ mov(operand, Immediate(lower)); | 4612 __ mov(operand, Immediate(lower)); |
4626 __ mov(operand2, Immediate(upper)); | 4613 __ mov(operand2, Immediate(upper)); |
4627 __ jmp(&done, Label::kNear); | 4614 __ jmp(&done, Label::kNear); |
4628 | 4615 |
4629 __ bind(&no_special_nan_handling); | 4616 __ bind(&no_special_nan_handling); |
4630 __ fst_d(operand); | 4617 __ fst_d(operand); |
4631 __ bind(&done); | 4618 __ bind(&done); |
4632 } else { | 4619 } else { |
4633 Register value = ToRegister(instr->value()); | 4620 Register value = ToRegister(instr->value()); |
4634 switch (elements_kind) { | 4621 switch (elements_kind) { |
4635 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: | |
4636 case EXTERNAL_UINT8_ELEMENTS: | |
4637 case EXTERNAL_INT8_ELEMENTS: | |
4638 case UINT8_ELEMENTS: | 4622 case UINT8_ELEMENTS: |
4639 case INT8_ELEMENTS: | 4623 case INT8_ELEMENTS: |
4640 case UINT8_CLAMPED_ELEMENTS: | 4624 case UINT8_CLAMPED_ELEMENTS: |
4641 __ mov_b(operand, value); | 4625 __ mov_b(operand, value); |
4642 break; | 4626 break; |
4643 case EXTERNAL_INT16_ELEMENTS: | |
4644 case EXTERNAL_UINT16_ELEMENTS: | |
4645 case UINT16_ELEMENTS: | 4627 case UINT16_ELEMENTS: |
4646 case INT16_ELEMENTS: | 4628 case INT16_ELEMENTS: |
4647 __ mov_w(operand, value); | 4629 __ mov_w(operand, value); |
4648 break; | 4630 break; |
4649 case EXTERNAL_INT32_ELEMENTS: | |
4650 case EXTERNAL_UINT32_ELEMENTS: | |
4651 case UINT32_ELEMENTS: | 4631 case UINT32_ELEMENTS: |
4652 case INT32_ELEMENTS: | 4632 case INT32_ELEMENTS: |
4653 __ mov(operand, value); | 4633 __ mov(operand, value); |
4654 break; | 4634 break; |
4655 case EXTERNAL_FLOAT32_ELEMENTS: | |
4656 case EXTERNAL_FLOAT64_ELEMENTS: | |
4657 case FLOAT32_ELEMENTS: | 4635 case FLOAT32_ELEMENTS: |
4658 case FLOAT64_ELEMENTS: | 4636 case FLOAT64_ELEMENTS: |
4659 case FAST_SMI_ELEMENTS: | 4637 case FAST_SMI_ELEMENTS: |
4660 case FAST_ELEMENTS: | 4638 case FAST_ELEMENTS: |
4661 case FAST_DOUBLE_ELEMENTS: | 4639 case FAST_DOUBLE_ELEMENTS: |
4662 case FAST_HOLEY_SMI_ELEMENTS: | 4640 case FAST_HOLEY_SMI_ELEMENTS: |
4663 case FAST_HOLEY_ELEMENTS: | 4641 case FAST_HOLEY_ELEMENTS: |
4664 case FAST_HOLEY_DOUBLE_ELEMENTS: | 4642 case FAST_HOLEY_DOUBLE_ELEMENTS: |
4665 case DICTIONARY_ELEMENTS: | 4643 case DICTIONARY_ELEMENTS: |
4666 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 4644 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4762 __ lea(key, operand); | 4740 __ lea(key, operand); |
4763 __ RecordWrite(elements, key, value, kSaveFPRegs, EMIT_REMEMBERED_SET, | 4741 __ RecordWrite(elements, key, value, kSaveFPRegs, EMIT_REMEMBERED_SET, |
4764 check_needed, | 4742 check_needed, |
4765 instr->hydrogen()->PointersToHereCheckForValue()); | 4743 instr->hydrogen()->PointersToHereCheckForValue()); |
4766 } | 4744 } |
4767 } | 4745 } |
4768 | 4746 |
4769 | 4747 |
4770 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { | 4748 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
4771 // By cases...external, fast-double, fast | 4749 // By cases...external, fast-double, fast |
4772 if (instr->is_typed_elements()) { | 4750 if (instr->is_fixed_typed_array()) { |
4773 DoStoreKeyedExternalArray(instr); | 4751 DoStoreKeyedExternalArray(instr); |
4774 } else if (instr->hydrogen()->value()->representation().IsDouble()) { | 4752 } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
4775 DoStoreKeyedFixedDoubleArray(instr); | 4753 DoStoreKeyedFixedDoubleArray(instr); |
4776 } else { | 4754 } else { |
4777 DoStoreKeyedFixedArray(instr); | 4755 DoStoreKeyedFixedArray(instr); |
4778 } | 4756 } |
4779 } | 4757 } |
4780 | 4758 |
4781 | 4759 |
4782 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 4760 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6471 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6449 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6472 } | 6450 } |
6473 | 6451 |
6474 | 6452 |
6475 #undef __ | 6453 #undef __ |
6476 | 6454 |
6477 } // namespace internal | 6455 } // namespace internal |
6478 } // namespace v8 | 6456 } // namespace v8 |
6479 | 6457 |
6480 #endif // V8_TARGET_ARCH_X87 | 6458 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |