OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 | 259 |
260 protected: | 260 protected: |
261 // Generates the assembler code for the stub. | 261 // Generates the assembler code for the stub. |
262 virtual void Generate(MacroAssembler* masm) = 0; | 262 virtual void Generate(MacroAssembler* masm) = 0; |
263 }; | 263 }; |
264 | 264 |
265 | 265 |
266 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 266 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
267 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; | 267 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
268 | 268 |
269 struct CodeStubInterfaceDescriptor { | 269 class CodeStubInterfaceDescriptor { |
270 public: | |
270 CodeStubInterfaceDescriptor(); | 271 CodeStubInterfaceDescriptor(); |
271 int register_param_count_; | |
272 | 272 |
273 Register stack_parameter_count_; | 273 void Initialize(int register_parameter_count, Register* registers, |
274 // if hint_stack_parameter_count_ > 0, the code stub can optimize the | 274 Address deoptimization_handler = NULL, |
275 // return sequence. Default value is -1, which means it is ignored. | 275 Representation* register_param_representations = NULL, |
276 int hint_stack_parameter_count_; | 276 int hint_stack_parameter_count = -1, |
277 StubFunctionMode function_mode_; | 277 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
278 Register* register_params_; | 278 void Initialize(int register_parameter_count, Register* registers, |
279 // Specifies Representations for the stub's parameter. Points to an array of | 279 Register stack_parameter_count, |
280 // Representations of the same length of the numbers of parameters to the | 280 Address deoptimization_handler = NULL, |
281 // stub, or if NULL (the default value), Representation of each parameter | 281 Representation* register_param_representations = NULL, |
282 // assumed to be Tagged() | 282 int hint_stack_parameter_count = -1, |
283 Representation* register_param_representations_; | 283 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
284 | 284 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
285 Address deoptimization_handler_; | |
286 HandlerArgumentsMode handler_arguments_mode_; | |
287 | |
288 bool initialized() const { return register_param_count_ >= 0; } | 285 bool initialized() const { return register_param_count_ >= 0; } |
289 | 286 |
290 int environment_length() const { | 287 int environment_length() const { |
291 return register_param_count_; | 288 return register_param_count_; |
292 } | 289 } |
293 | 290 |
294 void SetMissHandler(ExternalReference handler) { | 291 void SetMissHandler(ExternalReference handler) { |
295 miss_handler_ = handler; | 292 miss_handler_ = handler; |
296 has_miss_handler_ = true; | 293 has_miss_handler_ = true; |
297 // Our miss handler infrastructure doesn't currently support | 294 // Our miss handler infrastructure doesn't currently support |
298 // variable stack parameter counts. | 295 // variable stack parameter counts. |
299 ASSERT(!stack_parameter_count_.is_valid()); | 296 ASSERT(!stack_parameter_count_.is_valid()); |
300 } | 297 } |
301 | 298 |
302 ExternalReference miss_handler() { | 299 ExternalReference miss_handler() const { |
303 ASSERT(has_miss_handler_); | 300 ASSERT(has_miss_handler_); |
304 return miss_handler_; | 301 return miss_handler_; |
305 } | 302 } |
306 | 303 |
307 bool has_miss_handler() { | 304 bool has_miss_handler() const { |
308 return has_miss_handler_; | 305 return has_miss_handler_; |
309 } | 306 } |
310 | 307 |
311 Register GetParameterRegister(int index) const { | 308 Register GetParameterRegister(int index) const { |
312 return register_params_[index]; | 309 return register_params_[index]; |
313 } | 310 } |
314 | 311 |
315 bool IsParameterCountRegister(int index) { | 312 Representation GetRegisterParameterRepresentation(int index) const { |
313 ASSERT(index < register_param_count_); | |
314 if (register_param_representations_ == NULL) { | |
315 return Representation::Tagged(); | |
316 } | |
317 | |
318 return register_param_representations_[index]; | |
319 } | |
320 | |
321 bool IsParameterCountRegister(int index) const { | |
316 return GetParameterRegister(index).is(stack_parameter_count_); | 322 return GetParameterRegister(index).is(stack_parameter_count_); |
317 } | 323 } |
318 | 324 |
319 int GetHandlerParameterCount() { | 325 int GetHandlerParameterCount() const { |
320 int params = environment_length(); | 326 int params = environment_length(); |
321 if (handler_arguments_mode_ == PASS_ARGUMENTS) { | 327 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
322 params += 1; | 328 params += 1; |
323 } | 329 } |
324 return params; | 330 return params; |
325 } | 331 } |
326 | 332 |
333 int register_param_count() const { return register_param_count_; } | |
334 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } | |
335 Register stack_parameter_count() const { return stack_parameter_count_; } | |
336 StubFunctionMode function_mode() const { return function_mode_; } | |
337 Address deoptimization_handler() const { return deoptimization_handler_; } | |
338 Representation* register_param_representations() const { | |
339 return register_param_representations_; | |
340 } | |
341 | |
327 private: | 342 private: |
343 // Allocating the register parameter array is platform dependent, due to | |
344 // different sizes of the Register struct. | |
345 void InitializeRegisterParams(int register_parameter_count, | |
346 Register* registers); | |
347 | |
348 int register_param_count_; | |
349 | |
350 Register stack_parameter_count_; | |
351 // if hint_stack_parameter_count_ > 0, the code stub can optimize the | |
Jakob Kummerow
2014/06/24 17:23:24
nit: s/if/If/
mvstanton
2014/06/25 06:43:13
Done.
| |
352 // return sequence. Default value is -1, which means it is ignored. | |
353 int hint_stack_parameter_count_; | |
354 StubFunctionMode function_mode_; | |
355 // The Register params are allocated dynamically by the | |
356 // CodeStubInterfaceDescriptor, and freed on destruction. This is because | |
357 // static arrays of Registers cause creation of runtime static initializers | |
358 // which we don't want. | |
359 SmartArrayPointer<Register> register_params_; | |
360 // Specifies Representations for the stub's parameter. Points to an array of | |
361 // Representations of the same length of the numbers of parameters to the | |
362 // stub, or if NULL (the default value), Representation of each parameter | |
363 // assumed to be Tagged() | |
Jakob Kummerow
2014/06/24 17:23:24
nit: trailing full stop
mvstanton
2014/06/25 06:43:13
Done.
| |
364 Representation* register_param_representations_; | |
Jakob Kummerow
2014/06/24 17:23:24
This should probably be a SmartArrayPointer too, b
mvstanton
2014/06/25 06:43:13
Yep, I did this because otherwise the asymmetry is
| |
365 | |
366 Address deoptimization_handler_; | |
367 HandlerArgumentsMode handler_arguments_mode_; | |
368 | |
328 ExternalReference miss_handler_; | 369 ExternalReference miss_handler_; |
329 bool has_miss_handler_; | 370 bool has_miss_handler_; |
371 DISALLOW_COPY_AND_ASSIGN(CodeStubInterfaceDescriptor); | |
330 }; | 372 }; |
331 | 373 |
332 | 374 |
333 struct PlatformCallInterfaceDescriptor; | 375 struct PlatformCallInterfaceDescriptor; |
334 | 376 |
335 | 377 |
336 struct CallInterfaceDescriptor { | 378 struct CallInterfaceDescriptor { |
337 CallInterfaceDescriptor() | 379 CallInterfaceDescriptor() |
338 : register_param_count_(-1), | 380 : register_param_count_(-1), |
339 register_params_(NULL), | 381 register_params_(NULL), |
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2483 | 2525 |
2484 | 2526 |
2485 class CallDescriptors { | 2527 class CallDescriptors { |
2486 public: | 2528 public: |
2487 static void InitializeForIsolate(Isolate* isolate); | 2529 static void InitializeForIsolate(Isolate* isolate); |
2488 }; | 2530 }; |
2489 | 2531 |
2490 } } // namespace v8::internal | 2532 } } // namespace v8::internal |
2491 | 2533 |
2492 #endif // V8_CODE_STUBS_H_ | 2534 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |