Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1551 Object* CallStubCompiler::CompileMathFloorCall(Object* object, | 1551 Object* CallStubCompiler::CompileMathFloorCall(Object* object, |
| 1552 JSObject* holder, | 1552 JSObject* holder, |
| 1553 JSGlobalPropertyCell* cell, | 1553 JSGlobalPropertyCell* cell, |
| 1554 JSFunction* function, | 1554 JSFunction* function, |
| 1555 String* name) { | 1555 String* name) { |
| 1556 // TODO(872): implement this. | 1556 // TODO(872): implement this. |
| 1557 return Heap::undefined_value(); | 1557 return Heap::undefined_value(); |
| 1558 } | 1558 } |
| 1559 | 1559 |
| 1560 | 1560 |
| 1561 Object* CallStubCompiler::CompileMathAbsCall(Object* object, | |
| 1562 JSObject* holder, | |
| 1563 JSGlobalPropertyCell* cell, | |
| 1564 JSFunction* function, | |
| 1565 String* name) { | |
| 1566 // ----------- S t a t e ------------- | |
| 1567 // -- rcx : function name | |
| 1568 // -- rsp[0] : return address | |
| 1569 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | |
| 1570 // -- ... | |
| 1571 // -- rsp[(argc + 1) * 8] : receiver | |
| 1572 // ----------------------------------- | |
| 1573 | |
| 1574 const int argc = arguments().immediate(); | |
| 1575 | |
| 1576 // If the object is not a JSObject or we got an unexpected number of | |
| 1577 // arguments, bail out to the regular call. | |
| 1578 if (!object->IsJSObject() || argc != 1) return Heap::undefined_value(); | |
| 1579 | |
| 1580 Label miss; | |
| 1581 GenerateNameCheck(name, &miss); | |
| 1582 | |
| 1583 if (cell == NULL) { | |
| 1584 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); | |
| 1585 | |
|
antonm
2010/09/28 12:04:17
nit: maybe drop blank lines here, we imho don't ad
| |
| 1586 __ JumpIfSmi(rdx, &miss); | |
| 1587 | |
| 1588 CheckPrototypes(JSObject::cast(object), rdx, holder, rbx, rax, rdi, name, | |
| 1589 &miss); | |
| 1590 } else { | |
| 1591 ASSERT(cell->value() == function); | |
| 1592 GenerateGlobalReceiverCheck(JSObject::cast(object), holder, name, &miss); | |
| 1593 GenerateLoadFunctionFromCell(cell, function, &miss); | |
| 1594 } | |
| 1595 | |
| 1596 // Load the (only) argument into rax. | |
| 1597 __ movq(rax, Operand(rsp, 1 * kPointerSize)); | |
| 1598 | |
| 1599 // Check if the argument is a smi. | |
| 1600 Label not_smi; | |
| 1601 STATIC_ASSERT(kSmiTag == 0); | |
| 1602 __ JumpIfNotSmi(rax, ¬_smi); | |
| 1603 __ SmiToInteger32(rax, rax); | |
|
antonm
2010/09/28 12:04:17
do we need this tagging/untagging? Looks like MSB
| |
| 1604 | |
| 1605 // Set ebx to 1...1 (== -1) if the argument is negative, or to 0...0 | |
| 1606 // otherwise. | |
| 1607 __ movl(rbx, rax); | |
| 1608 __ sarl(rbx, Immediate(kBitsPerInt - 1)); | |
| 1609 | |
| 1610 // Do bitwise not or do nothing depending on ebx. | |
| 1611 __ xorl(rax, rbx); | |
| 1612 | |
| 1613 // Add 1 or do nothing depending on ebx. | |
| 1614 __ subl(rax, rbx); | |
| 1615 | |
| 1616 // If the result is still negative, go to the slow case. | |
| 1617 // This only happens for the most negative smi. | |
| 1618 Label slow; | |
| 1619 __ j(negative, &slow); | |
| 1620 | |
| 1621 // Smi case done. | |
| 1622 __ Integer32ToSmi(rax, rax); | |
| 1623 __ ret(2 * kPointerSize); | |
| 1624 | |
| 1625 // Check if the argument is a heap number and load its value. | |
| 1626 __ bind(¬_smi); | |
| 1627 __ CheckMap(rax, Factory::heap_number_map(), &slow, true); | |
| 1628 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); | |
| 1629 | |
| 1630 // Check the sign of the argument. If the argument is positive, | |
| 1631 // just return it. | |
| 1632 Label negative_sign; | |
| 1633 const int sign_mask_shift = | |
| 1634 (HeapNumber::kExponentOffset - HeapNumber::kValueOffset) * kBitsPerByte; | |
| 1635 __ movq(rdi, static_cast<int64_t>(HeapNumber::kSignMask) << sign_mask_shift, | |
| 1636 RelocInfo::NONE); | |
| 1637 __ testq(rbx, rdi); | |
| 1638 __ j(not_zero, &negative_sign); | |
| 1639 __ ret(2 * kPointerSize); | |
| 1640 | |
| 1641 // If the argument is negative, clear the sign, and return a new | |
| 1642 // number. We still have the sign mask in rdi. | |
| 1643 __ bind(&negative_sign); | |
| 1644 __ xor_(rbx, rdi); | |
| 1645 __ AllocateHeapNumber(rax, rdx, &slow); | |
| 1646 __ movq(FieldOperand(rax, HeapNumber::kValueOffset), rbx); | |
| 1647 __ ret(2 * kPointerSize); | |
| 1648 | |
| 1649 // Tail call the full function. We do not have to patch the receiver | |
| 1650 // because the function makes no use of it. | |
| 1651 __ bind(&slow); | |
| 1652 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); | |
| 1653 | |
| 1654 __ bind(&miss); | |
| 1655 // rcx: function name. | |
| 1656 Object* obj = GenerateMissBranch(); | |
| 1657 if (obj->IsFailure()) return obj; | |
| 1658 | |
| 1659 // Return the generated code. | |
| 1660 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); | |
| 1661 } | |
| 1662 | |
| 1663 | |
| 1561 Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, | 1664 Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, |
| 1562 JSObject* holder, | 1665 JSObject* holder, |
| 1563 String* name) { | 1666 String* name) { |
| 1564 // ----------- S t a t e ------------- | 1667 // ----------- S t a t e ------------- |
| 1565 // rcx : function name | 1668 // rcx : function name |
| 1566 // rsp[0] : return address | 1669 // rsp[0] : return address |
| 1567 // rsp[8] : argument argc | 1670 // rsp[8] : argument argc |
| 1568 // rsp[16] : argument argc - 1 | 1671 // rsp[16] : argument argc - 1 |
| 1569 // ... | 1672 // ... |
| 1570 // rsp[argc * 8] : argument 1 | 1673 // rsp[argc * 8] : argument 1 |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2831 // Return the generated code. | 2934 // Return the generated code. |
| 2832 return GetCode(); | 2935 return GetCode(); |
| 2833 } | 2936 } |
| 2834 | 2937 |
| 2835 | 2938 |
| 2836 #undef __ | 2939 #undef __ |
| 2837 | 2940 |
| 2838 } } // namespace v8::internal | 2941 } } // namespace v8::internal |
| 2839 | 2942 |
| 2840 #endif // V8_TARGET_ARCH_X64 | 2943 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |