| 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 3242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3253 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3253 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3254 } | 3254 } |
| 3255 | 3255 |
| 3256 | 3256 |
| 3257 static void GenerateSmiKeyCheck(MacroAssembler* masm, | 3257 static void GenerateSmiKeyCheck(MacroAssembler* masm, |
| 3258 Register key, | 3258 Register key, |
| 3259 Register scratch, | 3259 Register scratch, |
| 3260 XMMRegister xmm_scratch0, | 3260 XMMRegister xmm_scratch0, |
| 3261 XMMRegister xmm_scratch1, | 3261 XMMRegister xmm_scratch1, |
| 3262 Label* fail) { | 3262 Label* fail) { |
| 3263 // Check that key is a smi and if SSE2 is available a heap number | 3263 // Check that key is a smi or a heap number |
| 3264 // containing a smi and branch if the check fails. | 3264 // containing a smi and branch if the check fails. |
| 3265 if (CpuFeatures::IsSupported(SSE2)) { | 3265 Label key_ok, key_tag; |
| 3266 CpuFeatureScope use_sse2(masm, SSE2); | 3266 __ JumpIfSmi(key, &key_ok); |
| 3267 Label key_ok; | 3267 __ TaggedToI(key, scratch, xmm_scratch0, false, &key_tag, fail); |
| 3268 __ JumpIfSmi(key, &key_ok); | 3268 __ bind(&key_tag); |
| 3269 __ cmp(FieldOperand(key, HeapObject::kMapOffset), | 3269 __ SmiTag(scratch); |
| 3270 Immediate(Handle<Map>(masm->isolate()->heap()->heap_number_map()))); | 3270 __ j(overflow, fail); |
| 3271 __ j(not_equal, fail); | 3271 __ mov(key, scratch); |
| 3272 __ movdbl(xmm_scratch0, FieldOperand(key, HeapNumber::kValueOffset)); | 3272 __ bind(&key_ok); |
| 3273 __ cvttsd2si(scratch, Operand(xmm_scratch0)); | |
| 3274 __ cvtsi2sd(xmm_scratch1, scratch); | |
| 3275 __ ucomisd(xmm_scratch1, xmm_scratch0); | |
| 3276 __ j(not_equal, fail); | |
| 3277 __ j(parity_even, fail); // NaN. | |
| 3278 // Check if the key fits in the smi range. | |
| 3279 __ cmp(scratch, 0xc0000000); | |
| 3280 __ j(sign, fail); | |
| 3281 __ SmiTag(scratch); | |
| 3282 __ mov(key, scratch); | |
| 3283 __ bind(&key_ok); | |
| 3284 } else { | |
| 3285 __ JumpIfNotSmi(key, fail); | |
| 3286 } | |
| 3287 } | 3273 } |
| 3288 | 3274 |
| 3289 | 3275 |
| 3290 void KeyedStoreStubCompiler::GenerateStoreExternalArray( | 3276 void KeyedStoreStubCompiler::GenerateStoreExternalArray( |
| 3291 MacroAssembler* masm, | 3277 MacroAssembler* masm, |
| 3292 ElementsKind elements_kind) { | 3278 ElementsKind elements_kind) { |
| 3293 // ----------- S t a t e ------------- | 3279 // ----------- S t a t e ------------- |
| 3294 // -- eax : value | 3280 // -- eax : value |
| 3295 // -- ecx : key | 3281 // -- ecx : key |
| 3296 // -- edx : receiver | 3282 // -- edx : receiver |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3382 // edi: base pointer of external storage | 3368 // edi: base pointer of external storage |
| 3383 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { | 3369 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
| 3384 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 3370 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3385 __ fstp_s(Operand(edi, ecx, times_2, 0)); | 3371 __ fstp_s(Operand(edi, ecx, times_2, 0)); |
| 3386 __ ret(0); | 3372 __ ret(0); |
| 3387 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 3373 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| 3388 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 3374 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| 3389 __ fstp_d(Operand(edi, ecx, times_4, 0)); | 3375 __ fstp_d(Operand(edi, ecx, times_4, 0)); |
| 3390 __ ret(0); | 3376 __ ret(0); |
| 3391 } else { | 3377 } else { |
| 3392 // Perform float-to-int conversion with truncation (round-to-zero) | 3378 // Truncate the HeapNumber to an int32 |
| 3393 // behavior. | 3379 __ TruncateHeapNumberToI(eax, ebx); |
| 3394 | 3380 |
| 3395 // For the moment we make the slow call to the runtime on | 3381 if ((elements_kind == EXTERNAL_INT_ELEMENTS || |
| 3396 // processors that don't support SSE2. The code in IntegerConvert | 3382 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS)) { |
| 3397 // (code-stubs-ia32.cc) is roughly what is needed here though the | |
| 3398 // conversion failure case does not need to be handled. | |
| 3399 if (CpuFeatures::IsSupported(SSE2)) { | |
| 3400 if ((elements_kind == EXTERNAL_INT_ELEMENTS || | |
| 3401 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) && | |
| 3402 CpuFeatures::IsSupported(SSE3)) { | |
| 3403 CpuFeatureScope scope(masm, SSE3); | |
| 3404 // fisttp stores values as signed integers. To represent the | |
| 3405 // entire range of int and unsigned int arrays, store as a | |
| 3406 // 64-bit int and discard the high 32 bits. | |
| 3407 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | |
| 3408 __ sub(esp, Immediate(2 * kPointerSize)); | |
| 3409 __ fisttp_d(Operand(esp, 0)); | |
| 3410 | |
| 3411 // If conversion failed (NaN, infinity, or a number outside | |
| 3412 // signed int64 range), the result is 0x8000000000000000, and | |
| 3413 // we must handle this case in the runtime. | |
| 3414 Label ok; | |
| 3415 __ cmp(Operand(esp, kPointerSize), Immediate(0x80000000u)); | |
| 3416 __ j(not_equal, &ok); | |
| 3417 __ cmp(Operand(esp, 0), Immediate(0)); | |
| 3418 __ j(not_equal, &ok); | |
| 3419 __ add(esp, Immediate(2 * kPointerSize)); // Restore the stack. | |
| 3420 __ jmp(&slow); | |
| 3421 | |
| 3422 __ bind(&ok); | |
| 3423 __ pop(ebx); | |
| 3424 __ add(esp, Immediate(kPointerSize)); | |
| 3425 __ mov(Operand(edi, ecx, times_2, 0), ebx); | 3383 __ mov(Operand(edi, ecx, times_2, 0), ebx); |
| 3426 } else { | 3384 } else { |
| 3427 ASSERT(CpuFeatures::IsSupported(SSE2)); | 3385 // ebx: untagged integer value |
| 3428 CpuFeatureScope scope(masm, SSE2); | 3386 switch (elements_kind) { |
| 3429 __ cvttsd2si(ebx, FieldOperand(eax, HeapNumber::kValueOffset)); | 3387 case EXTERNAL_PIXEL_ELEMENTS: |
| 3430 __ cmp(ebx, 0x80000000u); | 3388 __ ClampUint8(ebx); |
| 3431 __ j(equal, &slow); | 3389 // Fall through. |
| 3432 // ebx: untagged integer value | 3390 case EXTERNAL_BYTE_ELEMENTS: |
| 3433 switch (elements_kind) { | 3391 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 3434 case EXTERNAL_PIXEL_ELEMENTS: | 3392 __ SmiUntag(ecx); |
| 3435 __ ClampUint8(ebx); | 3393 __ mov_b(Operand(edi, ecx, times_1, 0), ebx); |
| 3436 // Fall through. | 3394 break; |
| 3437 case EXTERNAL_BYTE_ELEMENTS: | 3395 case EXTERNAL_SHORT_ELEMENTS: |
| 3438 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3396 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3439 __ SmiUntag(ecx); | 3397 __ mov_w(Operand(edi, ecx, times_1, 0), ebx); |
| 3440 __ mov_b(Operand(edi, ecx, times_1, 0), ebx); | 3398 break; |
| 3441 break; | 3399 case EXTERNAL_INT_ELEMENTS: |
| 3442 case EXTERNAL_SHORT_ELEMENTS: | 3400 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3443 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3401 __ mov(Operand(edi, ecx, times_2, 0), ebx); |
| 3444 __ mov_w(Operand(edi, ecx, times_1, 0), ebx); | 3402 break; |
| 3445 break; | 3403 default: |
| 3446 case EXTERNAL_INT_ELEMENTS: | 3404 UNREACHABLE(); |
| 3447 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3405 break; |
| 3448 __ mov(Operand(edi, ecx, times_2, 0), ebx); | 3406 } |
| 3449 break; | |
| 3450 default: | |
| 3451 UNREACHABLE(); | |
| 3452 break; | |
| 3453 } | |
| 3454 } | |
| 3455 __ ret(0); // Return original value. | |
| 3456 } | 3407 } |
| 3408 __ ret(0); // Return original value. |
| 3457 } | 3409 } |
| 3458 } | 3410 } |
| 3459 | 3411 |
| 3460 // Slow case: call runtime. | 3412 // Slow case: call runtime. |
| 3461 __ bind(&slow); | 3413 __ bind(&slow); |
| 3462 Counters* counters = masm->isolate()->counters(); | 3414 Counters* counters = masm->isolate()->counters(); |
| 3463 __ IncrementCounter(counters->keyed_store_external_array_slow(), 1); | 3415 __ IncrementCounter(counters->keyed_store_external_array_slow(), 1); |
| 3464 | 3416 |
| 3465 // ----------- S t a t e ------------- | 3417 // ----------- S t a t e ------------- |
| 3466 // -- eax : value | 3418 // -- eax : value |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3766 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3718 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
| 3767 } | 3719 } |
| 3768 } | 3720 } |
| 3769 | 3721 |
| 3770 | 3722 |
| 3771 #undef __ | 3723 #undef __ |
| 3772 | 3724 |
| 3773 } } // namespace v8::internal | 3725 } } // namespace v8::internal |
| 3774 | 3726 |
| 3775 #endif // V8_TARGET_ARCH_IA32 | 3727 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |