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

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

Issue 553056: Inline smi code in count operations in the full code generator. (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/arm/full-codegen-arm.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 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 // of the key to detect a named property. 1475 // of the key to detect a named property.
1476 if (prop != NULL) { 1476 if (prop != NULL) {
1477 assign_type = 1477 assign_type =
1478 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; 1478 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
1479 } 1479 }
1480 1480
1481 // Evaluate expression and get value. 1481 // Evaluate expression and get value.
1482 if (assign_type == VARIABLE) { 1482 if (assign_type == VARIABLE) {
1483 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); 1483 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL);
1484 Location saved_location = location_; 1484 Location saved_location = location_;
1485 location_ = kStack; 1485 location_ = kAccumulator;
1486 EmitVariableLoad(expr->expression()->AsVariableProxy()->var(), 1486 EmitVariableLoad(expr->expression()->AsVariableProxy()->var(),
1487 Expression::kValue); 1487 Expression::kValue);
1488 location_ = saved_location; 1488 location_ = saved_location;
1489 } else { 1489 } else {
1490 // Reserve space for result of postfix operation. 1490 // Reserve space for result of postfix operation.
1491 if (expr->is_postfix() && context_ != Expression::kEffect) { 1491 if (expr->is_postfix() && context_ != Expression::kEffect) {
1492 __ push(Immediate(Smi::FromInt(0))); 1492 __ push(Immediate(Smi::FromInt(0)));
1493 } 1493 }
1494 VisitForValue(prop->obj(), kStack); 1494 VisitForValue(prop->obj(), kStack);
1495 if (assign_type == NAMED_PROPERTY) { 1495 if (assign_type == NAMED_PROPERTY) {
1496 EmitNamedPropertyLoad(prop); 1496 EmitNamedPropertyLoad(prop);
1497 } else { 1497 } else {
1498 VisitForValue(prop->key(), kStack); 1498 VisitForValue(prop->key(), kStack);
1499 EmitKeyedPropertyLoad(prop); 1499 EmitKeyedPropertyLoad(prop);
1500 } 1500 }
1501 __ push(eax);
1502 } 1501 }
1503 1502
1504 // Convert to number. 1503 // Call ToNumber only if operand is not a smi.
1504 Label no_conversion;
1505 __ test(eax, Immediate(kSmiTagMask));
1506 __ j(zero, &no_conversion);
1507 __ push(eax);
1505 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); 1508 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
1509 __ bind(&no_conversion);
1506 1510
1507 // Save result for postfix expressions. 1511 // Save result for postfix expressions.
1508 if (expr->is_postfix()) { 1512 if (expr->is_postfix()) {
1509 switch (context_) { 1513 switch (context_) {
1510 case Expression::kUninitialized: 1514 case Expression::kUninitialized:
1511 UNREACHABLE(); 1515 UNREACHABLE();
1512 case Expression::kEffect: 1516 case Expression::kEffect:
1513 // Do not save result. 1517 // Do not save result.
1514 break; 1518 break;
1515 case Expression::kValue: 1519 case Expression::kValue:
(...skipping 11 matching lines...) Expand all
1527 __ mov(Operand(esp, kPointerSize), eax); 1531 __ mov(Operand(esp, kPointerSize), eax);
1528 break; 1532 break;
1529 case KEYED_PROPERTY: 1533 case KEYED_PROPERTY:
1530 __ mov(Operand(esp, 2 * kPointerSize), eax); 1534 __ mov(Operand(esp, 2 * kPointerSize), eax);
1531 break; 1535 break;
1532 } 1536 }
1533 break; 1537 break;
1534 } 1538 }
1535 } 1539 }
1536 1540
1541 // Inline smi case if we are in a loop.
1542 Label stub_call, done;
1543 if (loop_depth() > 0) {
1544 if (expr->op() == Token::INC) {
1545 __ add(Operand(eax), Immediate(Smi::FromInt(1)));
1546 } else {
1547 __ sub(Operand(eax), Immediate(Smi::FromInt(1)));
1548 }
1549 __ j(overflow, &stub_call);
1550 // We could eliminate this smi check if we split the code at
1551 // the first smi check before calling ToNumber.
1552 __ test(eax, Immediate(kSmiTagMask));
1553 __ j(zero, &done);
1554 __ bind(&stub_call);
1555 // Call stub. Undo operation first.
1556 if (expr->op() == Token::INC) {
1557 __ sub(Operand(eax), Immediate(Smi::FromInt(1)));
1558 } else {
1559 __ add(Operand(eax), Immediate(Smi::FromInt(1)));
1560 }
1561 }
1537 // Call stub for +1/-1. 1562 // Call stub for +1/-1.
1538 __ push(eax); 1563 __ push(eax);
1539 __ push(Immediate(Smi::FromInt(1))); 1564 __ push(Immediate(Smi::FromInt(1)));
1540 GenericBinaryOpStub stub(expr->binary_op(), 1565 GenericBinaryOpStub stub(expr->binary_op(),
1541 NO_OVERWRITE, 1566 NO_OVERWRITE,
1542 NO_GENERIC_BINARY_FLAGS); 1567 NO_GENERIC_BINARY_FLAGS);
1543 __ CallStub(&stub); 1568 __ CallStub(&stub);
1569 __ bind(&done);
1544 1570
1545 // Store the value returned in eax. 1571 // Store the value returned in eax.
1546 switch (assign_type) { 1572 switch (assign_type) {
1547 case VARIABLE: 1573 case VARIABLE:
1548 if (expr->is_postfix()) { 1574 if (expr->is_postfix()) {
1549 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 1575 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
1550 Expression::kEffect); 1576 Expression::kEffect);
1551 // For all contexts except kEffect: We have the result on 1577 // For all contexts except kEffect: We have the result on
1552 // top of the stack. 1578 // top of the stack.
1553 if (context_ != Expression::kEffect) { 1579 if (context_ != Expression::kEffect) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 __ add(Operand(edx), Immediate(masm_->CodeObject())); 1821 __ add(Operand(edx), Immediate(masm_->CodeObject()));
1796 __ mov(Operand(esp, 0), edx); 1822 __ mov(Operand(esp, 0), edx);
1797 // And return. 1823 // And return.
1798 __ ret(0); 1824 __ ret(0);
1799 } 1825 }
1800 1826
1801 1827
1802 #undef __ 1828 #undef __
1803 1829
1804 } } // namespace v8::internal 1830 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698