Chromium Code Reviews| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 | 264 |
| 265 protected: | 265 protected: |
| 266 // Generates the assembler code for the stub. | 266 // Generates the assembler code for the stub. |
| 267 virtual void Generate(MacroAssembler* masm) = 0; | 267 virtual void Generate(MacroAssembler* masm) = 0; |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 | 270 |
| 271 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 271 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
| 272 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; | 272 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
| 273 | 273 |
| 274 class CodeStubInterfaceDescriptor { | 274 class InterfaceDescriptor { |
| 275 public: | |
| 276 bool initialized() const { return register_param_count_ >= 0; } | |
|
danno
2014/07/16 13:19:59
style: should be IsInitialized()
mvstanton
2014/07/17 09:04:05
Done.
| |
| 277 | |
| 278 int GetEnvironmentLength() const { | |
| 279 return register_param_count_; | |
| 280 } | |
|
danno
2014/07/16 13:19:59
I think with a little more "duplication", you can
mvstanton
2014/07/17 09:04:04
I fully factored this out so that customers who pr
| |
| 281 | |
| 282 int register_param_count() const { return register_param_count_; } | |
|
danno
2014/07/16 13:19:59
For consistency, make this GetRegisterParameterCou
mvstanton
2014/07/17 09:04:05
Done.
| |
| 283 | |
| 284 Register GetParameterRegister(int index) const { | |
| 285 return register_params_[index]; | |
| 286 } | |
| 287 | |
| 288 Representation GetParameterRepresentation(int index) const { | |
| 289 ASSERT(index < register_param_count_); | |
| 290 if (register_param_representations_.get() == NULL) { | |
| 291 return Representation::Tagged(); | |
| 292 } | |
| 293 | |
| 294 return register_param_representations_[index]; | |
| 295 } | |
| 296 | |
| 297 static const Register ContextRegister(); | |
| 298 | |
| 299 protected: | |
| 300 InterfaceDescriptor(); | |
| 301 virtual ~InterfaceDescriptor() {} | |
| 302 | |
| 303 void Initialize(int register_parameter_count, Register* registers, | |
| 304 Representation* register_param_representations); | |
| 305 | |
| 306 private: | |
| 307 int register_param_count_; | |
| 308 | |
| 309 // The Register params are allocated dynamically by the | |
| 310 // InterfaceDescriptor, and freed on destruction. This is because static | |
| 311 // arrays of Registers cause creation of runtime static initializers | |
| 312 // which we don't want. | |
| 313 SmartArrayPointer<Register> register_params_; | |
| 314 // Specifies Representations for the stub's parameter. Points to an array of | |
| 315 // Representations of the same length of the numbers of parameters to the | |
| 316 // stub, or if NULL (the default value), Representation of each parameter | |
| 317 // assumed to be Tagged(). | |
| 318 SmartArrayPointer<Representation> register_param_representations_; | |
| 319 | |
| 320 DISALLOW_COPY_AND_ASSIGN(InterfaceDescriptor); | |
| 321 }; | |
| 322 | |
| 323 | |
| 324 class CodeStubInterfaceDescriptor: public InterfaceDescriptor { | |
| 275 public: | 325 public: |
| 276 CodeStubInterfaceDescriptor(); | 326 CodeStubInterfaceDescriptor(); |
| 277 | 327 |
| 278 void Initialize(int register_parameter_count, Register* registers, | 328 void Initialize(int register_parameter_count, Register* registers, |
| 279 Address deoptimization_handler = NULL, | 329 Address deoptimization_handler = NULL, |
| 280 Representation* register_param_representations = NULL, | 330 Representation* register_param_representations = NULL, |
| 281 int hint_stack_parameter_count = -1, | 331 int hint_stack_parameter_count = -1, |
| 282 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | 332 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 283 void Initialize(int register_parameter_count, Register* registers, | 333 void Initialize(int register_parameter_count, Register* registers, |
| 284 Register stack_parameter_count, | 334 Register stack_parameter_count, |
| 285 Address deoptimization_handler = NULL, | 335 Address deoptimization_handler = NULL, |
| 286 Representation* register_param_representations = NULL, | 336 Representation* register_param_representations = NULL, |
| 287 int hint_stack_parameter_count = -1, | 337 int hint_stack_parameter_count = -1, |
| 288 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, | 338 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
| 289 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); | 339 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
| 290 bool initialized() const { return register_param_count_ >= 0; } | |
| 291 | |
| 292 int environment_length() const { | |
| 293 return register_param_count_; | |
| 294 } | |
| 295 | 340 |
| 296 void SetMissHandler(ExternalReference handler) { | 341 void SetMissHandler(ExternalReference handler) { |
| 297 miss_handler_ = handler; | 342 miss_handler_ = handler; |
| 298 has_miss_handler_ = true; | 343 has_miss_handler_ = true; |
| 299 // Our miss handler infrastructure doesn't currently support | 344 // Our miss handler infrastructure doesn't currently support |
| 300 // variable stack parameter counts. | 345 // variable stack parameter counts. |
| 301 ASSERT(!stack_parameter_count_.is_valid()); | 346 ASSERT(!stack_parameter_count_.is_valid()); |
| 302 } | 347 } |
| 303 | 348 |
| 304 ExternalReference miss_handler() const { | 349 ExternalReference miss_handler() const { |
| 305 ASSERT(has_miss_handler_); | 350 ASSERT(has_miss_handler_); |
| 306 return miss_handler_; | 351 return miss_handler_; |
| 307 } | 352 } |
| 308 | 353 |
| 309 bool has_miss_handler() const { | 354 bool has_miss_handler() const { |
| 310 return has_miss_handler_; | 355 return has_miss_handler_; |
| 311 } | 356 } |
| 312 | 357 |
| 313 Register GetParameterRegister(int index) const { | |
| 314 return register_params_[index]; | |
| 315 } | |
| 316 | |
| 317 Representation GetRegisterParameterRepresentation(int index) const { | |
| 318 ASSERT(index < register_param_count_); | |
| 319 if (register_param_representations_.get() == NULL) { | |
| 320 return Representation::Tagged(); | |
| 321 } | |
| 322 | |
| 323 return register_param_representations_[index]; | |
| 324 } | |
| 325 | |
| 326 bool IsParameterCountRegister(int index) const { | 358 bool IsParameterCountRegister(int index) const { |
| 327 return GetParameterRegister(index).is(stack_parameter_count_); | 359 return GetParameterRegister(index).is(stack_parameter_count_); |
| 328 } | 360 } |
| 329 | 361 |
| 330 int GetHandlerParameterCount() const { | 362 int GetHandlerParameterCount() const { |
| 331 int params = environment_length(); | 363 // Context is dealt with as a defined part of the frame, not as a parameter. |
| 364 int params = GetEnvironmentLength() - 1; | |
| 332 if (handler_arguments_mode_ == PASS_ARGUMENTS) { | 365 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
| 333 params += 1; | 366 params += 1; |
| 334 } | 367 } |
| 335 return params; | 368 return params; |
| 336 } | 369 } |
| 337 | 370 |
| 338 int register_param_count() const { return register_param_count_; } | |
| 339 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } | 371 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
| 340 Register stack_parameter_count() const { return stack_parameter_count_; } | 372 Register stack_parameter_count() const { return stack_parameter_count_; } |
| 341 StubFunctionMode function_mode() const { return function_mode_; } | 373 StubFunctionMode function_mode() const { return function_mode_; } |
| 342 Address deoptimization_handler() const { return deoptimization_handler_; } | 374 Address deoptimization_handler() const { return deoptimization_handler_; } |
| 343 Representation* register_param_representations() const { | |
| 344 return register_param_representations_.get(); | |
| 345 } | |
| 346 | 375 |
| 347 private: | 376 private: |
| 348 int register_param_count_; | |
| 349 | |
| 350 Register stack_parameter_count_; | 377 Register stack_parameter_count_; |
| 351 // If hint_stack_parameter_count_ > 0, the code stub can optimize the | 378 // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 352 // return sequence. Default value is -1, which means it is ignored. | 379 // return sequence. Default value is -1, which means it is ignored. |
| 353 int hint_stack_parameter_count_; | 380 int hint_stack_parameter_count_; |
| 354 StubFunctionMode function_mode_; | 381 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(). | |
| 364 SmartArrayPointer<Representation> register_param_representations_; | |
| 365 | 382 |
| 366 Address deoptimization_handler_; | 383 Address deoptimization_handler_; |
| 367 HandlerArgumentsMode handler_arguments_mode_; | 384 HandlerArgumentsMode handler_arguments_mode_; |
| 368 | 385 |
| 369 ExternalReference miss_handler_; | 386 ExternalReference miss_handler_; |
| 370 bool has_miss_handler_; | 387 bool has_miss_handler_; |
| 371 DISALLOW_COPY_AND_ASSIGN(CodeStubInterfaceDescriptor); | |
| 372 }; | 388 }; |
| 373 | 389 |
| 374 | 390 |
| 375 class PlatformCallInterfaceDescriptor; | 391 class PlatformCallInterfaceDescriptor; |
| 376 | 392 |
| 377 | 393 |
| 378 class CallInterfaceDescriptor { | 394 class CallInterfaceDescriptor: public InterfaceDescriptor { |
| 379 public: | 395 public: |
| 380 CallInterfaceDescriptor() | 396 CallInterfaceDescriptor() |
| 381 : register_param_count_(-1), | 397 : platform_specific_descriptor_(NULL) { } |
| 382 register_params_(NULL), | |
| 383 param_representations_(NULL), | |
| 384 platform_specific_descriptor_(NULL) { } | |
| 385 | 398 |
| 386 // A copy of the passed in registers and param_representations is made | 399 // A copy of the passed in registers and param_representations is made |
| 387 // and owned by the CallInterfaceDescriptor. | 400 // and owned by the CallInterfaceDescriptor. |
| 388 | 401 |
| 389 // TODO(mvstanton): Instead of taking parallel arrays register and | 402 // TODO(mvstanton): Instead of taking parallel arrays register and |
| 390 // param_representations, how about a struct that puts the representation | 403 // param_representations, how about a struct that puts the representation |
| 391 // and register side by side (eg, RegRep(r1, Representation::Tagged()). | 404 // and register side by side (eg, RegRep(r1, Representation::Tagged()). |
| 392 // The same should go for the CodeStubInterfaceDescriptor class. | 405 // The same should go for the CodeStubInterfaceDescriptor class. |
| 393 void Initialize(int register_parameter_count, Register* registers, | 406 void Initialize(int register_parameter_count, Register* registers, |
| 394 Representation* param_representations, | 407 Representation* param_representations, |
| 395 PlatformCallInterfaceDescriptor* platform_descriptor = NULL); | 408 PlatformCallInterfaceDescriptor* platform_descriptor = NULL); |
| 396 | 409 |
| 397 bool initialized() const { return register_param_count_ >= 0; } | |
| 398 | |
| 399 int environment_length() const { | |
| 400 return register_param_count_; | |
| 401 } | |
| 402 | |
| 403 Representation GetParameterRepresentation(int index) const { | |
| 404 return param_representations_[index]; | |
| 405 } | |
| 406 | |
| 407 Register GetParameterRegister(int index) const { | |
| 408 return register_params_[index]; | |
| 409 } | |
| 410 | |
| 411 PlatformCallInterfaceDescriptor* platform_specific_descriptor() const { | 410 PlatformCallInterfaceDescriptor* platform_specific_descriptor() const { |
| 412 return platform_specific_descriptor_; | 411 return platform_specific_descriptor_; |
| 413 } | 412 } |
| 414 | 413 |
| 415 private: | 414 private: |
| 416 int register_param_count_; | |
| 417 SmartArrayPointer<Register> register_params_; | |
| 418 SmartArrayPointer<Representation> param_representations_; | |
| 419 PlatformCallInterfaceDescriptor* platform_specific_descriptor_; | 415 PlatformCallInterfaceDescriptor* platform_specific_descriptor_; |
| 420 }; | 416 }; |
| 421 | 417 |
| 422 | 418 |
| 423 class HydrogenCodeStub : public CodeStub { | 419 class HydrogenCodeStub : public CodeStub { |
| 424 public: | 420 public: |
| 425 enum InitializationState { | 421 enum InitializationState { |
| 426 UNINITIALIZED, | 422 UNINITIALIZED, |
| 427 INITIALIZED | 423 INITIALIZED |
| 428 }; | 424 }; |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2540 | 2536 |
| 2541 | 2537 |
| 2542 class CallDescriptors { | 2538 class CallDescriptors { |
| 2543 public: | 2539 public: |
| 2544 static void InitializeForIsolate(Isolate* isolate); | 2540 static void InitializeForIsolate(Isolate* isolate); |
| 2545 }; | 2541 }; |
| 2546 | 2542 |
| 2547 } } // namespace v8::internal | 2543 } } // namespace v8::internal |
| 2548 | 2544 |
| 2549 #endif // V8_CODE_STUBS_H_ | 2545 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |