| 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" |
| 11 #include "src/globals.h" | 11 #include "src/globals.h" |
| 12 #include "src/ic/ic.h" | 12 #include "src/ic/ic.h" |
| 13 #include "src/ic/ic-conventions.h" | 13 #include "src/ic/ic-conventions.h" |
| 14 #include "src/interface-descriptors.h" |
| 14 #include "src/macro-assembler.h" | 15 #include "src/macro-assembler.h" |
| 15 #include "src/ostreams.h" | 16 #include "src/ostreams.h" |
| 16 | 17 |
| 17 namespace v8 { | 18 namespace v8 { |
| 18 namespace internal { | 19 namespace internal { |
| 19 | 20 |
| 20 // List of code stubs used on all platforms. | 21 // List of code stubs used on all platforms. |
| 21 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ | 22 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ |
| 22 V(CallFunction) \ | 23 V(CallFunction) \ |
| 23 V(CallConstruct) \ | 24 V(CallConstruct) \ |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 protected: | 274 protected: |
| 274 // Generates the assembler code for the stub. | 275 // Generates the assembler code for the stub. |
| 275 virtual void Generate(MacroAssembler* masm) = 0; | 276 virtual void Generate(MacroAssembler* masm) = 0; |
| 276 }; | 277 }; |
| 277 | 278 |
| 278 | 279 |
| 279 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 280 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
| 280 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; | 281 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
| 281 | 282 |
| 282 | 283 |
| 283 class PlatformInterfaceDescriptor; | |
| 284 | |
| 285 | |
| 286 class InterfaceDescriptor { | |
| 287 public: | |
| 288 bool IsInitialized() const { return register_param_count_ >= 0; } | |
| 289 | |
| 290 int GetEnvironmentLength() const { return register_param_count_; } | |
| 291 | |
| 292 int GetRegisterParameterCount() const { return register_param_count_; } | |
| 293 | |
| 294 Register GetParameterRegister(int index) const { | |
| 295 return register_params_[index]; | |
| 296 } | |
| 297 | |
| 298 Representation GetParameterRepresentation(int index) const { | |
| 299 DCHECK(index < register_param_count_); | |
| 300 if (register_param_representations_.get() == NULL) { | |
| 301 return Representation::Tagged(); | |
| 302 } | |
| 303 | |
| 304 return register_param_representations_[index]; | |
| 305 } | |
| 306 | |
| 307 // "Environment" versions of parameter functions. The first register | |
| 308 // parameter (context) is not included. | |
| 309 int GetEnvironmentParameterCount() const { | |
| 310 return GetEnvironmentLength() - 1; | |
| 311 } | |
| 312 | |
| 313 Register GetEnvironmentParameterRegister(int index) const { | |
| 314 return GetParameterRegister(index + 1); | |
| 315 } | |
| 316 | |
| 317 Representation GetEnvironmentParameterRepresentation(int index) const { | |
| 318 return GetParameterRepresentation(index + 1); | |
| 319 } | |
| 320 | |
| 321 // Some platforms have extra information to associate with the descriptor. | |
| 322 PlatformInterfaceDescriptor* platform_specific_descriptor() const { | |
| 323 return platform_specific_descriptor_; | |
| 324 } | |
| 325 | |
| 326 static const Register ContextRegister(); | |
| 327 | |
| 328 protected: | |
| 329 InterfaceDescriptor(); | |
| 330 virtual ~InterfaceDescriptor() {} | |
| 331 | |
| 332 void Initialize(int register_parameter_count, Register* registers, | |
| 333 Representation* register_param_representations, | |
| 334 PlatformInterfaceDescriptor* platform_descriptor = NULL); | |
| 335 | |
| 336 private: | |
| 337 int register_param_count_; | |
| 338 | |
| 339 // The Register params are allocated dynamically by the | |
| 340 // InterfaceDescriptor, and freed on destruction. This is because static | |
| 341 // arrays of Registers cause creation of runtime static initializers | |
| 342 // which we don't want. | |
| 343 SmartArrayPointer<Register> register_params_; | |
| 344 // Specifies Representations for the stub's parameter. Points to an array of | |
| 345 // Representations of the same length of the numbers of parameters to the | |
| 346 // stub, or if NULL (the default value), Representation of each parameter | |
| 347 // assumed to be Tagged(). | |
| 348 SmartArrayPointer<Representation> register_param_representations_; | |
| 349 | |
| 350 PlatformInterfaceDescriptor* platform_specific_descriptor_; | |
| 351 | |
| 352 DISALLOW_COPY_AND_ASSIGN(InterfaceDescriptor); | |
| 353 }; | |
| 354 | |
| 355 | |
| 356 class CodeStubInterfaceDescriptor: public InterfaceDescriptor { | 284 class CodeStubInterfaceDescriptor: public InterfaceDescriptor { |
| 357 public: | 285 public: |
| 358 CodeStubInterfaceDescriptor(); | 286 CodeStubInterfaceDescriptor(); |
| 359 | 287 |
| 360 void Initialize(CodeStub::Major major, int register_parameter_count, | 288 void Initialize(CodeStub::Major major, int register_parameter_count, |
| 361 Register* registers, Address deoptimization_handler = NULL, | 289 Register* registers, Address deoptimization_handler = NULL, |
| 362 Representation* register_param_representations = NULL, | 290 Representation* register_param_representations = NULL, |
| 363 int hint_stack_parameter_count = -1, | 291 int hint_stack_parameter_count = -1, |
| 364 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | 292 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 365 void Initialize(CodeStub::Major major, int register_parameter_count, | 293 void Initialize(CodeStub::Major major, int register_parameter_count, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 342 |
| 415 Address deoptimization_handler_; | 343 Address deoptimization_handler_; |
| 416 HandlerArgumentsMode handler_arguments_mode_; | 344 HandlerArgumentsMode handler_arguments_mode_; |
| 417 | 345 |
| 418 ExternalReference miss_handler_; | 346 ExternalReference miss_handler_; |
| 419 bool has_miss_handler_; | 347 bool has_miss_handler_; |
| 420 CodeStub::Major major_; | 348 CodeStub::Major major_; |
| 421 }; | 349 }; |
| 422 | 350 |
| 423 | 351 |
| 424 class CallInterfaceDescriptor: public InterfaceDescriptor { | |
| 425 public: | |
| 426 CallInterfaceDescriptor() { } | |
| 427 | |
| 428 // A copy of the passed in registers and param_representations is made | |
| 429 // and owned by the CallInterfaceDescriptor. | |
| 430 | |
| 431 // TODO(mvstanton): Instead of taking parallel arrays register and | |
| 432 // param_representations, how about a struct that puts the representation | |
| 433 // and register side by side (eg, RegRep(r1, Representation::Tagged()). | |
| 434 // The same should go for the CodeStubInterfaceDescriptor class. | |
| 435 void Initialize(int register_parameter_count, Register* registers, | |
| 436 Representation* param_representations, | |
| 437 PlatformInterfaceDescriptor* platform_descriptor = NULL); | |
| 438 }; | |
| 439 | |
| 440 | |
| 441 class HydrogenCodeStub : public CodeStub { | 352 class HydrogenCodeStub : public CodeStub { |
| 442 public: | 353 public: |
| 443 enum InitializationState { | 354 enum InitializationState { |
| 444 UNINITIALIZED, | 355 UNINITIALIZED, |
| 445 INITIALIZED | 356 INITIALIZED |
| 446 }; | 357 }; |
| 447 | 358 |
| 448 explicit HydrogenCodeStub(Isolate* isolate, | 359 explicit HydrogenCodeStub(Isolate* isolate, |
| 449 InitializationState state = INITIALIZED) | 360 InitializationState state = INITIALIZED) |
| 450 : CodeStub(isolate) { | 361 : CodeStub(isolate) { |
| (...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 Isolate* isolate); | 2564 Isolate* isolate); |
| 2654 | 2565 |
| 2655 virtual Major MajorKey() const V8_OVERRIDE { return ProfileEntryHook; } | 2566 virtual Major MajorKey() const V8_OVERRIDE { return ProfileEntryHook; } |
| 2656 | 2567 |
| 2657 void Generate(MacroAssembler* masm); | 2568 void Generate(MacroAssembler* masm); |
| 2658 | 2569 |
| 2659 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2570 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
| 2660 }; | 2571 }; |
| 2661 | 2572 |
| 2662 | 2573 |
| 2663 class CallDescriptors { | |
| 2664 public: | |
| 2665 static void InitializeForIsolate(Isolate* isolate); | |
| 2666 }; | |
| 2667 | |
| 2668 } } // namespace v8::internal | 2574 } } // namespace v8::internal |
| 2669 | 2575 |
| 2670 #endif // V8_CODE_STUBS_H_ | 2576 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |