| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 virtual Code::Kind GetCodeKind() const { return Code::STUB; } | 270 virtual Code::Kind GetCodeKind() const { return Code::STUB; } |
| 271 | 271 |
| 272 protected: | 272 protected: |
| 273 // Generates the assembler code for the stub. | 273 // Generates the assembler code for the stub. |
| 274 virtual void Generate(MacroAssembler* masm) = 0; | 274 virtual void Generate(MacroAssembler* masm) = 0; |
| 275 }; | 275 }; |
| 276 | 276 |
| 277 | 277 |
| 278 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 278 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
| 279 | 279 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
| 280 | 280 |
| 281 struct CodeStubInterfaceDescriptor { | 281 struct CodeStubInterfaceDescriptor { |
| 282 CodeStubInterfaceDescriptor(); | 282 CodeStubInterfaceDescriptor(); |
| 283 int register_param_count_; | 283 int register_param_count_; |
| 284 |
| 284 Register stack_parameter_count_; | 285 Register stack_parameter_count_; |
| 285 // if hint_stack_parameter_count_ > 0, the code stub can optimize the | 286 // if hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 286 // return sequence. Default value is -1, which means it is ignored. | 287 // return sequence. Default value is -1, which means it is ignored. |
| 287 int hint_stack_parameter_count_; | 288 int hint_stack_parameter_count_; |
| 288 StubFunctionMode function_mode_; | 289 StubFunctionMode function_mode_; |
| 289 Register* register_params_; | 290 Register* register_params_; |
| 291 |
| 290 Address deoptimization_handler_; | 292 Address deoptimization_handler_; |
| 293 HandlerArgumentsMode handler_arguments_mode_; |
| 291 | 294 |
| 292 int environment_length() const { | 295 int environment_length() const { |
| 293 if (stack_parameter_count_.is_valid()) { | |
| 294 return register_param_count_ + 1; | |
| 295 } | |
| 296 return register_param_count_; | 296 return register_param_count_; |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool initialized() const { return register_param_count_ >= 0; } | 299 bool initialized() const { return register_param_count_ >= 0; } |
| 300 | 300 |
| 301 void SetMissHandler(ExternalReference handler) { | 301 void SetMissHandler(ExternalReference handler) { |
| 302 miss_handler_ = handler; | 302 miss_handler_ = handler; |
| 303 has_miss_handler_ = true; | 303 has_miss_handler_ = true; |
| 304 // Our miss handler infrastructure doesn't currently support |
| 305 // variable stack parameter counts. |
| 306 ASSERT(!stack_parameter_count_.is_valid()); |
| 304 } | 307 } |
| 305 | 308 |
| 306 ExternalReference miss_handler() { | 309 ExternalReference miss_handler() { |
| 307 ASSERT(has_miss_handler_); | 310 ASSERT(has_miss_handler_); |
| 308 return miss_handler_; | 311 return miss_handler_; |
| 309 } | 312 } |
| 310 | 313 |
| 311 bool has_miss_handler() { | 314 bool has_miss_handler() { |
| 312 return has_miss_handler_; | 315 return has_miss_handler_; |
| 313 } | 316 } |
| 314 | 317 |
| 318 Register GetParameterRegister(int index) { |
| 319 return register_params_[index]; |
| 320 } |
| 321 |
| 322 bool IsParameterCountRegister(int index) { |
| 323 return GetParameterRegister(index).is(stack_parameter_count_); |
| 324 } |
| 325 |
| 326 int GetHandlerParameterCount() { |
| 327 int params = environment_length(); |
| 328 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
| 329 params += 1; |
| 330 } |
| 331 return params; |
| 332 } |
| 333 |
| 315 private: | 334 private: |
| 316 ExternalReference miss_handler_; | 335 ExternalReference miss_handler_; |
| 317 bool has_miss_handler_; | 336 bool has_miss_handler_; |
| 318 }; | 337 }; |
| 319 | 338 |
| 320 // A helper to make up for the fact that type Register is not fully | |
| 321 // defined outside of the platform directories | |
| 322 #define DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index) \ | |
| 323 ((index) == (descriptor)->register_param_count_) \ | |
| 324 ? (descriptor)->stack_parameter_count_ \ | |
| 325 : (descriptor)->register_params_[(index)] | |
| 326 | |
| 327 | 339 |
| 328 class HydrogenCodeStub : public CodeStub { | 340 class HydrogenCodeStub : public CodeStub { |
| 329 public: | 341 public: |
| 330 enum InitializationState { | 342 enum InitializationState { |
| 331 UNINITIALIZED, | 343 UNINITIALIZED, |
| 332 INITIALIZED | 344 INITIALIZED |
| 333 }; | 345 }; |
| 334 | 346 |
| 335 explicit HydrogenCodeStub(InitializationState state = INITIALIZED) { | 347 explicit HydrogenCodeStub(InitializationState state = INITIALIZED) { |
| 336 is_uninitialized_ = (state == UNINITIALIZED); | 348 is_uninitialized_ = (state == UNINITIALIZED); |
| (...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 int MinorKey() { return 0; } | 2369 int MinorKey() { return 0; } |
| 2358 | 2370 |
| 2359 void Generate(MacroAssembler* masm); | 2371 void Generate(MacroAssembler* masm); |
| 2360 | 2372 |
| 2361 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2373 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2362 }; | 2374 }; |
| 2363 | 2375 |
| 2364 } } // namespace v8::internal | 2376 } } // namespace v8::internal |
| 2365 | 2377 |
| 2366 #endif // V8_CODE_STUBS_H_ | 2378 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |