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

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

Issue 557016: Implement SUB and BIT_NOT unary operations in full codegenerator.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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/full-codegen.cc ('k') | src/x64/full-codegen-x64.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 Label no_conversion; 1463 Label no_conversion;
1464 __ test(result_register(), Immediate(kSmiTagMask)); 1464 __ test(result_register(), Immediate(kSmiTagMask));
1465 __ j(zero, &no_conversion); 1465 __ j(zero, &no_conversion);
1466 __ push(result_register()); 1466 __ push(result_register());
1467 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); 1467 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
1468 __ bind(&no_conversion); 1468 __ bind(&no_conversion);
1469 Apply(context_, result_register()); 1469 Apply(context_, result_register());
1470 break; 1470 break;
1471 } 1471 }
1472 1472
1473 case Token::SUB: {
1474 Comment cmt(masm_, "[ UnaryOperation (SUB)");
1475 bool overwrite =
1476 (expr->expression()->AsBinaryOperation() != NULL &&
1477 expr->expression()->AsBinaryOperation()->ResultOverwriteAllowed());
1478 GenericUnaryOpStub stub(Token::SUB, overwrite);
1479 // GenericUnaryOpStub expects the argument to be in the
1480 // accumulator register eax.
1481 VisitForValue(expr->expression(), kAccumulator);
1482 __ CallStub(&stub);
1483 Apply(context_, eax);
1484 break;
1485 }
1486
1487 case Token::BIT_NOT: {
1488 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)");
1489 bool overwrite =
1490 (expr->expression()->AsBinaryOperation() != NULL &&
1491 expr->expression()->AsBinaryOperation()->ResultOverwriteAllowed());
1492 GenericUnaryOpStub stub(Token::BIT_NOT, overwrite);
1493 // GenericUnaryOpStub expects the argument to be in the
1494 // accumulator register eax.
1495 VisitForValue(expr->expression(), kAccumulator);
1496 // Avoid calling the stub for Smis.
1497 Label smi, done;
1498 __ test(result_register(), Immediate(kSmiTagMask));
1499 __ j(zero, &smi);
1500 // Non-smi: call stub leaving result in accumulator register.
1501 __ CallStub(&stub);
1502 __ jmp(&done);
1503 // Perform operation directly on Smis.
1504 __ bind(&smi);
1505 __ not_(result_register());
1506 __ and_(result_register(), ~kSmiTagMask); // Remove inverted smi-tag.
1507 __ bind(&done);
1508 Apply(context_, result_register());
1509 }
1510
1473 default: 1511 default:
1474 UNREACHABLE(); 1512 UNREACHABLE();
1475 } 1513 }
1476 } 1514 }
1477 1515
1478 1516
1479 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { 1517 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
1480 Comment cmnt(masm_, "[ CountOperation"); 1518 Comment cmnt(masm_, "[ CountOperation");
1481 1519
1482 // Expression can only be a property, a global or a (parameter or local) 1520 // Expression can only be a property, a global or a (parameter or local)
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 __ add(Operand(edx), Immediate(masm_->CodeObject())); 1870 __ add(Operand(edx), Immediate(masm_->CodeObject()));
1833 __ mov(Operand(esp, 0), edx); 1871 __ mov(Operand(esp, 0), edx);
1834 // And return. 1872 // And return.
1835 __ ret(0); 1873 __ ret(0);
1836 } 1874 }
1837 1875
1838 1876
1839 #undef __ 1877 #undef __
1840 1878
1841 } } // namespace v8::internal 1879 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698