Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 6902112: Avoid using a register for constant external array indices. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (key_is_constant) {
Jakob Kummerow 2011/04/29 10:04:16 Sure I can. Like this? (I don't really like dupli
2495 __ add(scratch0(), external_pointer, Operand(constant_key * 4));
2496 } else {
2497 __ add(scratch0(), external_pointer, Operand(key, LSL, 2));
2498 }
2485 __ vldr(result.low(), scratch0(), 0); 2499 __ vldr(result.low(), scratch0(), 0);
2486 __ vcvt_f64_f32(result, result.low()); 2500 __ vcvt_f64_f32(result, result.low());
2487 } else if (array_type == kExternalDoubleArray) { 2501 } else if (array_type == kExternalDoubleArray) {
2488 CpuFeatures::Scope scope(VFP3); 2502 CpuFeatures::Scope scope(VFP3);
2489 DwVfpRegister result(ToDoubleRegister(instr->result())); 2503 DwVfpRegister result(ToDoubleRegister(instr->result()));
2490 __ add(scratch0(), external_pointer, Operand(key, LSL, 3)); 2504 Operand operand(key, LSL, 3);
Jakob Kummerow 2011/04/29 10:04:16 Or like this? (Empty initialization isn't possible
2505 if (key_is_constant) {
2506 operand = Operand(constant_key * 8);
2507 }
2508 __ add(scratch0(), external_pointer, operand);
2491 __ vldr(result, scratch0(), 0); 2509 __ vldr(result, scratch0(), 0);
2492 } else { 2510 } else {
2493 Register result(ToRegister(instr->result())); 2511 Register result(ToRegister(instr->result()));
2494 switch (array_type) { 2512 switch (array_type) {
2495 case kExternalByteArray: 2513 case kExternalByteArray: {
Jakob Kummerow 2011/04/29 10:04:16 Or maybe like this? (Doesn't avoid the multiline x
2496 __ ldrsb(result, MemOperand(external_pointer, key)); 2514 MemOperand operand(
2515 key_is_constant ? MemOperand(external_pointer, constant_key)
2516 : MemOperand(external_pointer, key));
2517 __ ldrsb(result, operand);
2497 break; 2518 break;
2519 }
2498 case kExternalUnsignedByteArray: 2520 case kExternalUnsignedByteArray:
2499 case kExternalPixelArray: 2521 case kExternalPixelArray:
2500 __ ldrb(result, MemOperand(external_pointer, key)); 2522 __ ldrb(result, key_is_constant
Jakob Kummerow 2011/04/29 10:04:16 Or, on second thought, maybe stick with my origina
2523 ? MemOperand(external_pointer, constant_key)
2524 : MemOperand(external_pointer, key));
2501 break; 2525 break;
2502 case kExternalShortArray: 2526 case kExternalShortArray:
2503 __ ldrsh(result, MemOperand(external_pointer, key, LSL, 1)); 2527 __ ldrsh(result, key_is_constant
2528 ? MemOperand(external_pointer, constant_key * 2)
2529 : MemOperand(external_pointer, key, LSL, 1));
2504 break; 2530 break;
2505 case kExternalUnsignedShortArray: 2531 case kExternalUnsignedShortArray:
2506 __ ldrh(result, MemOperand(external_pointer, key, LSL, 1)); 2532 __ ldrh(result, key_is_constant
2533 ? MemOperand(external_pointer, constant_key * 2)
2534 : MemOperand(external_pointer, key, LSL, 1));
2507 break; 2535 break;
2508 case kExternalIntArray: 2536 case kExternalIntArray:
2509 __ ldr(result, MemOperand(external_pointer, key, LSL, 2)); 2537 __ ldr(result, key_is_constant
2538 ? MemOperand(external_pointer, constant_key * 4)
2539 : MemOperand(external_pointer, key, LSL, 2));
2510 break; 2540 break;
2511 case kExternalUnsignedIntArray: 2541 case kExternalUnsignedIntArray:
2512 __ ldr(result, MemOperand(external_pointer, key, LSL, 2)); 2542 __ ldr(result, key_is_constant
2543 ? MemOperand(external_pointer, constant_key * 4)
2544 : MemOperand(external_pointer, key, LSL, 2));
2513 __ cmp(result, Operand(0x80000000)); 2545 __ cmp(result, Operand(0x80000000));
2514 // TODO(danno): we could be more clever here, perhaps having a special 2546 // TODO(danno): we could be more clever here, perhaps having a special
2515 // version of the stub that detects if the overflow case actually 2547 // version of the stub that detects if the overflow case actually
2516 // happens, and generate code that returns a double rather than int. 2548 // happens, and generate code that returns a double rather than int.
2517 DeoptimizeIf(cs, instr->environment()); 2549 DeoptimizeIf(cs, instr->environment());
2518 break; 2550 break;
2519 case kExternalFloatArray: 2551 case kExternalFloatArray:
2520 case kExternalDoubleArray: 2552 case kExternalDoubleArray:
2521 UNREACHABLE(); 2553 UNREACHABLE();
2522 break; 2554 break;
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
3232 __ add(key, scratch, Operand(FixedArray::kHeaderSize)); 3264 __ add(key, scratch, Operand(FixedArray::kHeaderSize));
3233 __ RecordWrite(elements, key, value); 3265 __ RecordWrite(elements, key, value);
3234 } 3266 }
3235 } 3267 }
3236 3268
3237 3269
3238 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3270 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3239 LStoreKeyedSpecializedArrayElement* instr) { 3271 LStoreKeyedSpecializedArrayElement* instr) {
3240 3272
3241 Register external_pointer = ToRegister(instr->external_pointer()); 3273 Register external_pointer = ToRegister(instr->external_pointer());
3242 Register key = ToRegister(instr->key()); 3274 Register key = no_reg;
3243 ExternalArrayType array_type = instr->array_type(); 3275 ExternalArrayType array_type = instr->array_type();
3276 bool key_is_constant = instr->key()->IsConstantOperand();
3277 int constant_key = 0;
3278 if (key_is_constant) {
3279 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
3280 if (constant_key & 0xF0000000) {
3281 Abort("array index constant value too big.");
3282 }
3283 } else {
3284 key = ToRegister(instr->key());
3285 }
3244 3286
3245 if (array_type == kExternalFloatArray) { 3287 if (array_type == kExternalFloatArray) {
3246 CpuFeatures::Scope scope(VFP3); 3288 CpuFeatures::Scope scope(VFP3);
3247 DwVfpRegister value(ToDoubleRegister(instr->value())); 3289 DwVfpRegister value(ToDoubleRegister(instr->value()));
3248 __ add(scratch0(), external_pointer, Operand(key, LSL, 2)); 3290 __ add(scratch0(), external_pointer,
3291 key_is_constant ? Operand(constant_key * 4) : Operand(key, LSL, 2));
3249 __ vcvt_f32_f64(double_scratch0().low(), value); 3292 __ vcvt_f32_f64(double_scratch0().low(), value);
3250 __ vstr(double_scratch0().low(), scratch0(), 0); 3293 __ vstr(double_scratch0().low(), scratch0(), 0);
3251 } else if (array_type == kExternalDoubleArray) { 3294 } else if (array_type == kExternalDoubleArray) {
3252 CpuFeatures::Scope scope(VFP3); 3295 CpuFeatures::Scope scope(VFP3);
3253 DwVfpRegister value(ToDoubleRegister(instr->value())); 3296 DwVfpRegister value(ToDoubleRegister(instr->value()));
3254 __ add(scratch0(), external_pointer, Operand(key, LSL, 3)); 3297 __ add(scratch0(), external_pointer,
3298 key_is_constant ? Operand(constant_key * 8) : Operand(key, LSL, 3));
3255 __ vstr(value, scratch0(), 0); 3299 __ vstr(value, scratch0(), 0);
3256 } else { 3300 } else {
3257 Register value(ToRegister(instr->value())); 3301 Register value(ToRegister(instr->value()));
3258 switch (array_type) { 3302 switch (array_type) {
3259 case kExternalPixelArray: 3303 case kExternalPixelArray:
3260 // Clamp the value to [0..255]. 3304 // Clamp the value to [0..255].
3261 __ Usat(value, 8, Operand(value)); 3305 __ Usat(value, 8, Operand(value));
3262 __ strb(value, MemOperand(external_pointer, key)); 3306 __ strb(value, key_is_constant
3307 ? MemOperand(external_pointer, constant_key)
3308 : MemOperand(external_pointer, key));
3263 break; 3309 break;
3264 case kExternalByteArray: 3310 case kExternalByteArray:
3265 case kExternalUnsignedByteArray: 3311 case kExternalUnsignedByteArray:
3266 __ strb(value, MemOperand(external_pointer, key)); 3312 __ strb(value, key_is_constant
3313 ? MemOperand(external_pointer, constant_key)
3314 : MemOperand(external_pointer, key));
3267 break; 3315 break;
3268 case kExternalShortArray: 3316 case kExternalShortArray:
3269 case kExternalUnsignedShortArray: 3317 case kExternalUnsignedShortArray:
3270 __ strh(value, MemOperand(external_pointer, key, LSL, 1)); 3318 __ strh(value, key_is_constant
3319 ? MemOperand(external_pointer, constant_key * 2)
3320 : MemOperand(external_pointer, key, LSL, 1));
3271 break; 3321 break;
3272 case kExternalIntArray: 3322 case kExternalIntArray:
3273 case kExternalUnsignedIntArray: 3323 case kExternalUnsignedIntArray:
3274 __ str(value, MemOperand(external_pointer, key, LSL, 2)); 3324 __ str(value, key_is_constant
3325 ? MemOperand(external_pointer, constant_key * 4)
3326 : MemOperand(external_pointer, key, LSL, 2));
3275 break; 3327 break;
3276 case kExternalFloatArray: 3328 case kExternalFloatArray:
3277 case kExternalDoubleArray: 3329 case kExternalDoubleArray:
3278 UNREACHABLE(); 3330 UNREACHABLE();
3279 break; 3331 break;
3280 } 3332 }
3281 } 3333 }
3282 } 3334 }
3283 3335
3284 3336
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
4303 ASSERT(osr_pc_offset_ == -1); 4355 ASSERT(osr_pc_offset_ == -1);
4304 osr_pc_offset_ = masm()->pc_offset(); 4356 osr_pc_offset_ = masm()->pc_offset();
4305 } 4357 }
4306 4358
4307 4359
4308 4360
4309 4361
4310 #undef __ 4362 #undef __
4311 4363
4312 } } // namespace v8::internal 4364 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698