Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 10260011: Fixed corner cases in truncation behavior when storing to TypedArrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | test/mjsunit/regress/regress-2110.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3394 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { 3394 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) {
3395 __ cvtsd2ss(xmm0, xmm0); 3395 __ cvtsd2ss(xmm0, xmm0);
3396 __ movss(Operand(rbx, rdi, times_4, 0), xmm0); 3396 __ movss(Operand(rbx, rdi, times_4, 0), xmm0);
3397 __ ret(0); 3397 __ ret(0);
3398 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { 3398 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
3399 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0); 3399 __ movsd(Operand(rbx, rdi, times_8, 0), xmm0);
3400 __ ret(0); 3400 __ ret(0);
3401 } else { 3401 } else {
3402 // Perform float-to-int conversion with truncation (round-to-zero) 3402 // Perform float-to-int conversion with truncation (round-to-zero)
3403 // behavior. 3403 // behavior.
3404 // Fast path: use machine instruction to convert to int64. If that
3405 // fails (out-of-range), go into the runtime.
3406 __ cvttsd2siq(rdx, xmm0);
3407 __ Set(kScratchRegister, V8_UINT64_C(0x8000000000000000));
3408 __ cmpq(rdx, kScratchRegister);
3409 __ j(equal, &slow);
3404 3410
3405 // Convert to int32 and store the low byte/word.
3406 // If the value is NaN or +/-infinity, the result is 0x80000000,
3407 // which is automatically zero when taken mod 2^n, n < 32.
3408 // rdx: value (converted to an untagged integer) 3411 // rdx: value (converted to an untagged integer)
3409 // rdi: untagged index 3412 // rdi: untagged index
3410 // rbx: base pointer of external storage 3413 // rbx: base pointer of external storage
3411 switch (elements_kind) { 3414 switch (elements_kind) {
3412 case EXTERNAL_BYTE_ELEMENTS: 3415 case EXTERNAL_BYTE_ELEMENTS:
3413 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 3416 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3414 __ cvttsd2si(rdx, xmm0);
3415 __ movb(Operand(rbx, rdi, times_1, 0), rdx); 3417 __ movb(Operand(rbx, rdi, times_1, 0), rdx);
3416 break; 3418 break;
3417 case EXTERNAL_SHORT_ELEMENTS: 3419 case EXTERNAL_SHORT_ELEMENTS:
3418 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 3420 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
3419 __ cvttsd2si(rdx, xmm0);
3420 __ movw(Operand(rbx, rdi, times_2, 0), rdx); 3421 __ movw(Operand(rbx, rdi, times_2, 0), rdx);
3421 break; 3422 break;
3422 case EXTERNAL_INT_ELEMENTS: 3423 case EXTERNAL_INT_ELEMENTS:
3423 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 3424 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
3424 // Convert to int64, so that NaN and infinities become
3425 // 0x8000000000000000, which is zero mod 2^32.
3426 __ cvttsd2siq(rdx, xmm0);
3427 __ movl(Operand(rbx, rdi, times_4, 0), rdx); 3425 __ movl(Operand(rbx, rdi, times_4, 0), rdx);
3428 break; 3426 break;
3429 case EXTERNAL_PIXEL_ELEMENTS: 3427 case EXTERNAL_PIXEL_ELEMENTS:
3430 case EXTERNAL_FLOAT_ELEMENTS: 3428 case EXTERNAL_FLOAT_ELEMENTS:
3431 case EXTERNAL_DOUBLE_ELEMENTS: 3429 case EXTERNAL_DOUBLE_ELEMENTS:
3432 case FAST_ELEMENTS: 3430 case FAST_ELEMENTS:
3433 case FAST_SMI_ONLY_ELEMENTS: 3431 case FAST_SMI_ONLY_ELEMENTS:
3434 case FAST_DOUBLE_ELEMENTS: 3432 case FAST_DOUBLE_ELEMENTS:
3435 case DICTIONARY_ELEMENTS: 3433 case DICTIONARY_ELEMENTS:
3436 case NON_STRICT_ARGUMENTS_ELEMENTS: 3434 case NON_STRICT_ARGUMENTS_ELEMENTS:
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3825 __ jmp(ic_slow, RelocInfo::CODE_TARGET); 3823 __ jmp(ic_slow, RelocInfo::CODE_TARGET);
3826 } 3824 }
3827 } 3825 }
3828 3826
3829 3827
3830 #undef __ 3828 #undef __
3831 3829
3832 } } // namespace v8::internal 3830 } } // namespace v8::internal
3833 3831
3834 #endif // V8_TARGET_ARCH_X64 3832 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | test/mjsunit/regress/regress-2110.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698