Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: src/compiler/linkage.h

Issue 1108563002: Detect simple tail calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Handle callers with args Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef V8_COMPILER_LINKAGE_H_ 5 #ifndef V8_COMPILER_LINKAGE_H_
6 #define V8_COMPILER_LINKAGE_H_ 6 #define V8_COMPILER_LINKAGE_H_
7 7
8 #include "src/base/flags.h" 8 #include "src/base/flags.h"
9 #include "src/compiler/frame.h" 9 #include "src/compiler/frame.h"
10 #include "src/compiler/machine-type.h" 10 #include "src/compiler/machine-type.h"
11 #include "src/compiler/operator.h" 11 #include "src/compiler/operator.h"
12 #include "src/frames.h" 12 #include "src/frames.h"
13 #include "src/runtime/runtime.h" 13 #include "src/runtime/runtime.h"
14 #include "src/zone.h" 14 #include "src/zone.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 18
19 class CallInterfaceDescriptor; 19 class CallInterfaceDescriptor;
20 20
21 namespace compiler { 21 namespace compiler {
22 22
23 class OsrHelper; 23 class OsrHelper;
24 24
25 // Describes the location for a parameter or a return value to a call. 25 // Describes the location for a parameter or a return value to a call.
26 class LinkageLocation { 26 class LinkageLocation {
27 public: 27 public:
28 explicit LinkageLocation(int location) : location_(location) {} 28 explicit LinkageLocation(int location) : location_(location) {}
29 29
30 bool is_register() const {
31 return 0 <= location_ && location_ <= ANY_REGISTER;
32 }
33
30 static const int16_t ANY_REGISTER = 1023; 34 static const int16_t ANY_REGISTER = 1023;
31 static const int16_t MAX_STACK_SLOT = 32767; 35 static const int16_t MAX_STACK_SLOT = 32767;
32 36
33 static LinkageLocation AnyRegister() { return LinkageLocation(ANY_REGISTER); } 37 static LinkageLocation AnyRegister() { return LinkageLocation(ANY_REGISTER); }
34 38
35 private: 39 private:
36 friend class CallDescriptor; 40 friend class CallDescriptor;
37 friend class OperandGenerator; 41 friend class OperandGenerator;
38 // location < 0 -> a stack slot on the caller frame 42 // location < 0 -> a stack slot on the caller frame
39 // 0 <= location < 1023 -> a specific machine register 43 // 0 <= location < 1023 -> a specific machine register
(...skipping 14 matching lines...) Expand all
54 kCallJSFunction, // target is a JSFunction object 58 kCallJSFunction, // target is a JSFunction object
55 kCallAddress // target is a machine pointer 59 kCallAddress // target is a machine pointer
56 }; 60 };
57 61
58 enum Flag { 62 enum Flag {
59 kNoFlags = 0u, 63 kNoFlags = 0u,
60 kNeedsFrameState = 1u << 0, 64 kNeedsFrameState = 1u << 0,
61 kPatchableCallSite = 1u << 1, 65 kPatchableCallSite = 1u << 1,
62 kNeedsNopAfterCall = 1u << 2, 66 kNeedsNopAfterCall = 1u << 2,
63 kHasExceptionHandler = 1u << 3, 67 kHasExceptionHandler = 1u << 3,
68 kIsTailCallAllowed = 1u << 4,
Benedikt Meurer 2015/04/29 04:06:05 Can we rename this to kSupportsTailCalls?
Sven Panne 2015/04/29 10:24:18 Done.
64 kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall 69 kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall
65 }; 70 };
66 typedef base::Flags<Flag> Flags; 71 typedef base::Flags<Flag> Flags;
67 72
68 CallDescriptor(Kind kind, MachineType target_type, LinkageLocation target_loc, 73 CallDescriptor(Kind kind, MachineType target_type, LinkageLocation target_loc,
69 const MachineSignature* machine_sig, 74 const MachineSignature* machine_sig,
70 LocationSignature* location_sig, size_t js_param_count, 75 LocationSignature* location_sig, size_t js_param_count,
71 Operator::Properties properties, 76 Operator::Properties properties,
72 RegList callee_saved_registers, Flags flags, 77 RegList callee_saved_registers, Flags flags,
73 const char* debug_name = "") 78 const char* debug_name = "")
(...skipping 27 matching lines...) Expand all
101 // The total number of inputs to this call, which includes the target, 106 // The total number of inputs to this call, which includes the target,
102 // receiver, context, etc. 107 // receiver, context, etc.
103 // TODO(titzer): this should input the framestate input too. 108 // TODO(titzer): this should input the framestate input too.
104 size_t InputCount() const { return 1 + machine_sig_->parameter_count(); } 109 size_t InputCount() const { return 1 + machine_sig_->parameter_count(); }
105 110
106 size_t FrameStateCount() const { return NeedsFrameState() ? 1 : 0; } 111 size_t FrameStateCount() const { return NeedsFrameState() ? 1 : 0; }
107 112
108 Flags flags() const { return flags_; } 113 Flags flags() const { return flags_; }
109 114
110 bool NeedsFrameState() const { return flags() & kNeedsFrameState; } 115 bool NeedsFrameState() const { return flags() & kNeedsFrameState; }
116 bool IsTailCallAllowed() const { return flags() & kIsTailCallAllowed; }
Benedikt Meurer 2015/04/29 04:06:05 SupportsTailCalls?
Sven Panne 2015/04/29 10:24:18 Done.
111 117
112 LinkageLocation GetReturnLocation(size_t index) const { 118 LinkageLocation GetReturnLocation(size_t index) const {
113 return location_sig_->GetReturn(index); 119 return location_sig_->GetReturn(index);
114 } 120 }
115 121
116 LinkageLocation GetInputLocation(size_t index) const { 122 LinkageLocation GetInputLocation(size_t index) const {
117 if (index == 0) return target_loc_; 123 if (index == 0) return target_loc_;
118 return location_sig_->GetParam(index - 1); 124 return location_sig_->GetParam(index - 1);
119 } 125 }
120 126
121 const MachineSignature* GetMachineSignature() const { return machine_sig_; } 127 const MachineSignature* GetMachineSignature() const { return machine_sig_; }
122 128
123 MachineType GetReturnType(size_t index) const { 129 MachineType GetReturnType(size_t index) const {
124 return machine_sig_->GetReturn(index); 130 return machine_sig_->GetReturn(index);
125 } 131 }
126 132
127 MachineType GetInputType(size_t index) const { 133 MachineType GetInputType(size_t index) const {
128 if (index == 0) return target_type_; 134 if (index == 0) return target_type_;
129 return machine_sig_->GetParam(index - 1); 135 return machine_sig_->GetParam(index - 1);
130 } 136 }
131 137
132 // Operator properties describe how this call can be optimized, if at all. 138 // Operator properties describe how this call can be optimized, if at all.
133 Operator::Properties properties() const { return properties_; } 139 Operator::Properties properties() const { return properties_; }
134 140
135 // Get the callee-saved registers, if any, across this call. 141 // Get the callee-saved registers, if any, across this call.
136 RegList CalleeSavedRegisters() const { return callee_saved_registers_; } 142 RegList CalleeSavedRegisters() const { return callee_saved_registers_; }
137 143
138 const char* debug_name() const { return debug_name_; } 144 const char* debug_name() const { return debug_name_; }
139 145
146 bool UsesOnlyRegisters() const;
147
140 private: 148 private:
141 friend class Linkage; 149 friend class Linkage;
142 150
143 const Kind kind_; 151 const Kind kind_;
144 const MachineType target_type_; 152 const MachineType target_type_;
145 const LinkageLocation target_loc_; 153 const LinkageLocation target_loc_;
146 const MachineSignature* const machine_sig_; 154 const MachineSignature* const machine_sig_;
147 const LocationSignature* const location_sig_; 155 const LocationSignature* const location_sig_;
148 const size_t js_param_count_; 156 const size_t js_param_count_;
149 const Operator::Properties properties_; 157 const Operator::Properties properties_;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 CallDescriptor* const incoming_; 246 CallDescriptor* const incoming_;
239 247
240 DISALLOW_COPY_AND_ASSIGN(Linkage); 248 DISALLOW_COPY_AND_ASSIGN(Linkage);
241 }; 249 };
242 250
243 } // namespace compiler 251 } // namespace compiler
244 } // namespace internal 252 } // namespace internal
245 } // namespace v8 253 } // namespace v8
246 254
247 #endif // V8_COMPILER_LINKAGE_H_ 255 #endif // V8_COMPILER_LINKAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698