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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 225393005: x64: Make sure that the upper half of a 64bit register contains 0 for int32 values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Added comment. Created 6 years, 8 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/x64/assembler-x64.cc ('k') | src/x64/lithium-x64.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (instr->IsCall()) { 277 if (instr->IsCall()) {
278 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); 278 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
279 } 279 }
280 if (!instr->IsLazyBailout() && !instr->IsGap()) { 280 if (!instr->IsLazyBailout() && !instr->IsGap()) {
281 safepoints_.BumpLastLazySafepointIndex(); 281 safepoints_.BumpLastLazySafepointIndex();
282 } 282 }
283 } 283 }
284 284
285 285
286 void LCodeGen::GenerateBodyInstructionPost(LInstruction* instr) { 286 void LCodeGen::GenerateBodyInstructionPost(LInstruction* instr) {
287 if (FLAG_debug_code && FLAG_enable_slow_asserts && instr->HasResult() &&
288 instr->hydrogen_value()->representation().IsInteger32() &&
289 instr->result()->IsRegister()) {
290 __ AssertZeroExtended(ToRegister(instr->result()));
291 }
292
287 if (instr->HasResult() && instr->MustSignExtendResult(chunk())) { 293 if (instr->HasResult() && instr->MustSignExtendResult(chunk())) {
288 if (instr->result()->IsRegister()) { 294 if (instr->result()->IsRegister()) {
289 Register result_reg = ToRegister(instr->result()); 295 Register result_reg = ToRegister(instr->result());
290 __ movsxlq(result_reg, result_reg); 296 __ movsxlq(result_reg, result_reg);
291 } else { 297 } else {
292 // Sign extend the 32bit result in the stack slots. 298 // Sign extend the 32bit result in the stack slots.
293 ASSERT(instr->result()->IsStackSlot()); 299 ASSERT(instr->result()->IsStackSlot());
294 Operand src = ToOperand(instr->result()); 300 Operand src = ToOperand(instr->result());
295 __ movsxlq(kScratchRegister, src); 301 __ movsxlq(kScratchRegister, src);
296 __ movq(src, kScratchRegister); 302 __ movq(src, kScratchRegister);
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 } 1320 }
1315 1321
1316 // Check for (0 / -x) that will produce negative zero. 1322 // Check for (0 / -x) that will produce negative zero.
1317 HDiv* hdiv = instr->hydrogen(); 1323 HDiv* hdiv = instr->hydrogen();
1318 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { 1324 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
1319 __ testl(dividend, dividend); 1325 __ testl(dividend, dividend);
1320 DeoptimizeIf(zero, instr->environment()); 1326 DeoptimizeIf(zero, instr->environment());
1321 } 1327 }
1322 1328
1323 __ TruncatingDiv(dividend, Abs(divisor)); 1329 __ TruncatingDiv(dividend, Abs(divisor));
1324 if (divisor < 0) __ negp(rdx); 1330 if (divisor < 0) __ negl(rdx);
1325 1331
1326 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { 1332 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1327 __ movl(rax, rdx); 1333 __ movl(rax, rdx);
1328 __ imull(rax, rax, Immediate(divisor)); 1334 __ imull(rax, rax, Immediate(divisor));
1329 __ subl(rax, dividend); 1335 __ subl(rax, dividend);
1330 DeoptimizeIf(not_equal, instr->environment()); 1336 DeoptimizeIf(not_equal, instr->environment());
1331 } 1337 }
1332 } 1338 }
1333 1339
1334 1340
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 __ xorl(ToRegister(left), Immediate(right_operand)); 1524 __ xorl(ToRegister(left), Immediate(right_operand));
1519 } 1525 }
1520 break; 1526 break;
1521 default: 1527 default:
1522 UNREACHABLE(); 1528 UNREACHABLE();
1523 break; 1529 break;
1524 } 1530 }
1525 } else if (right->IsStackSlot()) { 1531 } else if (right->IsStackSlot()) {
1526 switch (instr->op()) { 1532 switch (instr->op()) {
1527 case Token::BIT_AND: 1533 case Token::BIT_AND:
1528 __ andp(ToRegister(left), ToOperand(right)); 1534 if (instr->IsInteger32()) {
1535 __ andl(ToRegister(left), ToOperand(right));
1536 } else {
1537 __ andp(ToRegister(left), ToOperand(right));
1538 }
1529 break; 1539 break;
1530 case Token::BIT_OR: 1540 case Token::BIT_OR:
1531 __ orp(ToRegister(left), ToOperand(right)); 1541 if (instr->IsInteger32()) {
1542 __ orl(ToRegister(left), ToOperand(right));
1543 } else {
1544 __ orp(ToRegister(left), ToOperand(right));
1545 }
1532 break; 1546 break;
1533 case Token::BIT_XOR: 1547 case Token::BIT_XOR:
1534 __ xorp(ToRegister(left), ToOperand(right)); 1548 if (instr->IsInteger32()) {
1549 __ xorl(ToRegister(left), ToOperand(right));
1550 } else {
1551 __ xorp(ToRegister(left), ToOperand(right));
1552 }
1535 break; 1553 break;
1536 default: 1554 default:
1537 UNREACHABLE(); 1555 UNREACHABLE();
1538 break; 1556 break;
1539 } 1557 }
1540 } else { 1558 } else {
1541 ASSERT(right->IsRegister()); 1559 ASSERT(right->IsRegister());
1542 switch (instr->op()) { 1560 switch (instr->op()) {
1543 case Token::BIT_AND: 1561 case Token::BIT_AND:
1544 __ andp(ToRegister(left), ToRegister(right)); 1562 if (instr->IsInteger32()) {
1563 __ andl(ToRegister(left), ToRegister(right));
1564 } else {
1565 __ andp(ToRegister(left), ToRegister(right));
1566 }
1545 break; 1567 break;
1546 case Token::BIT_OR: 1568 case Token::BIT_OR:
1547 __ orp(ToRegister(left), ToRegister(right)); 1569 if (instr->IsInteger32()) {
1570 __ orl(ToRegister(left), ToRegister(right));
1571 } else {
1572 __ orp(ToRegister(left), ToRegister(right));
1573 }
1548 break; 1574 break;
1549 case Token::BIT_XOR: 1575 case Token::BIT_XOR:
1550 __ xorp(ToRegister(left), ToRegister(right)); 1576 if (instr->IsInteger32()) {
1577 __ xorl(ToRegister(left), ToRegister(right));
1578 } else {
1579 __ xorp(ToRegister(left), ToRegister(right));
1580 }
1551 break; 1581 break;
1552 default: 1582 default:
1553 UNREACHABLE(); 1583 UNREACHABLE();
1554 break; 1584 break;
1555 } 1585 }
1556 } 1586 }
1557 } 1587 }
1558 1588
1559 1589
1560 void LCodeGen::DoShiftI(LShiftI* instr) { 1590 void LCodeGen::DoShiftI(LShiftI* instr) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 } 1677 }
1648 } 1678 }
1649 1679
1650 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { 1680 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1651 DeoptimizeIf(overflow, instr->environment()); 1681 DeoptimizeIf(overflow, instr->environment());
1652 } 1682 }
1653 } 1683 }
1654 1684
1655 1685
1656 void LCodeGen::DoConstantI(LConstantI* instr) { 1686 void LCodeGen::DoConstantI(LConstantI* instr) {
1657 __ Set(ToRegister(instr->result()), instr->value()); 1687 Register dst = ToRegister(instr->result());
1688 if (instr->value() == 0) {
1689 __ xorl(dst, dst);
1690 } else {
1691 __ movl(dst, Immediate(instr->value()));
1692 }
1658 } 1693 }
1659 1694
1660 1695
1661 void LCodeGen::DoConstantS(LConstantS* instr) { 1696 void LCodeGen::DoConstantS(LConstantS* instr) {
1662 __ Move(ToRegister(instr->result()), instr->value()); 1697 __ Move(ToRegister(instr->result()), instr->value());
1663 } 1698 }
1664 1699
1665 1700
1666 void LCodeGen::DoConstantD(LConstantD* instr) { 1701 void LCodeGen::DoConstantD(LConstantD* instr) {
1667 ASSERT(instr->result()->IsDoubleRegister()); 1702 ASSERT(instr->result()->IsDoubleRegister());
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 __ movss(result, operand); 3063 __ movss(result, operand);
3029 __ cvtss2sd(result, result); 3064 __ cvtss2sd(result, result);
3030 } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || 3065 } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS ||
3031 elements_kind == FLOAT64_ELEMENTS) { 3066 elements_kind == FLOAT64_ELEMENTS) {
3032 __ movsd(ToDoubleRegister(instr->result()), operand); 3067 __ movsd(ToDoubleRegister(instr->result()), operand);
3033 } else { 3068 } else {
3034 Register result(ToRegister(instr->result())); 3069 Register result(ToRegister(instr->result()));
3035 switch (elements_kind) { 3070 switch (elements_kind) {
3036 case EXTERNAL_INT8_ELEMENTS: 3071 case EXTERNAL_INT8_ELEMENTS:
3037 case INT8_ELEMENTS: 3072 case INT8_ELEMENTS:
3038 __ movsxbq(result, operand); 3073 __ movsxbl(result, operand);
3039 break; 3074 break;
3040 case EXTERNAL_UINT8_ELEMENTS: 3075 case EXTERNAL_UINT8_ELEMENTS:
3041 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: 3076 case EXTERNAL_UINT8_CLAMPED_ELEMENTS:
3042 case UINT8_ELEMENTS: 3077 case UINT8_ELEMENTS:
3043 case UINT8_CLAMPED_ELEMENTS: 3078 case UINT8_CLAMPED_ELEMENTS:
3044 __ movzxbp(result, operand); 3079 __ movzxbl(result, operand);
3045 break; 3080 break;
3046 case EXTERNAL_INT16_ELEMENTS: 3081 case EXTERNAL_INT16_ELEMENTS:
3047 case INT16_ELEMENTS: 3082 case INT16_ELEMENTS:
3048 __ movsxwq(result, operand); 3083 __ movsxwl(result, operand);
3049 break; 3084 break;
3050 case EXTERNAL_UINT16_ELEMENTS: 3085 case EXTERNAL_UINT16_ELEMENTS:
3051 case UINT16_ELEMENTS: 3086 case UINT16_ELEMENTS:
3052 __ movzxwp(result, operand); 3087 __ movzxwl(result, operand);
3053 break; 3088 break;
3054 case EXTERNAL_INT32_ELEMENTS: 3089 case EXTERNAL_INT32_ELEMENTS:
3055 case INT32_ELEMENTS: 3090 case INT32_ELEMENTS:
3056 __ movsxlq(result, operand); 3091 __ movl(result, operand);
3057 break; 3092 break;
3058 case EXTERNAL_UINT32_ELEMENTS: 3093 case EXTERNAL_UINT32_ELEMENTS:
3059 case UINT32_ELEMENTS: 3094 case UINT32_ELEMENTS:
3060 __ movl(result, operand); 3095 __ movl(result, operand);
3061 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { 3096 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) {
3062 __ testl(result, result); 3097 __ testl(result, result);
3063 DeoptimizeIf(negative, instr->environment()); 3098 DeoptimizeIf(negative, instr->environment());
3064 } 3099 }
3065 break; 3100 break;
3066 case EXTERNAL_FLOAT32_ELEMENTS: 3101 case EXTERNAL_FLOAT32_ELEMENTS:
(...skipping 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after
5687 __ bind(deferred->exit()); 5722 __ bind(deferred->exit());
5688 __ bind(&done); 5723 __ bind(&done);
5689 } 5724 }
5690 5725
5691 5726
5692 #undef __ 5727 #undef __
5693 5728
5694 } } // namespace v8::internal 5729 } } // namespace v8::internal
5695 5730
5696 #endif // V8_TARGET_ARCH_X64 5731 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698