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 __ AllocateObjectInNewSpace(ecx, edx, ecx, no_reg, &generic_stub_call, false); | 1789 ExternalReference new_space_allocation_top = |
| 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); |
1790 | 1800 |
1791 // Allocated the JSObject, now initialize the fields and add the heap tag. | 1801 // Allocated the JSObject, now initialize the fields and add the heap tag. |
1792 // ebx: initial map | 1802 // ebx: initial map |
1793 // edx: JSObject | 1803 // edx: JSObject |
1794 __ mov(Operand(edx, JSObject::kMapOffset), ebx); | 1804 __ mov(Operand(edx, JSObject::kMapOffset), ebx); |
1795 __ mov(ebx, Factory::empty_fixed_array()); | 1805 __ mov(ebx, Factory::empty_fixed_array()); |
1796 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx); | 1806 __ mov(Operand(edx, JSObject::kPropertiesOffset), ebx); |
1797 __ mov(Operand(edx, JSObject::kElementsOffset), ebx); | 1807 __ mov(Operand(edx, JSObject::kElementsOffset), ebx); |
1798 __ or_(Operand(edx), Immediate(kHeapObjectTag)); | 1808 __ or_(Operand(edx), Immediate(kHeapObjectTag)); |
1799 | 1809 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 for (int i = shared->this_property_assignments_count(); | 1853 for (int i = shared->this_property_assignments_count(); |
1844 i < shared->CalculateInObjectProperties(); | 1854 i < shared->CalculateInObjectProperties(); |
1845 i++) { | 1855 i++) { |
1846 __ mov(Operand(edx, i * kPointerSize), edi); | 1856 __ mov(Operand(edx, i * kPointerSize), edi); |
1847 } | 1857 } |
1848 | 1858 |
1849 // Move argc to ebx and retreive the JSObject to return. | 1859 // Move argc to ebx and retreive the JSObject to return. |
1850 __ mov(ebx, eax); | 1860 __ mov(ebx, eax); |
1851 __ pop(eax); | 1861 __ pop(eax); |
1852 | 1862 |
1853 // Remove caller arguments and receiver from the stack and return. | 1863 // Remove caller arguments from the stack and return. |
1854 __ pop(ecx); | 1864 __ pop(ecx); |
1855 __ lea(esp, Operand(esp, ebx, times_pointer_size, 1 * kPointerSize)); | 1865 __ lea(esp, Operand(esp, ebx, times_4, 1 * kPointerSize)); // 1 ~ receiver |
1856 __ push(ecx); | 1866 __ push(ecx); |
1857 __ IncrementCounter(&Counters::constructed_objects, 1); | 1867 __ IncrementCounter(&Counters::constructed_objects, 1); |
1858 __ IncrementCounter(&Counters::constructed_objects_stub, 1); | 1868 __ IncrementCounter(&Counters::constructed_objects_stub, 1); |
1859 __ ret(0); | 1869 __ ret(0); |
1860 | 1870 |
1861 // Jump to the generic stub in case the specialized code cannot handle the | 1871 // Jump to the generic stub in case the specialized code cannot handle the |
1862 // construction. | 1872 // construction. |
1863 __ bind(&generic_stub_call); | 1873 __ bind(&generic_stub_call); |
1864 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); | 1874 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); |
1865 Handle<Code> generic_construct_stub(code); | 1875 Handle<Code> generic_construct_stub(code); |
1866 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 1876 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
1867 | 1877 |
1868 // Return the generated code. | 1878 // Return the generated code. |
1869 return GetCode(); | 1879 return GetCode(); |
1870 } | 1880 } |
1871 | 1881 |
1872 | 1882 |
1873 #undef __ | 1883 #undef __ |
1874 | 1884 |
1875 } } // namespace v8::internal | 1885 } } // namespace v8::internal |
OLD | NEW |