OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/frame.h" |
8 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
9 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
10 #include "src/compiler/osr.h" | 11 #include "src/compiler/osr.h" |
11 #include "src/compiler/pipeline.h" | 12 #include "src/compiler/pipeline.h" |
12 #include "src/scopes.h" | 13 #include "src/scopes.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 namespace compiler { | 17 namespace compiler { |
17 | 18 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 SharedFunctionInfo* shared = info->closure()->shared(); | 184 SharedFunctionInfo* shared = info->closure()->shared(); |
184 return GetJSCallDescriptor(zone, info->is_osr(), | 185 return GetJSCallDescriptor(zone, info->is_osr(), |
185 1 + shared->internal_formal_parameter_count(), | 186 1 + shared->internal_formal_parameter_count(), |
186 CallDescriptor::kNoFlags); | 187 CallDescriptor::kNoFlags); |
187 } | 188 } |
188 return NULL; // TODO(titzer): ? | 189 return NULL; // TODO(titzer): ? |
189 } | 190 } |
190 | 191 |
191 | 192 |
192 FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame) const { | 193 FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame) const { |
193 if (frame->GetSpillSlotCount() > 0 || incoming_->IsJSFunctionCall() || | 194 bool has_frame = frame->GetSpillSlotCount() > 0 || |
194 incoming_->kind() == CallDescriptor::kCallAddress) { | 195 incoming_->IsJSFunctionCall() || |
195 int offset; | 196 incoming_->kind() == CallDescriptor::kCallAddress; |
196 int register_save_area_size = frame->GetRegisterSaveAreaSize(); | 197 const int offset = (Frame::kFixedSlotCount - spill_slot - 1) * kPointerSize; |
197 if (spill_slot >= 0) { | 198 if (has_frame) { |
198 // Local or spill slot. Skip the frame pointer, function, and | |
199 // context in the fixed part of the frame. | |
200 offset = -(spill_slot + 1) * kPointerSize - register_save_area_size; | |
201 } else { | |
202 // Incoming parameter. Skip the return address. | |
203 offset = -(spill_slot + 1) * kPointerSize + kFPOnStackSize + | |
204 frame->PCOnStackSize(); | |
205 } | |
206 return FrameOffset::FromFramePointer(offset); | 199 return FrameOffset::FromFramePointer(offset); |
207 } else { | 200 } else { |
208 // No frame. Retrieve all parameters relative to stack pointer. | 201 // No frame. Retrieve all parameters relative to stack pointer. |
209 DCHECK(spill_slot < 0); // Must be a parameter. | 202 DCHECK(spill_slot < 0); // Must be a parameter. |
210 int register_save_area_size = frame->GetRegisterSaveAreaSize(); | 203 int offsetSpToFp = kPointerSize * (Frame::kFixedSlotCount - |
211 int offset = register_save_area_size - (spill_slot + 1) * kPointerSize + | 204 frame->GetTotalFrameSlotCount()); |
212 frame->PCOnStackSize(); | 205 return FrameOffset::FromStackPointer(offset - offsetSpToFp); |
213 return FrameOffset::FromStackPointer(offset); | |
214 } | 206 } |
215 } | 207 } |
216 | 208 |
217 | 209 |
218 // static | 210 // static |
219 int Linkage::FrameStateInputCount(Runtime::FunctionId function) { | 211 int Linkage::FrameStateInputCount(Runtime::FunctionId function) { |
220 // Most runtime functions need a FrameState. A few chosen ones that we know | 212 // Most runtime functions need a FrameState. A few chosen ones that we know |
221 // not to call into arbitrary JavaScript, not to throw, and not to deoptimize | 213 // not to call into arbitrary JavaScript, not to throw, and not to deoptimize |
222 // are blacklisted here and can be called without a FrameState. | 214 // are blacklisted here and can be called without a FrameState. |
223 switch (function) { | 215 switch (function) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 482 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
491 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 483 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
492 | 484 |
493 if (index == kOsrContextSpillSlotIndex) { | 485 if (index == kOsrContextSpillSlotIndex) { |
494 // Context. Use the parameter location of the context spill slot. | 486 // Context. Use the parameter location of the context spill slot. |
495 // Parameter (arity + 1) is special for the context of the function frame. | 487 // Parameter (arity + 1) is special for the context of the function frame. |
496 int context_index = 1 + 1 + parameter_count; // target + receiver + params | 488 int context_index = 1 + 1 + parameter_count; // target + receiver + params |
497 return incoming_->GetInputLocation(context_index); | 489 return incoming_->GetInputLocation(context_index); |
498 } else if (index >= first_stack_slot) { | 490 } else if (index >= first_stack_slot) { |
499 // Local variable stored in this (callee) stack. | 491 // Local variable stored in this (callee) stack. |
500 int spill_index = index - first_stack_slot; | 492 int spill_index = index - first_stack_slot + Frame::kJSFixedSlotCount; |
501 return LinkageLocation::ForCalleeFrameSlot(spill_index); | 493 return LinkageLocation::ForCalleeFrameSlot(spill_index); |
502 } else { | 494 } else { |
503 // Parameter. Use the assigned location from the incoming call descriptor. | 495 // Parameter. Use the assigned location from the incoming call descriptor. |
504 int parameter_index = 1 + index; // skip index 0, which is the target. | 496 int parameter_index = 1 + index; // skip index 0, which is the target. |
505 return incoming_->GetInputLocation(parameter_index); | 497 return incoming_->GetInputLocation(parameter_index); |
506 } | 498 } |
507 } | 499 } |
508 } // namespace compiler | 500 } // namespace compiler |
509 } // namespace internal | 501 } // namespace internal |
510 } // namespace v8 | 502 } // namespace v8 |
OLD | NEW |