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 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/cpu-profiler.h" | 9 #include "src/cpu-profiler.h" |
10 #include "src/hydrogen-osr.h" | 10 #include "src/hydrogen-osr.h" |
(...skipping 3211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3222 } | 3222 } |
3223 } else { | 3223 } else { |
3224 key = ToRegister(instr->key()); | 3224 key = ToRegister(instr->key()); |
3225 } | 3225 } |
3226 int element_size_shift = ElementsKindToShiftSize(elements_kind); | 3226 int element_size_shift = ElementsKindToShiftSize(elements_kind); |
3227 int shift_size = (instr->hydrogen()->key()->representation().IsSmi()) | 3227 int shift_size = (instr->hydrogen()->key()->representation().IsSmi()) |
3228 ? (element_size_shift - (kSmiTagSize + kSmiShiftSize)) | 3228 ? (element_size_shift - (kSmiTagSize + kSmiShiftSize)) |
3229 : element_size_shift; | 3229 : element_size_shift; |
3230 int base_offset = instr->base_offset(); | 3230 int base_offset = instr->base_offset(); |
3231 | 3231 |
3232 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || | 3232 if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { |
3233 elements_kind == FLOAT32_ELEMENTS || | |
3234 elements_kind == EXTERNAL_FLOAT64_ELEMENTS || | |
3235 elements_kind == FLOAT64_ELEMENTS) { | |
3236 FPURegister result = ToDoubleRegister(instr->result()); | 3233 FPURegister result = ToDoubleRegister(instr->result()); |
3237 if (key_is_constant) { | 3234 if (key_is_constant) { |
3238 __ Daddu(scratch0(), external_pointer, | 3235 __ Daddu(scratch0(), external_pointer, |
3239 constant_key << element_size_shift); | 3236 constant_key << element_size_shift); |
3240 } else { | 3237 } else { |
3241 if (shift_size < 0) { | 3238 if (shift_size < 0) { |
3242 if (shift_size == -32) { | 3239 if (shift_size == -32) { |
3243 __ dsra32(scratch0(), key, 0); | 3240 __ dsra32(scratch0(), key, 0); |
3244 } else { | 3241 } else { |
3245 __ dsra(scratch0(), key, -shift_size); | 3242 __ dsra(scratch0(), key, -shift_size); |
3246 } | 3243 } |
3247 } else { | 3244 } else { |
3248 __ dsll(scratch0(), key, shift_size); | 3245 __ dsll(scratch0(), key, shift_size); |
3249 } | 3246 } |
3250 __ Daddu(scratch0(), scratch0(), external_pointer); | 3247 __ Daddu(scratch0(), scratch0(), external_pointer); |
3251 } | 3248 } |
3252 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || | 3249 if (elements_kind == FLOAT32_ELEMENTS) { |
3253 elements_kind == FLOAT32_ELEMENTS) { | |
3254 __ lwc1(result, MemOperand(scratch0(), base_offset)); | 3250 __ lwc1(result, MemOperand(scratch0(), base_offset)); |
3255 __ cvt_d_s(result, result); | 3251 __ cvt_d_s(result, result); |
3256 } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS | 3252 } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS |
3257 __ ldc1(result, MemOperand(scratch0(), base_offset)); | 3253 __ ldc1(result, MemOperand(scratch0(), base_offset)); |
3258 } | 3254 } |
3259 } else { | 3255 } else { |
3260 Register result = ToRegister(instr->result()); | 3256 Register result = ToRegister(instr->result()); |
3261 MemOperand mem_operand = PrepareKeyedOperand( | 3257 MemOperand mem_operand = PrepareKeyedOperand( |
3262 key, external_pointer, key_is_constant, constant_key, | 3258 key, external_pointer, key_is_constant, constant_key, |
3263 element_size_shift, shift_size, base_offset); | 3259 element_size_shift, shift_size, base_offset); |
3264 switch (elements_kind) { | 3260 switch (elements_kind) { |
3265 case EXTERNAL_INT8_ELEMENTS: | |
3266 case INT8_ELEMENTS: | 3261 case INT8_ELEMENTS: |
3267 __ lb(result, mem_operand); | 3262 __ lb(result, mem_operand); |
3268 break; | 3263 break; |
3269 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: | |
3270 case EXTERNAL_UINT8_ELEMENTS: | |
3271 case UINT8_ELEMENTS: | 3264 case UINT8_ELEMENTS: |
3272 case UINT8_CLAMPED_ELEMENTS: | 3265 case UINT8_CLAMPED_ELEMENTS: |
3273 __ lbu(result, mem_operand); | 3266 __ lbu(result, mem_operand); |
3274 break; | 3267 break; |
3275 case EXTERNAL_INT16_ELEMENTS: | |
3276 case INT16_ELEMENTS: | 3268 case INT16_ELEMENTS: |
3277 __ lh(result, mem_operand); | 3269 __ lh(result, mem_operand); |
3278 break; | 3270 break; |
3279 case EXTERNAL_UINT16_ELEMENTS: | |
3280 case UINT16_ELEMENTS: | 3271 case UINT16_ELEMENTS: |
3281 __ lhu(result, mem_operand); | 3272 __ lhu(result, mem_operand); |
3282 break; | 3273 break; |
3283 case EXTERNAL_INT32_ELEMENTS: | |
3284 case INT32_ELEMENTS: | 3274 case INT32_ELEMENTS: |
3285 __ lw(result, mem_operand); | 3275 __ lw(result, mem_operand); |
3286 break; | 3276 break; |
3287 case EXTERNAL_UINT32_ELEMENTS: | |
3288 case UINT32_ELEMENTS: | 3277 case UINT32_ELEMENTS: |
3289 __ lw(result, mem_operand); | 3278 __ lw(result, mem_operand); |
3290 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { | 3279 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
3291 DeoptimizeIf(Ugreater_equal, instr, Deoptimizer::kNegativeValue, | 3280 DeoptimizeIf(Ugreater_equal, instr, Deoptimizer::kNegativeValue, |
3292 result, Operand(0x80000000)); | 3281 result, Operand(0x80000000)); |
3293 } | 3282 } |
3294 break; | 3283 break; |
3295 case FLOAT32_ELEMENTS: | 3284 case FLOAT32_ELEMENTS: |
3296 case FLOAT64_ELEMENTS: | 3285 case FLOAT64_ELEMENTS: |
3297 case EXTERNAL_FLOAT32_ELEMENTS: | |
3298 case EXTERNAL_FLOAT64_ELEMENTS: | |
3299 case FAST_DOUBLE_ELEMENTS: | 3286 case FAST_DOUBLE_ELEMENTS: |
3300 case FAST_ELEMENTS: | 3287 case FAST_ELEMENTS: |
3301 case FAST_SMI_ELEMENTS: | 3288 case FAST_SMI_ELEMENTS: |
3302 case FAST_HOLEY_DOUBLE_ELEMENTS: | 3289 case FAST_HOLEY_DOUBLE_ELEMENTS: |
3303 case FAST_HOLEY_ELEMENTS: | 3290 case FAST_HOLEY_ELEMENTS: |
3304 case FAST_HOLEY_SMI_ELEMENTS: | 3291 case FAST_HOLEY_SMI_ELEMENTS: |
3305 case DICTIONARY_ELEMENTS: | 3292 case DICTIONARY_ELEMENTS: |
3306 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 3293 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
3307 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: | 3294 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: |
3308 UNREACHABLE(); | 3295 UNREACHABLE(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3426 DeoptimizeIf(ne, instr, Deoptimizer::kHole, result, | 3413 DeoptimizeIf(ne, instr, Deoptimizer::kHole, result, |
3427 Operand(Smi::FromInt(Isolate::kArrayProtectorValid))); | 3414 Operand(Smi::FromInt(Isolate::kArrayProtectorValid))); |
3428 } | 3415 } |
3429 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | 3416 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
3430 __ bind(&done); | 3417 __ bind(&done); |
3431 } | 3418 } |
3432 } | 3419 } |
3433 | 3420 |
3434 | 3421 |
3435 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { | 3422 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { |
3436 if (instr->is_typed_elements()) { | 3423 if (instr->is_fixed_typed_array()) { |
3437 DoLoadKeyedExternalArray(instr); | 3424 DoLoadKeyedExternalArray(instr); |
3438 } else if (instr->hydrogen()->representation().IsDouble()) { | 3425 } else if (instr->hydrogen()->representation().IsDouble()) { |
3439 DoLoadKeyedFixedDoubleArray(instr); | 3426 DoLoadKeyedFixedDoubleArray(instr); |
3440 } else { | 3427 } else { |
3441 DoLoadKeyedFixedArray(instr); | 3428 DoLoadKeyedFixedArray(instr); |
3442 } | 3429 } |
3443 } | 3430 } |
3444 | 3431 |
3445 | 3432 |
3446 MemOperand LCodeGen::PrepareKeyedOperand(Register key, | 3433 MemOperand LCodeGen::PrepareKeyedOperand(Register key, |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4452 } | 4439 } |
4453 } else { | 4440 } else { |
4454 key = ToRegister(instr->key()); | 4441 key = ToRegister(instr->key()); |
4455 } | 4442 } |
4456 int element_size_shift = ElementsKindToShiftSize(elements_kind); | 4443 int element_size_shift = ElementsKindToShiftSize(elements_kind); |
4457 int shift_size = (instr->hydrogen()->key()->representation().IsSmi()) | 4444 int shift_size = (instr->hydrogen()->key()->representation().IsSmi()) |
4458 ? (element_size_shift - (kSmiTagSize + kSmiShiftSize)) | 4445 ? (element_size_shift - (kSmiTagSize + kSmiShiftSize)) |
4459 : element_size_shift; | 4446 : element_size_shift; |
4460 int base_offset = instr->base_offset(); | 4447 int base_offset = instr->base_offset(); |
4461 | 4448 |
4462 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || | 4449 if (elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { |
4463 elements_kind == FLOAT32_ELEMENTS || | |
4464 elements_kind == EXTERNAL_FLOAT64_ELEMENTS || | |
4465 elements_kind == FLOAT64_ELEMENTS) { | |
4466 Register address = scratch0(); | 4450 Register address = scratch0(); |
4467 FPURegister value(ToDoubleRegister(instr->value())); | 4451 FPURegister value(ToDoubleRegister(instr->value())); |
4468 if (key_is_constant) { | 4452 if (key_is_constant) { |
4469 if (constant_key != 0) { | 4453 if (constant_key != 0) { |
4470 __ Daddu(address, external_pointer, | 4454 __ Daddu(address, external_pointer, |
4471 Operand(constant_key << element_size_shift)); | 4455 Operand(constant_key << element_size_shift)); |
4472 } else { | 4456 } else { |
4473 address = external_pointer; | 4457 address = external_pointer; |
4474 } | 4458 } |
4475 } else { | 4459 } else { |
4476 if (shift_size < 0) { | 4460 if (shift_size < 0) { |
4477 if (shift_size == -32) { | 4461 if (shift_size == -32) { |
4478 __ dsra32(address, key, 0); | 4462 __ dsra32(address, key, 0); |
4479 } else { | 4463 } else { |
4480 __ dsra(address, key, -shift_size); | 4464 __ dsra(address, key, -shift_size); |
4481 } | 4465 } |
4482 } else { | 4466 } else { |
4483 __ dsll(address, key, shift_size); | 4467 __ dsll(address, key, shift_size); |
4484 } | 4468 } |
4485 __ Daddu(address, external_pointer, address); | 4469 __ Daddu(address, external_pointer, address); |
4486 } | 4470 } |
4487 | 4471 |
4488 if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || | 4472 if (elements_kind == FLOAT32_ELEMENTS) { |
4489 elements_kind == FLOAT32_ELEMENTS) { | |
4490 __ cvt_s_d(double_scratch0(), value); | 4473 __ cvt_s_d(double_scratch0(), value); |
4491 __ swc1(double_scratch0(), MemOperand(address, base_offset)); | 4474 __ swc1(double_scratch0(), MemOperand(address, base_offset)); |
4492 } else { // Storing doubles, not floats. | 4475 } else { // Storing doubles, not floats. |
4493 __ sdc1(value, MemOperand(address, base_offset)); | 4476 __ sdc1(value, MemOperand(address, base_offset)); |
4494 } | 4477 } |
4495 } else { | 4478 } else { |
4496 Register value(ToRegister(instr->value())); | 4479 Register value(ToRegister(instr->value())); |
4497 MemOperand mem_operand = PrepareKeyedOperand( | 4480 MemOperand mem_operand = PrepareKeyedOperand( |
4498 key, external_pointer, key_is_constant, constant_key, | 4481 key, external_pointer, key_is_constant, constant_key, |
4499 element_size_shift, shift_size, | 4482 element_size_shift, shift_size, |
4500 base_offset); | 4483 base_offset); |
4501 switch (elements_kind) { | 4484 switch (elements_kind) { |
4502 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: | |
4503 case EXTERNAL_INT8_ELEMENTS: | |
4504 case EXTERNAL_UINT8_ELEMENTS: | |
4505 case UINT8_ELEMENTS: | 4485 case UINT8_ELEMENTS: |
4506 case UINT8_CLAMPED_ELEMENTS: | 4486 case UINT8_CLAMPED_ELEMENTS: |
4507 case INT8_ELEMENTS: | 4487 case INT8_ELEMENTS: |
4508 __ sb(value, mem_operand); | 4488 __ sb(value, mem_operand); |
4509 break; | 4489 break; |
4510 case EXTERNAL_INT16_ELEMENTS: | |
4511 case EXTERNAL_UINT16_ELEMENTS: | |
4512 case INT16_ELEMENTS: | 4490 case INT16_ELEMENTS: |
4513 case UINT16_ELEMENTS: | 4491 case UINT16_ELEMENTS: |
4514 __ sh(value, mem_operand); | 4492 __ sh(value, mem_operand); |
4515 break; | 4493 break; |
4516 case EXTERNAL_INT32_ELEMENTS: | |
4517 case EXTERNAL_UINT32_ELEMENTS: | |
4518 case INT32_ELEMENTS: | 4494 case INT32_ELEMENTS: |
4519 case UINT32_ELEMENTS: | 4495 case UINT32_ELEMENTS: |
4520 __ sw(value, mem_operand); | 4496 __ sw(value, mem_operand); |
4521 break; | 4497 break; |
4522 case FLOAT32_ELEMENTS: | 4498 case FLOAT32_ELEMENTS: |
4523 case FLOAT64_ELEMENTS: | 4499 case FLOAT64_ELEMENTS: |
4524 case EXTERNAL_FLOAT32_ELEMENTS: | |
4525 case EXTERNAL_FLOAT64_ELEMENTS: | |
4526 case FAST_DOUBLE_ELEMENTS: | 4500 case FAST_DOUBLE_ELEMENTS: |
4527 case FAST_ELEMENTS: | 4501 case FAST_ELEMENTS: |
4528 case FAST_SMI_ELEMENTS: | 4502 case FAST_SMI_ELEMENTS: |
4529 case FAST_HOLEY_DOUBLE_ELEMENTS: | 4503 case FAST_HOLEY_DOUBLE_ELEMENTS: |
4530 case FAST_HOLEY_ELEMENTS: | 4504 case FAST_HOLEY_ELEMENTS: |
4531 case FAST_HOLEY_SMI_ELEMENTS: | 4505 case FAST_HOLEY_SMI_ELEMENTS: |
4532 case DICTIONARY_ELEMENTS: | 4506 case DICTIONARY_ELEMENTS: |
4533 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 4507 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
4534 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: | 4508 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: |
4535 UNREACHABLE(); | 4509 UNREACHABLE(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4642 kSaveFPRegs, | 4616 kSaveFPRegs, |
4643 EMIT_REMEMBERED_SET, | 4617 EMIT_REMEMBERED_SET, |
4644 check_needed, | 4618 check_needed, |
4645 instr->hydrogen()->PointersToHereCheckForValue()); | 4619 instr->hydrogen()->PointersToHereCheckForValue()); |
4646 } | 4620 } |
4647 } | 4621 } |
4648 | 4622 |
4649 | 4623 |
4650 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { | 4624 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
4651 // By cases: external, fast double | 4625 // By cases: external, fast double |
4652 if (instr->is_typed_elements()) { | 4626 if (instr->is_fixed_typed_array()) { |
4653 DoStoreKeyedExternalArray(instr); | 4627 DoStoreKeyedExternalArray(instr); |
4654 } else if (instr->hydrogen()->value()->representation().IsDouble()) { | 4628 } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
4655 DoStoreKeyedFixedDoubleArray(instr); | 4629 DoStoreKeyedFixedDoubleArray(instr); |
4656 } else { | 4630 } else { |
4657 DoStoreKeyedFixedArray(instr); | 4631 DoStoreKeyedFixedArray(instr); |
4658 } | 4632 } |
4659 } | 4633 } |
4660 | 4634 |
4661 | 4635 |
4662 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 4636 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6261 __ Push(at, ToRegister(instr->function())); | 6235 __ Push(at, ToRegister(instr->function())); |
6262 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6236 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6263 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6237 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6264 } | 6238 } |
6265 | 6239 |
6266 | 6240 |
6267 #undef __ | 6241 #undef __ |
6268 | 6242 |
6269 } // namespace internal | 6243 } // namespace internal |
6270 } // namespace v8 | 6244 } // namespace v8 |
OLD | NEW |