OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 | 361 |
362 int LCodeGen::ToInteger32(LConstantOperand* op) const { | 362 int LCodeGen::ToInteger32(LConstantOperand* op) const { |
363 Handle<Object> value = chunk_->LookupLiteral(op); | 363 Handle<Object> value = chunk_->LookupLiteral(op); |
364 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); | 364 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); |
365 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == | 365 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == |
366 value->Number()); | 366 value->Number()); |
367 return static_cast<int32_t>(value->Number()); | 367 return static_cast<int32_t>(value->Number()); |
368 } | 368 } |
369 | 369 |
370 | 370 |
371 double LCodeGen::ToDouble(LConstantOperand* op) const { | |
372 Handle<Object> value = chunk_->LookupLiteral(op); | |
373 return value->Number(); | |
374 } | |
375 | |
376 | |
371 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { | 377 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { |
372 Handle<Object> literal = chunk_->LookupLiteral(op); | 378 Handle<Object> literal = chunk_->LookupLiteral(op); |
373 ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged()); | 379 ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged()); |
374 return literal; | 380 return literal; |
375 } | 381 } |
376 | 382 |
377 | 383 |
378 Operand LCodeGen::ToOperand(LOperand* op) const { | 384 Operand LCodeGen::ToOperand(LOperand* op) const { |
379 // Does not handle registers. In X64 assembler, plain registers are not | 385 // Does not handle registers. In X64 assembler, plain registers are not |
380 // representable as an Operand. | 386 // representable as an Operand. |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1513 break; | 1519 break; |
1514 case Token::IN: | 1520 case Token::IN: |
1515 case Token::INSTANCEOF: | 1521 case Token::INSTANCEOF: |
1516 default: | 1522 default: |
1517 UNREACHABLE(); | 1523 UNREACHABLE(); |
1518 } | 1524 } |
1519 return cond; | 1525 return cond; |
1520 } | 1526 } |
1521 | 1527 |
1522 | 1528 |
1523 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { | |
1524 if (right->IsConstantOperand()) { | |
1525 int32_t value = ToInteger32(LConstantOperand::cast(right)); | |
1526 if (left->IsRegister()) { | |
1527 __ cmpl(ToRegister(left), Immediate(value)); | |
1528 } else { | |
1529 __ cmpl(ToOperand(left), Immediate(value)); | |
1530 } | |
1531 } else if (right->IsRegister()) { | |
1532 __ cmpl(ToRegister(left), ToRegister(right)); | |
1533 } else { | |
1534 __ cmpl(ToRegister(left), ToOperand(right)); | |
1535 } | |
1536 } | |
1537 | |
1538 | |
1539 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { | 1529 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { |
1540 LOperand* left = instr->InputAt(0); | 1530 LOperand* left = instr->InputAt(0); |
1541 LOperand* right = instr->InputAt(1); | 1531 LOperand* right = instr->InputAt(1); |
1542 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1532 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1543 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1533 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1534 Condition cc = TokenToCondition(instr->op(), instr->is_double()); | |
1544 | 1535 |
1545 if (instr->is_double()) { | 1536 if (left->IsConstantOperand() && right->IsConstantOperand()) { |
1546 // Don't base result on EFLAGS when a NaN is involved. Instead | 1537 // We can statically evaluate the comparison. |
1547 // jump to the false block. | 1538 double left_val = ToDouble(LConstantOperand::cast(left)); |
1548 __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right)); | 1539 double right_val = ToDouble(LConstantOperand::cast(right)); |
1549 __ j(parity_even, chunk_->GetAssemblyLabel(false_block)); | 1540 int next_block = |
1541 EvalComparison(instr->op(), left_val, right_val) ? true_block | |
1542 : false_block; | |
1543 EmitGoto(next_block); | |
1550 } else { | 1544 } else { |
1551 EmitCmpI(left, right); | 1545 if (instr->is_double()) { |
1546 // Don't base result on EFLAGS when a NaN is involved. Instead | |
1547 // jump to the false block. | |
1548 __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right)); | |
1549 __ j(parity_even, chunk_->GetAssemblyLabel(false_block)); | |
1550 } else { | |
1551 int32_t value; | |
1552 if (right->IsConstantOperand()) { | |
1553 value = ToInteger32(LConstantOperand::cast(right)); | |
1554 __ cmpl(ToRegister(left), Immediate(value)); | |
1555 } else if (left->IsConstantOperand()) { | |
1556 value = ToInteger32(LConstantOperand::cast(left)); | |
1557 if (right->IsRegister()) { | |
1558 __ cmpl(ToRegister(right), Immediate(value)); | |
1559 } else { | |
1560 __ cmpl(ToOperand(right), Immediate(value)); | |
1561 } | |
1562 // We transposed the operands. Reverse the condition. | |
1563 cc = ReverseCondition(cc); | |
1564 } else { | |
1565 __ cmpl(ToRegister(left), ToOperand(right)); | |
William Hesse
2011/10/20 10:28:40
The register and memory operand cases for right mu
| |
1566 } | |
1567 } | |
1568 EmitBranch(true_block, false_block, cc); | |
1552 } | 1569 } |
1553 | |
1554 Condition cc = TokenToCondition(instr->op(), instr->is_double()); | |
1555 EmitBranch(true_block, false_block, cc); | |
1556 } | 1570 } |
1557 | 1571 |
1558 | 1572 |
1559 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { | 1573 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) { |
1560 Register left = ToRegister(instr->InputAt(0)); | 1574 Register left = ToRegister(instr->InputAt(0)); |
1561 Register right = ToRegister(instr->InputAt(1)); | 1575 Register right = ToRegister(instr->InputAt(1)); |
1562 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1576 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1563 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1577 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1564 | 1578 |
1565 __ cmpq(left, right); | 1579 __ cmpq(left, right); |
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4148 RegisterEnvironmentForDeoptimization(environment); | 4162 RegisterEnvironmentForDeoptimization(environment); |
4149 ASSERT(osr_pc_offset_ == -1); | 4163 ASSERT(osr_pc_offset_ == -1); |
4150 osr_pc_offset_ = masm()->pc_offset(); | 4164 osr_pc_offset_ = masm()->pc_offset(); |
4151 } | 4165 } |
4152 | 4166 |
4153 #undef __ | 4167 #undef __ |
4154 | 4168 |
4155 } } // namespace v8::internal | 4169 } } // namespace v8::internal |
4156 | 4170 |
4157 #endif // V8_TARGET_ARCH_X64 | 4171 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |