Chromium Code Reviews| 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 2328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2339 key, | 2339 key, |
| 2340 times_pointer_size, | 2340 times_pointer_size, |
| 2341 FixedArray::kHeaderSize)); | 2341 FixedArray::kHeaderSize)); |
| 2342 | 2342 |
| 2343 // Check for the hole value. | 2343 // Check for the hole value. |
| 2344 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); | 2344 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
| 2345 DeoptimizeIf(equal, instr->environment()); | 2345 DeoptimizeIf(equal, instr->environment()); |
| 2346 } | 2346 } |
| 2347 | 2347 |
| 2348 | 2348 |
| 2349 Operand LCodeGen::BuildExternalArrayOperand(LOperand* external_pointer, | |
| 2350 LOperand* key, | |
| 2351 ExternalArrayType array_type) { | |
| 2352 Register external_pointer_reg = ToRegister(external_pointer); | |
| 2353 ScaleFactor scale_factor = times_1; | |
| 2354 int element_size = 1; | |
| 2355 switch (array_type) { | |
| 2356 case kExternalByteArray: | |
| 2357 case kExternalUnsignedByteArray: | |
| 2358 case kExternalPixelArray: | |
| 2359 scale_factor = times_1; | |
| 2360 element_size = 1; | |
| 2361 break; | |
| 2362 case kExternalShortArray: | |
| 2363 case kExternalUnsignedShortArray: | |
| 2364 scale_factor = times_2; | |
| 2365 element_size = 2; | |
| 2366 break; | |
| 2367 case kExternalIntArray: | |
| 2368 case kExternalUnsignedIntArray: | |
| 2369 case kExternalFloatArray: | |
| 2370 scale_factor = times_4; | |
| 2371 element_size = 4; | |
| 2372 break; | |
| 2373 case kExternalDoubleArray: | |
| 2374 scale_factor = times_8; | |
| 2375 element_size = 8; | |
| 2376 break; | |
| 2377 } | |
| 2378 int constant_value = 0; | |
| 2379 Register key_reg; | |
| 2380 bool key_is_constant = key->IsConstantOperand(); | |
| 2381 if (key_is_constant) { | |
| 2382 constant_value = ToInteger32(LConstantOperand::cast(key)); | |
| 2383 if (constant_value & 0xF0000000) { | |
| 2384 Abort("array index constant value too big"); | |
| 2385 } | |
| 2386 } else { | |
| 2387 key_reg = ToRegister(key); | |
| 2388 } | |
| 2389 if (key_is_constant) | |
|
fschneider
2011/04/29 09:13:47
Please always add { } for multiline if-statements.
Jakob Kummerow
2011/04/29 10:04:16
OK, I'll remember that.
| |
| 2390 return Operand(external_pointer_reg, constant_value * element_size); | |
| 2391 return Operand(external_pointer_reg, key_reg, scale_factor, 0); | |
| 2392 } | |
| 2393 | |
| 2394 | |
| 2349 void LCodeGen::DoLoadKeyedSpecializedArrayElement( | 2395 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
| 2350 LLoadKeyedSpecializedArrayElement* instr) { | 2396 LLoadKeyedSpecializedArrayElement* instr) { |
| 2351 Register external_pointer = ToRegister(instr->external_pointer()); | |
| 2352 Register key = ToRegister(instr->key()); | |
| 2353 ExternalArrayType array_type = instr->array_type(); | 2397 ExternalArrayType array_type = instr->array_type(); |
| 2398 Operand operand(BuildExternalArrayOperand(instr->external_pointer(), | |
| 2399 instr->key(), array_type)); | |
| 2354 if (array_type == kExternalFloatArray) { | 2400 if (array_type == kExternalFloatArray) { |
| 2355 XMMRegister result(ToDoubleRegister(instr->result())); | 2401 XMMRegister result(ToDoubleRegister(instr->result())); |
| 2356 __ movss(result, Operand(external_pointer, key, times_4, 0)); | 2402 __ movss(result, operand); |
| 2357 __ cvtss2sd(result, result); | 2403 __ cvtss2sd(result, result); |
| 2358 } else if (array_type == kExternalDoubleArray) { | 2404 } else if (array_type == kExternalDoubleArray) { |
| 2359 __ movsd(ToDoubleRegister(instr->result()), | 2405 __ movsd(ToDoubleRegister(instr->result()), operand); |
| 2360 Operand(external_pointer, key, times_8, 0)); | |
| 2361 } else { | 2406 } else { |
| 2362 Register result(ToRegister(instr->result())); | 2407 Register result(ToRegister(instr->result())); |
| 2363 switch (array_type) { | 2408 switch (array_type) { |
| 2364 case kExternalByteArray: | 2409 case kExternalByteArray: |
| 2365 __ movsxbq(result, Operand(external_pointer, key, times_1, 0)); | 2410 __ movsxbq(result, operand); |
| 2366 break; | 2411 break; |
| 2367 case kExternalUnsignedByteArray: | 2412 case kExternalUnsignedByteArray: |
| 2368 case kExternalPixelArray: | 2413 case kExternalPixelArray: |
| 2369 __ movzxbq(result, Operand(external_pointer, key, times_1, 0)); | 2414 __ movzxbq(result, operand); |
| 2370 break; | 2415 break; |
| 2371 case kExternalShortArray: | 2416 case kExternalShortArray: |
| 2372 __ movsxwq(result, Operand(external_pointer, key, times_2, 0)); | 2417 __ movsxwq(result, operand); |
| 2373 break; | 2418 break; |
| 2374 case kExternalUnsignedShortArray: | 2419 case kExternalUnsignedShortArray: |
| 2375 __ movzxwq(result, Operand(external_pointer, key, times_2, 0)); | 2420 __ movzxwq(result, operand); |
| 2376 break; | 2421 break; |
| 2377 case kExternalIntArray: | 2422 case kExternalIntArray: |
| 2378 __ movsxlq(result, Operand(external_pointer, key, times_4, 0)); | 2423 __ movsxlq(result, operand); |
| 2379 break; | 2424 break; |
| 2380 case kExternalUnsignedIntArray: | 2425 case kExternalUnsignedIntArray: |
| 2381 __ movl(result, Operand(external_pointer, key, times_4, 0)); | 2426 __ movl(result, operand); |
| 2382 __ testl(result, result); | 2427 __ testl(result, result); |
| 2383 // TODO(danno): we could be more clever here, perhaps having a special | 2428 // TODO(danno): we could be more clever here, perhaps having a special |
| 2384 // version of the stub that detects if the overflow case actually | 2429 // version of the stub that detects if the overflow case actually |
| 2385 // happens, and generate code that returns a double rather than int. | 2430 // happens, and generate code that returns a double rather than int. |
| 2386 DeoptimizeIf(negative, instr->environment()); | 2431 DeoptimizeIf(negative, instr->environment()); |
| 2387 break; | 2432 break; |
| 2388 case kExternalFloatArray: | 2433 case kExternalFloatArray: |
| 2389 case kExternalDoubleArray: | 2434 case kExternalDoubleArray: |
| 2390 UNREACHABLE(); | 2435 UNREACHABLE(); |
| 2391 break; | 2436 break; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3032 __ Move(rcx, instr->hydrogen()->name()); | 3077 __ Move(rcx, instr->hydrogen()->name()); |
| 3033 Handle<Code> ic = instr->strict_mode() | 3078 Handle<Code> ic = instr->strict_mode() |
| 3034 ? isolate()->builtins()->StoreIC_Initialize_Strict() | 3079 ? isolate()->builtins()->StoreIC_Initialize_Strict() |
| 3035 : isolate()->builtins()->StoreIC_Initialize(); | 3080 : isolate()->builtins()->StoreIC_Initialize(); |
| 3036 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3081 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 3037 } | 3082 } |
| 3038 | 3083 |
| 3039 | 3084 |
| 3040 void LCodeGen::DoStoreKeyedSpecializedArrayElement( | 3085 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
| 3041 LStoreKeyedSpecializedArrayElement* instr) { | 3086 LStoreKeyedSpecializedArrayElement* instr) { |
| 3042 Register external_pointer = ToRegister(instr->external_pointer()); | |
| 3043 Register key = ToRegister(instr->key()); | |
| 3044 ExternalArrayType array_type = instr->array_type(); | 3087 ExternalArrayType array_type = instr->array_type(); |
| 3088 Operand operand(BuildExternalArrayOperand(instr->external_pointer(), | |
| 3089 instr->key(), array_type)); | |
| 3045 if (array_type == kExternalFloatArray) { | 3090 if (array_type == kExternalFloatArray) { |
| 3046 XMMRegister value(ToDoubleRegister(instr->value())); | 3091 XMMRegister value(ToDoubleRegister(instr->value())); |
| 3047 __ cvtsd2ss(value, value); | 3092 __ cvtsd2ss(value, value); |
| 3048 __ movss(Operand(external_pointer, key, times_4, 0), value); | 3093 __ movss(operand, value); |
| 3049 } else if (array_type == kExternalDoubleArray) { | 3094 } else if (array_type == kExternalDoubleArray) { |
| 3050 __ movsd(Operand(external_pointer, key, times_8, 0), | 3095 __ movsd(operand, ToDoubleRegister(instr->value())); |
| 3051 ToDoubleRegister(instr->value())); | |
| 3052 } else { | 3096 } else { |
| 3053 Register value(ToRegister(instr->value())); | 3097 Register value(ToRegister(instr->value())); |
| 3054 switch (array_type) { | 3098 switch (array_type) { |
| 3055 case kExternalPixelArray: | 3099 case kExternalPixelArray: |
| 3056 { // Clamp the value to [0..255]. | 3100 { // Clamp the value to [0..255]. |
| 3057 NearLabel done; | 3101 NearLabel done; |
| 3058 __ testl(value, Immediate(0xFFFFFF00)); | 3102 __ testl(value, Immediate(0xFFFFFF00)); |
| 3059 __ j(zero, &done); | 3103 __ j(zero, &done); |
| 3060 __ setcc(negative, value); // 1 if negative, 0 if positive. | 3104 __ setcc(negative, value); // 1 if negative, 0 if positive. |
| 3061 __ decb(value); // 0 if negative, 255 if positive. | 3105 __ decb(value); // 0 if negative, 255 if positive. |
| 3062 __ bind(&done); | 3106 __ bind(&done); |
| 3063 __ movb(Operand(external_pointer, key, times_1, 0), value); | 3107 __ movb(operand, value); |
| 3064 } | 3108 } |
| 3065 break; | 3109 break; |
| 3066 case kExternalByteArray: | 3110 case kExternalByteArray: |
| 3067 case kExternalUnsignedByteArray: | 3111 case kExternalUnsignedByteArray: |
| 3068 __ movb(Operand(external_pointer, key, times_1, 0), value); | 3112 __ movb(operand, value); |
| 3069 break; | 3113 break; |
| 3070 case kExternalShortArray: | 3114 case kExternalShortArray: |
| 3071 case kExternalUnsignedShortArray: | 3115 case kExternalUnsignedShortArray: |
| 3072 __ movw(Operand(external_pointer, key, times_2, 0), value); | 3116 __ movw(operand, value); |
| 3073 break; | 3117 break; |
| 3074 case kExternalIntArray: | 3118 case kExternalIntArray: |
| 3075 case kExternalUnsignedIntArray: | 3119 case kExternalUnsignedIntArray: |
| 3076 __ movl(Operand(external_pointer, key, times_4, 0), value); | 3120 __ movl(operand, value); |
| 3077 break; | 3121 break; |
| 3078 case kExternalFloatArray: | 3122 case kExternalFloatArray: |
| 3079 case kExternalDoubleArray: | 3123 case kExternalDoubleArray: |
| 3080 UNREACHABLE(); | 3124 UNREACHABLE(); |
| 3081 break; | 3125 break; |
| 3082 } | 3126 } |
| 3083 } | 3127 } |
| 3084 } | 3128 } |
| 3085 | 3129 |
| 3086 | 3130 |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4049 RegisterEnvironmentForDeoptimization(environment); | 4093 RegisterEnvironmentForDeoptimization(environment); |
| 4050 ASSERT(osr_pc_offset_ == -1); | 4094 ASSERT(osr_pc_offset_ == -1); |
| 4051 osr_pc_offset_ = masm()->pc_offset(); | 4095 osr_pc_offset_ = masm()->pc_offset(); |
| 4052 } | 4096 } |
| 4053 | 4097 |
| 4054 #undef __ | 4098 #undef __ |
| 4055 | 4099 |
| 4056 } } // namespace v8::internal | 4100 } } // namespace v8::internal |
| 4057 | 4101 |
| 4058 #endif // V8_TARGET_ARCH_X64 | 4102 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |