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

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

Issue 22184004: Desugar bitwise negation into XOR and kill all UnaryOp stuff. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Feedback. Created 7 years, 4 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/lithium-codegen-x64.h ('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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 Register left = ToRegister(instr->left()); 1263 Register left = ToRegister(instr->left());
1264 LOperand* right = instr->right(); 1264 LOperand* right = instr->right();
1265 1265
1266 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1266 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1267 __ movl(kScratchRegister, left); 1267 __ movl(kScratchRegister, left);
1268 } 1268 }
1269 1269
1270 bool can_overflow = 1270 bool can_overflow =
1271 instr->hydrogen()->CheckFlag(HValue::kCanOverflow); 1271 instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
1272 if (right->IsConstantOperand()) { 1272 if (right->IsConstantOperand()) {
1273 int right_value = ToInteger32(LConstantOperand::cast(right)); 1273 int32_t right_value = ToInteger32(LConstantOperand::cast(right));
1274 if (right_value == -1) { 1274 if (right_value == -1) {
1275 __ negl(left); 1275 __ negl(left);
1276 } else if (right_value == 0) { 1276 } else if (right_value == 0) {
1277 __ xorl(left, left); 1277 __ xorl(left, left);
1278 } else if (right_value == 2) { 1278 } else if (right_value == 2) {
1279 __ addl(left, left); 1279 __ addl(left, left);
1280 } else if (!can_overflow) { 1280 } else if (!can_overflow) {
1281 // If the multiplication is known to not overflow, we 1281 // If the multiplication is known to not overflow, we
1282 // can use operations that don't set the overflow flag 1282 // can use operations that don't set the overflow flag
1283 // correctly. 1283 // correctly.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1355 }
1356 1356
1357 1357
1358 void LCodeGen::DoBitI(LBitI* instr) { 1358 void LCodeGen::DoBitI(LBitI* instr) {
1359 LOperand* left = instr->left(); 1359 LOperand* left = instr->left();
1360 LOperand* right = instr->right(); 1360 LOperand* right = instr->right();
1361 ASSERT(left->Equals(instr->result())); 1361 ASSERT(left->Equals(instr->result()));
1362 ASSERT(left->IsRegister()); 1362 ASSERT(left->IsRegister());
1363 1363
1364 if (right->IsConstantOperand()) { 1364 if (right->IsConstantOperand()) {
1365 int right_operand = ToInteger32(LConstantOperand::cast(right)); 1365 int32_t right_operand = ToInteger32(LConstantOperand::cast(right));
1366 switch (instr->op()) { 1366 switch (instr->op()) {
1367 case Token::BIT_AND: 1367 case Token::BIT_AND:
1368 __ andl(ToRegister(left), Immediate(right_operand)); 1368 __ andl(ToRegister(left), Immediate(right_operand));
1369 break; 1369 break;
1370 case Token::BIT_OR: 1370 case Token::BIT_OR:
1371 __ orl(ToRegister(left), Immediate(right_operand)); 1371 __ orl(ToRegister(left), Immediate(right_operand));
1372 break; 1372 break;
1373 case Token::BIT_XOR: 1373 case Token::BIT_XOR:
1374 __ xorl(ToRegister(left), Immediate(right_operand)); 1374 if (right_operand == int32_t(~0)) {
1375 __ not_(ToRegister(left));
Jakob Kummerow 2013/09/06 15:18:20 Leave the upper half of the register alone! :-( cr
1376 } else {
1377 __ xorl(ToRegister(left), Immediate(right_operand));
1378 }
1375 break; 1379 break;
1376 default: 1380 default:
1377 UNREACHABLE(); 1381 UNREACHABLE();
1378 break; 1382 break;
1379 } 1383 }
1380 } else if (right->IsStackSlot()) { 1384 } else if (right->IsStackSlot()) {
1381 switch (instr->op()) { 1385 switch (instr->op()) {
1382 case Token::BIT_AND: 1386 case Token::BIT_AND:
1383 __ and_(ToRegister(left), ToOperand(right)); 1387 __ and_(ToRegister(left), ToOperand(right));
1384 break; 1388 break;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 } 1439 }
1436 break; 1440 break;
1437 case Token::SHL: 1441 case Token::SHL:
1438 __ shll_cl(ToRegister(left)); 1442 __ shll_cl(ToRegister(left));
1439 break; 1443 break;
1440 default: 1444 default:
1441 UNREACHABLE(); 1445 UNREACHABLE();
1442 break; 1446 break;
1443 } 1447 }
1444 } else { 1448 } else {
1445 int value = ToInteger32(LConstantOperand::cast(right)); 1449 int32_t value = ToInteger32(LConstantOperand::cast(right));
1446 uint8_t shift_count = static_cast<uint8_t>(value & 0x1F); 1450 uint8_t shift_count = static_cast<uint8_t>(value & 0x1F);
1447 switch (instr->op()) { 1451 switch (instr->op()) {
1448 case Token::ROR: 1452 case Token::ROR:
1449 if (shift_count != 0) { 1453 if (shift_count != 0) {
1450 __ rorl(ToRegister(left), Immediate(shift_count)); 1454 __ rorl(ToRegister(left), Immediate(shift_count));
1451 } 1455 }
1452 break; 1456 break;
1453 case Token::SAR: 1457 case Token::SAR:
1454 if (shift_count != 0) { 1458 if (shift_count != 0) {
1455 __ sarl(ToRegister(left), Immediate(shift_count)); 1459 __ sarl(ToRegister(left), Immediate(shift_count));
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 if (encoding == String::ONE_BYTE_ENCODING) { 1653 if (encoding == String::ONE_BYTE_ENCODING) {
1650 __ movb(FieldOperand(string, index, times_1, SeqString::kHeaderSize), 1654 __ movb(FieldOperand(string, index, times_1, SeqString::kHeaderSize),
1651 value); 1655 value);
1652 } else { 1656 } else {
1653 __ movw(FieldOperand(string, index, times_2, SeqString::kHeaderSize), 1657 __ movw(FieldOperand(string, index, times_2, SeqString::kHeaderSize),
1654 value); 1658 value);
1655 } 1659 }
1656 } 1660 }
1657 1661
1658 1662
1659 void LCodeGen::DoBitNotI(LBitNotI* instr) {
1660 LOperand* input = instr->value();
1661 ASSERT(input->Equals(instr->result()));
1662 __ not_(ToRegister(input));
1663 }
1664
1665
1666 void LCodeGen::DoThrow(LThrow* instr) { 1663 void LCodeGen::DoThrow(LThrow* instr) {
1667 __ push(ToRegister(instr->value())); 1664 __ push(ToRegister(instr->value()));
1668 CallRuntime(Runtime::kThrow, 1, instr); 1665 CallRuntime(Runtime::kThrow, 1, instr);
1669 1666
1670 if (FLAG_debug_code) { 1667 if (FLAG_debug_code) {
1671 Comment("Unreachable code."); 1668 Comment("Unreachable code.");
1672 __ int3(); 1669 __ int3();
1673 } 1670 }
1674 } 1671 }
1675 1672
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 ExternalPixelArray::kExternalPointerOffset)); 2888 ExternalPixelArray::kExternalPointerOffset));
2892 } 2889 }
2893 2890
2894 2891
2895 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { 2892 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
2896 Register arguments = ToRegister(instr->arguments()); 2893 Register arguments = ToRegister(instr->arguments());
2897 Register result = ToRegister(instr->result()); 2894 Register result = ToRegister(instr->result());
2898 2895
2899 if (instr->length()->IsConstantOperand() && 2896 if (instr->length()->IsConstantOperand() &&
2900 instr->index()->IsConstantOperand()) { 2897 instr->index()->IsConstantOperand()) {
2901 int const_index = ToInteger32(LConstantOperand::cast(instr->index())); 2898 int32_t const_index = ToInteger32(LConstantOperand::cast(instr->index()));
2902 int const_length = ToInteger32(LConstantOperand::cast(instr->length())); 2899 int32_t const_length = ToInteger32(LConstantOperand::cast(instr->length()));
2903 int index = (const_length - const_index) + 1; 2900 int index = (const_length - const_index) + 1;
2904 __ movq(result, Operand(arguments, index * kPointerSize)); 2901 __ movq(result, Operand(arguments, index * kPointerSize));
2905 } else { 2902 } else {
2906 Register length = ToRegister(instr->length()); 2903 Register length = ToRegister(instr->length());
2907 // There are two words between the frame pointer and the last argument. 2904 // There are two words between the frame pointer and the last argument.
2908 // Subtracting from length accounts for one of them add one more. 2905 // Subtracting from length accounts for one of them add one more.
2909 if (instr->index()->IsRegister()) { 2906 if (instr->index()->IsRegister()) {
2910 __ subl(length, ToRegister(instr->index())); 2907 __ subl(length, ToRegister(instr->index()));
2911 } else { 2908 } else {
2912 __ subl(length, ToOperand(instr->index())); 2909 __ subl(length, ToOperand(instr->index()));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 3076
3080 Operand LCodeGen::BuildFastArrayOperand( 3077 Operand LCodeGen::BuildFastArrayOperand(
3081 LOperand* elements_pointer, 3078 LOperand* elements_pointer,
3082 LOperand* key, 3079 LOperand* key,
3083 ElementsKind elements_kind, 3080 ElementsKind elements_kind,
3084 uint32_t offset, 3081 uint32_t offset,
3085 uint32_t additional_index) { 3082 uint32_t additional_index) {
3086 Register elements_pointer_reg = ToRegister(elements_pointer); 3083 Register elements_pointer_reg = ToRegister(elements_pointer);
3087 int shift_size = ElementsKindToShiftSize(elements_kind); 3084 int shift_size = ElementsKindToShiftSize(elements_kind);
3088 if (key->IsConstantOperand()) { 3085 if (key->IsConstantOperand()) {
3089 int constant_value = ToInteger32(LConstantOperand::cast(key)); 3086 int32_t constant_value = ToInteger32(LConstantOperand::cast(key));
3090 if (constant_value & 0xF0000000) { 3087 if (constant_value & 0xF0000000) {
3091 Abort(kArrayIndexConstantValueTooBig); 3088 Abort(kArrayIndexConstantValueTooBig);
3092 } 3089 }
3093 return Operand(elements_pointer_reg, 3090 return Operand(elements_pointer_reg,
3094 ((constant_value + additional_index) << shift_size) 3091 ((constant_value + additional_index) << shift_size)
3095 + offset); 3092 + offset);
3096 } else { 3093 } else {
3097 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); 3094 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
3098 return Operand(elements_pointer_reg, 3095 return Operand(elements_pointer_reg,
3099 ToRegister(key), 3096 ToRegister(key),
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 4086
4090 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 4087 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
4091 if (instr->hydrogen()->skip_check()) return; 4088 if (instr->hydrogen()->skip_check()) return;
4092 4089
4093 if (instr->length()->IsRegister()) { 4090 if (instr->length()->IsRegister()) {
4094 Register reg = ToRegister(instr->length()); 4091 Register reg = ToRegister(instr->length());
4095 if (!instr->hydrogen()->length()->representation().IsSmi()) { 4092 if (!instr->hydrogen()->length()->representation().IsSmi()) {
4096 __ AssertZeroExtended(reg); 4093 __ AssertZeroExtended(reg);
4097 } 4094 }
4098 if (instr->index()->IsConstantOperand()) { 4095 if (instr->index()->IsConstantOperand()) {
4099 int constant_index = 4096 int32_t constant_index =
4100 ToInteger32(LConstantOperand::cast(instr->index())); 4097 ToInteger32(LConstantOperand::cast(instr->index()));
4101 if (instr->hydrogen()->length()->representation().IsSmi()) { 4098 if (instr->hydrogen()->length()->representation().IsSmi()) {
4102 __ Cmp(reg, Smi::FromInt(constant_index)); 4099 __ Cmp(reg, Smi::FromInt(constant_index));
4103 } else { 4100 } else {
4104 __ cmpq(reg, Immediate(constant_index)); 4101 __ cmpq(reg, Immediate(constant_index));
4105 } 4102 }
4106 } else { 4103 } else {
4107 Register reg2 = ToRegister(instr->index()); 4104 Register reg2 = ToRegister(instr->index());
4108 if (!instr->hydrogen()->index()->representation().IsSmi()) { 4105 if (!instr->hydrogen()->index()->representation().IsSmi()) {
4109 __ AssertZeroExtended(reg2); 4106 __ AssertZeroExtended(reg2);
4110 } 4107 }
4111 __ cmpq(reg, reg2); 4108 __ cmpq(reg, reg2);
4112 } 4109 }
4113 } else { 4110 } else {
4114 Operand length = ToOperand(instr->length()); 4111 Operand length = ToOperand(instr->length());
4115 if (instr->index()->IsConstantOperand()) { 4112 if (instr->index()->IsConstantOperand()) {
4116 int constant_index = 4113 int32_t constant_index =
4117 ToInteger32(LConstantOperand::cast(instr->index())); 4114 ToInteger32(LConstantOperand::cast(instr->index()));
4118 if (instr->hydrogen()->length()->representation().IsSmi()) { 4115 if (instr->hydrogen()->length()->representation().IsSmi()) {
4119 __ Cmp(length, Smi::FromInt(constant_index)); 4116 __ Cmp(length, Smi::FromInt(constant_index));
4120 } else { 4117 } else {
4121 __ cmpq(length, Immediate(constant_index)); 4118 __ cmpq(length, Immediate(constant_index));
4122 } 4119 }
4123 } else { 4120 } else {
4124 __ cmpq(length, ToRegister(instr->index())); 4121 __ cmpq(length, ToRegister(instr->index()));
4125 } 4122 }
4126 } 4123 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
4393 // result register contain a valid pointer because it is already 4390 // result register contain a valid pointer because it is already
4394 // contained in the register pointer map. 4391 // contained in the register pointer map.
4395 __ Set(result, 0); 4392 __ Set(result, 0);
4396 4393
4397 PushSafepointRegistersScope scope(this); 4394 PushSafepointRegistersScope scope(this);
4398 __ push(string); 4395 __ push(string);
4399 // Push the index as a smi. This is safe because of the checks in 4396 // Push the index as a smi. This is safe because of the checks in
4400 // DoStringCharCodeAt above. 4397 // DoStringCharCodeAt above.
4401 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); 4398 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
4402 if (instr->index()->IsConstantOperand()) { 4399 if (instr->index()->IsConstantOperand()) {
4403 int const_index = ToInteger32(LConstantOperand::cast(instr->index())); 4400 int32_t const_index = ToInteger32(LConstantOperand::cast(instr->index()));
4404 __ Push(Smi::FromInt(const_index)); 4401 __ Push(Smi::FromInt(const_index));
4405 } else { 4402 } else {
4406 Register index = ToRegister(instr->index()); 4403 Register index = ToRegister(instr->index());
4407 __ Integer32ToSmi(index, index); 4404 __ Integer32ToSmi(index, index);
4408 __ push(index); 4405 __ push(index);
4409 } 4406 }
4410 CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2, instr); 4407 CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2, instr);
4411 __ AssertSmi(rax); 4408 __ AssertSmi(rax);
4412 __ SmiToInteger32(rax, rax); 4409 __ SmiToInteger32(rax, rax);
4413 __ StoreToSafepointRegisterSlot(result, rax); 4410 __ StoreToSafepointRegisterSlot(result, rax);
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
5594 FixedArray::kHeaderSize - kPointerSize)); 5591 FixedArray::kHeaderSize - kPointerSize));
5595 __ bind(&done); 5592 __ bind(&done);
5596 } 5593 }
5597 5594
5598 5595
5599 #undef __ 5596 #undef __
5600 5597
5601 } } // namespace v8::internal 5598 } } // namespace v8::internal
5602 5599
5603 #endif // V8_TARGET_ARCH_X64 5600 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698