| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 #endif | 145 #endif |
| 146 | 146 |
| 147 // Strict mode functions need to replace the receiver with undefined | 147 // Strict mode functions need to replace the receiver with undefined |
| 148 // when called as functions (without an explicit receiver | 148 // when called as functions (without an explicit receiver |
| 149 // object). rcx is zero for method calls and non-zero for function | 149 // object). rcx is zero for method calls and non-zero for function |
| 150 // calls. | 150 // calls. |
| 151 if (!info_->is_classic_mode() || info_->is_native()) { | 151 if (!info_->is_classic_mode() || info_->is_native()) { |
| 152 Label ok; | 152 Label ok; |
| 153 __ testq(rcx, rcx); | 153 __ testq(rcx, rcx); |
| 154 __ j(zero, &ok, Label::kNear); | 154 __ j(zero, &ok, Label::kNear); |
| 155 // +1 for return address. | 155 StackArgumentsAccessor args(rsp, scope()->num_parameters()); |
| 156 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; | |
| 157 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | 156 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
| 158 __ movq(Operand(rsp, receiver_offset), kScratchRegister); | 157 __ movq(args.GetReceiverOperand(), kScratchRegister); |
| 159 __ bind(&ok); | 158 __ bind(&ok); |
| 160 } | 159 } |
| 161 } | 160 } |
| 162 | 161 |
| 163 info()->set_prologue_offset(masm_->pc_offset()); | 162 info()->set_prologue_offset(masm_->pc_offset()); |
| 164 if (NeedsEagerFrame()) { | 163 if (NeedsEagerFrame()) { |
| 165 ASSERT(!frame_is_built_); | 164 ASSERT(!frame_is_built_); |
| 166 frame_is_built_ = true; | 165 frame_is_built_ = true; |
| 167 __ push(rbp); // Caller's frame pointer. | 166 __ push(rbp); // Caller's frame pointer. |
| 168 __ movq(rbp, rsp); | 167 __ movq(rbp, rsp); |
| (...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2890 | 2889 |
| 2891 | 2890 |
| 2892 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { | 2891 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
| 2893 Register arguments = ToRegister(instr->arguments()); | 2892 Register arguments = ToRegister(instr->arguments()); |
| 2894 Register result = ToRegister(instr->result()); | 2893 Register result = ToRegister(instr->result()); |
| 2895 | 2894 |
| 2896 if (instr->length()->IsConstantOperand() && | 2895 if (instr->length()->IsConstantOperand() && |
| 2897 instr->index()->IsConstantOperand()) { | 2896 instr->index()->IsConstantOperand()) { |
| 2898 int32_t const_index = ToInteger32(LConstantOperand::cast(instr->index())); | 2897 int32_t const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
| 2899 int32_t const_length = ToInteger32(LConstantOperand::cast(instr->length())); | 2898 int32_t const_length = ToInteger32(LConstantOperand::cast(instr->length())); |
| 2900 int index = (const_length - const_index) + 1; | 2899 StackArgumentsAccessor args(arguments, const_length, |
| 2901 __ movq(result, Operand(arguments, index * kPointerSize)); | 2900 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 2901 __ movq(result, args.GetArgumentOperand(const_index)); |
| 2902 } else { | 2902 } else { |
| 2903 Register length = ToRegister(instr->length()); | 2903 Register length = ToRegister(instr->length()); |
| 2904 // There are two words between the frame pointer and the last argument. | 2904 // There are two words between the frame pointer and the last argument. |
| 2905 // Subtracting from length accounts for one of them add one more. | 2905 // Subtracting from length accounts for one of them add one more. |
| 2906 if (instr->index()->IsRegister()) { | 2906 if (instr->index()->IsRegister()) { |
| 2907 __ subl(length, ToRegister(instr->index())); | 2907 __ subl(length, ToRegister(instr->index())); |
| 2908 } else { | 2908 } else { |
| 2909 __ subl(length, ToOperand(instr->index())); | 2909 __ subl(length, ToOperand(instr->index())); |
| 2910 } | 2910 } |
| 2911 __ movq(result, | 2911 StackArgumentsAccessor args(arguments, length, |
| 2912 Operand(arguments, length, times_pointer_size, kPointerSize)); | 2912 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 2913 __ movq(result, args.GetArgumentOperand(0)); |
| 2913 } | 2914 } |
| 2914 } | 2915 } |
| 2915 | 2916 |
| 2916 | 2917 |
| 2917 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { | 2918 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
| 2918 ElementsKind elements_kind = instr->elements_kind(); | 2919 ElementsKind elements_kind = instr->elements_kind(); |
| 2919 LOperand* key = instr->key(); | 2920 LOperand* key = instr->key(); |
| 2920 if (!key->IsConstantOperand()) { | 2921 if (!key->IsConstantOperand()) { |
| 2921 Register key_reg = ToRegister(key); | 2922 Register key_reg = ToRegister(key); |
| 2922 // Even though the HLoad/StoreKeyed (in this case) instructions force | 2923 // Even though the HLoad/StoreKeyed (in this case) instructions force |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3106 | 3107 |
| 3107 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 3108 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 3108 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3109 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 3109 } | 3110 } |
| 3110 | 3111 |
| 3111 | 3112 |
| 3112 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { | 3113 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { |
| 3113 Register result = ToRegister(instr->result()); | 3114 Register result = ToRegister(instr->result()); |
| 3114 | 3115 |
| 3115 if (instr->hydrogen()->from_inlined()) { | 3116 if (instr->hydrogen()->from_inlined()) { |
| 3116 __ lea(result, Operand(rsp, -2 * kPointerSize)); | 3117 __ lea(result, Operand(rsp, -kFPOnStackSize + -kPCOnStackSize)); |
| 3117 } else { | 3118 } else { |
| 3118 // Check for arguments adapter frame. | 3119 // Check for arguments adapter frame. |
| 3119 Label done, adapted; | 3120 Label done, adapted; |
| 3120 __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); | 3121 __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); |
| 3121 __ Cmp(Operand(result, StandardFrameConstants::kContextOffset), | 3122 __ Cmp(Operand(result, StandardFrameConstants::kContextOffset), |
| 3122 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 3123 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 3123 __ j(equal, &adapted, Label::kNear); | 3124 __ j(equal, &adapted, Label::kNear); |
| 3124 | 3125 |
| 3125 // No arguments adaptor frame. | 3126 // No arguments adaptor frame. |
| 3126 __ movq(result, rbp); | 3127 __ movq(result, rbp); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3228 __ push(receiver); | 3229 __ push(receiver); |
| 3229 __ movq(receiver, length); | 3230 __ movq(receiver, length); |
| 3230 | 3231 |
| 3231 // Loop through the arguments pushing them onto the execution | 3232 // Loop through the arguments pushing them onto the execution |
| 3232 // stack. | 3233 // stack. |
| 3233 Label invoke, loop; | 3234 Label invoke, loop; |
| 3234 // length is a small non-negative integer, due to the test above. | 3235 // length is a small non-negative integer, due to the test above. |
| 3235 __ testl(length, length); | 3236 __ testl(length, length); |
| 3236 __ j(zero, &invoke, Label::kNear); | 3237 __ j(zero, &invoke, Label::kNear); |
| 3237 __ bind(&loop); | 3238 __ bind(&loop); |
| 3238 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); | 3239 StackArgumentsAccessor args(elements, length, |
| 3240 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 3241 __ push(args.GetArgumentOperand(0)); |
| 3239 __ decl(length); | 3242 __ decl(length); |
| 3240 __ j(not_zero, &loop); | 3243 __ j(not_zero, &loop); |
| 3241 | 3244 |
| 3242 // Invoke the function. | 3245 // Invoke the function. |
| 3243 __ bind(&invoke); | 3246 __ bind(&invoke); |
| 3244 ASSERT(instr->HasPointerMap()); | 3247 ASSERT(instr->HasPointerMap()); |
| 3245 LPointerMap* pointers = instr->pointer_map(); | 3248 LPointerMap* pointers = instr->pointer_map(); |
| 3246 RecordPosition(pointers->position()); | 3249 RecordPosition(pointers->position()); |
| 3247 SafepointGenerator safepoint_generator( | 3250 SafepointGenerator safepoint_generator( |
| 3248 this, pointers, Safepoint::kLazyDeopt); | 3251 this, pointers, Safepoint::kLazyDeopt); |
| (...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5516 FixedArray::kHeaderSize - kPointerSize)); | 5519 FixedArray::kHeaderSize - kPointerSize)); |
| 5517 __ bind(&done); | 5520 __ bind(&done); |
| 5518 } | 5521 } |
| 5519 | 5522 |
| 5520 | 5523 |
| 5521 #undef __ | 5524 #undef __ |
| 5522 | 5525 |
| 5523 } } // namespace v8::internal | 5526 } } // namespace v8::internal |
| 5524 | 5527 |
| 5525 #endif // V8_TARGET_ARCH_X64 | 5528 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |