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

Side by Side Diff: src/x64/lithium-codegen-x64.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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.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 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 key, 2392 key,
2393 times_pointer_size, 2393 times_pointer_size,
2394 FixedArray::kHeaderSize)); 2394 FixedArray::kHeaderSize));
2395 2395
2396 // Check for the hole value. 2396 // Check for the hole value.
2397 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); 2397 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2398 DeoptimizeIf(equal, instr->environment()); 2398 DeoptimizeIf(equal, instr->environment());
2399 } 2399 }
2400 2400
2401 2401
2402 Operand LCodeGen::BuildExternalArrayOperand(LOperand* external_pointer,
2403 LOperand* key,
2404 ExternalArrayType array_type) {
2405 Register external_pointer_reg = ToRegister(external_pointer);
2406 int shift_size = ExternalArrayTypeToShiftSize(array_type);
2407 if (key->IsConstantOperand()) {
2408 int constant_value = ToInteger32(LConstantOperand::cast(key));
2409 if (constant_value & 0xF0000000) {
2410 Abort("array index constant value too big");
2411 }
2412 return Operand(external_pointer_reg, constant_value * (1 << shift_size));
2413 } else {
2414 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2415 return Operand(external_pointer_reg, ToRegister(key), scale_factor, 0);
2416 }
2417 }
2418
2419
2402 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2420 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2403 LLoadKeyedSpecializedArrayElement* instr) { 2421 LLoadKeyedSpecializedArrayElement* instr) {
2404 Register external_pointer = ToRegister(instr->external_pointer());
2405 Register key = ToRegister(instr->key());
2406 ExternalArrayType array_type = instr->array_type(); 2422 ExternalArrayType array_type = instr->array_type();
2423 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
2424 instr->key(), array_type));
2407 if (array_type == kExternalFloatArray) { 2425 if (array_type == kExternalFloatArray) {
2408 XMMRegister result(ToDoubleRegister(instr->result())); 2426 XMMRegister result(ToDoubleRegister(instr->result()));
2409 __ movss(result, Operand(external_pointer, key, times_4, 0)); 2427 __ movss(result, operand);
2410 __ cvtss2sd(result, result); 2428 __ cvtss2sd(result, result);
2411 } else if (array_type == kExternalDoubleArray) { 2429 } else if (array_type == kExternalDoubleArray) {
2412 __ movsd(ToDoubleRegister(instr->result()), 2430 __ movsd(ToDoubleRegister(instr->result()), operand);
2413 Operand(external_pointer, key, times_8, 0));
2414 } else { 2431 } else {
2415 Register result(ToRegister(instr->result())); 2432 Register result(ToRegister(instr->result()));
2416 switch (array_type) { 2433 switch (array_type) {
2417 case kExternalByteArray: 2434 case kExternalByteArray:
2418 __ movsxbq(result, Operand(external_pointer, key, times_1, 0)); 2435 __ movsxbq(result, operand);
2419 break; 2436 break;
2420 case kExternalUnsignedByteArray: 2437 case kExternalUnsignedByteArray:
2421 case kExternalPixelArray: 2438 case kExternalPixelArray:
2422 __ movzxbq(result, Operand(external_pointer, key, times_1, 0)); 2439 __ movzxbq(result, operand);
2423 break; 2440 break;
2424 case kExternalShortArray: 2441 case kExternalShortArray:
2425 __ movsxwq(result, Operand(external_pointer, key, times_2, 0)); 2442 __ movsxwq(result, operand);
2426 break; 2443 break;
2427 case kExternalUnsignedShortArray: 2444 case kExternalUnsignedShortArray:
2428 __ movzxwq(result, Operand(external_pointer, key, times_2, 0)); 2445 __ movzxwq(result, operand);
2429 break; 2446 break;
2430 case kExternalIntArray: 2447 case kExternalIntArray:
2431 __ movsxlq(result, Operand(external_pointer, key, times_4, 0)); 2448 __ movsxlq(result, operand);
2432 break; 2449 break;
2433 case kExternalUnsignedIntArray: 2450 case kExternalUnsignedIntArray:
2434 __ movl(result, Operand(external_pointer, key, times_4, 0)); 2451 __ movl(result, operand);
2435 __ testl(result, result); 2452 __ testl(result, result);
2436 // TODO(danno): we could be more clever here, perhaps having a special 2453 // TODO(danno): we could be more clever here, perhaps having a special
2437 // version of the stub that detects if the overflow case actually 2454 // version of the stub that detects if the overflow case actually
2438 // happens, and generate code that returns a double rather than int. 2455 // happens, and generate code that returns a double rather than int.
2439 DeoptimizeIf(negative, instr->environment()); 2456 DeoptimizeIf(negative, instr->environment());
2440 break; 2457 break;
2441 case kExternalFloatArray: 2458 case kExternalFloatArray:
2442 case kExternalDoubleArray: 2459 case kExternalDoubleArray:
2443 UNREACHABLE(); 2460 UNREACHABLE();
2444 break; 2461 break;
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 __ Move(rcx, instr->hydrogen()->name()); 3102 __ Move(rcx, instr->hydrogen()->name());
3086 Handle<Code> ic = instr->strict_mode() 3103 Handle<Code> ic = instr->strict_mode()
3087 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3104 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3088 : isolate()->builtins()->StoreIC_Initialize(); 3105 : isolate()->builtins()->StoreIC_Initialize();
3089 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3106 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3090 } 3107 }
3091 3108
3092 3109
3093 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3110 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3094 LStoreKeyedSpecializedArrayElement* instr) { 3111 LStoreKeyedSpecializedArrayElement* instr) {
3095 Register external_pointer = ToRegister(instr->external_pointer());
3096 Register key = ToRegister(instr->key());
3097 ExternalArrayType array_type = instr->array_type(); 3112 ExternalArrayType array_type = instr->array_type();
3113 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
3114 instr->key(), array_type));
3098 if (array_type == kExternalFloatArray) { 3115 if (array_type == kExternalFloatArray) {
3099 XMMRegister value(ToDoubleRegister(instr->value())); 3116 XMMRegister value(ToDoubleRegister(instr->value()));
3100 __ cvtsd2ss(value, value); 3117 __ cvtsd2ss(value, value);
3101 __ movss(Operand(external_pointer, key, times_4, 0), value); 3118 __ movss(operand, value);
3102 } else if (array_type == kExternalDoubleArray) { 3119 } else if (array_type == kExternalDoubleArray) {
3103 __ movsd(Operand(external_pointer, key, times_8, 0), 3120 __ movsd(operand, ToDoubleRegister(instr->value()));
3104 ToDoubleRegister(instr->value()));
3105 } else { 3121 } else {
3106 Register value(ToRegister(instr->value())); 3122 Register value(ToRegister(instr->value()));
3107 switch (array_type) { 3123 switch (array_type) {
3108 case kExternalPixelArray: 3124 case kExternalPixelArray:
3109 { // Clamp the value to [0..255]. 3125 { // Clamp the value to [0..255].
3110 NearLabel done; 3126 NearLabel done;
3111 __ testl(value, Immediate(0xFFFFFF00)); 3127 __ testl(value, Immediate(0xFFFFFF00));
3112 __ j(zero, &done); 3128 __ j(zero, &done);
3113 __ setcc(negative, value); // 1 if negative, 0 if positive. 3129 __ setcc(negative, value); // 1 if negative, 0 if positive.
3114 __ decb(value); // 0 if negative, 255 if positive. 3130 __ decb(value); // 0 if negative, 255 if positive.
3115 __ bind(&done); 3131 __ bind(&done);
3116 __ movb(Operand(external_pointer, key, times_1, 0), value); 3132 __ movb(operand, value);
3117 } 3133 }
3118 break; 3134 break;
3119 case kExternalByteArray: 3135 case kExternalByteArray:
3120 case kExternalUnsignedByteArray: 3136 case kExternalUnsignedByteArray:
3121 __ movb(Operand(external_pointer, key, times_1, 0), value); 3137 __ movb(operand, value);
3122 break; 3138 break;
3123 case kExternalShortArray: 3139 case kExternalShortArray:
3124 case kExternalUnsignedShortArray: 3140 case kExternalUnsignedShortArray:
3125 __ movw(Operand(external_pointer, key, times_2, 0), value); 3141 __ movw(operand, value);
3126 break; 3142 break;
3127 case kExternalIntArray: 3143 case kExternalIntArray:
3128 case kExternalUnsignedIntArray: 3144 case kExternalUnsignedIntArray:
3129 __ movl(Operand(external_pointer, key, times_4, 0), value); 3145 __ movl(operand, value);
3130 break; 3146 break;
3131 case kExternalFloatArray: 3147 case kExternalFloatArray:
3132 case kExternalDoubleArray: 3148 case kExternalDoubleArray:
3133 UNREACHABLE(); 3149 UNREACHABLE();
3134 break; 3150 break;
3135 } 3151 }
3136 } 3152 }
3137 } 3153 }
3138 3154
3139 3155
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 RegisterEnvironmentForDeoptimization(environment); 4118 RegisterEnvironmentForDeoptimization(environment);
4103 ASSERT(osr_pc_offset_ == -1); 4119 ASSERT(osr_pc_offset_ == -1);
4104 osr_pc_offset_ = masm()->pc_offset(); 4120 osr_pc_offset_ = masm()->pc_offset();
4105 } 4121 }
4106 4122
4107 #undef __ 4123 #undef __
4108 4124
4109 } } // namespace v8::internal 4125 } } // namespace v8::internal
4110 4126
4111 #endif // V8_TARGET_ARCH_X64 4127 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698