| 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/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (GetReturnLocation(i) != other->GetReturnLocation(i)) return false; | 49 if (GetReturnLocation(i) != other->GetReturnLocation(i)) return false; |
| 50 } | 50 } |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 bool CallDescriptor::CanTailCall(const Node* node) const { | 55 bool CallDescriptor::CanTailCall(const Node* node) const { |
| 56 // Determine the number of stack parameters passed in | 56 // Determine the number of stack parameters passed in |
| 57 size_t stack_params = 0; | 57 size_t stack_params = 0; |
| 58 for (size_t i = 0; i < InputCount(); ++i) { | 58 for (size_t i = 0; i < InputCount(); ++i) { |
| 59 if (!GetInputLocation(i).is_register()) { | 59 if (!GetInputLocation(i).IsRegister()) { |
| 60 ++stack_params; | 60 ++stack_params; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 // Ensure the input linkage contains the stack parameters in the right order | 63 // Ensure the input linkage contains the stack parameters in the right order |
| 64 size_t current_stack_param = 0; | 64 size_t current_stack_param = 0; |
| 65 for (size_t i = 0; i < InputCount(); ++i) { | 65 for (size_t i = 0; i < InputCount(); ++i) { |
| 66 if (!GetInputLocation(i).is_register()) { | 66 if (!GetInputLocation(i).IsRegister()) { |
| 67 if (GetInputLocation(i) != | 67 if (GetInputLocation(i) != LinkageLocation::ForCallerFrameSlot( |
| 68 LinkageLocation(static_cast<int>(current_stack_param) - | 68 static_cast<int>(current_stack_param) - |
| 69 static_cast<int>(stack_params))) { | 69 static_cast<int>(stack_params))) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 ++current_stack_param; | 72 ++current_stack_param; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 // Tail calling is currently allowed if return locations match and all | 75 // Tail calling is currently allowed if return locations match and all |
| 76 // parameters are either in registers or on the stack but match exactly in | 76 // parameters are either in registers or on the stack but match exactly in |
| 77 // number and content. | 77 // number and content. |
| 78 CallDescriptor const* other = OpParameter<CallDescriptor const*>(node); | 78 CallDescriptor const* other = OpParameter<CallDescriptor const*>(node); |
| 79 if (!HasSameReturnLocationsAs(other)) return false; | 79 if (!HasSameReturnLocationsAs(other)) return false; |
| 80 size_t current_input = 0; | 80 size_t current_input = 0; |
| 81 size_t other_input = 0; | 81 size_t other_input = 0; |
| 82 while (true) { | 82 while (true) { |
| 83 if (other_input >= other->InputCount()) { | 83 if (other_input >= other->InputCount()) { |
| 84 while (current_input < InputCount()) { | 84 while (current_input < InputCount()) { |
| 85 if (!GetInputLocation(current_input).is_register()) { | 85 if (!GetInputLocation(current_input).IsRegister()) { |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 ++current_input; | 88 ++current_input; |
| 89 } | 89 } |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 if (current_input >= InputCount()) { | 92 if (current_input >= InputCount()) { |
| 93 while (other_input < other->InputCount()) { | 93 while (other_input < other->InputCount()) { |
| 94 if (!other->GetInputLocation(other_input).is_register()) { | 94 if (!other->GetInputLocation(other_input).IsRegister()) { |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 ++other_input; | 97 ++other_input; |
| 98 } | 98 } |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 if (GetInputLocation(current_input).is_register()) { | 101 if (GetInputLocation(current_input).IsRegister()) { |
| 102 ++current_input; | 102 ++current_input; |
| 103 continue; | 103 continue; |
| 104 } | 104 } |
| 105 if (other->GetInputLocation(other_input).is_register()) { | 105 if (other->GetInputLocation(other_input).IsRegister()) { |
| 106 ++other_input; | 106 ++other_input; |
| 107 continue; | 107 continue; |
| 108 } | 108 } |
| 109 if (GetInputLocation(current_input) != | 109 if (GetInputLocation(current_input) != |
| 110 other->GetInputLocation(other_input)) { | 110 other->GetInputLocation(other_input)) { |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 Node* input = node->InputAt(static_cast<int>(other_input)); | 113 Node* input = node->InputAt(static_cast<int>(other_input)); |
| 114 if (input->opcode() != IrOpcode::kParameter) { | 114 if (input->opcode() != IrOpcode::kParameter) { |
| 115 return false; | 115 return false; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // without a FrameState or will be lowered by JSIntrinsicLowering internally. | 231 // without a FrameState or will be lowered by JSIntrinsicLowering internally. |
| 232 const Runtime::Function* const f = Runtime::FunctionForId(function); | 232 const Runtime::Function* const f = Runtime::FunctionForId(function); |
| 233 if (f->intrinsic_type == Runtime::IntrinsicType::INLINE) return 0; | 233 if (f->intrinsic_type == Runtime::IntrinsicType::INLINE) return 0; |
| 234 | 234 |
| 235 return 1; | 235 return 1; |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 bool CallDescriptor::UsesOnlyRegisters() const { | 239 bool CallDescriptor::UsesOnlyRegisters() const { |
| 240 for (size_t i = 0; i < InputCount(); ++i) { | 240 for (size_t i = 0; i < InputCount(); ++i) { |
| 241 if (!GetInputLocation(i).is_register()) return false; | 241 if (!GetInputLocation(i).IsRegister()) return false; |
| 242 } | 242 } |
| 243 for (size_t i = 0; i < ReturnCount(); ++i) { | 243 for (size_t i = 0; i < ReturnCount(); ++i) { |
| 244 if (!GetReturnLocation(i).is_register()) return false; | 244 if (!GetReturnLocation(i).IsRegister()) return false; |
| 245 } | 245 } |
| 246 return true; | 246 return true; |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 //============================================================================== | 250 //============================================================================== |
| 251 // Provide unimplemented methods on unsupported architectures, to at least link. | 251 // Provide unimplemented methods on unsupported architectures, to at least link. |
| 252 //============================================================================== | 252 //============================================================================== |
| 253 #if !V8_TURBOFAN_BACKEND | 253 #if !V8_TURBOFAN_BACKEND |
| 254 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, | 254 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 279 Operator::Properties properties, MachineType return_type) { | 279 Operator::Properties properties, MachineType return_type) { |
| 280 UNIMPLEMENTED(); | 280 UNIMPLEMENTED(); |
| 281 return NULL; | 281 return NULL; |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 #endif // !V8_TURBOFAN_BACKEND | 285 #endif // !V8_TURBOFAN_BACKEND |
| 286 } // namespace compiler | 286 } // namespace compiler |
| 287 } // namespace internal | 287 } // namespace internal |
| 288 } // namespace v8 | 288 } // namespace v8 |
| OLD | NEW |