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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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: add arch-independent ExternalArrayTypeToShiftSize() function 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/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.cc » ('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 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 key, 2382 key,
2383 times_pointer_size, 2383 times_pointer_size,
2384 FixedArray::kHeaderSize)); 2384 FixedArray::kHeaderSize));
2385 2385
2386 // Check for the hole value. 2386 // Check for the hole value.
2387 __ cmp(result, factory()->the_hole_value()); 2387 __ cmp(result, factory()->the_hole_value());
2388 DeoptimizeIf(equal, instr->environment()); 2388 DeoptimizeIf(equal, instr->environment());
2389 } 2389 }
2390 2390
2391 2391
2392 Operand LCodeGen::BuildExternalArrayOperand(LOperand* external_pointer,
2393 LOperand* key,
2394 ExternalArrayType array_type) {
2395 Register external_pointer_reg = ToRegister(external_pointer);
2396 int shift_size = ExternalArrayTypeToShiftSize(array_type);
2397 if (key->IsConstantOperand()) {
2398 int constant_value = ToInteger32(LConstantOperand::cast(key));
2399 if (constant_value & 0xF0000000) {
2400 Abort("array index constant value too big");
2401 }
2402 return Operand(external_pointer_reg, constant_value * (1 << shift_size));
2403 } else {
2404 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2405 return Operand(external_pointer_reg, ToRegister(key), scale_factor, 0);
2406 }
2407 }
2408
2409
2392 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2410 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2393 LLoadKeyedSpecializedArrayElement* instr) { 2411 LLoadKeyedSpecializedArrayElement* instr) {
2394 Register external_pointer = ToRegister(instr->external_pointer());
2395 Register key = ToRegister(instr->key());
2396 ExternalArrayType array_type = instr->array_type(); 2412 ExternalArrayType array_type = instr->array_type();
2413 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
2414 instr->key(), array_type));
2397 if (array_type == kExternalFloatArray) { 2415 if (array_type == kExternalFloatArray) {
2398 XMMRegister result(ToDoubleRegister(instr->result())); 2416 XMMRegister result(ToDoubleRegister(instr->result()));
2399 __ movss(result, Operand(external_pointer, key, times_4, 0)); 2417 __ movss(result, operand);
2400 __ cvtss2sd(result, result); 2418 __ cvtss2sd(result, result);
2401 } else if (array_type == kExternalDoubleArray) { 2419 } else if (array_type == kExternalDoubleArray) {
2402 __ movdbl(ToDoubleRegister(instr->result()), 2420 __ movdbl(ToDoubleRegister(instr->result()), operand);
2403 Operand(external_pointer, key, times_8, 0));
2404 } else { 2421 } else {
2405 Register result(ToRegister(instr->result())); 2422 Register result(ToRegister(instr->result()));
2406 switch (array_type) { 2423 switch (array_type) {
2407 case kExternalByteArray: 2424 case kExternalByteArray:
2408 __ movsx_b(result, Operand(external_pointer, key, times_1, 0)); 2425 __ movsx_b(result, operand);
2409 break; 2426 break;
2410 case kExternalUnsignedByteArray: 2427 case kExternalUnsignedByteArray:
2411 case kExternalPixelArray: 2428 case kExternalPixelArray:
2412 __ movzx_b(result, Operand(external_pointer, key, times_1, 0)); 2429 __ movzx_b(result, operand);
2413 break; 2430 break;
2414 case kExternalShortArray: 2431 case kExternalShortArray:
2415 __ movsx_w(result, Operand(external_pointer, key, times_2, 0)); 2432 __ movsx_w(result, operand);
2416 break; 2433 break;
2417 case kExternalUnsignedShortArray: 2434 case kExternalUnsignedShortArray:
2418 __ movzx_w(result, Operand(external_pointer, key, times_2, 0)); 2435 __ movzx_w(result, operand);
2419 break; 2436 break;
2420 case kExternalIntArray: 2437 case kExternalIntArray:
2421 __ mov(result, Operand(external_pointer, key, times_4, 0)); 2438 __ mov(result, operand);
2422 break; 2439 break;
2423 case kExternalUnsignedIntArray: 2440 case kExternalUnsignedIntArray:
2424 __ mov(result, Operand(external_pointer, key, times_4, 0)); 2441 __ mov(result, operand);
2425 __ test(result, Operand(result)); 2442 __ test(result, Operand(result));
2426 // TODO(danno): we could be more clever here, perhaps having a special 2443 // TODO(danno): we could be more clever here, perhaps having a special
2427 // version of the stub that detects if the overflow case actually 2444 // version of the stub that detects if the overflow case actually
2428 // happens, and generate code that returns a double rather than int. 2445 // happens, and generate code that returns a double rather than int.
2429 DeoptimizeIf(negative, instr->environment()); 2446 DeoptimizeIf(negative, instr->environment());
2430 break; 2447 break;
2431 case kExternalFloatArray: 2448 case kExternalFloatArray:
2432 case kExternalDoubleArray: 2449 case kExternalDoubleArray:
2433 UNREACHABLE(); 2450 UNREACHABLE();
2434 break; 2451 break;
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 3115
3099 3116
3100 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3117 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3101 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); 3118 __ cmp(ToRegister(instr->index()), ToOperand(instr->length()));
3102 DeoptimizeIf(above_equal, instr->environment()); 3119 DeoptimizeIf(above_equal, instr->environment());
3103 } 3120 }
3104 3121
3105 3122
3106 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3123 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3107 LStoreKeyedSpecializedArrayElement* instr) { 3124 LStoreKeyedSpecializedArrayElement* instr) {
3108 Register external_pointer = ToRegister(instr->external_pointer());
3109 Register key = ToRegister(instr->key());
3110 ExternalArrayType array_type = instr->array_type(); 3125 ExternalArrayType array_type = instr->array_type();
3126 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
3127 instr->key(), array_type));
3111 if (array_type == kExternalFloatArray) { 3128 if (array_type == kExternalFloatArray) {
3112 __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value())); 3129 __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value()));
3113 __ movss(Operand(external_pointer, key, times_4, 0), xmm0); 3130 __ movss(operand, xmm0);
3114 } else if (array_type == kExternalDoubleArray) { 3131 } else if (array_type == kExternalDoubleArray) {
3115 __ movdbl(Operand(external_pointer, key, times_8, 0), 3132 __ movdbl(operand, ToDoubleRegister(instr->value()));
3116 ToDoubleRegister(instr->value()));
3117 } else { 3133 } else {
3118 Register value = ToRegister(instr->value()); 3134 Register value = ToRegister(instr->value());
3119 switch (array_type) { 3135 switch (array_type) {
3120 case kExternalPixelArray: { 3136 case kExternalPixelArray: {
3121 // Clamp the value to [0..255]. 3137 // Clamp the value to [0..255].
3122 Register temp = ToRegister(instr->TempAt(0)); 3138 Register temp = ToRegister(instr->TempAt(0));
3123 // The dec_b below requires that the clamped value is in a byte 3139 // The dec_b below requires that the clamped value is in a byte
3124 // register. eax is an arbitrary choice to satisfy this requirement, we 3140 // register. eax is an arbitrary choice to satisfy this requirement, we
3125 // hinted the register allocator to give us eax when building the 3141 // hinted the register allocator to give us eax when building the
3126 // instruction. 3142 // instruction.
3127 ASSERT(temp.is(eax)); 3143 ASSERT(temp.is(eax));
3128 __ mov(temp, ToRegister(instr->value())); 3144 __ mov(temp, ToRegister(instr->value()));
3129 NearLabel done; 3145 NearLabel done;
3130 __ test(temp, Immediate(0xFFFFFF00)); 3146 __ test(temp, Immediate(0xFFFFFF00));
3131 __ j(zero, &done); 3147 __ j(zero, &done);
3132 __ setcc(negative, temp); // 1 if negative, 0 if positive. 3148 __ setcc(negative, temp); // 1 if negative, 0 if positive.
3133 __ dec_b(temp); // 0 if negative, 255 if positive. 3149 __ dec_b(temp); // 0 if negative, 255 if positive.
3134 __ bind(&done); 3150 __ bind(&done);
3135 __ mov_b(Operand(external_pointer, key, times_1, 0), temp); 3151 __ mov_b(operand, temp);
3136 break; 3152 break;
3137 } 3153 }
3138 case kExternalByteArray: 3154 case kExternalByteArray:
3139 case kExternalUnsignedByteArray: 3155 case kExternalUnsignedByteArray:
3140 __ mov_b(Operand(external_pointer, key, times_1, 0), value); 3156 __ mov_b(operand, value);
3141 break; 3157 break;
3142 case kExternalShortArray: 3158 case kExternalShortArray:
3143 case kExternalUnsignedShortArray: 3159 case kExternalUnsignedShortArray:
3144 __ mov_w(Operand(external_pointer, key, times_2, 0), value); 3160 __ mov_w(operand, value);
3145 break; 3161 break;
3146 case kExternalIntArray: 3162 case kExternalIntArray:
3147 case kExternalUnsignedIntArray: 3163 case kExternalUnsignedIntArray:
3148 __ mov(Operand(external_pointer, key, times_4, 0), value); 3164 __ mov(operand, value);
3149 break; 3165 break;
3150 case kExternalFloatArray: 3166 case kExternalFloatArray:
3151 case kExternalDoubleArray: 3167 case kExternalDoubleArray:
3152 UNREACHABLE(); 3168 UNREACHABLE();
3153 break; 3169 break;
3154 } 3170 }
3155 } 3171 }
3156 } 3172 }
3157 3173
3158 3174
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4305 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4321 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4306 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4322 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4307 } 4323 }
4308 4324
4309 4325
4310 #undef __ 4326 #undef __
4311 4327
4312 } } // namespace v8::internal 4328 } } // namespace v8::internal
4313 4329
4314 #endif // V8_TARGET_ARCH_IA32 4330 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698