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 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 __ cmp(result, scratch); | 2604 __ cmp(result, scratch); |
2605 DeoptimizeIf(eq, instr->environment()); | 2605 DeoptimizeIf(eq, instr->environment()); |
2606 } | 2606 } |
2607 } | 2607 } |
2608 | 2608 |
2609 | 2609 |
2610 void LCodeGen::DoLoadKeyedSpecializedArrayElement( | 2610 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
2611 LLoadKeyedSpecializedArrayElement* instr) { | 2611 LLoadKeyedSpecializedArrayElement* instr) { |
2612 Register external_pointer = ToRegister(instr->external_pointer()); | 2612 Register external_pointer = ToRegister(instr->external_pointer()); |
2613 Register key = no_reg; | 2613 Register key = no_reg; |
2614 ExternalArrayType array_type = instr->array_type(); | 2614 JSObject::ElementsKind elements_kind = instr->elements_kind(); |
2615 bool key_is_constant = instr->key()->IsConstantOperand(); | 2615 bool key_is_constant = instr->key()->IsConstantOperand(); |
2616 int constant_key = 0; | 2616 int constant_key = 0; |
2617 if (key_is_constant) { | 2617 if (key_is_constant) { |
2618 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); | 2618 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); |
2619 if (constant_key & 0xF0000000) { | 2619 if (constant_key & 0xF0000000) { |
2620 Abort("array index constant value too big."); | 2620 Abort("array index constant value too big."); |
2621 } | 2621 } |
2622 } else { | 2622 } else { |
2623 key = ToRegister(instr->key()); | 2623 key = ToRegister(instr->key()); |
2624 } | 2624 } |
2625 int shift_size = ExternalArrayTypeToShiftSize(array_type); | 2625 int shift_size = ElementsKindToShiftSize(elements_kind); |
2626 | 2626 |
2627 if (array_type == kExternalFloatArray || array_type == kExternalDoubleArray) { | 2627 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || |
| 2628 elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { |
2628 CpuFeatures::Scope scope(VFP3); | 2629 CpuFeatures::Scope scope(VFP3); |
2629 DwVfpRegister result(ToDoubleRegister(instr->result())); | 2630 DwVfpRegister result(ToDoubleRegister(instr->result())); |
2630 Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) | 2631 Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) |
2631 : Operand(key, LSL, shift_size)); | 2632 : Operand(key, LSL, shift_size)); |
2632 __ add(scratch0(), external_pointer, operand); | 2633 __ add(scratch0(), external_pointer, operand); |
2633 if (array_type == kExternalFloatArray) { | 2634 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { |
2634 __ vldr(result.low(), scratch0(), 0); | 2635 __ vldr(result.low(), scratch0(), 0); |
2635 __ vcvt_f64_f32(result, result.low()); | 2636 __ vcvt_f64_f32(result, result.low()); |
2636 } else { // i.e. array_type == kExternalDoubleArray | 2637 } else { // i.e. elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS |
2637 __ vldr(result, scratch0(), 0); | 2638 __ vldr(result, scratch0(), 0); |
2638 } | 2639 } |
2639 } else { | 2640 } else { |
2640 Register result(ToRegister(instr->result())); | 2641 Register result(ToRegister(instr->result())); |
2641 MemOperand mem_operand(key_is_constant | 2642 MemOperand mem_operand(key_is_constant |
2642 ? MemOperand(external_pointer, constant_key * (1 << shift_size)) | 2643 ? MemOperand(external_pointer, constant_key * (1 << shift_size)) |
2643 : MemOperand(external_pointer, key, LSL, shift_size)); | 2644 : MemOperand(external_pointer, key, LSL, shift_size)); |
2644 switch (array_type) { | 2645 switch (elements_kind) { |
2645 case kExternalByteArray: | 2646 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
2646 __ ldrsb(result, mem_operand); | 2647 __ ldrsb(result, mem_operand); |
2647 break; | 2648 break; |
2648 case kExternalUnsignedByteArray: | 2649 case JSObject::EXTERNAL_PIXEL_ELEMENTS: |
2649 case kExternalPixelArray: | 2650 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
2650 __ ldrb(result, mem_operand); | 2651 __ ldrb(result, mem_operand); |
2651 break; | 2652 break; |
2652 case kExternalShortArray: | 2653 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
2653 __ ldrsh(result, mem_operand); | 2654 __ ldrsh(result, mem_operand); |
2654 break; | 2655 break; |
2655 case kExternalUnsignedShortArray: | 2656 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
2656 __ ldrh(result, mem_operand); | 2657 __ ldrh(result, mem_operand); |
2657 break; | 2658 break; |
2658 case kExternalIntArray: | 2659 case JSObject::EXTERNAL_INT_ELEMENTS: |
2659 __ ldr(result, mem_operand); | 2660 __ ldr(result, mem_operand); |
2660 break; | 2661 break; |
2661 case kExternalUnsignedIntArray: | 2662 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2662 __ ldr(result, mem_operand); | 2663 __ ldr(result, mem_operand); |
2663 __ cmp(result, Operand(0x80000000)); | 2664 __ cmp(result, Operand(0x80000000)); |
2664 // TODO(danno): we could be more clever here, perhaps having a special | 2665 // TODO(danno): we could be more clever here, perhaps having a special |
2665 // version of the stub that detects if the overflow case actually | 2666 // version of the stub that detects if the overflow case actually |
2666 // happens, and generate code that returns a double rather than int. | 2667 // happens, and generate code that returns a double rather than int. |
2667 DeoptimizeIf(cs, instr->environment()); | 2668 DeoptimizeIf(cs, instr->environment()); |
2668 break; | 2669 break; |
2669 case kExternalFloatArray: | 2670 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
2670 case kExternalDoubleArray: | 2671 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: |
| 2672 case JSObject::FAST_DOUBLE_ELEMENTS: |
| 2673 case JSObject::FAST_ELEMENTS: |
| 2674 case JSObject::DICTIONARY_ELEMENTS: |
2671 UNREACHABLE(); | 2675 UNREACHABLE(); |
2672 break; | 2676 break; |
2673 } | 2677 } |
2674 } | 2678 } |
2675 } | 2679 } |
2676 | 2680 |
2677 | 2681 |
2678 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { | 2682 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
2679 ASSERT(ToRegister(instr->object()).is(r1)); | 2683 ASSERT(ToRegister(instr->object()).is(r1)); |
2680 ASSERT(ToRegister(instr->key()).is(r0)); | 2684 ASSERT(ToRegister(instr->key()).is(r0)); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 __ RecordWrite(elements, key, value); | 3420 __ RecordWrite(elements, key, value); |
3417 } | 3421 } |
3418 } | 3422 } |
3419 | 3423 |
3420 | 3424 |
3421 void LCodeGen::DoStoreKeyedSpecializedArrayElement( | 3425 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
3422 LStoreKeyedSpecializedArrayElement* instr) { | 3426 LStoreKeyedSpecializedArrayElement* instr) { |
3423 | 3427 |
3424 Register external_pointer = ToRegister(instr->external_pointer()); | 3428 Register external_pointer = ToRegister(instr->external_pointer()); |
3425 Register key = no_reg; | 3429 Register key = no_reg; |
3426 ExternalArrayType array_type = instr->array_type(); | 3430 JSObject::ElementsKind elements_kind = instr->elements_kind(); |
3427 bool key_is_constant = instr->key()->IsConstantOperand(); | 3431 bool key_is_constant = instr->key()->IsConstantOperand(); |
3428 int constant_key = 0; | 3432 int constant_key = 0; |
3429 if (key_is_constant) { | 3433 if (key_is_constant) { |
3430 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); | 3434 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); |
3431 if (constant_key & 0xF0000000) { | 3435 if (constant_key & 0xF0000000) { |
3432 Abort("array index constant value too big."); | 3436 Abort("array index constant value too big."); |
3433 } | 3437 } |
3434 } else { | 3438 } else { |
3435 key = ToRegister(instr->key()); | 3439 key = ToRegister(instr->key()); |
3436 } | 3440 } |
3437 int shift_size = ExternalArrayTypeToShiftSize(array_type); | 3441 int shift_size = ElementsKindToShiftSize(elements_kind); |
3438 | 3442 |
3439 if (array_type == kExternalFloatArray || array_type == kExternalDoubleArray) { | 3443 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || |
| 3444 elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { |
3440 CpuFeatures::Scope scope(VFP3); | 3445 CpuFeatures::Scope scope(VFP3); |
3441 DwVfpRegister value(ToDoubleRegister(instr->value())); | 3446 DwVfpRegister value(ToDoubleRegister(instr->value())); |
3442 Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) | 3447 Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) |
3443 : Operand(key, LSL, shift_size)); | 3448 : Operand(key, LSL, shift_size)); |
3444 __ add(scratch0(), external_pointer, operand); | 3449 __ add(scratch0(), external_pointer, operand); |
3445 if (array_type == kExternalFloatArray) { | 3450 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { |
3446 __ vcvt_f32_f64(double_scratch0().low(), value); | 3451 __ vcvt_f32_f64(double_scratch0().low(), value); |
3447 __ vstr(double_scratch0().low(), scratch0(), 0); | 3452 __ vstr(double_scratch0().low(), scratch0(), 0); |
3448 } else { // i.e. array_type == kExternalDoubleArray | 3453 } else { // i.e. elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS |
3449 __ vstr(value, scratch0(), 0); | 3454 __ vstr(value, scratch0(), 0); |
3450 } | 3455 } |
3451 } else { | 3456 } else { |
3452 Register value(ToRegister(instr->value())); | 3457 Register value(ToRegister(instr->value())); |
3453 MemOperand mem_operand(key_is_constant | 3458 MemOperand mem_operand(key_is_constant |
3454 ? MemOperand(external_pointer, constant_key * (1 << shift_size)) | 3459 ? MemOperand(external_pointer, constant_key * (1 << shift_size)) |
3455 : MemOperand(external_pointer, key, LSL, shift_size)); | 3460 : MemOperand(external_pointer, key, LSL, shift_size)); |
3456 switch (array_type) { | 3461 switch (elements_kind) { |
3457 case kExternalPixelArray: | 3462 case JSObject::EXTERNAL_PIXEL_ELEMENTS: |
3458 case kExternalByteArray: | 3463 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
3459 case kExternalUnsignedByteArray: | 3464 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3460 __ strb(value, mem_operand); | 3465 __ strb(value, mem_operand); |
3461 break; | 3466 break; |
3462 case kExternalShortArray: | 3467 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
3463 case kExternalUnsignedShortArray: | 3468 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
3464 __ strh(value, mem_operand); | 3469 __ strh(value, mem_operand); |
3465 break; | 3470 break; |
3466 case kExternalIntArray: | 3471 case JSObject::EXTERNAL_INT_ELEMENTS: |
3467 case kExternalUnsignedIntArray: | 3472 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3468 __ str(value, mem_operand); | 3473 __ str(value, mem_operand); |
3469 break; | 3474 break; |
3470 case kExternalFloatArray: | 3475 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
3471 case kExternalDoubleArray: | 3476 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: |
| 3477 case JSObject::FAST_DOUBLE_ELEMENTS: |
| 3478 case JSObject::FAST_ELEMENTS: |
| 3479 case JSObject::DICTIONARY_ELEMENTS: |
3472 UNREACHABLE(); | 3480 UNREACHABLE(); |
3473 break; | 3481 break; |
3474 } | 3482 } |
3475 } | 3483 } |
3476 } | 3484 } |
3477 | 3485 |
3478 | 3486 |
3479 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 3487 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
3480 ASSERT(ToRegister(instr->object()).is(r2)); | 3488 ASSERT(ToRegister(instr->object()).is(r2)); |
3481 ASSERT(ToRegister(instr->key()).is(r1)); | 3489 ASSERT(ToRegister(instr->key()).is(r1)); |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4571 ASSERT(osr_pc_offset_ == -1); | 4579 ASSERT(osr_pc_offset_ == -1); |
4572 osr_pc_offset_ = masm()->pc_offset(); | 4580 osr_pc_offset_ = masm()->pc_offset(); |
4573 } | 4581 } |
4574 | 4582 |
4575 | 4583 |
4576 | 4584 |
4577 | 4585 |
4578 #undef __ | 4586 #undef __ |
4579 | 4587 |
4580 } } // namespace v8::internal | 4588 } } // namespace v8::internal |
OLD | NEW |