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 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2469 // Check for the hole value. | 2469 // Check for the hole value. |
2470 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); | 2470 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); |
2471 __ cmp(result, scratch); | 2471 __ cmp(result, scratch); |
2472 DeoptimizeIf(eq, instr->environment()); | 2472 DeoptimizeIf(eq, instr->environment()); |
2473 } | 2473 } |
2474 | 2474 |
2475 | 2475 |
2476 void LCodeGen::DoLoadKeyedSpecializedArrayElement( | 2476 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
2477 LLoadKeyedSpecializedArrayElement* instr) { | 2477 LLoadKeyedSpecializedArrayElement* instr) { |
2478 Register external_pointer = ToRegister(instr->external_pointer()); | 2478 Register external_pointer = ToRegister(instr->external_pointer()); |
2479 Register key = ToRegister(instr->key()); | 2479 Register key = no_reg; |
2480 ExternalArrayType array_type = instr->array_type(); | 2480 ExternalArrayType array_type = instr->array_type(); |
2481 bool key_is_constant = instr->key()->IsConstantOperand(); | |
2482 int constant_key = 0; | |
2483 if (key_is_constant) { | |
2484 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); | |
2485 if (constant_key & 0xF0000000) { | |
2486 Abort("array index constant value too big."); | |
2487 } | |
2488 } else { | |
2489 key = ToRegister(instr->key()); | |
2490 } | |
2481 if (array_type == kExternalFloatArray) { | 2491 if (array_type == kExternalFloatArray) { |
2482 CpuFeatures::Scope scope(VFP3); | 2492 CpuFeatures::Scope scope(VFP3); |
2483 DwVfpRegister result(ToDoubleRegister(instr->result())); | 2493 DwVfpRegister result(ToDoubleRegister(instr->result())); |
2484 __ add(scratch0(), external_pointer, Operand(key, LSL, 2)); | 2494 __ add(scratch0(), external_pointer, |
2495 key_is_constant ? Operand(constant_key * 4) : Operand(key, LSL, 2)); | |
danno
2011/04/28 17:59:55
Can you break out the Operand into another line to
| |
2485 __ vldr(result.low(), scratch0(), 0); | 2496 __ vldr(result.low(), scratch0(), 0); |
2486 __ vcvt_f64_f32(result, result.low()); | 2497 __ vcvt_f64_f32(result, result.low()); |
2487 } else if (array_type == kExternalDoubleArray) { | 2498 } else if (array_type == kExternalDoubleArray) { |
2488 CpuFeatures::Scope scope(VFP3); | 2499 CpuFeatures::Scope scope(VFP3); |
2489 DwVfpRegister result(ToDoubleRegister(instr->result())); | 2500 DwVfpRegister result(ToDoubleRegister(instr->result())); |
2490 __ add(scratch0(), external_pointer, Operand(key, LSL, 3)); | 2501 __ add(scratch0(), external_pointer, |
2502 key_is_constant ? Operand(constant_key * 8) : Operand(key, LSL, 3)); | |
danno
2011/04/28 17:59:55
Same here and below?
| |
2491 __ vldr(result, scratch0(), 0); | 2503 __ vldr(result, scratch0(), 0); |
2492 } else { | 2504 } else { |
2493 Register result(ToRegister(instr->result())); | 2505 Register result(ToRegister(instr->result())); |
2494 switch (array_type) { | 2506 switch (array_type) { |
2495 case kExternalByteArray: | 2507 case kExternalByteArray: |
2496 __ ldrsb(result, MemOperand(external_pointer, key)); | 2508 __ ldrsb(result, key_is_constant |
2509 ? MemOperand(external_pointer, constant_key) | |
2510 : MemOperand(external_pointer, key)); | |
2497 break; | 2511 break; |
2498 case kExternalUnsignedByteArray: | 2512 case kExternalUnsignedByteArray: |
2499 case kExternalPixelArray: | 2513 case kExternalPixelArray: |
2500 __ ldrb(result, MemOperand(external_pointer, key)); | 2514 __ ldrb(result, key_is_constant |
2515 ? MemOperand(external_pointer, constant_key) | |
2516 : MemOperand(external_pointer, key)); | |
2501 break; | 2517 break; |
2502 case kExternalShortArray: | 2518 case kExternalShortArray: |
2503 __ ldrsh(result, MemOperand(external_pointer, key, LSL, 1)); | 2519 __ ldrsh(result, key_is_constant |
2520 ? MemOperand(external_pointer, constant_key * 2) | |
2521 : MemOperand(external_pointer, key, LSL, 1)); | |
2504 break; | 2522 break; |
2505 case kExternalUnsignedShortArray: | 2523 case kExternalUnsignedShortArray: |
2506 __ ldrh(result, MemOperand(external_pointer, key, LSL, 1)); | 2524 __ ldrh(result, key_is_constant |
2525 ? MemOperand(external_pointer, constant_key * 2) | |
2526 : MemOperand(external_pointer, key, LSL, 1)); | |
2507 break; | 2527 break; |
2508 case kExternalIntArray: | 2528 case kExternalIntArray: |
2509 __ ldr(result, MemOperand(external_pointer, key, LSL, 2)); | 2529 __ ldr(result, key_is_constant |
2530 ? MemOperand(external_pointer, constant_key * 4) | |
2531 : MemOperand(external_pointer, key, LSL, 2)); | |
2510 break; | 2532 break; |
2511 case kExternalUnsignedIntArray: | 2533 case kExternalUnsignedIntArray: |
2512 __ ldr(result, MemOperand(external_pointer, key, LSL, 2)); | 2534 __ ldr(result, key_is_constant |
2535 ? MemOperand(external_pointer, constant_key * 4) | |
2536 : MemOperand(external_pointer, key, LSL, 2)); | |
2513 __ cmp(result, Operand(0x80000000)); | 2537 __ cmp(result, Operand(0x80000000)); |
2514 // TODO(danno): we could be more clever here, perhaps having a special | 2538 // TODO(danno): we could be more clever here, perhaps having a special |
2515 // version of the stub that detects if the overflow case actually | 2539 // version of the stub that detects if the overflow case actually |
2516 // happens, and generate code that returns a double rather than int. | 2540 // happens, and generate code that returns a double rather than int. |
2517 DeoptimizeIf(cs, instr->environment()); | 2541 DeoptimizeIf(cs, instr->environment()); |
2518 break; | 2542 break; |
2519 case kExternalFloatArray: | 2543 case kExternalFloatArray: |
2520 case kExternalDoubleArray: | 2544 case kExternalDoubleArray: |
2521 UNREACHABLE(); | 2545 UNREACHABLE(); |
2522 break; | 2546 break; |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3232 __ add(key, scratch, Operand(FixedArray::kHeaderSize)); | 3256 __ add(key, scratch, Operand(FixedArray::kHeaderSize)); |
3233 __ RecordWrite(elements, key, value); | 3257 __ RecordWrite(elements, key, value); |
3234 } | 3258 } |
3235 } | 3259 } |
3236 | 3260 |
3237 | 3261 |
3238 void LCodeGen::DoStoreKeyedSpecializedArrayElement( | 3262 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
3239 LStoreKeyedSpecializedArrayElement* instr) { | 3263 LStoreKeyedSpecializedArrayElement* instr) { |
3240 | 3264 |
3241 Register external_pointer = ToRegister(instr->external_pointer()); | 3265 Register external_pointer = ToRegister(instr->external_pointer()); |
3242 Register key = ToRegister(instr->key()); | 3266 Register key = no_reg; |
3243 ExternalArrayType array_type = instr->array_type(); | 3267 ExternalArrayType array_type = instr->array_type(); |
3268 bool key_is_constant = instr->key()->IsConstantOperand(); | |
3269 int constant_key = 0; | |
3270 if (key_is_constant) { | |
3271 constant_key = ToInteger32(LConstantOperand::cast(instr->key())); | |
3272 if (constant_key & 0xF0000000) { | |
3273 Abort("array index constant value too big."); | |
3274 } | |
3275 } else { | |
3276 key = ToRegister(instr->key()); | |
3277 } | |
3244 | 3278 |
3245 if (array_type == kExternalFloatArray) { | 3279 if (array_type == kExternalFloatArray) { |
3246 CpuFeatures::Scope scope(VFP3); | 3280 CpuFeatures::Scope scope(VFP3); |
3247 DwVfpRegister value(ToDoubleRegister(instr->value())); | 3281 DwVfpRegister value(ToDoubleRegister(instr->value())); |
3248 __ add(scratch0(), external_pointer, Operand(key, LSL, 2)); | 3282 __ add(scratch0(), external_pointer, |
3283 key_is_constant ? Operand(constant_key * 4) : Operand(key, LSL, 2)); | |
3249 __ vcvt_f32_f64(double_scratch0().low(), value); | 3284 __ vcvt_f32_f64(double_scratch0().low(), value); |
3250 __ vstr(double_scratch0().low(), scratch0(), 0); | 3285 __ vstr(double_scratch0().low(), scratch0(), 0); |
3251 } else if (array_type == kExternalDoubleArray) { | 3286 } else if (array_type == kExternalDoubleArray) { |
3252 CpuFeatures::Scope scope(VFP3); | 3287 CpuFeatures::Scope scope(VFP3); |
3253 DwVfpRegister value(ToDoubleRegister(instr->value())); | 3288 DwVfpRegister value(ToDoubleRegister(instr->value())); |
3254 __ add(scratch0(), external_pointer, Operand(key, LSL, 3)); | 3289 __ add(scratch0(), external_pointer, |
3290 key_is_constant ? Operand(constant_key * 8) : Operand(key, LSL, 3)); | |
3255 __ vstr(value, scratch0(), 0); | 3291 __ vstr(value, scratch0(), 0); |
3256 } else { | 3292 } else { |
3257 Register value(ToRegister(instr->value())); | 3293 Register value(ToRegister(instr->value())); |
3258 switch (array_type) { | 3294 switch (array_type) { |
3259 case kExternalPixelArray: | 3295 case kExternalPixelArray: |
3260 // Clamp the value to [0..255]. | 3296 // Clamp the value to [0..255]. |
3261 __ Usat(value, 8, Operand(value)); | 3297 __ Usat(value, 8, Operand(value)); |
3262 __ strb(value, MemOperand(external_pointer, key)); | 3298 __ strb(value, key_is_constant |
3299 ? MemOperand(external_pointer, constant_key) | |
3300 : MemOperand(external_pointer, key)); | |
3263 break; | 3301 break; |
3264 case kExternalByteArray: | 3302 case kExternalByteArray: |
3265 case kExternalUnsignedByteArray: | 3303 case kExternalUnsignedByteArray: |
3266 __ strb(value, MemOperand(external_pointer, key)); | 3304 __ strb(value, key_is_constant |
3305 ? MemOperand(external_pointer, constant_key) | |
3306 : MemOperand(external_pointer, key)); | |
3267 break; | 3307 break; |
3268 case kExternalShortArray: | 3308 case kExternalShortArray: |
3269 case kExternalUnsignedShortArray: | 3309 case kExternalUnsignedShortArray: |
3270 __ strh(value, MemOperand(external_pointer, key, LSL, 1)); | 3310 __ strh(value, key_is_constant |
3311 ? MemOperand(external_pointer, constant_key * 2) | |
3312 : MemOperand(external_pointer, key, LSL, 1)); | |
3271 break; | 3313 break; |
3272 case kExternalIntArray: | 3314 case kExternalIntArray: |
3273 case kExternalUnsignedIntArray: | 3315 case kExternalUnsignedIntArray: |
3274 __ str(value, MemOperand(external_pointer, key, LSL, 2)); | 3316 __ str(value, key_is_constant |
3317 ? MemOperand(external_pointer, constant_key * 4) | |
3318 : MemOperand(external_pointer, key, LSL, 2)); | |
3275 break; | 3319 break; |
3276 case kExternalFloatArray: | 3320 case kExternalFloatArray: |
3277 case kExternalDoubleArray: | 3321 case kExternalDoubleArray: |
3278 UNREACHABLE(); | 3322 UNREACHABLE(); |
3279 break; | 3323 break; |
3280 } | 3324 } |
3281 } | 3325 } |
3282 } | 3326 } |
3283 | 3327 |
3284 | 3328 |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4303 ASSERT(osr_pc_offset_ == -1); | 4347 ASSERT(osr_pc_offset_ == -1); |
4304 osr_pc_offset_ = masm()->pc_offset(); | 4348 osr_pc_offset_ = masm()->pc_offset(); |
4305 } | 4349 } |
4306 | 4350 |
4307 | 4351 |
4308 | 4352 |
4309 | 4353 |
4310 #undef __ | 4354 #undef __ |
4311 | 4355 |
4312 } } // namespace v8::internal | 4356 } } // namespace v8::internal |
OLD | NEW |