OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3286 if (constant_key & 0xF0000000) { | 3286 if (constant_key & 0xF0000000) { |
3287 Abort(kArrayIndexConstantValueTooBig); | 3287 Abort(kArrayIndexConstantValueTooBig); |
3288 } | 3288 } |
3289 } else { | 3289 } else { |
3290 key = ToRegister(instr->key()); | 3290 key = ToRegister(instr->key()); |
3291 } | 3291 } |
3292 int element_size_shift = ElementsKindToShiftSize(elements_kind); | 3292 int element_size_shift = ElementsKindToShiftSize(elements_kind); |
3293 bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); | 3293 bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); |
3294 int base_offset = instr->base_offset(); | 3294 int base_offset = instr->base_offset(); |
3295 | 3295 |
3296 if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { | 3296 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || |
| 3297 elements_kind == FLOAT32_ELEMENTS || |
| 3298 elements_kind == EXTERNAL_FLOAT64_ELEMENTS || |
| 3299 elements_kind == FLOAT64_ELEMENTS) { |
3297 DoubleRegister result = ToDoubleRegister(instr->result()); | 3300 DoubleRegister result = ToDoubleRegister(instr->result()); |
3298 if (key_is_constant) { | 3301 if (key_is_constant) { |
3299 __ Add(scratch0(), external_pointer, constant_key << element_size_shift, | 3302 __ Add(scratch0(), external_pointer, constant_key << element_size_shift, |
3300 r0); | 3303 r0); |
3301 } else { | 3304 } else { |
3302 __ IndexToArrayOffset(r0, key, element_size_shift, key_is_smi); | 3305 __ IndexToArrayOffset(r0, key, element_size_shift, key_is_smi); |
3303 __ add(scratch0(), external_pointer, r0); | 3306 __ add(scratch0(), external_pointer, r0); |
3304 } | 3307 } |
3305 if (elements_kind == FLOAT32_ELEMENTS) { | 3308 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || |
| 3309 elements_kind == FLOAT32_ELEMENTS) { |
3306 __ lfs(result, MemOperand(scratch0(), base_offset)); | 3310 __ lfs(result, MemOperand(scratch0(), base_offset)); |
3307 } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS | 3311 } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS |
3308 __ lfd(result, MemOperand(scratch0(), base_offset)); | 3312 __ lfd(result, MemOperand(scratch0(), base_offset)); |
3309 } | 3313 } |
3310 } else { | 3314 } else { |
3311 Register result = ToRegister(instr->result()); | 3315 Register result = ToRegister(instr->result()); |
3312 MemOperand mem_operand = | 3316 MemOperand mem_operand = |
3313 PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi, | 3317 PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi, |
3314 constant_key, element_size_shift, base_offset); | 3318 constant_key, element_size_shift, base_offset); |
3315 switch (elements_kind) { | 3319 switch (elements_kind) { |
| 3320 case EXTERNAL_INT8_ELEMENTS: |
3316 case INT8_ELEMENTS: | 3321 case INT8_ELEMENTS: |
3317 if (key_is_constant) { | 3322 if (key_is_constant) { |
3318 __ LoadByte(result, mem_operand, r0); | 3323 __ LoadByte(result, mem_operand, r0); |
3319 } else { | 3324 } else { |
3320 __ lbzx(result, mem_operand); | 3325 __ lbzx(result, mem_operand); |
3321 } | 3326 } |
3322 __ extsb(result, result); | 3327 __ extsb(result, result); |
3323 break; | 3328 break; |
| 3329 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: |
| 3330 case EXTERNAL_UINT8_ELEMENTS: |
3324 case UINT8_ELEMENTS: | 3331 case UINT8_ELEMENTS: |
3325 case UINT8_CLAMPED_ELEMENTS: | 3332 case UINT8_CLAMPED_ELEMENTS: |
3326 if (key_is_constant) { | 3333 if (key_is_constant) { |
3327 __ LoadByte(result, mem_operand, r0); | 3334 __ LoadByte(result, mem_operand, r0); |
3328 } else { | 3335 } else { |
3329 __ lbzx(result, mem_operand); | 3336 __ lbzx(result, mem_operand); |
3330 } | 3337 } |
3331 break; | 3338 break; |
| 3339 case EXTERNAL_INT16_ELEMENTS: |
3332 case INT16_ELEMENTS: | 3340 case INT16_ELEMENTS: |
3333 if (key_is_constant) { | 3341 if (key_is_constant) { |
3334 __ LoadHalfWordArith(result, mem_operand, r0); | 3342 __ LoadHalfWordArith(result, mem_operand, r0); |
3335 } else { | 3343 } else { |
3336 __ lhax(result, mem_operand); | 3344 __ lhax(result, mem_operand); |
3337 } | 3345 } |
3338 break; | 3346 break; |
| 3347 case EXTERNAL_UINT16_ELEMENTS: |
3339 case UINT16_ELEMENTS: | 3348 case UINT16_ELEMENTS: |
3340 if (key_is_constant) { | 3349 if (key_is_constant) { |
3341 __ LoadHalfWord(result, mem_operand, r0); | 3350 __ LoadHalfWord(result, mem_operand, r0); |
3342 } else { | 3351 } else { |
3343 __ lhzx(result, mem_operand); | 3352 __ lhzx(result, mem_operand); |
3344 } | 3353 } |
3345 break; | 3354 break; |
| 3355 case EXTERNAL_INT32_ELEMENTS: |
3346 case INT32_ELEMENTS: | 3356 case INT32_ELEMENTS: |
3347 if (key_is_constant) { | 3357 if (key_is_constant) { |
3348 __ LoadWordArith(result, mem_operand, r0); | 3358 __ LoadWordArith(result, mem_operand, r0); |
3349 } else { | 3359 } else { |
3350 __ lwax(result, mem_operand); | 3360 __ lwax(result, mem_operand); |
3351 } | 3361 } |
3352 break; | 3362 break; |
| 3363 case EXTERNAL_UINT32_ELEMENTS: |
3353 case UINT32_ELEMENTS: | 3364 case UINT32_ELEMENTS: |
3354 if (key_is_constant) { | 3365 if (key_is_constant) { |
3355 __ LoadWord(result, mem_operand, r0); | 3366 __ LoadWord(result, mem_operand, r0); |
3356 } else { | 3367 } else { |
3357 __ lwzx(result, mem_operand); | 3368 __ lwzx(result, mem_operand); |
3358 } | 3369 } |
3359 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { | 3370 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
3360 __ lis(r0, Operand(SIGN_EXT_IMM16(0x8000))); | 3371 __ lis(r0, Operand(SIGN_EXT_IMM16(0x8000))); |
3361 __ cmplw(result, r0); | 3372 __ cmplw(result, r0); |
3362 DeoptimizeIf(ge, instr, Deoptimizer::kNegativeValue); | 3373 DeoptimizeIf(ge, instr, Deoptimizer::kNegativeValue); |
3363 } | 3374 } |
3364 break; | 3375 break; |
3365 case FLOAT32_ELEMENTS: | 3376 case FLOAT32_ELEMENTS: |
3366 case FLOAT64_ELEMENTS: | 3377 case FLOAT64_ELEMENTS: |
| 3378 case EXTERNAL_FLOAT32_ELEMENTS: |
| 3379 case EXTERNAL_FLOAT64_ELEMENTS: |
3367 case FAST_HOLEY_DOUBLE_ELEMENTS: | 3380 case FAST_HOLEY_DOUBLE_ELEMENTS: |
3368 case FAST_HOLEY_ELEMENTS: | 3381 case FAST_HOLEY_ELEMENTS: |
3369 case FAST_HOLEY_SMI_ELEMENTS: | 3382 case FAST_HOLEY_SMI_ELEMENTS: |
3370 case FAST_DOUBLE_ELEMENTS: | 3383 case FAST_DOUBLE_ELEMENTS: |
3371 case FAST_ELEMENTS: | 3384 case FAST_ELEMENTS: |
3372 case FAST_SMI_ELEMENTS: | 3385 case FAST_SMI_ELEMENTS: |
3373 case DICTIONARY_ELEMENTS: | 3386 case DICTIONARY_ELEMENTS: |
3374 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 3387 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
3375 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: | 3388 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: |
3376 UNREACHABLE(); | 3389 UNREACHABLE(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3493 __ CmpSmiLiteral(result, Smi::FromInt(Isolate::kArrayProtectorValid), r0); | 3506 __ CmpSmiLiteral(result, Smi::FromInt(Isolate::kArrayProtectorValid), r0); |
3494 DeoptimizeIf(ne, instr, Deoptimizer::kHole); | 3507 DeoptimizeIf(ne, instr, Deoptimizer::kHole); |
3495 } | 3508 } |
3496 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | 3509 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
3497 __ bind(&done); | 3510 __ bind(&done); |
3498 } | 3511 } |
3499 } | 3512 } |
3500 | 3513 |
3501 | 3514 |
3502 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { | 3515 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
3503 if (instr->is_fixed_typed_array()) { | 3516 if (instr->is_typed_elements()) { |
3504 DoLoadKeyedExternalArray(instr); | 3517 DoLoadKeyedExternalArray(instr); |
3505 } else if (instr->hydrogen()->representation().IsDouble()) { | 3518 } else if (instr->hydrogen()->representation().IsDouble()) { |
3506 DoLoadKeyedFixedDoubleArray(instr); | 3519 DoLoadKeyedFixedDoubleArray(instr); |
3507 } else { | 3520 } else { |
3508 DoLoadKeyedFixedArray(instr); | 3521 DoLoadKeyedFixedArray(instr); |
3509 } | 3522 } |
3510 } | 3523 } |
3511 | 3524 |
3512 | 3525 |
3513 MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base, | 3526 MemOperand LCodeGen::PrepareKeyedOperand(Register key, Register base, |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4540 if (constant_key & 0xF0000000) { | 4553 if (constant_key & 0xF0000000) { |
4541 Abort(kArrayIndexConstantValueTooBig); | 4554 Abort(kArrayIndexConstantValueTooBig); |
4542 } | 4555 } |
4543 } else { | 4556 } else { |
4544 key = ToRegister(instr->key()); | 4557 key = ToRegister(instr->key()); |
4545 } | 4558 } |
4546 int element_size_shift = ElementsKindToShiftSize(elements_kind); | 4559 int element_size_shift = ElementsKindToShiftSize(elements_kind); |
4547 bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); | 4560 bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); |
4548 int base_offset = instr->base_offset(); | 4561 int base_offset = instr->base_offset(); |
4549 | 4562 |
4550 if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { | 4563 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || |
| 4564 elements_kind == FLOAT32_ELEMENTS || |
| 4565 elements_kind == EXTERNAL_FLOAT64_ELEMENTS || |
| 4566 elements_kind == FLOAT64_ELEMENTS) { |
4551 Register address = scratch0(); | 4567 Register address = scratch0(); |
4552 DoubleRegister value(ToDoubleRegister(instr->value())); | 4568 DoubleRegister value(ToDoubleRegister(instr->value())); |
4553 if (key_is_constant) { | 4569 if (key_is_constant) { |
4554 if (constant_key != 0) { | 4570 if (constant_key != 0) { |
4555 __ Add(address, external_pointer, constant_key << element_size_shift, | 4571 __ Add(address, external_pointer, constant_key << element_size_shift, |
4556 r0); | 4572 r0); |
4557 } else { | 4573 } else { |
4558 address = external_pointer; | 4574 address = external_pointer; |
4559 } | 4575 } |
4560 } else { | 4576 } else { |
4561 __ IndexToArrayOffset(r0, key, element_size_shift, key_is_smi); | 4577 __ IndexToArrayOffset(r0, key, element_size_shift, key_is_smi); |
4562 __ add(address, external_pointer, r0); | 4578 __ add(address, external_pointer, r0); |
4563 } | 4579 } |
4564 if (elements_kind == FLOAT32_ELEMENTS) { | 4580 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || |
| 4581 elements_kind == FLOAT32_ELEMENTS) { |
4565 __ frsp(double_scratch0(), value); | 4582 __ frsp(double_scratch0(), value); |
4566 __ stfs(double_scratch0(), MemOperand(address, base_offset)); | 4583 __ stfs(double_scratch0(), MemOperand(address, base_offset)); |
4567 } else { // Storing doubles, not floats. | 4584 } else { // Storing doubles, not floats. |
4568 __ stfd(value, MemOperand(address, base_offset)); | 4585 __ stfd(value, MemOperand(address, base_offset)); |
4569 } | 4586 } |
4570 } else { | 4587 } else { |
4571 Register value(ToRegister(instr->value())); | 4588 Register value(ToRegister(instr->value())); |
4572 MemOperand mem_operand = | 4589 MemOperand mem_operand = |
4573 PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi, | 4590 PrepareKeyedOperand(key, external_pointer, key_is_constant, key_is_smi, |
4574 constant_key, element_size_shift, base_offset); | 4591 constant_key, element_size_shift, base_offset); |
4575 switch (elements_kind) { | 4592 switch (elements_kind) { |
| 4593 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: |
| 4594 case EXTERNAL_INT8_ELEMENTS: |
| 4595 case EXTERNAL_UINT8_ELEMENTS: |
4576 case UINT8_ELEMENTS: | 4596 case UINT8_ELEMENTS: |
4577 case UINT8_CLAMPED_ELEMENTS: | 4597 case UINT8_CLAMPED_ELEMENTS: |
4578 case INT8_ELEMENTS: | 4598 case INT8_ELEMENTS: |
4579 if (key_is_constant) { | 4599 if (key_is_constant) { |
4580 __ StoreByte(value, mem_operand, r0); | 4600 __ StoreByte(value, mem_operand, r0); |
4581 } else { | 4601 } else { |
4582 __ stbx(value, mem_operand); | 4602 __ stbx(value, mem_operand); |
4583 } | 4603 } |
4584 break; | 4604 break; |
| 4605 case EXTERNAL_INT16_ELEMENTS: |
| 4606 case EXTERNAL_UINT16_ELEMENTS: |
4585 case INT16_ELEMENTS: | 4607 case INT16_ELEMENTS: |
4586 case UINT16_ELEMENTS: | 4608 case UINT16_ELEMENTS: |
4587 if (key_is_constant) { | 4609 if (key_is_constant) { |
4588 __ StoreHalfWord(value, mem_operand, r0); | 4610 __ StoreHalfWord(value, mem_operand, r0); |
4589 } else { | 4611 } else { |
4590 __ sthx(value, mem_operand); | 4612 __ sthx(value, mem_operand); |
4591 } | 4613 } |
4592 break; | 4614 break; |
| 4615 case EXTERNAL_INT32_ELEMENTS: |
| 4616 case EXTERNAL_UINT32_ELEMENTS: |
4593 case INT32_ELEMENTS: | 4617 case INT32_ELEMENTS: |
4594 case UINT32_ELEMENTS: | 4618 case UINT32_ELEMENTS: |
4595 if (key_is_constant) { | 4619 if (key_is_constant) { |
4596 __ StoreWord(value, mem_operand, r0); | 4620 __ StoreWord(value, mem_operand, r0); |
4597 } else { | 4621 } else { |
4598 __ stwx(value, mem_operand); | 4622 __ stwx(value, mem_operand); |
4599 } | 4623 } |
4600 break; | 4624 break; |
4601 case FLOAT32_ELEMENTS: | 4625 case FLOAT32_ELEMENTS: |
4602 case FLOAT64_ELEMENTS: | 4626 case FLOAT64_ELEMENTS: |
| 4627 case EXTERNAL_FLOAT32_ELEMENTS: |
| 4628 case EXTERNAL_FLOAT64_ELEMENTS: |
4603 case FAST_DOUBLE_ELEMENTS: | 4629 case FAST_DOUBLE_ELEMENTS: |
4604 case FAST_ELEMENTS: | 4630 case FAST_ELEMENTS: |
4605 case FAST_SMI_ELEMENTS: | 4631 case FAST_SMI_ELEMENTS: |
4606 case FAST_HOLEY_DOUBLE_ELEMENTS: | 4632 case FAST_HOLEY_DOUBLE_ELEMENTS: |
4607 case FAST_HOLEY_ELEMENTS: | 4633 case FAST_HOLEY_ELEMENTS: |
4608 case FAST_HOLEY_SMI_ELEMENTS: | 4634 case FAST_HOLEY_SMI_ELEMENTS: |
4609 case DICTIONARY_ELEMENTS: | 4635 case DICTIONARY_ELEMENTS: |
4610 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 4636 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
4611 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: | 4637 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: |
4612 UNREACHABLE(); | 4638 UNREACHABLE(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4710 __ Add(key, store_base, offset, r0); | 4736 __ Add(key, store_base, offset, r0); |
4711 __ RecordWrite(elements, key, value, GetLinkRegisterState(), kSaveFPRegs, | 4737 __ RecordWrite(elements, key, value, GetLinkRegisterState(), kSaveFPRegs, |
4712 EMIT_REMEMBERED_SET, check_needed, | 4738 EMIT_REMEMBERED_SET, check_needed, |
4713 hinstr->PointersToHereCheckForValue()); | 4739 hinstr->PointersToHereCheckForValue()); |
4714 } | 4740 } |
4715 } | 4741 } |
4716 | 4742 |
4717 | 4743 |
4718 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { | 4744 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
4719 // By cases: external, fast double | 4745 // By cases: external, fast double |
4720 if (instr->is_fixed_typed_array()) { | 4746 if (instr->is_typed_elements()) { |
4721 DoStoreKeyedExternalArray(instr); | 4747 DoStoreKeyedExternalArray(instr); |
4722 } else if (instr->hydrogen()->value()->representation().IsDouble()) { | 4748 } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
4723 DoStoreKeyedFixedDoubleArray(instr); | 4749 DoStoreKeyedFixedDoubleArray(instr); |
4724 } else { | 4750 } else { |
4725 DoStoreKeyedFixedArray(instr); | 4751 DoStoreKeyedFixedArray(instr); |
4726 } | 4752 } |
4727 } | 4753 } |
4728 | 4754 |
4729 | 4755 |
4730 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 4756 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6288 __ Push(scope_info); | 6314 __ Push(scope_info); |
6289 __ push(ToRegister(instr->function())); | 6315 __ push(ToRegister(instr->function())); |
6290 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6316 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6291 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6317 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6292 } | 6318 } |
6293 | 6319 |
6294 | 6320 |
6295 #undef __ | 6321 #undef __ |
6296 } // namespace internal | 6322 } // namespace internal |
6297 } // namespace v8 | 6323 } // namespace v8 |
OLD | NEW |