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 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 __ bind(&with_write_barrier); | 1578 __ bind(&with_write_barrier); |
1579 | 1579 |
1580 __ lw(a3, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 1580 __ lw(a3, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
1581 | 1581 |
1582 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { | 1582 if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { |
1583 Label fast_object, not_fast_object; | 1583 Label fast_object, not_fast_object; |
1584 __ CheckFastObjectElements(a3, t3, ¬_fast_object); | 1584 __ CheckFastObjectElements(a3, t3, ¬_fast_object); |
1585 __ jmp(&fast_object); | 1585 __ jmp(&fast_object); |
1586 // In case of fast smi-only, convert to fast object, otherwise bail out. | 1586 // In case of fast smi-only, convert to fast object, otherwise bail out. |
1587 __ bind(¬_fast_object); | 1587 __ bind(¬_fast_object); |
1588 __ CheckFastSmiElements(a3, t3, &call_builtin); | 1588 __ CheckFastSmiOnlyElements(a3, t3, &call_builtin); |
1589 // edx: receiver | 1589 // edx: receiver |
1590 // r3: map | 1590 // r3: map |
1591 Label try_holey_map; | 1591 __ LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, |
1592 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, | |
1593 FAST_ELEMENTS, | 1592 FAST_ELEMENTS, |
1594 a3, | 1593 a3, |
1595 t3, | 1594 t3, |
1596 &try_holey_map); | |
1597 __ mov(a2, receiver); | |
1598 ElementsTransitionGenerator:: | |
1599 GenerateMapChangeElementsTransition(masm()); | |
1600 __ jmp(&fast_object); | |
1601 | |
1602 __ bind(&try_holey_map); | |
1603 __ LoadTransitionedArrayMapConditional(FAST_HOLEY_SMI_ELEMENTS, | |
1604 FAST_HOLEY_ELEMENTS, | |
1605 a3, | |
1606 t3, | |
1607 &call_builtin); | 1595 &call_builtin); |
1608 __ mov(a2, receiver); | 1596 __ mov(a2, receiver); |
1609 ElementsTransitionGenerator:: | 1597 ElementsTransitionGenerator::GenerateSmiOnlyToObject(masm()); |
1610 GenerateMapChangeElementsTransition(masm()); | |
1611 __ bind(&fast_object); | 1598 __ bind(&fast_object); |
1612 } else { | 1599 } else { |
1613 __ CheckFastObjectElements(a3, a3, &call_builtin); | 1600 __ CheckFastObjectElements(a3, a3, &call_builtin); |
1614 } | 1601 } |
1615 | 1602 |
1616 // Save new length. | 1603 // Save new length. |
1617 __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 1604 __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
1618 | 1605 |
1619 // Store the value. | 1606 // Store the value. |
1620 // We may need a register containing the address end_elements below, | 1607 // We may need a register containing the address end_elements below, |
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3378 return true; | 3365 return true; |
3379 | 3366 |
3380 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3367 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3381 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3368 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
3382 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3369 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3383 case EXTERNAL_PIXEL_ELEMENTS: | 3370 case EXTERNAL_PIXEL_ELEMENTS: |
3384 return false; | 3371 return false; |
3385 | 3372 |
3386 case EXTERNAL_FLOAT_ELEMENTS: | 3373 case EXTERNAL_FLOAT_ELEMENTS: |
3387 case EXTERNAL_DOUBLE_ELEMENTS: | 3374 case EXTERNAL_DOUBLE_ELEMENTS: |
3388 case FAST_SMI_ELEMENTS: | 3375 case FAST_SMI_ONLY_ELEMENTS: |
3389 case FAST_ELEMENTS: | 3376 case FAST_ELEMENTS: |
3390 case FAST_DOUBLE_ELEMENTS: | 3377 case FAST_DOUBLE_ELEMENTS: |
3391 case FAST_HOLEY_SMI_ELEMENTS: | |
3392 case FAST_HOLEY_ELEMENTS: | |
3393 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
3394 case DICTIONARY_ELEMENTS: | 3378 case DICTIONARY_ELEMENTS: |
3395 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3379 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3396 UNREACHABLE(); | 3380 UNREACHABLE(); |
3397 return false; | 3381 return false; |
3398 } | 3382 } |
3399 return false; | 3383 return false; |
3400 } | 3384 } |
3401 | 3385 |
3402 | 3386 |
3403 static void GenerateSmiKeyCheck(MacroAssembler* masm, | 3387 static void GenerateSmiKeyCheck(MacroAssembler* masm, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 if (CpuFeatures::IsSupported(FPU)) { | 3501 if (CpuFeatures::IsSupported(FPU)) { |
3518 CpuFeatures::Scope scope(FPU); | 3502 CpuFeatures::Scope scope(FPU); |
3519 __ ldc1(f0, MemOperand(t3, 0)); | 3503 __ ldc1(f0, MemOperand(t3, 0)); |
3520 } else { | 3504 } else { |
3521 // t3: pointer to the beginning of the double we want to load. | 3505 // t3: pointer to the beginning of the double we want to load. |
3522 __ lw(a2, MemOperand(t3, 0)); | 3506 __ lw(a2, MemOperand(t3, 0)); |
3523 __ lw(a3, MemOperand(t3, Register::kSizeInBytes)); | 3507 __ lw(a3, MemOperand(t3, Register::kSizeInBytes)); |
3524 } | 3508 } |
3525 break; | 3509 break; |
3526 case FAST_ELEMENTS: | 3510 case FAST_ELEMENTS: |
3527 case FAST_SMI_ELEMENTS: | 3511 case FAST_SMI_ONLY_ELEMENTS: |
3528 case FAST_DOUBLE_ELEMENTS: | 3512 case FAST_DOUBLE_ELEMENTS: |
3529 case FAST_HOLEY_ELEMENTS: | |
3530 case FAST_HOLEY_SMI_ELEMENTS: | |
3531 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
3532 case DICTIONARY_ELEMENTS: | 3513 case DICTIONARY_ELEMENTS: |
3533 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3514 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3534 UNREACHABLE(); | 3515 UNREACHABLE(); |
3535 break; | 3516 break; |
3536 } | 3517 } |
3537 | 3518 |
3538 // For integer array types: | 3519 // For integer array types: |
3539 // a2: value | 3520 // a2: value |
3540 // For float array type: | 3521 // For float array type: |
3541 // f0: value (if FPU is supported) | 3522 // f0: value (if FPU is supported) |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3881 t0, f2); // These are: scratch2, single_scratch. | 3862 t0, f2); // These are: scratch2, single_scratch. |
3882 if (destination == FloatingPointHelper::kFPURegisters) { | 3863 if (destination == FloatingPointHelper::kFPURegisters) { |
3883 CpuFeatures::Scope scope(FPU); | 3864 CpuFeatures::Scope scope(FPU); |
3884 __ sdc1(f0, MemOperand(a3, 0)); | 3865 __ sdc1(f0, MemOperand(a3, 0)); |
3885 } else { | 3866 } else { |
3886 __ sw(t2, MemOperand(a3, 0)); | 3867 __ sw(t2, MemOperand(a3, 0)); |
3887 __ sw(t3, MemOperand(a3, Register::kSizeInBytes)); | 3868 __ sw(t3, MemOperand(a3, Register::kSizeInBytes)); |
3888 } | 3869 } |
3889 break; | 3870 break; |
3890 case FAST_ELEMENTS: | 3871 case FAST_ELEMENTS: |
3891 case FAST_SMI_ELEMENTS: | 3872 case FAST_SMI_ONLY_ELEMENTS: |
3892 case FAST_DOUBLE_ELEMENTS: | 3873 case FAST_DOUBLE_ELEMENTS: |
3893 case FAST_HOLEY_ELEMENTS: | |
3894 case FAST_HOLEY_SMI_ELEMENTS: | |
3895 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
3896 case DICTIONARY_ELEMENTS: | 3874 case DICTIONARY_ELEMENTS: |
3897 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3875 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3898 UNREACHABLE(); | 3876 UNREACHABLE(); |
3899 break; | 3877 break; |
3900 } | 3878 } |
3901 | 3879 |
3902 // Entry registers are intact, a0 holds the value which is the return value. | 3880 // Entry registers are intact, a0 holds the value which is the return value. |
3903 __ mov(v0, a0); | 3881 __ mov(v0, a0); |
3904 __ Ret(); | 3882 __ Ret(); |
3905 | 3883 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3949 case EXTERNAL_INT_ELEMENTS: | 3927 case EXTERNAL_INT_ELEMENTS: |
3950 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3928 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
3951 __ sll(t8, key, 1); | 3929 __ sll(t8, key, 1); |
3952 __ addu(t8, a3, t8); | 3930 __ addu(t8, a3, t8); |
3953 __ sw(t3, MemOperand(t8, 0)); | 3931 __ sw(t3, MemOperand(t8, 0)); |
3954 break; | 3932 break; |
3955 case EXTERNAL_PIXEL_ELEMENTS: | 3933 case EXTERNAL_PIXEL_ELEMENTS: |
3956 case EXTERNAL_FLOAT_ELEMENTS: | 3934 case EXTERNAL_FLOAT_ELEMENTS: |
3957 case EXTERNAL_DOUBLE_ELEMENTS: | 3935 case EXTERNAL_DOUBLE_ELEMENTS: |
3958 case FAST_ELEMENTS: | 3936 case FAST_ELEMENTS: |
3959 case FAST_SMI_ELEMENTS: | 3937 case FAST_SMI_ONLY_ELEMENTS: |
3960 case FAST_DOUBLE_ELEMENTS: | 3938 case FAST_DOUBLE_ELEMENTS: |
3961 case FAST_HOLEY_ELEMENTS: | |
3962 case FAST_HOLEY_SMI_ELEMENTS: | |
3963 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
3964 case DICTIONARY_ELEMENTS: | 3939 case DICTIONARY_ELEMENTS: |
3965 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3940 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3966 UNREACHABLE(); | 3941 UNREACHABLE(); |
3967 break; | 3942 break; |
3968 } | 3943 } |
3969 } | 3944 } |
3970 | 3945 |
3971 // Entry registers are intact, a0 holds the value | 3946 // Entry registers are intact, a0 holds the value |
3972 // which is the return value. | 3947 // which is the return value. |
3973 __ mov(v0, a0); | 3948 __ mov(v0, a0); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 case EXTERNAL_INT_ELEMENTS: | 4099 case EXTERNAL_INT_ELEMENTS: |
4125 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 4100 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
4126 __ sll(t8, key, 1); | 4101 __ sll(t8, key, 1); |
4127 __ addu(t8, a3, t8); | 4102 __ addu(t8, a3, t8); |
4128 __ sw(t3, MemOperand(t8, 0)); | 4103 __ sw(t3, MemOperand(t8, 0)); |
4129 break; | 4104 break; |
4130 case EXTERNAL_PIXEL_ELEMENTS: | 4105 case EXTERNAL_PIXEL_ELEMENTS: |
4131 case EXTERNAL_FLOAT_ELEMENTS: | 4106 case EXTERNAL_FLOAT_ELEMENTS: |
4132 case EXTERNAL_DOUBLE_ELEMENTS: | 4107 case EXTERNAL_DOUBLE_ELEMENTS: |
4133 case FAST_ELEMENTS: | 4108 case FAST_ELEMENTS: |
4134 case FAST_SMI_ELEMENTS: | 4109 case FAST_SMI_ONLY_ELEMENTS: |
4135 case FAST_DOUBLE_ELEMENTS: | 4110 case FAST_DOUBLE_ELEMENTS: |
4136 case FAST_HOLEY_ELEMENTS: | |
4137 case FAST_HOLEY_SMI_ELEMENTS: | |
4138 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
4139 case DICTIONARY_ELEMENTS: | 4111 case DICTIONARY_ELEMENTS: |
4140 case NON_STRICT_ARGUMENTS_ELEMENTS: | 4112 case NON_STRICT_ARGUMENTS_ELEMENTS: |
4141 UNREACHABLE(); | 4113 UNREACHABLE(); |
4142 break; | 4114 break; |
4143 } | 4115 } |
4144 } | 4116 } |
4145 } | 4117 } |
4146 } | 4118 } |
4147 | 4119 |
4148 // Slow case, key and receiver still in a0 and a1. | 4120 // Slow case, key and receiver still in a0 and a1. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4307 Register elements_reg = a3; | 4279 Register elements_reg = a3; |
4308 Register length_reg = t1; | 4280 Register length_reg = t1; |
4309 Register scratch2 = t2; | 4281 Register scratch2 = t2; |
4310 | 4282 |
4311 // This stub is meant to be tail-jumped to, the receiver must already | 4283 // This stub is meant to be tail-jumped to, the receiver must already |
4312 // have been verified by the caller to not be a smi. | 4284 // have been verified by the caller to not be a smi. |
4313 | 4285 |
4314 // Check that the key is a smi or a heap number convertible to a smi. | 4286 // Check that the key is a smi or a heap number convertible to a smi. |
4315 GenerateSmiKeyCheck(masm, key_reg, t0, t1, f2, &miss_force_generic); | 4287 GenerateSmiKeyCheck(masm, key_reg, t0, t1, f2, &miss_force_generic); |
4316 | 4288 |
4317 if (IsFastSmiElementsKind(elements_kind)) { | 4289 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
4318 __ JumpIfNotSmi(value_reg, &transition_elements_kind); | 4290 __ JumpIfNotSmi(value_reg, &transition_elements_kind); |
4319 } | 4291 } |
4320 | 4292 |
4321 // Check that the key is within bounds. | 4293 // Check that the key is within bounds. |
4322 __ lw(elements_reg, | 4294 __ lw(elements_reg, |
4323 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); | 4295 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); |
4324 if (is_js_array) { | 4296 if (is_js_array) { |
4325 __ lw(scratch, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); | 4297 __ lw(scratch, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); |
4326 } else { | 4298 } else { |
4327 __ lw(scratch, FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); | 4299 __ lw(scratch, FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); |
4328 } | 4300 } |
4329 // Compare smis. | 4301 // Compare smis. |
4330 if (is_js_array && grow_mode == ALLOW_JSARRAY_GROWTH) { | 4302 if (is_js_array && grow_mode == ALLOW_JSARRAY_GROWTH) { |
4331 __ Branch(&grow, hs, key_reg, Operand(scratch)); | 4303 __ Branch(&grow, hs, key_reg, Operand(scratch)); |
4332 } else { | 4304 } else { |
4333 __ Branch(&miss_force_generic, hs, key_reg, Operand(scratch)); | 4305 __ Branch(&miss_force_generic, hs, key_reg, Operand(scratch)); |
4334 } | 4306 } |
4335 | 4307 |
4336 // Make sure elements is a fast element array, not 'cow'. | 4308 // Make sure elements is a fast element array, not 'cow'. |
4337 __ CheckMap(elements_reg, | 4309 __ CheckMap(elements_reg, |
4338 scratch, | 4310 scratch, |
4339 Heap::kFixedArrayMapRootIndex, | 4311 Heap::kFixedArrayMapRootIndex, |
4340 &miss_force_generic, | 4312 &miss_force_generic, |
4341 DONT_DO_SMI_CHECK); | 4313 DONT_DO_SMI_CHECK); |
4342 | 4314 |
4343 __ bind(&finish_store); | 4315 __ bind(&finish_store); |
4344 | 4316 |
4345 if (IsFastSmiElementsKind(elements_kind)) { | 4317 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
4346 __ Addu(scratch, | 4318 __ Addu(scratch, |
4347 elements_reg, | 4319 elements_reg, |
4348 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 4320 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
4349 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); | 4321 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); |
4350 __ sll(scratch2, key_reg, kPointerSizeLog2 - kSmiTagSize); | 4322 __ sll(scratch2, key_reg, kPointerSizeLog2 - kSmiTagSize); |
4351 __ Addu(scratch, scratch, scratch2); | 4323 __ Addu(scratch, scratch, scratch2); |
4352 __ sw(value_reg, MemOperand(scratch)); | 4324 __ sw(value_reg, MemOperand(scratch)); |
4353 } else { | 4325 } else { |
4354 ASSERT(IsFastObjectElementsKind(elements_kind)); | 4326 ASSERT(elements_kind == FAST_ELEMENTS); |
4355 __ Addu(scratch, | 4327 __ Addu(scratch, |
4356 elements_reg, | 4328 elements_reg, |
4357 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 4329 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
4358 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); | 4330 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); |
4359 __ sll(scratch2, key_reg, kPointerSizeLog2 - kSmiTagSize); | 4331 __ sll(scratch2, key_reg, kPointerSizeLog2 - kSmiTagSize); |
4360 __ Addu(scratch, scratch, scratch2); | 4332 __ Addu(scratch, scratch, scratch2); |
4361 __ sw(value_reg, MemOperand(scratch)); | 4333 __ sw(value_reg, MemOperand(scratch)); |
4362 __ mov(receiver_reg, value_reg); | 4334 __ mov(receiver_reg, value_reg); |
| 4335 ASSERT(elements_kind == FAST_ELEMENTS); |
4363 __ RecordWrite(elements_reg, // Object. | 4336 __ RecordWrite(elements_reg, // Object. |
4364 scratch, // Address. | 4337 scratch, // Address. |
4365 receiver_reg, // Value. | 4338 receiver_reg, // Value. |
4366 kRAHasNotBeenSaved, | 4339 kRAHasNotBeenSaved, |
4367 kDontSaveFPRegs); | 4340 kDontSaveFPRegs); |
4368 } | 4341 } |
4369 // value_reg (a0) is preserved. | 4342 // value_reg (a0) is preserved. |
4370 // Done. | 4343 // Done. |
4371 __ Ret(); | 4344 __ Ret(); |
4372 | 4345 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4591 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4564 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
4592 } | 4565 } |
4593 } | 4566 } |
4594 | 4567 |
4595 | 4568 |
4596 #undef __ | 4569 #undef __ |
4597 | 4570 |
4598 } } // namespace v8::internal | 4571 } } // namespace v8::internal |
4599 | 4572 |
4600 #endif // V8_TARGET_ARCH_MIPS | 4573 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |