| 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 = |
| 197 if (spill_slot >= 0) { | 198 (StandardFrameConstants::kFixedSlotCountAboveFp - spill_slot - 1) * |
| 198 // Local or spill slot. Skip the frame pointer, function, and | 199 kPointerSize; |
| 199 // context in the fixed part of the frame. | 200 if (has_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); | 201 return FrameOffset::FromFramePointer(offset); |
| 207 } else { | 202 } else { |
| 208 // No frame. Retrieve all parameters relative to stack pointer. | 203 // No frame. Retrieve all parameters relative to stack pointer. |
| 209 DCHECK(spill_slot < 0); // Must be a parameter. | 204 DCHECK(spill_slot < 0); // Must be a parameter. |
| 210 int register_save_area_size = frame->GetRegisterSaveAreaSize(); | 205 int offsetSpToFp = |
| 211 int offset = register_save_area_size - (spill_slot + 1) * kPointerSize + | 206 kPointerSize * (StandardFrameConstants::kFixedSlotCountAboveFp - |
| 212 frame->PCOnStackSize(); | 207 frame->GetTotalFrameSlotCount()); |
| 213 return FrameOffset::FromStackPointer(offset); | 208 return FrameOffset::FromStackPointer(offset - offsetSpToFp); |
| 214 } | 209 } |
| 215 } | 210 } |
| 216 | 211 |
| 217 | 212 |
| 218 // static | 213 // static |
| 219 int Linkage::FrameStateInputCount(Runtime::FunctionId function) { | 214 int Linkage::FrameStateInputCount(Runtime::FunctionId function) { |
| 220 // Most runtime functions need a FrameState. A few chosen ones that we know | 215 // 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 | 216 // not to call into arbitrary JavaScript, not to throw, and not to deoptimize |
| 222 // are blacklisted here and can be called without a FrameState. | 217 // are blacklisted here and can be called without a FrameState. |
| 223 switch (function) { | 218 switch (function) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 493 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
| 499 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 494 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
| 500 | 495 |
| 501 if (index == kOsrContextSpillSlotIndex) { | 496 if (index == kOsrContextSpillSlotIndex) { |
| 502 // Context. Use the parameter location of the context spill slot. | 497 // Context. Use the parameter location of the context spill slot. |
| 503 // Parameter (arity + 1) is special for the context of the function frame. | 498 // Parameter (arity + 1) is special for the context of the function frame. |
| 504 int context_index = 1 + 1 + parameter_count; // target + receiver + params | 499 int context_index = 1 + 1 + parameter_count; // target + receiver + params |
| 505 return incoming_->GetInputLocation(context_index); | 500 return incoming_->GetInputLocation(context_index); |
| 506 } else if (index >= first_stack_slot) { | 501 } else if (index >= first_stack_slot) { |
| 507 // Local variable stored in this (callee) stack. | 502 // Local variable stored in this (callee) stack. |
| 508 int spill_index = index - first_stack_slot; | 503 int spill_index = |
| 504 index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; |
| 509 return LinkageLocation::ForCalleeFrameSlot(spill_index); | 505 return LinkageLocation::ForCalleeFrameSlot(spill_index); |
| 510 } else { | 506 } else { |
| 511 // Parameter. Use the assigned location from the incoming call descriptor. | 507 // Parameter. Use the assigned location from the incoming call descriptor. |
| 512 int parameter_index = 1 + index; // skip index 0, which is the target. | 508 int parameter_index = 1 + index; // skip index 0, which is the target. |
| 513 return incoming_->GetInputLocation(parameter_index); | 509 return incoming_->GetInputLocation(parameter_index); |
| 514 } | 510 } |
| 515 } | 511 } |
| 516 } // namespace compiler | 512 } // namespace compiler |
| 517 } // namespace internal | 513 } // namespace internal |
| 518 } // namespace v8 | 514 } // namespace v8 |
| OLD | NEW |