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

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

Issue 7489045: ARM: Fast path for compare against constant. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 3 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
OLDNEW
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 int LCodeGen::ToInteger32(LConstantOperand* op) const { 311 int LCodeGen::ToInteger32(LConstantOperand* op) const {
312 Handle<Object> value = chunk_->LookupLiteral(op); 312 Handle<Object> value = chunk_->LookupLiteral(op);
313 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); 313 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32());
314 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == 314 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) ==
315 value->Number()); 315 value->Number());
316 return static_cast<int32_t>(value->Number()); 316 return static_cast<int32_t>(value->Number());
317 } 317 }
318 318
319 319
320 double LCodeGen::ToDouble(LConstantOperand* op) const {
321 Handle<Object> value = chunk_->LookupLiteral(op);
322 return value->Number();
323 }
324
325
320 Immediate LCodeGen::ToImmediate(LOperand* op) { 326 Immediate LCodeGen::ToImmediate(LOperand* op) {
321 LConstantOperand* const_op = LConstantOperand::cast(op); 327 LConstantOperand* const_op = LConstantOperand::cast(op);
322 Handle<Object> literal = chunk_->LookupLiteral(const_op); 328 Handle<Object> literal = chunk_->LookupLiteral(const_op);
323 Representation r = chunk_->LookupLiteralRepresentation(const_op); 329 Representation r = chunk_->LookupLiteralRepresentation(const_op);
324 if (r.IsInteger32()) { 330 if (r.IsInteger32()) {
325 ASSERT(literal->IsNumber()); 331 ASSERT(literal->IsNumber());
326 return Immediate(static_cast<int32_t>(literal->Number())); 332 return Immediate(static_cast<int32_t>(literal->Number()));
327 } else if (r.IsDouble()) { 333 } else if (r.IsDouble()) {
328 Abort("unsupported double immediate"); 334 Abort("unsupported double immediate");
329 } 335 }
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 break; 1526 break;
1521 case Token::IN: 1527 case Token::IN:
1522 case Token::INSTANCEOF: 1528 case Token::INSTANCEOF:
1523 default: 1529 default:
1524 UNREACHABLE(); 1530 UNREACHABLE();
1525 } 1531 }
1526 return cond; 1532 return cond;
1527 } 1533 }
1528 1534
1529 1535
1530 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) {
1531 if (right->IsConstantOperand()) {
1532 __ cmp(ToOperand(left), ToImmediate(right));
1533 } else {
1534 __ cmp(ToRegister(left), ToOperand(right));
1535 }
1536 }
1537
1538
1539 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { 1536 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
1540 LOperand* left = instr->InputAt(0); 1537 LOperand* left = instr->InputAt(0);
1541 LOperand* right = instr->InputAt(1); 1538 LOperand* right = instr->InputAt(1);
1542 int false_block = chunk_->LookupDestination(instr->false_block_id()); 1539 int false_block = chunk_->LookupDestination(instr->false_block_id());
1543 int true_block = chunk_->LookupDestination(instr->true_block_id()); 1540 int true_block = chunk_->LookupDestination(instr->true_block_id());
1541 Condition cc = TokenToCondition(instr->op(), instr->is_double());
1544 1542
1545 if (instr->is_double()) { 1543 if (left->IsConstantOperand() && right->IsConstantOperand()) {
1546 // Don't base result on EFLAGS when a NaN is involved. Instead 1544 // We can statically evaluate the comparison.
1547 // jump to the false block. 1545 double left_val = ToDouble(LConstantOperand::cast(left));
1548 __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right)); 1546 double right_val = ToDouble(LConstantOperand::cast(right));
1549 __ j(parity_even, chunk_->GetAssemblyLabel(false_block)); 1547 int next_block =
1548 EvalComparison(instr->op(), left_val, right_val) ? true_block
1549 : false_block;
1550 EmitGoto(next_block);
1550 } else { 1551 } else {
1551 EmitCmpI(left, right); 1552 if (instr->is_double()) {
1553 // Don't base result on EFLAGS when a NaN is involved. Instead
1554 // jump to the false block.
1555 __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
1556 __ j(parity_even, chunk_->GetAssemblyLabel(false_block));
1557 } else {
1558 if (right->IsConstantOperand()) {
1559 __ cmp(ToOperand(left), ToImmediate(right));
William Hesse 2011/10/20 10:28:40 If the immediate value is 0, this can also be test
Alexandre 2011/10/20 10:59:49 I forgot to change it to tst for Intel. I intentio
1560 } else if (left->IsConstantOperand()) {
1561 __ cmp(ToOperand(right), ToImmediate(left));
1562 // We transposed the operands. Reverse the condition.
1563 cc = ReverseCondition(cc);
1564 } else {
1565 __ cmp(ToRegister(left), ToOperand(right));
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 Operand right = ToOperand(instr->InputAt(1)); 1575 Operand right = ToOperand(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 __ cmp(left, Operand(right)); 1579 __ cmp(left, Operand(right));
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after
4378 env->deoptimization_index()); 4392 env->deoptimization_index());
4379 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4393 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4380 } 4394 }
4381 4395
4382 4396
4383 #undef __ 4397 #undef __
4384 4398
4385 } } // namespace v8::internal 4399 } } // namespace v8::internal
4386 4400
4387 #endif // V8_TARGET_ARCH_IA32 4401 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698