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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 763 |
764 // Fill all the in-object properties with appropriate filler. | 764 // Fill all the in-object properties with appropriate filler. |
765 // a1: constructor function | 765 // a1: constructor function |
766 // a2: initial map | 766 // a2: initial map |
767 // a3: object size (in words) | 767 // a3: object size (in words) |
768 // t4: JSObject (not tagged) | 768 // t4: JSObject (not tagged) |
769 // t5: First in-object property of JSObject (not tagged) | 769 // t5: First in-object property of JSObject (not tagged) |
770 __ sll(t0, a3, kPointerSizeLog2); | 770 __ sll(t0, a3, kPointerSizeLog2); |
771 __ addu(t6, t4, t0); // End of object. | 771 __ addu(t6, t4, t0); // End of object. |
772 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); | 772 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
773 { Label loop, entry; | 773 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); |
774 if (count_constructions) { | 774 if (count_constructions) { |
775 // To allow for truncation. | 775 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset)); |
776 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); | 776 __ Ext(a0, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, |
777 } else { | 777 kBitsPerByte); |
778 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); | 778 __ sll(t0, a0, kPointerSizeLog2); |
| 779 __ addu(a0, t5, t0); |
| 780 // a0: offset of first field after pre-allocated fields |
| 781 if (FLAG_debug_code) { |
| 782 __ Assert(le, "Unexpected number of pre-allocated property fields.", |
| 783 a0, Operand(t6)); |
779 } | 784 } |
780 __ jmp(&entry); | 785 __ InitializeFieldsWithFiller(t5, a0, t7); |
781 __ bind(&loop); | 786 // To allow for truncation. |
782 __ sw(t7, MemOperand(t5, 0)); | 787 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); |
783 __ addiu(t5, t5, kPointerSize); | |
784 __ bind(&entry); | |
785 __ Branch(&loop, Uless, t5, Operand(t6)); | |
786 } | 788 } |
| 789 __ InitializeFieldsWithFiller(t5, t6, t7); |
787 | 790 |
788 // Add the object tag to make the JSObject real, so that we can continue | 791 // Add the object tag to make the JSObject real, so that we can continue |
789 // and jump into the continuation code at any time from now on. Any | 792 // and jump into the continuation code at any time from now on. Any |
790 // failures need to undo the allocation, so that the heap is in a | 793 // failures need to undo the allocation, so that the heap is in a |
791 // consistent state and verifiable. | 794 // consistent state and verifiable. |
792 __ Addu(t4, t4, Operand(kHeapObjectTag)); | 795 __ Addu(t4, t4, Operand(kHeapObjectTag)); |
793 | 796 |
794 // Check if a non-empty properties array is needed. Continue with | 797 // Check if a non-empty properties array is needed. Continue with |
795 // allocated object if not fall through to runtime call if it is. | 798 // allocated object if not fall through to runtime call if it is. |
796 // a1: constructor function | 799 // a1: constructor function |
797 // t4: JSObject | 800 // t4: JSObject |
798 // t5: start of next object (not tagged) | 801 // t5: start of next object (not tagged) |
799 __ lbu(a3, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); | 802 __ lbu(a3, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); |
800 // The field instance sizes contains both pre-allocated property fields | 803 // The field instance sizes contains both pre-allocated property fields |
801 // and in-object properties. | 804 // and in-object properties. |
802 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset)); | 805 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset)); |
803 __ And(t6, | 806 __ Ext(t6, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, |
804 a0, | 807 kBitsPerByte); |
805 Operand(0x000000FF << Map::kPreAllocatedPropertyFieldsByte * 8)); | 808 __ Addu(a3, a3, Operand(t6)); |
806 __ srl(t0, t6, Map::kPreAllocatedPropertyFieldsByte * 8); | 809 __ Ext(t6, a0, Map::kInObjectPropertiesByte * kBitsPerByte, |
807 __ Addu(a3, a3, Operand(t0)); | 810 kBitsPerByte); |
808 __ And(t6, a0, Operand(0x000000FF << Map::kInObjectPropertiesByte * 8)); | 811 __ subu(a3, a3, t6); |
809 __ srl(t0, t6, Map::kInObjectPropertiesByte * 8); | |
810 __ subu(a3, a3, t0); | |
811 | 812 |
812 // Done if no extra properties are to be allocated. | 813 // Done if no extra properties are to be allocated. |
813 __ Branch(&allocated, eq, a3, Operand(zero_reg)); | 814 __ Branch(&allocated, eq, a3, Operand(zero_reg)); |
814 __ Assert(greater_equal, "Property allocation count failed.", | 815 __ Assert(greater_equal, "Property allocation count failed.", |
815 a3, Operand(zero_reg)); | 816 a3, Operand(zero_reg)); |
816 | 817 |
817 // Scale the number of elements by pointer size and add the header for | 818 // Scale the number of elements by pointer size and add the header for |
818 // FixedArrays to the start of the next object calculation from above. | 819 // FixedArrays to the start of the next object calculation from above. |
819 // a1: constructor | 820 // a1: constructor |
820 // a3: number of elements in properties array | 821 // a3: number of elements in properties array |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 | 1386 |
1386 | 1387 |
1387 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1388 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
1388 const int kIndexOffset = -5 * kPointerSize; | 1389 const int kIndexOffset = -5 * kPointerSize; |
1389 const int kLimitOffset = -4 * kPointerSize; | 1390 const int kLimitOffset = -4 * kPointerSize; |
1390 const int kArgsOffset = 2 * kPointerSize; | 1391 const int kArgsOffset = 2 * kPointerSize; |
1391 const int kRecvOffset = 3 * kPointerSize; | 1392 const int kRecvOffset = 3 * kPointerSize; |
1392 const int kFunctionOffset = 4 * kPointerSize; | 1393 const int kFunctionOffset = 4 * kPointerSize; |
1393 | 1394 |
1394 { | 1395 { |
1395 FrameScope frame_scope(masm, StackFrame::INTERNAL); | 1396 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1397 |
1396 __ lw(a0, MemOperand(fp, kFunctionOffset)); // Get the function. | 1398 __ lw(a0, MemOperand(fp, kFunctionOffset)); // Get the function. |
1397 __ push(a0); | 1399 __ push(a0); |
1398 __ lw(a0, MemOperand(fp, kArgsOffset)); // Get the args array. | 1400 __ lw(a0, MemOperand(fp, kArgsOffset)); // Get the args array. |
1399 __ push(a0); | 1401 __ push(a0); |
1400 // Returns (in v0) number of arguments to copy to stack as Smi. | 1402 // Returns (in v0) number of arguments to copy to stack as Smi. |
1401 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); | 1403 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); |
1402 | 1404 |
1403 // Check the stack for overflow. We are not trying to catch | 1405 // Check the stack for overflow. We are not trying to catch |
1404 // interruptions (e.g. debug break and preemption) here, so the "real stack | 1406 // interruptions (e.g. debug break and preemption) here, so the "real stack |
1405 // limit" is checked. | 1407 // limit" is checked. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 Label call_proxy; | 1521 Label call_proxy; |
1520 ParameterCount actual(a0); | 1522 ParameterCount actual(a0); |
1521 __ sra(a0, a0, kSmiTagSize); | 1523 __ sra(a0, a0, kSmiTagSize); |
1522 __ lw(a1, MemOperand(fp, kFunctionOffset)); | 1524 __ lw(a1, MemOperand(fp, kFunctionOffset)); |
1523 __ GetObjectType(a1, a2, a2); | 1525 __ GetObjectType(a1, a2, a2); |
1524 __ Branch(&call_proxy, ne, a2, Operand(JS_FUNCTION_TYPE)); | 1526 __ Branch(&call_proxy, ne, a2, Operand(JS_FUNCTION_TYPE)); |
1525 | 1527 |
1526 __ InvokeFunction(a1, actual, CALL_FUNCTION, | 1528 __ InvokeFunction(a1, actual, CALL_FUNCTION, |
1527 NullCallWrapper(), CALL_AS_METHOD); | 1529 NullCallWrapper(), CALL_AS_METHOD); |
1528 | 1530 |
1529 frame_scope.GenerateLeaveFrame(); | 1531 scope.GenerateLeaveFrame(); |
| 1532 |
1530 __ Ret(USE_DELAY_SLOT); | 1533 __ Ret(USE_DELAY_SLOT); |
1531 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. | 1534 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. |
1532 | 1535 |
1533 // Invoke the function proxy. | 1536 // Invoke the function proxy. |
1534 __ bind(&call_proxy); | 1537 __ bind(&call_proxy); |
1535 __ push(a1); // Add function proxy as last argument. | 1538 __ push(a1); // Add function proxy as last argument. |
1536 __ Addu(a0, a0, Operand(1)); | 1539 __ Addu(a0, a0, Operand(1)); |
1537 __ li(a2, Operand(0, RelocInfo::NONE)); | 1540 __ li(a2, Operand(0, RelocInfo::NONE)); |
1538 __ SetCallKind(t1, CALL_AS_METHOD); | 1541 __ SetCallKind(t1, CALL_AS_METHOD); |
1539 __ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY); | 1542 __ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY); |
1540 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1543 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1541 RelocInfo::CODE_TARGET); | 1544 RelocInfo::CODE_TARGET); |
1542 | |
1543 // Tear down the internal frame and remove function, receiver and args. | 1545 // Tear down the internal frame and remove function, receiver and args. |
1544 } | 1546 } |
1545 | 1547 |
1546 __ Ret(USE_DELAY_SLOT); | 1548 __ Ret(USE_DELAY_SLOT); |
1547 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. | 1549 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. |
1548 } | 1550 } |
1549 | 1551 |
1550 | 1552 |
1551 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1553 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
1552 __ sll(a0, a0, kSmiTagSize); | 1554 __ sll(a0, a0, kSmiTagSize); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 __ bind(&dont_adapt_arguments); | 1687 __ bind(&dont_adapt_arguments); |
1686 __ Jump(a3); | 1688 __ Jump(a3); |
1687 } | 1689 } |
1688 | 1690 |
1689 | 1691 |
1690 #undef __ | 1692 #undef __ |
1691 | 1693 |
1692 } } // namespace v8::internal | 1694 } } // namespace v8::internal |
1693 | 1695 |
1694 #endif // V8_TARGET_ARCH_MIPS | 1696 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |