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

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

Issue 696223002: Now with more checkings! Skip the CallFunctionStub when the callee function can be statically deter… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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_IMPL_H_ 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_
6 #define V8_COMPILER_LINKAGE_IMPL_H_ 6 #define V8_COMPILER_LINKAGE_IMPL_H_
7 7
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 10 matching lines...) Expand all
21 DCHECK(locations->return_count_ <= 2); 21 DCHECK(locations->return_count_ <= 2);
22 if (locations->return_count_ > 0) { 22 if (locations->return_count_ > 0) {
23 locations->AddReturn(regloc(LinkageTraits::ReturnValueReg())); 23 locations->AddReturn(regloc(LinkageTraits::ReturnValueReg()));
24 } 24 }
25 if (locations->return_count_ > 1) { 25 if (locations->return_count_ > 1) {
26 locations->AddReturn(regloc(LinkageTraits::ReturnValue2Reg())); 26 locations->AddReturn(regloc(LinkageTraits::ReturnValue2Reg()));
27 } 27 }
28 } 28 }
29 29
30 // TODO(turbofan): cache call descriptors for JSFunction calls. 30 // TODO(turbofan): cache call descriptors for JSFunction calls.
31 static CallDescriptor* GetJSCallDescriptor(Zone* zone, 31 static CallDescriptor* GetJSCallDescriptor(Zone* zone, int js_parameter_count,
32 int js_parameter_count) { 32 CallDescriptor::Flags flags) {
33 const size_t return_count = 1; 33 const size_t return_count = 1;
34 const size_t context_count = 1; 34 const size_t context_count = 1;
35 const size_t parameter_count = js_parameter_count + context_count; 35 const size_t parameter_count = js_parameter_count + context_count;
36 36
37 LocationSignature::Builder locations(zone, return_count, parameter_count); 37 LocationSignature::Builder locations(zone, return_count, parameter_count);
38 MachineSignature::Builder types(zone, return_count, parameter_count); 38 MachineSignature::Builder types(zone, return_count, parameter_count);
39 39
40 // Add returns. 40 // Add returns.
41 AddReturnLocations(&locations); 41 AddReturnLocations(&locations);
42 for (size_t i = 0; i < return_count; i++) { 42 for (size_t i = 0; i < return_count; i++) {
43 types.AddReturn(kMachAnyTagged); 43 types.AddReturn(kMachAnyTagged);
44 } 44 }
45 45
46 // All parameters to JS calls go on the stack. 46 // All parameters to JS calls go on the stack.
47 for (int i = 0; i < js_parameter_count; i++) { 47 for (int i = 0; i < js_parameter_count; i++) {
48 int spill_slot_index = i - js_parameter_count; 48 int spill_slot_index = i - js_parameter_count;
49 locations.AddParam(stackloc(spill_slot_index)); 49 locations.AddParam(stackloc(spill_slot_index));
50 types.AddParam(kMachAnyTagged); 50 types.AddParam(kMachAnyTagged);
51 } 51 }
52 // Add context. 52 // Add context.
53 locations.AddParam(regloc(LinkageTraits::ContextReg())); 53 locations.AddParam(regloc(LinkageTraits::ContextReg()));
54 types.AddParam(kMachAnyTagged); 54 types.AddParam(kMachAnyTagged);
55 55
56 // The target for JS function calls is the JSFunction object. 56 // The target for JS function calls is the JSFunction object.
57 MachineType target_type = kMachAnyTagged; 57 MachineType target_type = kMachAnyTagged;
58 LinkageLocation target_loc = regloc(LinkageTraits::JSCallFunctionReg()); 58 LinkageLocation target_loc = regloc(LinkageTraits::JSCallFunctionReg());
59 return new (zone) CallDescriptor(CallDescriptor::kCallJSFunction, // kind 59 return new (zone) CallDescriptor( // --
60 target_type, // target MachineType 60 CallDescriptor::kCallJSFunction, // kind
61 target_loc, // target location 61 target_type, // target MachineType
62 types.Build(), // machine_sig 62 target_loc, // target location
63 locations.Build(), // location_sig 63 types.Build(), // machine_sig
64 js_parameter_count, // js_parameter_count 64 locations.Build(), // location_sig
65 Operator::kNoProperties, // properties 65 js_parameter_count, // js_parameter_count
66 kNoCalleeSaved, // callee-saved 66 Operator::kNoProperties, // properties
67 CallDescriptor::kNeedsFrameState, // flags 67 kNoCalleeSaved, // callee-saved
68 "js-call"); 68 flags, // flags
69 "js-call");
69 } 70 }
70 71
71 72
72 // TODO(turbofan): cache call descriptors for runtime calls. 73 // TODO(turbofan): cache call descriptors for runtime calls.
73 static CallDescriptor* GetRuntimeCallDescriptor( 74 static CallDescriptor* GetRuntimeCallDescriptor(
74 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, 75 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count,
75 Operator::Properties properties) { 76 Operator::Properties properties) {
76 const size_t function_count = 1; 77 const size_t function_count = 1;
77 const size_t num_args_count = 1; 78 const size_t num_args_count = 1;
78 const size_t context_count = 1; 79 const size_t context_count = 1;
(...skipping 30 matching lines...) Expand all
109 locations.AddParam(regloc(LinkageTraits::ContextReg())); 110 locations.AddParam(regloc(LinkageTraits::ContextReg()));
110 types.AddParam(kMachAnyTagged); 111 types.AddParam(kMachAnyTagged);
111 112
112 CallDescriptor::Flags flags = Linkage::NeedsFrameState(function_id) 113 CallDescriptor::Flags flags = Linkage::NeedsFrameState(function_id)
113 ? CallDescriptor::kNeedsFrameState 114 ? CallDescriptor::kNeedsFrameState
114 : CallDescriptor::kNoFlags; 115 : CallDescriptor::kNoFlags;
115 116
116 // The target for runtime calls is a code object. 117 // The target for runtime calls is a code object.
117 MachineType target_type = kMachAnyTagged; 118 MachineType target_type = kMachAnyTagged;
118 LinkageLocation target_loc = LinkageLocation::AnyRegister(); 119 LinkageLocation target_loc = LinkageLocation::AnyRegister();
119 return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject, // kind 120 return new (zone) CallDescriptor( // --
120 target_type, // target MachineType 121 CallDescriptor::kCallCodeObject, // kind
121 target_loc, // target location 122 target_type, // target MachineType
122 types.Build(), // machine_sig 123 target_loc, // target location
123 locations.Build(), // location_sig 124 types.Build(), // machine_sig
124 js_parameter_count, // js_parameter_count 125 locations.Build(), // location_sig
125 properties, // properties 126 js_parameter_count, // js_parameter_count
126 kNoCalleeSaved, // callee-saved 127 properties, // properties
127 flags, // flags 128 kNoCalleeSaved, // callee-saved
128 function->name); // debug name 129 flags, // flags
130 function->name); // debug name
129 } 131 }
130 132
131 133
132 // TODO(turbofan): cache call descriptors for code stub calls. 134 // TODO(turbofan): cache call descriptors for code stub calls.
133 static CallDescriptor* GetStubCallDescriptor( 135 static CallDescriptor* GetStubCallDescriptor(
134 Zone* zone, const CallInterfaceDescriptor& descriptor, 136 Zone* zone, const CallInterfaceDescriptor& descriptor,
135 int stack_parameter_count, CallDescriptor::Flags flags) { 137 int stack_parameter_count, CallDescriptor::Flags flags) {
136 const int register_parameter_count = 138 const int register_parameter_count =
137 descriptor.GetEnvironmentParameterCount(); 139 descriptor.GetEnvironmentParameterCount();
138 const int js_parameter_count = 140 const int js_parameter_count =
(...skipping 23 matching lines...) Expand all
162 } 164 }
163 types.AddParam(kMachAnyTagged); 165 types.AddParam(kMachAnyTagged);
164 } 166 }
165 // Add context. 167 // Add context.
166 locations.AddParam(regloc(LinkageTraits::ContextReg())); 168 locations.AddParam(regloc(LinkageTraits::ContextReg()));
167 types.AddParam(kMachAnyTagged); 169 types.AddParam(kMachAnyTagged);
168 170
169 // The target for stub calls is a code object. 171 // The target for stub calls is a code object.
170 MachineType target_type = kMachAnyTagged; 172 MachineType target_type = kMachAnyTagged;
171 LinkageLocation target_loc = LinkageLocation::AnyRegister(); 173 LinkageLocation target_loc = LinkageLocation::AnyRegister();
172 return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject, // kind 174 return new (zone) CallDescriptor( // --
173 target_type, // target MachineType 175 CallDescriptor::kCallCodeObject, // kind
174 target_loc, // target location 176 target_type, // target MachineType
175 types.Build(), // machine_sig 177 target_loc, // target location
176 locations.Build(), // location_sig 178 types.Build(), // machine_sig
177 js_parameter_count, // js_parameter_count 179 locations.Build(), // location_sig
178 Operator::kNoProperties, // properties 180 js_parameter_count, // js_parameter_count
179 kNoCalleeSaved, // callee-saved registers 181 Operator::kNoProperties, // properties
180 flags, // flags 182 kNoCalleeSaved, // callee-saved registers
181 descriptor.DebugName(zone->isolate())); 183 flags, // flags
184 descriptor.DebugName(zone->isolate()));
182 } 185 }
183 186
184 static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone, 187 static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone,
185 MachineSignature* msig) { 188 MachineSignature* msig) {
186 LocationSignature::Builder locations(zone, msig->return_count(), 189 LocationSignature::Builder locations(zone, msig->return_count(),
187 msig->parameter_count()); 190 msig->parameter_count());
188 // Add return location(s). 191 // Add return location(s).
189 AddReturnLocations(&locations); 192 AddReturnLocations(&locations);
190 193
191 // Add register and/or stack parameter(s). 194 // Add register and/or stack parameter(s).
192 const int parameter_count = static_cast<int>(msig->parameter_count()); 195 const int parameter_count = static_cast<int>(msig->parameter_count());
193 for (int i = 0; i < parameter_count; i++) { 196 for (int i = 0; i < parameter_count; i++) {
194 if (i < LinkageTraits::CRegisterParametersLength()) { 197 if (i < LinkageTraits::CRegisterParametersLength()) {
195 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i))); 198 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i)));
196 } else { 199 } else {
197 locations.AddParam(stackloc(-1 - i)); 200 locations.AddParam(stackloc(-1 - i));
198 } 201 }
199 } 202 }
200 203
201 // The target for C calls is always an address (i.e. machine pointer). 204 // The target for C calls is always an address (i.e. machine pointer).
202 MachineType target_type = kMachPtr; 205 MachineType target_type = kMachPtr;
203 LinkageLocation target_loc = LinkageLocation::AnyRegister(); 206 LinkageLocation target_loc = LinkageLocation::AnyRegister();
204 return new (zone) CallDescriptor(CallDescriptor::kCallAddress, // kind 207 return new (zone) CallDescriptor( // --
205 target_type, // target MachineType 208 CallDescriptor::kCallAddress, // kind
206 target_loc, // target location 209 target_type, // target MachineType
207 msig, // machine_sig 210 target_loc, // target location
208 locations.Build(), // location_sig 211 msig, // machine_sig
209 0, // js_parameter_count 212 locations.Build(), // location_sig
210 Operator::kNoProperties, // properties 213 0, // js_parameter_count
211 LinkageTraits::CCalleeSaveRegisters(), 214 Operator::kNoProperties, // properties
212 CallDescriptor::kNoFlags, "c-call"); 215 LinkageTraits::CCalleeSaveRegisters(), CallDescriptor::kNoFlags,
216 "c-call");
213 } 217 }
214 218
215 static LinkageLocation regloc(Register reg) { 219 static LinkageLocation regloc(Register reg) {
216 return LinkageLocation(Register::ToAllocationIndex(reg)); 220 return LinkageLocation(Register::ToAllocationIndex(reg));
217 } 221 }
218 222
219 static LinkageLocation stackloc(int i) { 223 static LinkageLocation stackloc(int i) {
220 DCHECK_LT(i, 0); 224 DCHECK_LT(i, 0);
221 return LinkageLocation(i); 225 return LinkageLocation(i);
222 } 226 }
223 }; 227 };
224 } // namespace compiler 228 } // namespace compiler
225 } // namespace internal 229 } // namespace internal
226 } // namespace v8 230 } // namespace v8
227 231
228 #endif // V8_COMPILER_LINKAGE_IMPL_H_ 232 #endif // V8_COMPILER_LINKAGE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698