OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 #endif | 127 #endif |
128 | 128 |
129 // Strict mode functions need to replace the receiver with undefined | 129 // Strict mode functions need to replace the receiver with undefined |
130 // when called as functions (without an explicit receiver | 130 // when called as functions (without an explicit receiver |
131 // object). rcx is zero for method calls and non-zero for function | 131 // object). rcx is zero for method calls and non-zero for function |
132 // calls. | 132 // calls. |
133 if (!info_->is_classic_mode() || info_->is_native()) { | 133 if (!info_->is_classic_mode() || info_->is_native()) { |
134 Label ok; | 134 Label ok; |
135 __ testq(rcx, rcx); | 135 __ testq(rcx, rcx); |
136 __ j(zero, &ok, Label::kNear); | 136 __ j(zero, &ok, Label::kNear); |
137 // +1 for return address. | 137 StackArgumentsAccessor args(rsp, scope()->num_parameters()); |
138 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; | |
139 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | 138 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
140 __ movq(Operand(rsp, receiver_offset), kScratchRegister); | 139 __ movq(args.GetReceiverOperand(), kScratchRegister); |
141 __ bind(&ok); | 140 __ bind(&ok); |
142 } | 141 } |
143 } | 142 } |
144 | 143 |
145 info()->set_prologue_offset(masm_->pc_offset()); | 144 info()->set_prologue_offset(masm_->pc_offset()); |
146 if (NeedsEagerFrame()) { | 145 if (NeedsEagerFrame()) { |
147 ASSERT(!frame_is_built_); | 146 ASSERT(!frame_is_built_); |
148 frame_is_built_ = true; | 147 frame_is_built_ = true; |
149 __ push(rbp); // Caller's frame pointer. | 148 __ push(rbp); // Caller's frame pointer. |
150 __ movq(rbp, rsp); | 149 __ movq(rbp, rsp); |
(...skipping 2670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 | 2820 |
2822 | 2821 |
2823 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { | 2822 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
2824 Register arguments = ToRegister(instr->arguments()); | 2823 Register arguments = ToRegister(instr->arguments()); |
2825 Register result = ToRegister(instr->result()); | 2824 Register result = ToRegister(instr->result()); |
2826 | 2825 |
2827 if (instr->length()->IsConstantOperand() && | 2826 if (instr->length()->IsConstantOperand() && |
2828 instr->index()->IsConstantOperand()) { | 2827 instr->index()->IsConstantOperand()) { |
2829 int32_t const_index = ToInteger32(LConstantOperand::cast(instr->index())); | 2828 int32_t const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
2830 int32_t const_length = ToInteger32(LConstantOperand::cast(instr->length())); | 2829 int32_t const_length = ToInteger32(LConstantOperand::cast(instr->length())); |
2831 int index = (const_length - const_index) + 1; | 2830 StackArgumentsAccessor args(arguments, const_length, |
2832 __ movq(result, Operand(arguments, index * kPointerSize)); | 2831 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 2832 __ movq(result, args.GetArgumentOperand(const_index)); |
2833 } else { | 2833 } else { |
2834 Register length = ToRegister(instr->length()); | 2834 Register length = ToRegister(instr->length()); |
2835 // There are two words between the frame pointer and the last argument. | 2835 // There are two words between the frame pointer and the last argument. |
2836 // Subtracting from length accounts for one of them add one more. | 2836 // Subtracting from length accounts for one of them add one more. |
2837 if (instr->index()->IsRegister()) { | 2837 if (instr->index()->IsRegister()) { |
2838 __ subl(length, ToRegister(instr->index())); | 2838 __ subl(length, ToRegister(instr->index())); |
2839 } else { | 2839 } else { |
2840 __ subl(length, ToOperand(instr->index())); | 2840 __ subl(length, ToOperand(instr->index())); |
2841 } | 2841 } |
2842 __ movq(result, | 2842 StackArgumentsAccessor args(arguments, length, |
2843 Operand(arguments, length, times_pointer_size, kPointerSize)); | 2843 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 2844 __ movq(result, args.GetArgumentOperand(0)); |
2844 } | 2845 } |
2845 } | 2846 } |
2846 | 2847 |
2847 | 2848 |
2848 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { | 2849 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
2849 ElementsKind elements_kind = instr->elements_kind(); | 2850 ElementsKind elements_kind = instr->elements_kind(); |
2850 LOperand* key = instr->key(); | 2851 LOperand* key = instr->key(); |
2851 if (!key->IsConstantOperand()) { | 2852 if (!key->IsConstantOperand()) { |
2852 Register key_reg = ToRegister(key); | 2853 Register key_reg = ToRegister(key); |
2853 // Even though the HLoad/StoreKeyed (in this case) instructions force | 2854 // Even though the HLoad/StoreKeyed (in this case) instructions force |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3037 | 3038 |
3038 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 3039 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
3039 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3040 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
3040 } | 3041 } |
3041 | 3042 |
3042 | 3043 |
3043 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { | 3044 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { |
3044 Register result = ToRegister(instr->result()); | 3045 Register result = ToRegister(instr->result()); |
3045 | 3046 |
3046 if (instr->hydrogen()->from_inlined()) { | 3047 if (instr->hydrogen()->from_inlined()) { |
3047 __ lea(result, Operand(rsp, -2 * kPointerSize)); | 3048 __ lea(result, Operand(rsp, -kFPOnStackSize + -kPCOnStackSize)); |
3048 } else { | 3049 } else { |
3049 // Check for arguments adapter frame. | 3050 // Check for arguments adapter frame. |
3050 Label done, adapted; | 3051 Label done, adapted; |
3051 __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 3052 __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
3052 __ Cmp(Operand(result, StandardFrameConstants::kContextOffset), | 3053 __ Cmp(Operand(result, StandardFrameConstants::kContextOffset), |
3053 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 3054 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
3054 __ j(equal, &adapted, Label::kNear); | 3055 __ j(equal, &adapted, Label::kNear); |
3055 | 3056 |
3056 // No arguments adaptor frame. | 3057 // No arguments adaptor frame. |
3057 __ movq(result, rbp); | 3058 __ movq(result, rbp); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 __ push(receiver); | 3160 __ push(receiver); |
3160 __ movq(receiver, length); | 3161 __ movq(receiver, length); |
3161 | 3162 |
3162 // Loop through the arguments pushing them onto the execution | 3163 // Loop through the arguments pushing them onto the execution |
3163 // stack. | 3164 // stack. |
3164 Label invoke, loop; | 3165 Label invoke, loop; |
3165 // length is a small non-negative integer, due to the test above. | 3166 // length is a small non-negative integer, due to the test above. |
3166 __ testl(length, length); | 3167 __ testl(length, length); |
3167 __ j(zero, &invoke, Label::kNear); | 3168 __ j(zero, &invoke, Label::kNear); |
3168 __ bind(&loop); | 3169 __ bind(&loop); |
3169 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); | 3170 StackArgumentsAccessor args(elements, length, |
| 3171 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 3172 __ push(args.GetArgumentOperand(0)); |
3170 __ decl(length); | 3173 __ decl(length); |
3171 __ j(not_zero, &loop); | 3174 __ j(not_zero, &loop); |
3172 | 3175 |
3173 // Invoke the function. | 3176 // Invoke the function. |
3174 __ bind(&invoke); | 3177 __ bind(&invoke); |
3175 ASSERT(instr->HasPointerMap()); | 3178 ASSERT(instr->HasPointerMap()); |
3176 LPointerMap* pointers = instr->pointer_map(); | 3179 LPointerMap* pointers = instr->pointer_map(); |
3177 RecordPosition(pointers->position()); | 3180 RecordPosition(pointers->position()); |
3178 SafepointGenerator safepoint_generator( | 3181 SafepointGenerator safepoint_generator( |
3179 this, pointers, Safepoint::kLazyDeopt); | 3182 this, pointers, Safepoint::kLazyDeopt); |
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5440 FixedArray::kHeaderSize - kPointerSize)); | 5443 FixedArray::kHeaderSize - kPointerSize)); |
5441 __ bind(&done); | 5444 __ bind(&done); |
5442 } | 5445 } |
5443 | 5446 |
5444 | 5447 |
5445 #undef __ | 5448 #undef __ |
5446 | 5449 |
5447 } } // namespace v8::internal | 5450 } } // namespace v8::internal |
5448 | 5451 |
5449 #endif // V8_TARGET_ARCH_X64 | 5452 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |