| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 void FastNewClosureStub::Generate(MacroAssembler* masm) { | 63 void FastNewClosureStub::Generate(MacroAssembler* masm) { |
| 64 // Create a new closure from the given function info in new | 64 // Create a new closure from the given function info in new |
| 65 // space. Set the context to the current context in esi. | 65 // space. Set the context to the current context in esi. |
| 66 Label gc; | 66 Label gc; |
| 67 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT); | 67 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT); |
| 68 | 68 |
| 69 // Get the function info from the stack. | 69 // Get the function info from the stack. |
| 70 __ mov(edx, Operand(esp, 1 * kPointerSize)); | 70 __ mov(edx, Operand(esp, 1 * kPointerSize)); |
| 71 | 71 |
| 72 int map_index = strict_mode_ == kStrictMode |
| 73 ? Context::STRICT_MODE_FUNCTION_MAP_INDEX |
| 74 : Context::FUNCTION_MAP_INDEX; |
| 75 |
| 72 // Compute the function map in the current global context and set that | 76 // Compute the function map in the current global context and set that |
| 73 // as the map of the allocated object. | 77 // as the map of the allocated object. |
| 74 __ mov(ecx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 78 __ mov(ecx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 75 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset)); | 79 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset)); |
| 76 __ mov(ecx, Operand(ecx, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); | 80 __ mov(ecx, Operand(ecx, Context::SlotOffset(map_index))); |
| 77 __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx); | 81 __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx); |
| 78 | 82 |
| 79 // Initialize the rest of the function. We don't have to update the | 83 // Initialize the rest of the function. We don't have to update the |
| 80 // write barrier because the allocated object is in new space. | 84 // write barrier because the allocated object is in new space. |
| 81 __ mov(ebx, Immediate(Factory::empty_fixed_array())); | 85 __ mov(ebx, Immediate(Factory::empty_fixed_array())); |
| 82 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ebx); | 86 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ebx); |
| 83 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx); | 87 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx); |
| 84 __ mov(FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset), | 88 __ mov(FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset), |
| 85 Immediate(Factory::the_hole_value())); | 89 Immediate(Factory::the_hole_value())); |
| 86 __ mov(FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset), edx); | 90 __ mov(FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset), edx); |
| (...skipping 3565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3652 __ mov(Operand(esp, 2 * kPointerSize), edx); | 3656 __ mov(Operand(esp, 2 * kPointerSize), edx); |
| 3653 | 3657 |
| 3654 // Try the new space allocation. Start out with computing the size of | 3658 // Try the new space allocation. Start out with computing the size of |
| 3655 // the arguments object and the elements array. | 3659 // the arguments object and the elements array. |
| 3656 NearLabel add_arguments_object; | 3660 NearLabel add_arguments_object; |
| 3657 __ bind(&try_allocate); | 3661 __ bind(&try_allocate); |
| 3658 __ test(ecx, Operand(ecx)); | 3662 __ test(ecx, Operand(ecx)); |
| 3659 __ j(zero, &add_arguments_object); | 3663 __ j(zero, &add_arguments_object); |
| 3660 __ lea(ecx, Operand(ecx, times_2, FixedArray::kHeaderSize)); | 3664 __ lea(ecx, Operand(ecx, times_2, FixedArray::kHeaderSize)); |
| 3661 __ bind(&add_arguments_object); | 3665 __ bind(&add_arguments_object); |
| 3662 __ add(Operand(ecx), Immediate(Heap::kArgumentsObjectSize)); | 3666 __ add(Operand(ecx), Immediate(GetArgumentsObjectSize())); |
| 3663 | 3667 |
| 3664 // Do the allocation of both objects in one go. | 3668 // Do the allocation of both objects in one go. |
| 3665 __ AllocateInNewSpace(ecx, eax, edx, ebx, &runtime, TAG_OBJECT); | 3669 __ AllocateInNewSpace(ecx, eax, edx, ebx, &runtime, TAG_OBJECT); |
| 3666 | 3670 |
| 3667 // Get the arguments boilerplate from the current (global) context. | 3671 // Get the arguments boilerplate from the current (global) context. |
| 3668 int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX); | |
| 3669 __ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 3672 __ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 3670 __ mov(edi, FieldOperand(edi, GlobalObject::kGlobalContextOffset)); | 3673 __ mov(edi, FieldOperand(edi, GlobalObject::kGlobalContextOffset)); |
| 3671 __ mov(edi, Operand(edi, offset)); | 3674 __ mov(edi, Operand(edi, |
| 3675 Context::SlotOffset(GetArgumentsBoilerplateIndex()))); |
| 3672 | 3676 |
| 3673 // Copy the JS object part. | 3677 // Copy the JS object part. |
| 3674 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { | 3678 for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) { |
| 3675 __ mov(ebx, FieldOperand(edi, i)); | 3679 __ mov(ebx, FieldOperand(edi, i)); |
| 3676 __ mov(FieldOperand(eax, i), ebx); | 3680 __ mov(FieldOperand(eax, i), ebx); |
| 3677 } | 3681 } |
| 3678 | 3682 |
| 3679 // Setup the callee in-object property. | 3683 if (type_ == NEW_NON_STRICT) { |
| 3680 STATIC_ASSERT(Heap::arguments_callee_index == 0); | 3684 // Setup the callee in-object property. |
| 3681 __ mov(ebx, Operand(esp, 3 * kPointerSize)); | 3685 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); |
| 3682 __ mov(FieldOperand(eax, JSObject::kHeaderSize), ebx); | 3686 __ mov(ebx, Operand(esp, 3 * kPointerSize)); |
| 3687 __ mov(FieldOperand(eax, JSObject::kHeaderSize + |
| 3688 Heap::kArgumentsCalleeIndex * kPointerSize), |
| 3689 ebx); |
| 3690 } |
| 3683 | 3691 |
| 3684 // Get the length (smi tagged) and set that as an in-object property too. | 3692 // Get the length (smi tagged) and set that as an in-object property too. |
| 3685 STATIC_ASSERT(Heap::arguments_length_index == 1); | 3693 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
| 3686 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | 3694 __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
| 3687 __ mov(FieldOperand(eax, JSObject::kHeaderSize + kPointerSize), ecx); | 3695 __ mov(FieldOperand(eax, JSObject::kHeaderSize + |
| 3696 Heap::kArgumentsLengthIndex * kPointerSize), |
| 3697 ecx); |
| 3688 | 3698 |
| 3689 // If there are no actual arguments, we're done. | 3699 // If there are no actual arguments, we're done. |
| 3690 Label done; | 3700 Label done; |
| 3691 __ test(ecx, Operand(ecx)); | 3701 __ test(ecx, Operand(ecx)); |
| 3692 __ j(zero, &done); | 3702 __ j(zero, &done); |
| 3693 | 3703 |
| 3694 // Get the parameters pointer from the stack. | 3704 // Get the parameters pointer from the stack. |
| 3695 __ mov(edx, Operand(esp, 2 * kPointerSize)); | 3705 __ mov(edx, Operand(esp, 2 * kPointerSize)); |
| 3696 | 3706 |
| 3697 // Setup the elements pointer in the allocated arguments object and | 3707 // Setup the elements pointer in the allocated arguments object and |
| 3698 // initialize the header in the elements fixed array. | 3708 // initialize the header in the elements fixed array. |
| 3699 __ lea(edi, Operand(eax, Heap::kArgumentsObjectSize)); | 3709 __ lea(edi, Operand(eax, GetArgumentsObjectSize())); |
| 3700 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); | 3710 __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi); |
| 3701 __ mov(FieldOperand(edi, FixedArray::kMapOffset), | 3711 __ mov(FieldOperand(edi, FixedArray::kMapOffset), |
| 3702 Immediate(Factory::fixed_array_map())); | 3712 Immediate(Factory::fixed_array_map())); |
| 3713 |
| 3703 __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx); | 3714 __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx); |
| 3704 // Untag the length for the loop below. | 3715 // Untag the length for the loop below. |
| 3705 __ SmiUntag(ecx); | 3716 __ SmiUntag(ecx); |
| 3706 | 3717 |
| 3707 // Copy the fixed array slots. | 3718 // Copy the fixed array slots. |
| 3708 NearLabel loop; | 3719 NearLabel loop; |
| 3709 __ bind(&loop); | 3720 __ bind(&loop); |
| 3710 __ mov(ebx, Operand(edx, -1 * kPointerSize)); // Skip receiver. | 3721 __ mov(ebx, Operand(edx, -1 * kPointerSize)); // Skip receiver. |
| 3711 __ mov(FieldOperand(edi, FixedArray::kHeaderSize), ebx); | 3722 __ mov(FieldOperand(edi, FixedArray::kHeaderSize), ebx); |
| 3712 __ add(Operand(edi), Immediate(kPointerSize)); | 3723 __ add(Operand(edi), Immediate(kPointerSize)); |
| (...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6498 } | 6509 } |
| 6499 __ ret(0); | 6510 __ ret(0); |
| 6500 } | 6511 } |
| 6501 | 6512 |
| 6502 | 6513 |
| 6503 #undef __ | 6514 #undef __ |
| 6504 | 6515 |
| 6505 } } // namespace v8::internal | 6516 } } // namespace v8::internal |
| 6506 | 6517 |
| 6507 #endif // V8_TARGET_ARCH_IA32 | 6518 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |