| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 descriptor->register_param_count_ = 2; | 68 descriptor->register_param_count_ = 2; |
| 69 descriptor->register_params_ = registers; | 69 descriptor->register_params_ = registers; |
| 70 Address entry = | 70 Address entry = |
| 71 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; | 71 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; |
| 72 descriptor->deoptimization_handler_ = FUNCTION_ADDR(entry); | 72 descriptor->deoptimization_handler_ = FUNCTION_ADDR(entry); |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 static void InitializeArrayConstructorDescriptor(Isolate* isolate, | 76 static void InitializeArrayConstructorDescriptor(Isolate* isolate, |
| 77 CodeStubInterfaceDescriptor* descriptor) { | 77 CodeStubInterfaceDescriptor* descriptor) { |
| 78 // register state |
| 79 // r1 -- constructor function |
| 80 // r2 -- type info cell with elements kind |
| 81 // r0 -- number of arguments to the constructor function |
| 78 static Register registers[] = { r1, r2 }; | 82 static Register registers[] = { r1, r2 }; |
| 79 descriptor->register_param_count_ = 2; | 83 descriptor->register_param_count_ = 2; |
| 80 // stack param count needs (constructor pointer, and single argument) | 84 // stack param count needs (constructor pointer, and single argument) |
| 81 descriptor->stack_parameter_count_ = &r0; | 85 descriptor->stack_parameter_count_ = &r0; |
| 82 descriptor->register_params_ = registers; | 86 descriptor->register_params_ = registers; |
| 83 descriptor->extra_expression_stack_count_ = 1; | 87 descriptor->extra_expression_stack_count_ = 1; |
| 84 descriptor->deoptimization_handler_ = | 88 descriptor->deoptimization_handler_ = |
| 85 FUNCTION_ADDR(ArrayConstructor_StubFailure); | 89 FUNCTION_ADDR(ArrayConstructor_StubFailure); |
| 86 } | 90 } |
| 87 | 91 |
| (...skipping 5484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5572 | 5576 |
| 5573 __ bind(&done); | 5577 __ bind(&done); |
| 5574 __ add(sp, sp, Operand(3 * kPointerSize)); | 5578 __ add(sp, sp, Operand(3 * kPointerSize)); |
| 5575 __ Ret(); | 5579 __ Ret(); |
| 5576 | 5580 |
| 5577 __ bind(&slowcase); | 5581 __ bind(&slowcase); |
| 5578 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); | 5582 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); |
| 5579 } | 5583 } |
| 5580 | 5584 |
| 5581 | 5585 |
| 5586 static void GenerateRecordCallTargetNoArray(MacroAssembler* masm) { |
| 5587 // Cache the called function in a global property cell. Cache states |
| 5588 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 5589 // megamorphic. |
| 5590 // r1 : the function to call |
| 5591 // r2 : cache cell for call target |
| 5592 ASSERT(!FLAG_optimize_constructed_arrays); |
| 5593 Label done; |
| 5594 |
| 5595 ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()), |
| 5596 masm->isolate()->heap()->undefined_value()); |
| 5597 ASSERT_EQ(*TypeFeedbackCells::UninitializedSentinel(masm->isolate()), |
| 5598 masm->isolate()->heap()->the_hole_value()); |
| 5599 |
| 5600 // Load the cache state into r3. |
| 5601 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5602 |
| 5603 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 5604 // function without changing the state. |
| 5605 __ cmp(r3, r1); |
| 5606 __ b(eq, &done); |
| 5607 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
| 5608 __ b(eq, &done); |
| 5609 |
| 5610 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 5611 // megamorphic. |
| 5612 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 5613 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 5614 // write-barrier is needed. |
| 5615 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex, ne); |
| 5616 __ str(ip, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset), ne); |
| 5617 |
| 5618 // An uninitialized cache is patched with the function. |
| 5619 __ str(r1, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset), eq); |
| 5620 // No need for a write barrier here - cells are rescanned. |
| 5621 |
| 5622 __ bind(&done); |
| 5623 } |
| 5624 |
| 5625 |
| 5582 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 5626 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 5583 // Cache the called function in a global property cell. Cache states | 5627 // Cache the called function in a global property cell. Cache states |
| 5584 // are uninitialized, monomorphic (indicated by a JSFunction), and | 5628 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 5585 // megamorphic. | 5629 // megamorphic. |
| 5586 // r1 : the function to call | 5630 // r1 : the function to call |
| 5587 // r2 : cache cell for call target | 5631 // r2 : cache cell for call target |
| 5632 ASSERT(FLAG_optimize_constructed_arrays); |
| 5588 Label initialize, done, miss, megamorphic, not_array_function; | 5633 Label initialize, done, miss, megamorphic, not_array_function; |
| 5589 | 5634 |
| 5590 ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()), | 5635 ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()), |
| 5591 masm->isolate()->heap()->undefined_value()); | 5636 masm->isolate()->heap()->undefined_value()); |
| 5592 ASSERT_EQ(*TypeFeedbackCells::UninitializedSentinel(masm->isolate()), | 5637 ASSERT_EQ(*TypeFeedbackCells::UninitializedSentinel(masm->isolate()), |
| 5593 masm->isolate()->heap()->the_hole_value()); | 5638 masm->isolate()->heap()->the_hole_value()); |
| 5594 | 5639 |
| 5595 // Load the cache state into r3. | 5640 // Load the cache state into r3. |
| 5596 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 5641 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5597 | 5642 |
| 5598 // A monomorphic cache hit or an already megamorphic state: invoke the | 5643 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 5599 // function without changing the state. | 5644 // function without changing the state. |
| 5600 __ cmp(r3, r1); | 5645 __ cmp(r3, r1); |
| 5601 __ b(eq, &done); | 5646 __ b(eq, &done); |
| 5602 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); | 5647 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
| 5603 __ b(eq, &done); | 5648 __ b(eq, &done); |
| 5604 | 5649 |
| 5605 // Special handling of the Array() function, which caches not only the | 5650 // Special handling of the Array() function, which caches not only the |
| 5606 // monomorphic Array function but the initial ElementsKind with special | 5651 // monomorphic Array function but the initial ElementsKind with special |
| 5607 // sentinels | 5652 // sentinels |
| 5608 Handle<Object> terminal_kind_sentinel = | 5653 Handle<Object> terminal_kind_sentinel = |
| 5609 TypeFeedbackCells::MonomorphicArraySentinel(LAST_FAST_ELEMENTS_KIND); | 5654 TypeFeedbackCells::MonomorphicArraySentinel(masm->isolate(), |
| 5655 LAST_FAST_ELEMENTS_KIND); |
| 5610 __ cmp(r3, Operand(terminal_kind_sentinel)); | 5656 __ cmp(r3, Operand(terminal_kind_sentinel)); |
| 5611 __ b(ne, &miss); | 5657 __ b(ne, &miss); |
| 5612 // Load the global or builtins object from the current context | |
| 5613 __ ldr(r3, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
| 5614 __ ldr(r3, FieldMemOperand(r3, GlobalObject::kGlobalContextOffset)); | |
| 5615 // Make sure the function is the Array() function | 5658 // Make sure the function is the Array() function |
| 5616 __ ldr(r3, | 5659 __ LoadArrayFunction(r3); |
| 5617 MemOperand(r3, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | |
| 5618 __ cmp(r1, r3); | 5660 __ cmp(r1, r3); |
| 5619 Label megamorphic_pre; | 5661 __ b(ne, &megamorphic); |
| 5620 __ b(ne, &megamorphic_pre); | |
| 5621 __ jmp(&done); | 5662 __ jmp(&done); |
| 5622 | 5663 |
| 5623 __ bind(&megamorphic_pre); | |
| 5624 __ jmp(&megamorphic); | |
| 5625 | |
| 5626 __ bind(&miss); | 5664 __ bind(&miss); |
| 5627 | 5665 |
| 5628 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 5666 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 5629 // megamorphic. | 5667 // megamorphic. |
| 5630 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 5668 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 5631 __ b(eq, &initialize); | 5669 __ b(eq, &initialize); |
| 5632 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 5670 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 5633 // write-barrier is needed. | 5671 // write-barrier is needed. |
| 5634 __ bind(&megamorphic); | 5672 __ bind(&megamorphic); |
| 5635 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 5673 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 5636 __ str(ip, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 5674 __ str(ip, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5637 | 5675 |
| 5638 // An uninitialized cache is patched with the function or sentinel to | 5676 // An uninitialized cache is patched with the function or sentinel to |
| 5639 // indicate the ElementsKind if function is the Array constructor. | 5677 // indicate the ElementsKind if function is the Array constructor. |
| 5640 __ bind(&initialize); | 5678 __ bind(&initialize); |
| 5641 __ ldr(r3, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
| 5642 __ ldr(r3, FieldMemOperand(r3, GlobalObject::kGlobalContextOffset)); | |
| 5643 __ ldr(r3, | |
| 5644 MemOperand(r3, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | |
| 5645 // Make sure the function is the Array() function | 5679 // Make sure the function is the Array() function |
| 5680 __ LoadArrayFunction(r3); |
| 5646 __ cmp(r1, r3); | 5681 __ cmp(r1, r3); |
| 5647 __ b(ne, ¬_array_function); | 5682 __ b(ne, ¬_array_function); |
| 5648 | 5683 |
| 5649 // The target function is the Array constructor, install a sentinel value in | 5684 // The target function is the Array constructor, install a sentinel value in |
| 5650 // the constructor's type info cell that will track the initial ElementsKind | 5685 // the constructor's type info cell that will track the initial ElementsKind |
| 5651 // that should be used for the array when its constructed. | 5686 // that should be used for the array when its constructed. |
| 5652 Handle<Object> initial_kind_sentinel = | 5687 Handle<Object> initial_kind_sentinel = |
| 5653 TypeFeedbackCells::MonomorphicArraySentinel( | 5688 TypeFeedbackCells::MonomorphicArraySentinel(masm->isolate(), |
| 5654 GetInitialFastElementsKind()); | 5689 GetInitialFastElementsKind()); |
| 5655 __ mov(r3, Operand(initial_kind_sentinel)); | 5690 __ mov(r3, Operand(initial_kind_sentinel)); |
| 5656 __ str(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 5691 __ str(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5657 __ b(&done); | 5692 __ b(&done); |
| 5658 | 5693 |
| 5659 __ bind(¬_array_function); | 5694 __ bind(¬_array_function); |
| 5660 __ str(r1, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 5695 __ str(r1, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5661 // No need for a write barrier here - cells are rescanned. | 5696 // No need for a write barrier here - cells are rescanned. |
| 5662 | 5697 |
| 5663 __ bind(&done); | 5698 __ bind(&done); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5689 } | 5724 } |
| 5690 | 5725 |
| 5691 // Check that the function is really a JavaScript function. | 5726 // Check that the function is really a JavaScript function. |
| 5692 // r1: pushed function (to be verified) | 5727 // r1: pushed function (to be verified) |
| 5693 __ JumpIfSmi(r1, &non_function); | 5728 __ JumpIfSmi(r1, &non_function); |
| 5694 // Get the map of the function object. | 5729 // Get the map of the function object. |
| 5695 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); | 5730 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
| 5696 __ b(ne, &slow); | 5731 __ b(ne, &slow); |
| 5697 | 5732 |
| 5698 if (RecordCallTarget()) { | 5733 if (RecordCallTarget()) { |
| 5699 GenerateRecordCallTarget(masm); | 5734 if (FLAG_optimize_constructed_arrays) { |
| 5735 GenerateRecordCallTarget(masm); |
| 5736 } else { |
| 5737 GenerateRecordCallTargetNoArray(masm); |
| 5738 } |
| 5700 } | 5739 } |
| 5701 | 5740 |
| 5702 // Fast-case: Invoke the function now. | 5741 // Fast-case: Invoke the function now. |
| 5703 // r1: pushed function | 5742 // r1: pushed function |
| 5704 ParameterCount actual(argc_); | 5743 ParameterCount actual(argc_); |
| 5705 | 5744 |
| 5706 if (ReceiverMightBeImplicit()) { | 5745 if (ReceiverMightBeImplicit()) { |
| 5707 Label call_as_function; | 5746 Label call_as_function; |
| 5708 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex); | 5747 __ CompareRoot(r4, Heap::kTheHoleValueRootIndex); |
| 5709 __ b(eq, &call_as_function); | 5748 __ b(eq, &call_as_function); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5764 // r2 : cache cell for call target | 5803 // r2 : cache cell for call target |
| 5765 Label slow, non_function_call; | 5804 Label slow, non_function_call; |
| 5766 | 5805 |
| 5767 // Check that the function is not a smi. | 5806 // Check that the function is not a smi. |
| 5768 __ JumpIfSmi(r1, &non_function_call); | 5807 __ JumpIfSmi(r1, &non_function_call); |
| 5769 // Check that the function is a JSFunction. | 5808 // Check that the function is a JSFunction. |
| 5770 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); | 5809 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
| 5771 __ b(ne, &slow); | 5810 __ b(ne, &slow); |
| 5772 | 5811 |
| 5773 if (RecordCallTarget()) { | 5812 if (RecordCallTarget()) { |
| 5774 GenerateRecordCallTarget(masm); | 5813 if (FLAG_optimize_constructed_arrays) { |
| 5814 GenerateRecordCallTarget(masm); |
| 5815 } else { |
| 5816 GenerateRecordCallTargetNoArray(masm); |
| 5817 } |
| 5775 } | 5818 } |
| 5776 | 5819 |
| 5777 // Jump to the function-specific construct stub. | 5820 // Jump to the function-specific construct stub. |
| 5778 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 5821 Register jmp_reg = FLAG_optimize_constructed_arrays ? r3 : r2; |
| 5779 __ ldr(r3, FieldMemOperand(r3, SharedFunctionInfo::kConstructStubOffset)); | 5822 __ ldr(jmp_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 5780 __ add(pc, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); | 5823 __ ldr(jmp_reg, FieldMemOperand(jmp_reg, |
| 5824 SharedFunctionInfo::kConstructStubOffset)); |
| 5825 __ add(pc, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 5781 | 5826 |
| 5782 // r0: number of arguments | 5827 // r0: number of arguments |
| 5783 // r1: called object | 5828 // r1: called object |
| 5784 // r3: object type | 5829 // r3: object type |
| 5785 Label do_call; | 5830 Label do_call; |
| 5786 __ bind(&slow); | 5831 __ bind(&slow); |
| 5787 __ cmp(r3, Operand(JS_FUNCTION_PROXY_TYPE)); | 5832 __ cmp(r3, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 5788 __ b(ne, &non_function_call); | 5833 __ b(ne, &non_function_call); |
| 5789 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 5834 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 5790 __ jmp(&do_call); | 5835 __ jmp(&do_call); |
| (...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7997 | 8042 |
| 7998 __ Pop(lr, r5, r1); | 8043 __ Pop(lr, r5, r1); |
| 7999 __ Ret(); | 8044 __ Ret(); |
| 8000 } | 8045 } |
| 8001 | 8046 |
| 8002 #undef __ | 8047 #undef __ |
| 8003 | 8048 |
| 8004 } } // namespace v8::internal | 8049 } } // namespace v8::internal |
| 8005 | 8050 |
| 8006 #endif // V8_TARGET_ARCH_ARM | 8051 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |