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

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: 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
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 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 key, 2386 key,
2387 times_pointer_size, 2387 times_pointer_size,
2388 FixedArray::kHeaderSize)); 2388 FixedArray::kHeaderSize));
2389 2389
2390 // Check for the hole value. 2390 // Check for the hole value.
2391 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); 2391 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2392 DeoptimizeIf(equal, instr->environment()); 2392 DeoptimizeIf(equal, instr->environment());
2393 } 2393 }
2394 2394
2395 2395
2396 Operand LCodeGen::BuildExternalArrayOperand(LOperand* external_pointer,
2397 LOperand* key,
2398 ExternalArrayType array_type) {
2399 Register external_pointer_reg = ToRegister(external_pointer);
2400 ScaleFactor scale_factor = times_1;
2401 int element_size = 1;
2402 switch (array_type) {
2403 case kExternalByteArray:
2404 case kExternalUnsignedByteArray:
2405 case kExternalPixelArray:
2406 scale_factor = times_1;
2407 element_size = 1;
2408 break;
2409 case kExternalShortArray:
2410 case kExternalUnsignedShortArray:
2411 scale_factor = times_2;
2412 element_size = 2;
2413 break;
2414 case kExternalIntArray:
2415 case kExternalUnsignedIntArray:
2416 case kExternalFloatArray:
2417 scale_factor = times_4;
2418 element_size = 4;
2419 break;
2420 case kExternalDoubleArray:
2421 scale_factor = times_8;
2422 element_size = 8;
2423 break;
2424 }
2425 if (key->IsConstantOperand()) {
2426 int constant_value = ToInteger32(LConstantOperand::cast(key));
2427 if (constant_value & 0xF0000000) {
2428 Abort("array index constant value too big");
2429 }
2430 return Operand(external_pointer_reg, constant_value * element_size);
2431 } else {
2432 return Operand(external_pointer_reg, ToRegister(key), scale_factor, 0);
2433 }
2434 }
2435
2436
2396 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2437 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2397 LLoadKeyedSpecializedArrayElement* instr) { 2438 LLoadKeyedSpecializedArrayElement* instr) {
2398 Register external_pointer = ToRegister(instr->external_pointer());
2399 Register key = ToRegister(instr->key());
2400 ExternalArrayType array_type = instr->array_type(); 2439 ExternalArrayType array_type = instr->array_type();
2440 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
2441 instr->key(), array_type));
2401 if (array_type == kExternalFloatArray) { 2442 if (array_type == kExternalFloatArray) {
2402 XMMRegister result(ToDoubleRegister(instr->result())); 2443 XMMRegister result(ToDoubleRegister(instr->result()));
2403 __ movss(result, Operand(external_pointer, key, times_4, 0)); 2444 __ movss(result, operand);
2404 __ cvtss2sd(result, result); 2445 __ cvtss2sd(result, result);
2405 } else if (array_type == kExternalDoubleArray) { 2446 } else if (array_type == kExternalDoubleArray) {
2406 __ movsd(ToDoubleRegister(instr->result()), 2447 __ movsd(ToDoubleRegister(instr->result()), operand);
2407 Operand(external_pointer, key, times_8, 0));
2408 } else { 2448 } else {
2409 Register result(ToRegister(instr->result())); 2449 Register result(ToRegister(instr->result()));
2410 switch (array_type) { 2450 switch (array_type) {
2411 case kExternalByteArray: 2451 case kExternalByteArray:
2412 __ movsxbq(result, Operand(external_pointer, key, times_1, 0)); 2452 __ movsxbq(result, operand);
2413 break; 2453 break;
2414 case kExternalUnsignedByteArray: 2454 case kExternalUnsignedByteArray:
2415 case kExternalPixelArray: 2455 case kExternalPixelArray:
2416 __ movzxbq(result, Operand(external_pointer, key, times_1, 0)); 2456 __ movzxbq(result, operand);
2417 break; 2457 break;
2418 case kExternalShortArray: 2458 case kExternalShortArray:
2419 __ movsxwq(result, Operand(external_pointer, key, times_2, 0)); 2459 __ movsxwq(result, operand);
2420 break; 2460 break;
2421 case kExternalUnsignedShortArray: 2461 case kExternalUnsignedShortArray:
2422 __ movzxwq(result, Operand(external_pointer, key, times_2, 0)); 2462 __ movzxwq(result, operand);
2423 break; 2463 break;
2424 case kExternalIntArray: 2464 case kExternalIntArray:
2425 __ movsxlq(result, Operand(external_pointer, key, times_4, 0)); 2465 __ movsxlq(result, operand);
2426 break; 2466 break;
2427 case kExternalUnsignedIntArray: 2467 case kExternalUnsignedIntArray:
2428 __ movl(result, Operand(external_pointer, key, times_4, 0)); 2468 __ movl(result, operand);
2429 __ testl(result, result); 2469 __ testl(result, result);
2430 // TODO(danno): we could be more clever here, perhaps having a special 2470 // TODO(danno): we could be more clever here, perhaps having a special
2431 // version of the stub that detects if the overflow case actually 2471 // version of the stub that detects if the overflow case actually
2432 // happens, and generate code that returns a double rather than int. 2472 // happens, and generate code that returns a double rather than int.
2433 DeoptimizeIf(negative, instr->environment()); 2473 DeoptimizeIf(negative, instr->environment());
2434 break; 2474 break;
2435 case kExternalFloatArray: 2475 case kExternalFloatArray:
2436 case kExternalDoubleArray: 2476 case kExternalDoubleArray:
2437 UNREACHABLE(); 2477 UNREACHABLE();
2438 break; 2478 break;
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 __ Move(rcx, instr->hydrogen()->name()); 3119 __ Move(rcx, instr->hydrogen()->name());
3080 Handle<Code> ic = instr->strict_mode() 3120 Handle<Code> ic = instr->strict_mode()
3081 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3121 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3082 : isolate()->builtins()->StoreIC_Initialize(); 3122 : isolate()->builtins()->StoreIC_Initialize();
3083 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3123 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3084 } 3124 }
3085 3125
3086 3126
3087 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3127 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3088 LStoreKeyedSpecializedArrayElement* instr) { 3128 LStoreKeyedSpecializedArrayElement* instr) {
3089 Register external_pointer = ToRegister(instr->external_pointer());
3090 Register key = ToRegister(instr->key());
3091 ExternalArrayType array_type = instr->array_type(); 3129 ExternalArrayType array_type = instr->array_type();
3130 Operand operand(BuildExternalArrayOperand(instr->external_pointer(),
3131 instr->key(), array_type));
3092 if (array_type == kExternalFloatArray) { 3132 if (array_type == kExternalFloatArray) {
3093 XMMRegister value(ToDoubleRegister(instr->value())); 3133 XMMRegister value(ToDoubleRegister(instr->value()));
3094 __ cvtsd2ss(value, value); 3134 __ cvtsd2ss(value, value);
3095 __ movss(Operand(external_pointer, key, times_4, 0), value); 3135 __ movss(operand, value);
3096 } else if (array_type == kExternalDoubleArray) { 3136 } else if (array_type == kExternalDoubleArray) {
3097 __ movsd(Operand(external_pointer, key, times_8, 0), 3137 __ movsd(operand, ToDoubleRegister(instr->value()));
3098 ToDoubleRegister(instr->value()));
3099 } else { 3138 } else {
3100 Register value(ToRegister(instr->value())); 3139 Register value(ToRegister(instr->value()));
3101 switch (array_type) { 3140 switch (array_type) {
3102 case kExternalPixelArray: 3141 case kExternalPixelArray:
3103 { // Clamp the value to [0..255]. 3142 { // Clamp the value to [0..255].
3104 NearLabel done; 3143 NearLabel done;
3105 __ testl(value, Immediate(0xFFFFFF00)); 3144 __ testl(value, Immediate(0xFFFFFF00));
3106 __ j(zero, &done); 3145 __ j(zero, &done);
3107 __ setcc(negative, value); // 1 if negative, 0 if positive. 3146 __ setcc(negative, value); // 1 if negative, 0 if positive.
3108 __ decb(value); // 0 if negative, 255 if positive. 3147 __ decb(value); // 0 if negative, 255 if positive.
3109 __ bind(&done); 3148 __ bind(&done);
3110 __ movb(Operand(external_pointer, key, times_1, 0), value); 3149 __ movb(operand, value);
3111 } 3150 }
3112 break; 3151 break;
3113 case kExternalByteArray: 3152 case kExternalByteArray:
3114 case kExternalUnsignedByteArray: 3153 case kExternalUnsignedByteArray:
3115 __ movb(Operand(external_pointer, key, times_1, 0), value); 3154 __ movb(operand, value);
3116 break; 3155 break;
3117 case kExternalShortArray: 3156 case kExternalShortArray:
3118 case kExternalUnsignedShortArray: 3157 case kExternalUnsignedShortArray:
3119 __ movw(Operand(external_pointer, key, times_2, 0), value); 3158 __ movw(operand, value);
3120 break; 3159 break;
3121 case kExternalIntArray: 3160 case kExternalIntArray:
3122 case kExternalUnsignedIntArray: 3161 case kExternalUnsignedIntArray:
3123 __ movl(Operand(external_pointer, key, times_4, 0), value); 3162 __ movl(operand, value);
3124 break; 3163 break;
3125 case kExternalFloatArray: 3164 case kExternalFloatArray:
3126 case kExternalDoubleArray: 3165 case kExternalDoubleArray:
3127 UNREACHABLE(); 3166 UNREACHABLE();
3128 break; 3167 break;
3129 } 3168 }
3130 } 3169 }
3131 } 3170 }
3132 3171
3133 3172
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 RegisterEnvironmentForDeoptimization(environment); 4135 RegisterEnvironmentForDeoptimization(environment);
4097 ASSERT(osr_pc_offset_ == -1); 4136 ASSERT(osr_pc_offset_ == -1);
4098 osr_pc_offset_ = masm()->pc_offset(); 4137 osr_pc_offset_ = masm()->pc_offset();
4099 } 4138 }
4100 4139
4101 #undef __ 4140 #undef __
4102 4141
4103 } } // namespace v8::internal 4142 } } // namespace v8::internal
4104 4143
4105 #endif // V8_TARGET_ARCH_X64 4144 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698