| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 CodeStubInterfaceDescriptor* descriptor) { | 54 CodeStubInterfaceDescriptor* descriptor) { |
| 55 static Register registers[] = { r0, r1 }; | 55 static Register registers[] = { r0, r1 }; |
| 56 descriptor->register_param_count_ = 2; | 56 descriptor->register_param_count_ = 2; |
| 57 descriptor->register_params_ = registers; | 57 descriptor->register_params_ = registers; |
| 58 Address entry = | 58 Address entry = |
| 59 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; | 59 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; |
| 60 descriptor->deoptimization_handler_ = FUNCTION_ADDR(entry); | 60 descriptor->deoptimization_handler_ = FUNCTION_ADDR(entry); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 static void InitializeArrayConstructorDescriptor(Isolate* isolate, |
| 65 CodeStubInterfaceDescriptor* descriptor) { |
| 66 static Register registers[] = { r1, r2 }; |
| 67 descriptor->register_param_count_ = 2; |
| 68 // stack param count needs (constructor pointer, and single argument) |
| 69 descriptor->stack_parameter_count_ = &r0; |
| 70 descriptor->register_params_ = registers; |
| 71 descriptor->extra_expression_stack_count_ = 1; |
| 72 descriptor->deoptimization_handler_ = |
| 73 FUNCTION_ADDR(ArrayConstructor_StubFailure); |
| 74 } |
| 75 |
| 76 |
| 77 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 78 Isolate* isolate, |
| 79 CodeStubInterfaceDescriptor* descriptor) { |
| 80 InitializeArrayConstructorDescriptor(isolate, descriptor); |
| 81 } |
| 82 |
| 83 |
| 84 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
| 85 Isolate* isolate, |
| 86 CodeStubInterfaceDescriptor* descriptor) { |
| 87 InitializeArrayConstructorDescriptor(isolate, descriptor); |
| 88 } |
| 89 |
| 90 |
| 91 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
| 92 Isolate* isolate, |
| 93 CodeStubInterfaceDescriptor* descriptor) { |
| 94 InitializeArrayConstructorDescriptor(isolate, descriptor); |
| 95 } |
| 96 |
| 97 |
| 64 #define __ ACCESS_MASM(masm) | 98 #define __ ACCESS_MASM(masm) |
| 65 | 99 |
| 66 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 100 static void EmitIdenticalObjectComparison(MacroAssembler* masm, |
| 67 Label* slow, | 101 Label* slow, |
| 68 Condition cond); | 102 Condition cond); |
| 69 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 103 static void EmitSmiNonsmiComparison(MacroAssembler* masm, |
| 70 Register lhs, | 104 Register lhs, |
| 71 Register rhs, | 105 Register rhs, |
| 72 Label* lhs_not_nan, | 106 Label* lhs_not_nan, |
| 73 Label* slow, | 107 Label* slow, |
| (...skipping 5500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5574 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); | 5608 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); |
| 5575 } | 5609 } |
| 5576 | 5610 |
| 5577 | 5611 |
| 5578 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 5612 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 5579 // Cache the called function in a global property cell. Cache states | 5613 // Cache the called function in a global property cell. Cache states |
| 5580 // are uninitialized, monomorphic (indicated by a JSFunction), and | 5614 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 5581 // megamorphic. | 5615 // megamorphic. |
| 5582 // r1 : the function to call | 5616 // r1 : the function to call |
| 5583 // r2 : cache cell for call target | 5617 // r2 : cache cell for call target |
| 5584 Label done; | 5618 Label initialize, done, miss, megamorphic, not_array_function; |
| 5585 | 5619 |
| 5586 ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()), | 5620 ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()), |
| 5587 masm->isolate()->heap()->undefined_value()); | 5621 masm->isolate()->heap()->undefined_value()); |
| 5588 ASSERT_EQ(*TypeFeedbackCells::UninitializedSentinel(masm->isolate()), | 5622 ASSERT_EQ(*TypeFeedbackCells::UninitializedSentinel(masm->isolate()), |
| 5589 masm->isolate()->heap()->the_hole_value()); | 5623 masm->isolate()->heap()->the_hole_value()); |
| 5590 | 5624 |
| 5591 // Load the cache state into r3. | 5625 // Load the cache state into r3. |
| 5592 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 5626 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5593 | 5627 |
| 5594 // A monomorphic cache hit or an already megamorphic state: invoke the | 5628 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 5595 // function without changing the state. | 5629 // function without changing the state. |
| 5596 __ cmp(r3, r1); | 5630 __ cmp(r3, r1); |
| 5597 __ b(eq, &done); | 5631 __ b(eq, &done); |
| 5598 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); | 5632 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
| 5599 __ b(eq, &done); | 5633 __ b(eq, &done); |
| 5600 | 5634 |
| 5635 // Special handling of the Array() function, which caches not only the |
| 5636 // monomorphic Array function but the initial ElementsKind with special |
| 5637 // sentinels |
| 5638 Handle<Object> terminal_kind_sentinel = |
| 5639 TypeFeedbackCells::MonomorphicArraySentinel(LAST_FAST_ELEMENTS_KIND); |
| 5640 __ cmp(r3, Operand(terminal_kind_sentinel)); |
| 5641 __ b(ne, &miss); |
| 5642 // Load the global or builtins object from the current context |
| 5643 __ ldr(r3, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 5644 __ ldr(r3, FieldMemOperand(r3, GlobalObject::kGlobalContextOffset)); |
| 5645 // Make sure the function is the Array() function |
| 5646 __ ldr(r3, |
| 5647 MemOperand(r3, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
| 5648 __ cmp(r1, r3); |
| 5649 Label megamorphic_pre; |
| 5650 __ b(ne, &megamorphic_pre); |
| 5651 __ jmp(&done); |
| 5652 |
| 5653 __ bind(&megamorphic_pre); |
| 5654 __ jmp(&megamorphic); |
| 5655 |
| 5656 __ bind(&miss); |
| 5657 |
| 5601 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 5658 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 5602 // megamorphic. | 5659 // megamorphic. |
| 5603 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 5660 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 5661 __ b(eq, &initialize); |
| 5604 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 5662 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 5605 // write-barrier is needed. | 5663 // write-barrier is needed. |
| 5606 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex, ne); | 5664 __ bind(&megamorphic); |
| 5607 __ str(ip, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset), ne); | 5665 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 5666 __ str(ip, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5608 | 5667 |
| 5609 // An uninitialized cache is patched with the function. | 5668 // An uninitialized cache is patched with the function or sentinel to |
| 5610 __ str(r1, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset), eq); | 5669 // indicate the ElementsKind if function is the Array constructor. |
| 5670 __ bind(&initialize); |
| 5671 __ ldr(r3, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 5672 __ ldr(r3, FieldMemOperand(r3, GlobalObject::kGlobalContextOffset)); |
| 5673 __ ldr(r3, |
| 5674 MemOperand(r3, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
| 5675 // Make sure the function is the Array() function |
| 5676 __ cmp(r1, r3); |
| 5677 __ b(ne, ¬_array_function); |
| 5678 |
| 5679 // The target function is the Array constructor, install a sentinel value in |
| 5680 // the constructor's type info cell that will track the initial ElementsKind |
| 5681 // that should be used for the array when its constructed. |
| 5682 Handle<Object> initial_kind_sentinel = |
| 5683 TypeFeedbackCells::MonomorphicArraySentinel( |
| 5684 GetInitialFastElementsKind()); |
| 5685 __ mov(r3, Operand(initial_kind_sentinel)); |
| 5686 __ str(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5687 __ b(&done); |
| 5688 |
| 5689 __ bind(¬_array_function); |
| 5690 __ str(r1, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 5611 // No need for a write barrier here - cells are rescanned. | 5691 // No need for a write barrier here - cells are rescanned. |
| 5612 | 5692 |
| 5613 __ bind(&done); | 5693 __ bind(&done); |
| 5614 } | 5694 } |
| 5615 | 5695 |
| 5616 | 5696 |
| 5617 void CallFunctionStub::Generate(MacroAssembler* masm) { | 5697 void CallFunctionStub::Generate(MacroAssembler* masm) { |
| 5618 // r1 : the function to call | 5698 // r1 : the function to call |
| 5619 // r2 : cache cell for call target | 5699 // r2 : cache cell for call target |
| 5620 Label slow, non_function; | 5700 Label slow, non_function; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5718 __ JumpIfSmi(r1, &non_function_call); | 5798 __ JumpIfSmi(r1, &non_function_call); |
| 5719 // Check that the function is a JSFunction. | 5799 // Check that the function is a JSFunction. |
| 5720 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); | 5800 __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
| 5721 __ b(ne, &slow); | 5801 __ b(ne, &slow); |
| 5722 | 5802 |
| 5723 if (RecordCallTarget()) { | 5803 if (RecordCallTarget()) { |
| 5724 GenerateRecordCallTarget(masm); | 5804 GenerateRecordCallTarget(masm); |
| 5725 } | 5805 } |
| 5726 | 5806 |
| 5727 // Jump to the function-specific construct stub. | 5807 // Jump to the function-specific construct stub. |
| 5728 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 5808 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 5729 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); | 5809 __ ldr(r3, FieldMemOperand(r3, SharedFunctionInfo::kConstructStubOffset)); |
| 5730 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); | 5810 __ add(pc, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 5731 | 5811 |
| 5732 // r0: number of arguments | 5812 // r0: number of arguments |
| 5733 // r1: called object | 5813 // r1: called object |
| 5734 // r3: object type | 5814 // r3: object type |
| 5735 Label do_call; | 5815 Label do_call; |
| 5736 __ bind(&slow); | 5816 __ bind(&slow); |
| 5737 __ cmp(r3, Operand(JS_FUNCTION_PROXY_TYPE)); | 5817 __ cmp(r3, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 5738 __ b(ne, &non_function_call); | 5818 __ b(ne, &non_function_call); |
| 5739 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 5819 __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 5740 __ jmp(&do_call); | 5820 __ jmp(&do_call); |
| (...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7946 | 8026 |
| 7947 __ Pop(lr, r5, r1); | 8027 __ Pop(lr, r5, r1); |
| 7948 __ Ret(); | 8028 __ Ret(); |
| 7949 } | 8029 } |
| 7950 | 8030 |
| 7951 #undef __ | 8031 #undef __ |
| 7952 | 8032 |
| 7953 } } // namespace v8::internal | 8033 } } // namespace v8::internal |
| 7954 | 8034 |
| 7955 #endif // V8_TARGET_ARCH_ARM | 8035 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |