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 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 void LCodeGen::DoLoadElements(LLoadElements* instr) { | 2209 void LCodeGen::DoLoadElements(LLoadElements* instr) { |
2210 Register result = ToRegister(instr->result()); | 2210 Register result = ToRegister(instr->result()); |
2211 Register input = ToRegister(instr->InputAt(0)); | 2211 Register input = ToRegister(instr->InputAt(0)); |
2212 __ movq(result, FieldOperand(input, JSObject::kElementsOffset)); | 2212 __ movq(result, FieldOperand(input, JSObject::kElementsOffset)); |
2213 if (FLAG_debug_code) { | 2213 if (FLAG_debug_code) { |
2214 NearLabel done; | 2214 NearLabel done; |
2215 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), | 2215 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), |
2216 Heap::kFixedArrayMapRootIndex); | 2216 Heap::kFixedArrayMapRootIndex); |
2217 __ j(equal, &done); | 2217 __ j(equal, &done); |
2218 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), | 2218 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), |
2219 Heap::kExternalPixelArrayMapRootIndex); | 2219 Heap::kFixedCOWArrayMapRootIndex); |
2220 __ j(equal, &done); | 2220 __ j(equal, &done); |
2221 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), | 2221 Register temp((result.is(rax)) ? rbx : rax); |
2222 Heap::kFixedCOWArrayMapRootIndex); | 2222 __ push(temp); |
2223 __ Check(equal, "Check for fast elements failed."); | 2223 __ movq(temp, FieldOperand(result, HeapObject::kMapOffset)); |
| 2224 __ movzxbq(temp, FieldOperand(temp, Map::kInstanceTypeOffset)); |
| 2225 __ subq(temp, Immediate(FIRST_EXTERNAL_ARRAY_TYPE)); |
| 2226 __ cmpq(temp, Immediate(kExternalArrayTypeCount)); |
| 2227 __ pop(temp); |
| 2228 __ Check(below, "Check for fast elements failed."); |
2224 __ bind(&done); | 2229 __ bind(&done); |
2225 } | 2230 } |
2226 } | 2231 } |
2227 | 2232 |
2228 | 2233 |
2229 void LCodeGen::DoLoadExternalArrayPointer( | 2234 void LCodeGen::DoLoadExternalArrayPointer( |
2230 LLoadExternalArrayPointer* instr) { | 2235 LLoadExternalArrayPointer* instr) { |
2231 Register result = ToRegister(instr->result()); | 2236 Register result = ToRegister(instr->result()); |
2232 Register input = ToRegister(instr->InputAt(0)); | 2237 Register input = ToRegister(instr->InputAt(0)); |
2233 __ movq(result, FieldOperand(input, | 2238 __ movq(result, FieldOperand(input, |
(...skipping 30 matching lines...) Expand all Loading... |
2264 key, | 2269 key, |
2265 times_pointer_size, | 2270 times_pointer_size, |
2266 FixedArray::kHeaderSize)); | 2271 FixedArray::kHeaderSize)); |
2267 | 2272 |
2268 // Check for the hole value. | 2273 // Check for the hole value. |
2269 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); | 2274 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
2270 DeoptimizeIf(equal, instr->environment()); | 2275 DeoptimizeIf(equal, instr->environment()); |
2271 } | 2276 } |
2272 | 2277 |
2273 | 2278 |
2274 void LCodeGen::DoLoadPixelArrayElement(LLoadPixelArrayElement* instr) { | 2279 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
2275 Register external_elements = ToRegister(instr->external_pointer()); | 2280 LLoadKeyedSpecializedArrayElement* instr) { |
| 2281 Register external_pointer = ToRegister(instr->external_pointer()); |
2276 Register key = ToRegister(instr->key()); | 2282 Register key = ToRegister(instr->key()); |
2277 Register result = ToRegister(instr->result()); | 2283 ExternalArrayType array_type = instr->array_type(); |
2278 ASSERT(result.is(external_elements)); | 2284 if (array_type == kExternalFloatArray) { |
2279 | 2285 XMMRegister result(ToDoubleRegister(instr->result())); |
2280 // Load the result. | 2286 __ movss(result, Operand(external_pointer, key, times_4, 0)); |
2281 __ movzxbq(result, Operand(external_elements, key, times_1, 0)); | 2287 __ cvtss2sd(result, result); |
| 2288 } else { |
| 2289 Register result(ToRegister(instr->result())); |
| 2290 switch (array_type) { |
| 2291 case kExternalByteArray: |
| 2292 __ movsxbq(result, Operand(external_pointer, key, times_1, 0)); |
| 2293 break; |
| 2294 case kExternalUnsignedByteArray: |
| 2295 case kExternalPixelArray: |
| 2296 __ movzxbq(result, Operand(external_pointer, key, times_1, 0)); |
| 2297 break; |
| 2298 case kExternalShortArray: |
| 2299 __ movsxwq(result, Operand(external_pointer, key, times_2, 0)); |
| 2300 break; |
| 2301 case kExternalUnsignedShortArray: |
| 2302 __ movzxwq(result, Operand(external_pointer, key, times_2, 0)); |
| 2303 break; |
| 2304 case kExternalIntArray: |
| 2305 __ movsxlq(result, Operand(external_pointer, key, times_4, 0)); |
| 2306 break; |
| 2307 case kExternalUnsignedIntArray: |
| 2308 __ movl(result, Operand(external_pointer, key, times_4, 0)); |
| 2309 __ testl(result, result); |
| 2310 // TODO(danno): we could be more clever here, perhaps having a special |
| 2311 // version of the stub that detects if the overflow case actually |
| 2312 // happens, and generate code that returns a double rather than int. |
| 2313 DeoptimizeIf(negative, instr->environment()); |
| 2314 break; |
| 2315 case kExternalFloatArray: |
| 2316 UNREACHABLE(); |
| 2317 break; |
| 2318 } |
| 2319 } |
2282 } | 2320 } |
2283 | 2321 |
2284 | 2322 |
2285 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { | 2323 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
2286 ASSERT(ToRegister(instr->object()).is(rdx)); | 2324 ASSERT(ToRegister(instr->object()).is(rdx)); |
2287 ASSERT(ToRegister(instr->key()).is(rax)); | 2325 ASSERT(ToRegister(instr->key()).is(rax)); |
2288 | 2326 |
2289 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2327 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
2290 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2328 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2291 } | 2329 } |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 ASSERT(ToRegister(instr->value()).is(rax)); | 2923 ASSERT(ToRegister(instr->value()).is(rax)); |
2886 | 2924 |
2887 __ Move(rcx, instr->hydrogen()->name()); | 2925 __ Move(rcx, instr->hydrogen()->name()); |
2888 Handle<Code> ic = info_->is_strict() | 2926 Handle<Code> ic = info_->is_strict() |
2889 ? isolate()->builtins()->StoreIC_Initialize_Strict() | 2927 ? isolate()->builtins()->StoreIC_Initialize_Strict() |
2890 : isolate()->builtins()->StoreIC_Initialize(); | 2928 : isolate()->builtins()->StoreIC_Initialize(); |
2891 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2929 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2892 } | 2930 } |
2893 | 2931 |
2894 | 2932 |
2895 void LCodeGen::DoStorePixelArrayElement(LStorePixelArrayElement* instr) { | 2933 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
| 2934 LStoreKeyedSpecializedArrayElement* instr) { |
2896 Register external_pointer = ToRegister(instr->external_pointer()); | 2935 Register external_pointer = ToRegister(instr->external_pointer()); |
2897 Register key = ToRegister(instr->key()); | 2936 Register key = ToRegister(instr->key()); |
2898 Register value = ToRegister(instr->value()); | 2937 ExternalArrayType array_type = instr->array_type(); |
2899 | 2938 if (array_type == kExternalFloatArray) { |
2900 { // Clamp the value to [0..255]. | 2939 XMMRegister value(ToDoubleRegister(instr->value())); |
2901 NearLabel done; | 2940 __ cvtsd2ss(value, value); |
2902 __ testl(value, Immediate(0xFFFFFF00)); | 2941 __ movss(Operand(external_pointer, key, times_4, 0), value); |
2903 __ j(zero, &done); | 2942 } else { |
2904 __ setcc(negative, value); // 1 if negative, 0 if positive. | 2943 Register value(ToRegister(instr->value())); |
2905 __ decb(value); // 0 if negative, 255 if positive. | 2944 switch (array_type) { |
2906 __ bind(&done); | 2945 case kExternalPixelArray: |
| 2946 { // Clamp the value to [0..255]. |
| 2947 NearLabel done; |
| 2948 __ testl(value, Immediate(0xFFFFFF00)); |
| 2949 __ j(zero, &done); |
| 2950 __ setcc(negative, value); // 1 if negative, 0 if positive. |
| 2951 __ decb(value); // 0 if negative, 255 if positive. |
| 2952 __ bind(&done); |
| 2953 __ movb(Operand(external_pointer, key, times_1, 0), value); |
| 2954 } |
| 2955 break; |
| 2956 case kExternalByteArray: |
| 2957 case kExternalUnsignedByteArray: |
| 2958 __ movb(Operand(external_pointer, key, times_1, 0), value); |
| 2959 break; |
| 2960 case kExternalShortArray: |
| 2961 case kExternalUnsignedShortArray: |
| 2962 __ movw(Operand(external_pointer, key, times_2, 0), value); |
| 2963 break; |
| 2964 case kExternalIntArray: |
| 2965 case kExternalUnsignedIntArray: |
| 2966 __ movl(Operand(external_pointer, key, times_4, 0), value); |
| 2967 break; |
| 2968 case kExternalFloatArray: |
| 2969 UNREACHABLE(); |
| 2970 break; |
| 2971 } |
2907 } | 2972 } |
2908 | |
2909 __ movb(Operand(external_pointer, key, times_1, 0), value); | |
2910 } | 2973 } |
2911 | 2974 |
2912 | 2975 |
2913 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { | 2976 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
2914 if (instr->length()->IsRegister()) { | 2977 if (instr->length()->IsRegister()) { |
2915 __ cmpq(ToRegister(instr->index()), ToRegister(instr->length())); | 2978 __ cmpq(ToRegister(instr->index()), ToRegister(instr->length())); |
2916 } else { | 2979 } else { |
2917 __ cmpq(ToRegister(instr->index()), ToOperand(instr->length())); | 2980 __ cmpq(ToRegister(instr->index()), ToOperand(instr->length())); |
2918 } | 2981 } |
2919 DeoptimizeIf(above_equal, instr->environment()); | 2982 DeoptimizeIf(above_equal, instr->environment()); |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3879 RegisterEnvironmentForDeoptimization(environment); | 3942 RegisterEnvironmentForDeoptimization(environment); |
3880 ASSERT(osr_pc_offset_ == -1); | 3943 ASSERT(osr_pc_offset_ == -1); |
3881 osr_pc_offset_ = masm()->pc_offset(); | 3944 osr_pc_offset_ = masm()->pc_offset(); |
3882 } | 3945 } |
3883 | 3946 |
3884 #undef __ | 3947 #undef __ |
3885 | 3948 |
3886 } } // namespace v8::internal | 3949 } } // namespace v8::internal |
3887 | 3950 |
3888 #endif // V8_TARGET_ARCH_X64 | 3951 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |