OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 &miss); | 2239 &miss); |
2240 GenerateLoadFunctionFromCell(cell, function, &miss); | 2240 GenerateLoadFunctionFromCell(cell, function, &miss); |
2241 } | 2241 } |
2242 // Load the (only) argument into rax. | 2242 // Load the (only) argument into rax. |
2243 __ movq(rax, Operand(rsp, 1 * kPointerSize)); | 2243 __ movq(rax, Operand(rsp, 1 * kPointerSize)); |
2244 | 2244 |
2245 // Check if the argument is a smi. | 2245 // Check if the argument is a smi. |
2246 Label not_smi; | 2246 Label not_smi; |
2247 STATIC_ASSERT(kSmiTag == 0); | 2247 STATIC_ASSERT(kSmiTag == 0); |
2248 __ JumpIfNotSmi(rax, ¬_smi); | 2248 __ JumpIfNotSmi(rax, ¬_smi); |
2249 __ SmiToInteger32(rax, rax); | |
2250 | 2249 |
2251 // Set ebx to 1...1 (== -1) if the argument is negative, or to 0...0 | 2250 // Set ebx to 1...1 (== -1) if the argument is negative, or to 0...0 |
2252 // otherwise. | 2251 // otherwise. |
2253 __ movl(rbx, rax); | 2252 __ movq(rbx, rax); |
2254 __ sarl(rbx, Immediate(kBitsPerInt - 1)); | 2253 __ sar(rbx, Immediate(kBitsPerPointer - 1)); |
2255 | 2254 |
2256 // Do bitwise not or do nothing depending on ebx. | 2255 // Do bitwise not or do nothing depending on ebx. |
2257 __ xorl(rax, rbx); | 2256 __ xor_(rax, rbx); |
2258 | 2257 |
2259 // Add 1 or do nothing depending on ebx. | 2258 // Add 1 or do nothing depending on ebx. |
2260 __ subl(rax, rbx); | 2259 if (SmiValuesAre32Bits()) { |
| 2260 __ subq(rax, rbx); |
| 2261 } else { |
| 2262 ASSERT(SmiValuesAre31Bits()); |
| 2263 __ subl(rax, rbx); |
| 2264 } |
2261 | 2265 |
2262 // If the result is still negative, go to the slow case. | 2266 // If the result is still negative, go to the slow case. |
2263 // This only happens for the most negative smi. | 2267 // This only happens for the most negative smi. |
2264 Label slow; | 2268 Label slow; |
2265 __ j(negative, &slow); | 2269 __ j(negative, &slow); |
2266 | 2270 |
2267 // Smi case done. | |
2268 __ Integer32ToSmi(rax, rax); | |
2269 __ ret(2 * kPointerSize); | 2271 __ ret(2 * kPointerSize); |
2270 | 2272 |
2271 // Check if the argument is a heap number and load its value. | 2273 // Check if the argument is a heap number and load its value. |
2272 __ bind(¬_smi); | 2274 __ bind(¬_smi); |
2273 __ CheckMap(rax, factory()->heap_number_map(), &slow, DONT_DO_SMI_CHECK); | 2275 __ CheckMap(rax, factory()->heap_number_map(), &slow, DONT_DO_SMI_CHECK); |
2274 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); | 2276 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); |
2275 | 2277 |
2276 // Check the sign of the argument. If the argument is positive, | 2278 // Check the sign of the argument. If the argument is positive, |
2277 // just return it. | 2279 // just return it. |
2278 Label negative_sign; | 2280 Label negative_sign; |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 __ CheckMap(key, | 3053 __ CheckMap(key, |
3052 masm->isolate()->factory()->heap_number_map(), | 3054 masm->isolate()->factory()->heap_number_map(), |
3053 fail, | 3055 fail, |
3054 DONT_DO_SMI_CHECK); | 3056 DONT_DO_SMI_CHECK); |
3055 __ movsd(xmm_scratch0, FieldOperand(key, HeapNumber::kValueOffset)); | 3057 __ movsd(xmm_scratch0, FieldOperand(key, HeapNumber::kValueOffset)); |
3056 __ cvttsd2si(scratch, xmm_scratch0); | 3058 __ cvttsd2si(scratch, xmm_scratch0); |
3057 __ cvtlsi2sd(xmm_scratch1, scratch); | 3059 __ cvtlsi2sd(xmm_scratch1, scratch); |
3058 __ ucomisd(xmm_scratch1, xmm_scratch0); | 3060 __ ucomisd(xmm_scratch1, xmm_scratch0); |
3059 __ j(not_equal, fail); | 3061 __ j(not_equal, fail); |
3060 __ j(parity_even, fail); // NaN. | 3062 __ j(parity_even, fail); // NaN. |
| 3063 __ JumpIfNotValidSmiValue(scratch, fail); |
3061 __ Integer32ToSmi(key, scratch); | 3064 __ Integer32ToSmi(key, scratch); |
3062 __ bind(&key_ok); | 3065 __ bind(&key_ok); |
3063 } | 3066 } |
3064 | 3067 |
3065 | 3068 |
3066 void KeyedStoreStubCompiler::GenerateStoreExternalArray( | 3069 void KeyedStoreStubCompiler::GenerateStoreExternalArray( |
3067 MacroAssembler* masm, | 3070 MacroAssembler* masm, |
3068 ElementsKind elements_kind) { | 3071 ElementsKind elements_kind) { |
3069 // ----------- S t a t e ------------- | 3072 // ----------- S t a t e ------------- |
3070 // -- rax : value | 3073 // -- rax : value |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3514 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3517 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3515 } | 3518 } |
3516 } | 3519 } |
3517 | 3520 |
3518 | 3521 |
3519 #undef __ | 3522 #undef __ |
3520 | 3523 |
3521 } } // namespace v8::internal | 3524 } } // namespace v8::internal |
3522 | 3525 |
3523 #endif // V8_TARGET_ARCH_X64 | 3526 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |