OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 index.translate(holder), Representation::Tagged()); | 1586 index.translate(holder), Representation::Tagged()); |
1587 GenerateJumpFunction(object, rdi, &miss); | 1587 GenerateJumpFunction(object, rdi, &miss); |
1588 | 1588 |
1589 HandlerFrontendFooter(&miss); | 1589 HandlerFrontendFooter(&miss); |
1590 | 1590 |
1591 // Return the generated code. | 1591 // Return the generated code. |
1592 return GetCode(Code::FAST, name); | 1592 return GetCode(Code::FAST, name); |
1593 } | 1593 } |
1594 | 1594 |
1595 | 1595 |
1596 Handle<Code> CallStubCompiler::CompileArrayPopCall( | |
1597 Handle<Object> object, | |
1598 Handle<JSObject> holder, | |
1599 Handle<Cell> cell, | |
1600 Handle<JSFunction> function, | |
1601 Handle<String> name, | |
1602 Code::StubType type) { | |
1603 // If object is not an array or is observed or sealed, bail out to regular | |
1604 // call. | |
1605 if (!object->IsJSArray() || | |
1606 !cell.is_null() || | |
1607 Handle<JSArray>::cast(object)->map()->is_observed() || | |
1608 !Handle<JSArray>::cast(object)->map()->is_extensible()) { | |
1609 return Handle<Code>::null(); | |
1610 } | |
1611 | |
1612 Label miss, return_undefined, call_builtin; | |
1613 | |
1614 HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss); | |
1615 | |
1616 // Get the elements array of the object. | |
1617 __ movp(rbx, FieldOperand(rdx, JSArray::kElementsOffset)); | |
1618 | |
1619 // Check that the elements are in fast mode and writable. | |
1620 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | |
1621 Heap::kFixedArrayMapRootIndex); | |
1622 __ j(not_equal, &call_builtin); | |
1623 | |
1624 // Get the array's length into rcx and calculate new length. | |
1625 __ SmiToInteger32(rcx, FieldOperand(rdx, JSArray::kLengthOffset)); | |
1626 __ subl(rcx, Immediate(1)); | |
1627 __ j(negative, &return_undefined); | |
1628 | |
1629 // Get the last element. | |
1630 __ LoadRoot(r9, Heap::kTheHoleValueRootIndex); | |
1631 __ movp(rax, FieldOperand(rbx, | |
1632 rcx, times_pointer_size, | |
1633 FixedArray::kHeaderSize)); | |
1634 // Check if element is already the hole. | |
1635 __ cmpq(rax, r9); | |
1636 // If so, call slow-case to also check prototypes for value. | |
1637 __ j(equal, &call_builtin); | |
1638 | |
1639 // Set the array's length. | |
1640 __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rcx); | |
1641 | |
1642 // Fill with the hole and return original value. | |
1643 __ movp(FieldOperand(rbx, | |
1644 rcx, times_pointer_size, | |
1645 FixedArray::kHeaderSize), | |
1646 r9); | |
1647 const int argc = arguments().immediate(); | |
1648 __ ret((argc + 1) * kPointerSize); | |
1649 | |
1650 __ bind(&return_undefined); | |
1651 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | |
1652 __ ret((argc + 1) * kPointerSize); | |
1653 | |
1654 __ bind(&call_builtin); | |
1655 __ TailCallExternalReference( | |
1656 ExternalReference(Builtins::c_ArrayPop, isolate()), | |
1657 argc + 1, | |
1658 1); | |
1659 | |
1660 HandlerFrontendFooter(&miss); | |
1661 | |
1662 // Return the generated code. | |
1663 return GetCode(type, name); | |
1664 } | |
1665 | |
1666 | |
1667 Handle<Code> CallStubCompiler::CompileFastApiCall( | 1596 Handle<Code> CallStubCompiler::CompileFastApiCall( |
1668 const CallOptimization& optimization, | 1597 const CallOptimization& optimization, |
1669 Handle<Object> object, | 1598 Handle<Object> object, |
1670 Handle<JSObject> holder, | 1599 Handle<JSObject> holder, |
1671 Handle<Cell> cell, | 1600 Handle<Cell> cell, |
1672 Handle<JSFunction> function, | 1601 Handle<JSFunction> function, |
1673 Handle<String> name) { | 1602 Handle<String> name) { |
1674 ASSERT(optimization.is_simple_api_call()); | 1603 ASSERT(optimization.is_simple_api_call()); |
1675 // Bail out if object is a global object as we don't want to | 1604 // Bail out if object is a global object as we don't want to |
1676 // repatch it to global receiver. | 1605 // repatch it to global receiver. |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 // ----------------------------------- | 2178 // ----------------------------------- |
2250 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 2179 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
2251 } | 2180 } |
2252 | 2181 |
2253 | 2182 |
2254 #undef __ | 2183 #undef __ |
2255 | 2184 |
2256 } } // namespace v8::internal | 2185 } } // namespace v8::internal |
2257 | 2186 |
2258 #endif // V8_TARGET_ARCH_X64 | 2187 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |