OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 | 1779 |
1780 // Now allocate the JSObject on the heap by moving the new space allocation | 1780 // Now allocate the JSObject on the heap by moving the new space allocation |
1781 // top forward. | 1781 // top forward. |
1782 // edi: constructor | 1782 // edi: constructor |
1783 // ebx: initial map | 1783 // ebx: initial map |
1784 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); | 1784 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset)); |
1785 __ shl(ecx, kPointerSizeLog2); | 1785 __ shl(ecx, kPointerSizeLog2); |
1786 // Make sure that the maximum heap object size will never cause us | 1786 // Make sure that the maximum heap object size will never cause us |
1787 // problems here. | 1787 // problems here. |
1788 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= JSObject::kMaxInstanceSize); | 1788 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= JSObject::kMaxInstanceSize); |
1789 ExternalReference new_space_allocation_top = | 1789 __ AllocateObjectInNewSpace(ecx, edx, ecx, no_reg, &generic_stub_call, false); |
1790 ExternalReference::new_space_allocation_top_address(); | |
1791 __ mov(edx, Operand::StaticVariable(new_space_allocation_top)); | |
1792 __ add(ecx, Operand(edx)); // Calculate new top. | |
1793 ExternalReference new_space_allocation_limit = | |
1794 ExternalReference::new_space_allocation_limit_address(); | |
1795 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); | |
1796 __ j(above_equal, &generic_stub_call); | |
1797 | |
1798 // Update new space top. | |
1799 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); | |
1800 | 1790 |
1801 // Allocated the JSObject, now initialize the fields and add the heap tag. | 1791 // Allocated the JSObject, now initialize the fields and add the heap tag. |
1802 // ebx: initial map | 1792 // ebx: initial map |
1803 // edx: JSObject | 1793 // edx: JSObject |
1804 __ mov(Operand(edx, JSObject::kMapOffset), ebx); | 1794 __ mov(Operand(edx, JSObject::kMapOffset), ebx); |
1805 __ mov(ebx, Factory::empty_fixed_array()); | 1795 __ mov(ebx, Factory::empty_fixed_array()); |
1806 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx); | 1796 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx); |
1807 __ mov(Operand(edx, JSObject::kElementsOffset), ebx); | 1797 __ mov(Operand(edx, JSObject::kElementsOffset), ebx); |
1808 __ or_(Operand(edx), Immediate(kHeapObjectTag)); | 1798 __ or_(Operand(edx), Immediate(kHeapObjectTag)); |
1809 | 1799 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 for (int i = shared->this_property_assignments_count(); | 1843 for (int i = shared->this_property_assignments_count(); |
1854 i < shared->CalculateInObjectProperties(); | 1844 i < shared->CalculateInObjectProperties(); |
1855 i++) { | 1845 i++) { |
1856 __ mov(Operand(edx, i * kPointerSize), edi); | 1846 __ mov(Operand(edx, i * kPointerSize), edi); |
1857 } | 1847 } |
1858 | 1848 |
1859 // Move argc to ebx and retreive the JSObject to return. | 1849 // Move argc to ebx and retreive the JSObject to return. |
1860 __ mov(ebx, eax); | 1850 __ mov(ebx, eax); |
1861 __ pop(eax); | 1851 __ pop(eax); |
1862 | 1852 |
1863 // Remove caller arguments from the stack and return. | 1853 // Remove caller arguments and receiver from the stack and return. |
1864 __ pop(ecx); | 1854 __ pop(ecx); |
1865 __ lea(esp, Operand(esp, ebx, times_4, 1 * kPointerSize)); // 1 ~ receiver | 1855 __ lea(esp, Operand(esp, ebx, times_pointer_size, 1 * kPointerSize)); |
1866 __ push(ecx); | 1856 __ push(ecx); |
1867 __ IncrementCounter(&Counters::constructed_objects, 1); | 1857 __ IncrementCounter(&Counters::constructed_objects, 1); |
1868 __ IncrementCounter(&Counters::constructed_objects_stub, 1); | 1858 __ IncrementCounter(&Counters::constructed_objects_stub, 1); |
1869 __ ret(0); | 1859 __ ret(0); |
1870 | 1860 |
1871 // Jump to the generic stub in case the specialized code cannot handle the | 1861 // Jump to the generic stub in case the specialized code cannot handle the |
1872 // construction. | 1862 // construction. |
1873 __ bind(&generic_stub_call); | 1863 __ bind(&generic_stub_call); |
1874 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); | 1864 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); |
1875 Handle<Code> generic_construct_stub(code); | 1865 Handle<Code> generic_construct_stub(code); |
1876 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 1866 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
1877 | 1867 |
1878 // Return the generated code. | 1868 // Return the generated code. |
1879 return GetCode(); | 1869 return GetCode(); |
1880 } | 1870 } |
1881 | 1871 |
1882 | 1872 |
1883 #undef __ | 1873 #undef __ |
1884 | 1874 |
1885 } } // namespace v8::internal | 1875 } } // namespace v8::internal |
OLD | NEW |