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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 static Register registers[] = { rax, rbx }; | 56 static Register registers[] = { rax, rbx }; |
57 descriptor->register_param_count_ = 2; | 57 descriptor->register_param_count_ = 2; |
58 descriptor->register_params_ = registers; | 58 descriptor->register_params_ = registers; |
59 descriptor->deoptimization_handler_ = | 59 descriptor->deoptimization_handler_ = |
60 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; | 60 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 static void InitializeArrayConstructorDescriptor(Isolate* isolate, | 64 static void InitializeArrayConstructorDescriptor(Isolate* isolate, |
65 CodeStubInterfaceDescriptor* descriptor) { | 65 CodeStubInterfaceDescriptor* descriptor) { |
| 66 // register state |
| 67 // rdi -- constructor function |
| 68 // rbx -- type info cell with elements kind |
| 69 // rax -- number of arguments to the constructor function |
66 static Register registers[] = { rdi, rbx }; | 70 static Register registers[] = { rdi, rbx }; |
67 descriptor->register_param_count_ = 2; | 71 descriptor->register_param_count_ = 2; |
68 // stack param count needs (constructor pointer, and single argument) | 72 // stack param count needs (constructor pointer, and single argument) |
69 descriptor->stack_parameter_count_ = &rax; | 73 descriptor->stack_parameter_count_ = &rax; |
70 descriptor->register_params_ = registers; | 74 descriptor->register_params_ = registers; |
71 descriptor->extra_expression_stack_count_ = 1; | 75 descriptor->extra_expression_stack_count_ = 1; |
72 descriptor->deoptimization_handler_ = | 76 descriptor->deoptimization_handler_ = |
73 FUNCTION_ADDR(ArrayConstructor_StubFailure); | 77 FUNCTION_ADDR(ArrayConstructor_StubFailure); |
74 } | 78 } |
75 | 79 |
(...skipping 3834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3910 // rdi : the function to call | 3914 // rdi : the function to call |
3911 Isolate* isolate = masm->isolate(); | 3915 Isolate* isolate = masm->isolate(); |
3912 Label initialize, done, miss, megamorphic, not_array_function; | 3916 Label initialize, done, miss, megamorphic, not_array_function; |
3913 | 3917 |
3914 // Load the cache state into rcx. | 3918 // Load the cache state into rcx. |
3915 __ movq(rcx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset)); | 3919 __ movq(rcx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset)); |
3916 | 3920 |
3917 // A monomorphic cache hit or an already megamorphic state: invoke the | 3921 // A monomorphic cache hit or an already megamorphic state: invoke the |
3918 // function without changing the state. | 3922 // function without changing the state. |
3919 __ cmpq(rcx, rdi); | 3923 __ cmpq(rcx, rdi); |
3920 __ j(equal, &done, Label::kFar); | 3924 __ j(equal, &done); |
3921 __ Cmp(rcx, TypeFeedbackCells::MegamorphicSentinel(isolate)); | 3925 __ Cmp(rcx, TypeFeedbackCells::MegamorphicSentinel(isolate)); |
3922 __ j(equal, &done, Label::kFar); | 3926 __ j(equal, &done); |
3923 | 3927 |
3924 // Special handling of the Array() function, which caches not only the | 3928 // Special handling of the Array() function, which caches not only the |
3925 // monomorphic Array function but the initial ElementsKind with special | 3929 // monomorphic Array function but the initial ElementsKind with special |
3926 // sentinels | 3930 // sentinels |
3927 Handle<Object> terminal_kind_sentinel = | 3931 Handle<Object> terminal_kind_sentinel = |
3928 TypeFeedbackCells::MonomorphicArraySentinel(LAST_FAST_ELEMENTS_KIND); | 3932 TypeFeedbackCells::MonomorphicArraySentinel(LAST_FAST_ELEMENTS_KIND); |
3929 __ Cmp(rcx, terminal_kind_sentinel); | 3933 __ Cmp(rcx, terminal_kind_sentinel); |
3930 __ j(not_equal, &miss, Label::kFar); | 3934 __ j(not_equal, &miss); |
3931 // Load the global or builtins object from the current context | |
3932 __ movq(rcx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
3933 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset)); | |
3934 __ movq(rcx, | |
3935 Operand(rcx, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | |
3936 // Make sure the function is the Array() function | 3935 // Make sure the function is the Array() function |
| 3936 __ LoadArrayFunction(rcx); |
3937 __ cmpq(rdi, rcx); | 3937 __ cmpq(rdi, rcx); |
3938 Label megamorphic_pre; | 3938 __ j(not_equal, &megamorphic); |
3939 __ j(not_equal, &megamorphic_pre, Label::kFar); | |
3940 __ jmp(&done); | 3939 __ jmp(&done); |
3941 | 3940 |
3942 __ bind(&megamorphic_pre); | |
3943 __ jmp(&megamorphic, Label::kFar); | |
3944 | |
3945 __ bind(&miss); | 3941 __ bind(&miss); |
3946 | 3942 |
3947 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 3943 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
3948 // megamorphic. | 3944 // megamorphic. |
3949 __ Cmp(rcx, TypeFeedbackCells::UninitializedSentinel(isolate)); | 3945 __ Cmp(rcx, TypeFeedbackCells::UninitializedSentinel(isolate)); |
3950 __ j(equal, &initialize, Label::kFar); | 3946 __ j(equal, &initialize); |
3951 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 3947 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
3952 // write-barrier is needed. | 3948 // write-barrier is needed. |
3953 __ bind(&megamorphic); | 3949 __ bind(&megamorphic); |
3954 __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), | 3950 __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), |
3955 TypeFeedbackCells::MegamorphicSentinel(isolate)); | 3951 TypeFeedbackCells::MegamorphicSentinel(isolate)); |
3956 __ jmp(&done, Label::kNear); | 3952 __ jmp(&done, Label::kNear); |
3957 | 3953 |
3958 // An uninitialized cache is patched with the function or sentinel to | 3954 // An uninitialized cache is patched with the function or sentinel to |
3959 // indicate the ElementsKind if function is the Array constructor. | 3955 // indicate the ElementsKind if function is the Array constructor. |
3960 __ bind(&initialize); | 3956 __ bind(&initialize); |
3961 __ movq(rcx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
3962 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset)); | |
3963 __ movq(rcx, | |
3964 Operand(rcx, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | |
3965 // Make sure the function is the Array() function | 3957 // Make sure the function is the Array() function |
| 3958 __ LoadArrayFunction(rcx); |
3966 __ cmpq(rdi, rcx); | 3959 __ cmpq(rdi, rcx); |
3967 __ j(not_equal, ¬_array_function); | 3960 __ j(not_equal, ¬_array_function); |
3968 | 3961 |
3969 // The target function is the Array constructor, install a sentinel value in | 3962 // The target function is the Array constructor, install a sentinel value in |
3970 // the constructor's type info cell that will track the initial ElementsKind | 3963 // the constructor's type info cell that will track the initial ElementsKind |
3971 // that should be used for the array when its constructed. | 3964 // that should be used for the array when its constructed. |
3972 Handle<Object> initial_kind_sentinel = | 3965 Handle<Object> initial_kind_sentinel = |
3973 TypeFeedbackCells::MonomorphicArraySentinel( | 3966 TypeFeedbackCells::MonomorphicArraySentinel( |
3974 GetInitialFastElementsKind()); | 3967 GetInitialFastElementsKind()); |
3975 __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), | 3968 __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), |
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6788 #endif | 6781 #endif |
6789 | 6782 |
6790 __ Ret(); | 6783 __ Ret(); |
6791 } | 6784 } |
6792 | 6785 |
6793 #undef __ | 6786 #undef __ |
6794 | 6787 |
6795 } } // namespace v8::internal | 6788 } } // namespace v8::internal |
6796 | 6789 |
6797 #endif // V8_TARGET_ARCH_X64 | 6790 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |