| 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 __ IncrementCounter(counters->string_ctor_gc_required(), 1, r3, r4); | 660 __ IncrementCounter(counters->string_ctor_gc_required(), 1, r3, r4); |
| 661 { | 661 { |
| 662 FrameScope scope(masm, StackFrame::INTERNAL); | 662 FrameScope scope(masm, StackFrame::INTERNAL); |
| 663 __ push(argument); | 663 __ push(argument); |
| 664 __ CallRuntime(Runtime::kNewStringWrapper, 1); | 664 __ CallRuntime(Runtime::kNewStringWrapper, 1); |
| 665 } | 665 } |
| 666 __ Ret(); | 666 __ Ret(); |
| 667 } | 667 } |
| 668 | 668 |
| 669 | 669 |
| 670 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { | 670 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 671 bool is_api_function, |
| 672 bool count_constructions) { |
| 671 // ----------- S t a t e ------------- | 673 // ----------- S t a t e ------------- |
| 672 // -- r0 : number of arguments | 674 // -- r0 : number of arguments |
| 673 // -- r1 : constructor function | 675 // -- r1 : constructor function |
| 674 // -- lr : return address | 676 // -- lr : return address |
| 675 // -- sp[...]: constructor arguments | 677 // -- sp[...]: constructor arguments |
| 676 // ----------------------------------- | 678 // ----------------------------------- |
| 677 | 679 |
| 678 Label slow, non_function_call; | |
| 679 // Check that the function is not a smi. | |
| 680 __ JumpIfSmi(r1, &non_function_call); | |
| 681 // Check that the function is a JSFunction. | |
| 682 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); | |
| 683 __ b(ne, &slow); | |
| 684 | |
| 685 // Jump to the function-specific construct stub. | |
| 686 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | |
| 687 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); | |
| 688 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 689 | |
| 690 // r0: number of arguments | |
| 691 // r1: called object | |
| 692 // r2: object type | |
| 693 Label do_call; | |
| 694 __ bind(&slow); | |
| 695 __ cmp(r2, Operand(JS_FUNCTION_PROXY_TYPE)); | |
| 696 __ b(ne, &non_function_call); | |
| 697 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | |
| 698 __ jmp(&do_call); | |
| 699 | |
| 700 __ bind(&non_function_call); | |
| 701 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | |
| 702 __ bind(&do_call); | |
| 703 // Set expected number of arguments to zero (not changing r0). | |
| 704 __ mov(r2, Operand(0, RelocInfo::NONE)); | |
| 705 __ SetCallKind(r5, CALL_AS_METHOD); | |
| 706 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | |
| 707 RelocInfo::CODE_TARGET); | |
| 708 } | |
| 709 | |
| 710 | |
| 711 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | |
| 712 bool is_api_function, | |
| 713 bool count_constructions) { | |
| 714 // Should never count constructions for api objects. | 680 // Should never count constructions for api objects. |
| 715 ASSERT(!is_api_function || !count_constructions); | 681 ASSERT(!is_api_function || !count_constructions); |
| 716 | 682 |
| 717 Isolate* isolate = masm->isolate(); | 683 Isolate* isolate = masm->isolate(); |
| 718 | 684 |
| 719 // Enter a construct frame. | 685 // Enter a construct frame. |
| 720 { | 686 { |
| 721 FrameScope scope(masm, StackFrame::CONSTRUCT); | 687 FrameScope scope(masm, StackFrame::CONSTRUCT); |
| 722 | 688 |
| 723 // Preserve the two incoming parameters on the stack. | 689 // Preserve the two incoming parameters on the stack. |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 __ mov(r5, Operand(r4)); | 1076 __ mov(r5, Operand(r4)); |
| 1111 __ mov(r6, Operand(r4)); | 1077 __ mov(r6, Operand(r4)); |
| 1112 __ mov(r7, Operand(r4)); | 1078 __ mov(r7, Operand(r4)); |
| 1113 if (kR9Available == 1) { | 1079 if (kR9Available == 1) { |
| 1114 __ mov(r9, Operand(r4)); | 1080 __ mov(r9, Operand(r4)); |
| 1115 } | 1081 } |
| 1116 | 1082 |
| 1117 // Invoke the code and pass argc as r0. | 1083 // Invoke the code and pass argc as r0. |
| 1118 __ mov(r0, Operand(r3)); | 1084 __ mov(r0, Operand(r3)); |
| 1119 if (is_construct) { | 1085 if (is_construct) { |
| 1120 __ Call(masm->isolate()->builtins()->JSConstructCall()); | 1086 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
| 1087 __ CallStub(&stub); |
| 1121 } else { | 1088 } else { |
| 1122 ParameterCount actual(r0); | 1089 ParameterCount actual(r0); |
| 1123 __ InvokeFunction(r1, actual, CALL_FUNCTION, | 1090 __ InvokeFunction(r1, actual, CALL_FUNCTION, |
| 1124 NullCallWrapper(), CALL_AS_METHOD); | 1091 NullCallWrapper(), CALL_AS_METHOD); |
| 1125 } | 1092 } |
| 1126 // Exit the JS frame and remove the parameters (except function), and | 1093 // Exit the JS frame and remove the parameters (except function), and |
| 1127 // return. | 1094 // return. |
| 1128 // Respect ABI stack constraint. | 1095 // Respect ABI stack constraint. |
| 1129 } | 1096 } |
| 1130 __ Jump(lr); | 1097 __ Jump(lr); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 __ bind(&dont_adapt_arguments); | 1738 __ bind(&dont_adapt_arguments); |
| 1772 __ Jump(r3); | 1739 __ Jump(r3); |
| 1773 } | 1740 } |
| 1774 | 1741 |
| 1775 | 1742 |
| 1776 #undef __ | 1743 #undef __ |
| 1777 | 1744 |
| 1778 } } // namespace v8::internal | 1745 } } // namespace v8::internal |
| 1779 | 1746 |
| 1780 #endif // V8_TARGET_ARCH_ARM | 1747 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |