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 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2176 void LCodeGen::DoLoadElements(LLoadElements* instr) { | 2176 void LCodeGen::DoLoadElements(LLoadElements* instr) { |
2177 Register result = ToRegister(instr->result()); | 2177 Register result = ToRegister(instr->result()); |
2178 Register input = ToRegister(instr->InputAt(0)); | 2178 Register input = ToRegister(instr->InputAt(0)); |
2179 __ mov(result, FieldOperand(input, JSObject::kElementsOffset)); | 2179 __ mov(result, FieldOperand(input, JSObject::kElementsOffset)); |
2180 if (FLAG_debug_code) { | 2180 if (FLAG_debug_code) { |
2181 NearLabel done; | 2181 NearLabel done; |
2182 __ cmp(FieldOperand(result, HeapObject::kMapOffset), | 2182 __ cmp(FieldOperand(result, HeapObject::kMapOffset), |
2183 Immediate(factory()->fixed_array_map())); | 2183 Immediate(factory()->fixed_array_map())); |
2184 __ j(equal, &done); | 2184 __ j(equal, &done); |
2185 __ cmp(FieldOperand(result, HeapObject::kMapOffset), | 2185 __ cmp(FieldOperand(result, HeapObject::kMapOffset), |
2186 Immediate(factory()->external_pixel_array_map())); | 2186 Immediate(factory()->fixed_cow_array_map())); |
2187 __ j(equal, &done); | 2187 __ j(equal, &done); |
2188 __ cmp(FieldOperand(result, HeapObject::kMapOffset), | 2188 Register temp((result.is(eax)) ? ebx : eax); |
Mads Ager (chromium)
2011/03/24 11:31:20
Does it hurt anything to just let the register all
danno
2011/03/24 13:18:38
Since this is only for debug code to verify/assert
fschneider
2011/03/24 13:26:11
No worry :) It's only when FLAG_debug_code is on.
| |
2189 Immediate(factory()->fixed_cow_array_map())); | 2189 __ push(temp); |
2190 __ Check(equal, "Check for fast elements or pixel array failed."); | 2190 __ mov(temp, FieldOperand(result, HeapObject::kMapOffset)); |
2191 __ movzx_b(temp, FieldOperand(temp, Map::kInstanceTypeOffset)); | |
2192 __ sub(Operand(temp), Immediate(FIRST_EXTERNAL_ARRAY_TYPE)); | |
2193 __ cmp(Operand(temp), Immediate(kExternalArrayTypeCount)); | |
2194 __ pop(temp); | |
2195 __ Check(below, "Check for fast elements or pixel array failed."); | |
2191 __ bind(&done); | 2196 __ bind(&done); |
2192 } | 2197 } |
2193 } | 2198 } |
2194 | 2199 |
2195 | 2200 |
2196 void LCodeGen::DoLoadExternalArrayPointer( | 2201 void LCodeGen::DoLoadExternalArrayPointer( |
2197 LLoadExternalArrayPointer* instr) { | 2202 LLoadExternalArrayPointer* instr) { |
2198 Register result = ToRegister(instr->result()); | 2203 Register result = ToRegister(instr->result()); |
2199 Register input = ToRegister(instr->InputAt(0)); | 2204 Register input = ToRegister(instr->InputAt(0)); |
2200 __ mov(result, FieldOperand(input, | 2205 __ mov(result, FieldOperand(input, |
(...skipping 27 matching lines...) Expand all Loading... | |
2228 key, | 2233 key, |
2229 times_pointer_size, | 2234 times_pointer_size, |
2230 FixedArray::kHeaderSize)); | 2235 FixedArray::kHeaderSize)); |
2231 | 2236 |
2232 // Check for the hole value. | 2237 // Check for the hole value. |
2233 __ cmp(result, factory()->the_hole_value()); | 2238 __ cmp(result, factory()->the_hole_value()); |
2234 DeoptimizeIf(equal, instr->environment()); | 2239 DeoptimizeIf(equal, instr->environment()); |
2235 } | 2240 } |
2236 | 2241 |
2237 | 2242 |
2238 void LCodeGen::DoLoadPixelArrayElement(LLoadPixelArrayElement* instr) { | 2243 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
2244 LLoadKeyedSpecializedArrayElement* instr) { | |
2239 Register external_pointer = ToRegister(instr->external_pointer()); | 2245 Register external_pointer = ToRegister(instr->external_pointer()); |
2240 Register key = ToRegister(instr->key()); | 2246 Register key = ToRegister(instr->key()); |
2241 Register result = ToRegister(instr->result()); | 2247 ExternalArrayType array_type = instr->array_type(); |
2242 ASSERT(result.is(external_pointer)); | 2248 switch (array_type) { |
2243 | 2249 case kExternalByteArray: |
2244 // Load the result. | 2250 __ movsx_b(ToRegister(instr->result()), |
Kevin Millikin (Chromium)
2011/03/24 11:21:00
I think if you named ToRegister(instr->result()) w
danno
2011/03/24 13:18:38
The problem is that the ToRegister asserts in the
Kevin Millikin (Chromium)
2011/03/24 13:29:40
I didn't think of the ToDoubleRegister case. You
| |
2245 __ movzx_b(result, Operand(external_pointer, key, times_1, 0)); | 2251 Operand(external_pointer, key, times_1, 0)); |
2252 break; | |
2253 case kExternalUnsignedByteArray: | |
2254 case kExternalPixelArray: | |
2255 __ movzx_b(ToRegister(instr->result()), | |
2256 Operand(external_pointer, key, times_1, 0)); | |
2257 break; | |
2258 case kExternalShortArray: | |
2259 __ movsx_w(ToRegister(instr->result()), | |
2260 Operand(external_pointer, key, times_2, 0)); | |
2261 break; | |
2262 case kExternalUnsignedShortArray: | |
2263 __ movzx_w(ToRegister(instr->result()), | |
2264 Operand(external_pointer, key, times_2, 0)); | |
2265 break; | |
2266 case kExternalIntArray: | |
2267 __ mov(ToRegister(instr->result()), | |
2268 Operand(external_pointer, key, times_4, 0)); | |
2269 break; | |
2270 case kExternalUnsignedIntArray: { | |
2271 Register result(ToRegister(instr->result())); | |
Kevin Millikin (Chromium)
2011/03/24 11:21:00
Indentation looks off a bit.
danno
2011/03/24 13:18:38
Not sure what you mean, I introduced a separate sc
Kevin Millikin (Chromium)
2011/03/24 13:29:40
"Register" looks indented by 3 (lines up with the
| |
2272 __ mov(result, Operand(external_pointer, key, times_4, 0)); | |
2273 __ cmp(Operand(result), Immediate(0x80000000)); | |
Kevin Millikin (Chromium)
2011/03/24 11:21:00
Alternatively (seems more idiomatic to me for some
danno
2011/03/24 13:18:38
Done.
Lasse Reichstein
2011/03/24 22:09:02
Or use:
__ test(result, Operand(result));
Deop
| |
2274 // TODO(danno): we could be more clever here, perhaps having a special | |
2275 // version of the stub that detects if the overflow case actually happens, | |
2276 // and generate code that returns a double rather than int. | |
2277 DeoptimizeIf(above_equal, instr->environment()); | |
2278 break; | |
2279 } | |
2280 case kExternalFloatArray: { | |
2281 XMMRegister result(ToDoubleRegister(instr->result())); | |
2282 __ movss(result, Operand(external_pointer, key, times_4, 0)); | |
2283 __ cvtss2sd(result, result); | |
2284 break; | |
2285 } | |
2286 } | |
2246 } | 2287 } |
2247 | 2288 |
2248 | 2289 |
2249 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { | 2290 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
2250 ASSERT(ToRegister(instr->context()).is(esi)); | 2291 ASSERT(ToRegister(instr->context()).is(esi)); |
2251 ASSERT(ToRegister(instr->object()).is(edx)); | 2292 ASSERT(ToRegister(instr->object()).is(edx)); |
2252 ASSERT(ToRegister(instr->key()).is(eax)); | 2293 ASSERT(ToRegister(instr->key()).is(eax)); |
2253 | 2294 |
2254 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2295 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
2255 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2296 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2860 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2901 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2861 } | 2902 } |
2862 | 2903 |
2863 | 2904 |
2864 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { | 2905 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
2865 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); | 2906 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); |
2866 DeoptimizeIf(above_equal, instr->environment()); | 2907 DeoptimizeIf(above_equal, instr->environment()); |
2867 } | 2908 } |
2868 | 2909 |
2869 | 2910 |
2870 void LCodeGen::DoStorePixelArrayElement(LStorePixelArrayElement* instr) { | 2911 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
2912 LStoreKeyedSpecializedArrayElement* instr) { | |
2871 Register external_pointer = ToRegister(instr->external_pointer()); | 2913 Register external_pointer = ToRegister(instr->external_pointer()); |
2872 Register key = ToRegister(instr->key()); | 2914 Register key = ToRegister(instr->key()); |
2873 Register value = ToRegister(instr->value()); | |
2874 ASSERT(ToRegister(instr->TempAt(0)).is(eax)); | |
2875 | 2915 |
2876 __ mov(eax, value); | 2916 switch (instr->array_type()) { |
2877 { // Clamp the value to [0..255]. | 2917 case kExternalPixelArray: |
2878 NearLabel done; | 2918 { // Clamp the value to [0..255]. |
2879 __ test(eax, Immediate(0xFFFFFF00)); | 2919 ASSERT(ToRegister(instr->TempAt(0)).is(eax)); |
Mads Ager (chromium)
2011/03/24 11:31:20
Instead of having this assert, let's just do
Regi
danno
2011/03/24 13:18:38
Actually, I think this assert it important, since
| |
2880 __ j(zero, &done); | 2920 __ mov(eax, ToRegister(instr->value())); |
2881 __ setcc(negative, eax); // 1 if negative, 0 if positive. | 2921 NearLabel done; |
2882 __ dec_b(eax); // 0 if negative, 255 if positive. | 2922 __ test(eax, Immediate(0xFFFFFF00)); |
2883 __ bind(&done); | 2923 __ j(zero, &done); |
2924 __ setcc(negative, eax); // 1 if negative, 0 if positive. | |
2925 __ dec_b(eax); // 0 if negative, 255 if positive. | |
2926 __ bind(&done); | |
2927 __ mov_b(Operand(external_pointer, key, times_1, 0), eax); | |
2928 } | |
2929 break; | |
2930 case kExternalByteArray: | |
2931 case kExternalUnsignedByteArray: | |
2932 __ mov_b(Operand(external_pointer, key, times_1, 0), | |
2933 ToRegister(instr->value())); | |
2934 break; | |
2935 case kExternalShortArray: | |
2936 case kExternalUnsignedShortArray: | |
2937 __ mov_w(Operand(external_pointer, key, times_2, 0), | |
2938 ToRegister(instr->value())); | |
2939 break; | |
2940 case kExternalIntArray: | |
2941 case kExternalUnsignedIntArray: | |
2942 __ mov(Operand(external_pointer, key, times_4, 0), | |
2943 ToRegister(instr->value())); | |
2944 break; | |
2945 case kExternalFloatArray: { | |
2946 XMMRegister temp(ToDoubleRegister(instr->TempAt(0))); | |
2947 __ cvtsd2ss(temp, ToDoubleRegister(instr->value())); | |
2948 __ movss(Operand(external_pointer, key, times_4, 0), temp); | |
2949 break; | |
2950 } | |
2884 } | 2951 } |
2885 __ mov_b(Operand(external_pointer, key, times_1, 0), eax); | |
2886 } | 2952 } |
2887 | 2953 |
2888 | 2954 |
2889 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { | 2955 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
2890 Register value = ToRegister(instr->value()); | 2956 Register value = ToRegister(instr->value()); |
2891 Register elements = ToRegister(instr->object()); | 2957 Register elements = ToRegister(instr->object()); |
2892 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; | 2958 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
2893 | 2959 |
2894 // Do the store. | 2960 // Do the store. |
2895 if (instr->key()->IsConstantOperand()) { | 2961 if (instr->key()->IsConstantOperand()) { |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4002 ASSERT(osr_pc_offset_ == -1); | 4068 ASSERT(osr_pc_offset_ == -1); |
4003 osr_pc_offset_ = masm()->pc_offset(); | 4069 osr_pc_offset_ = masm()->pc_offset(); |
4004 } | 4070 } |
4005 | 4071 |
4006 | 4072 |
4007 #undef __ | 4073 #undef __ |
4008 | 4074 |
4009 } } // namespace v8::internal | 4075 } } // namespace v8::internal |
4010 | 4076 |
4011 #endif // V8_TARGET_ARCH_IA32 | 4077 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |