| 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/code-stub-assembler.h" | 10 #include "src/code-stub-assembler.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 V(MathPow) \ | 41 V(MathPow) \ |
| 42 V(ProfileEntryHook) \ | 42 V(ProfileEntryHook) \ |
| 43 V(RecordWrite) \ | 43 V(RecordWrite) \ |
| 44 V(RegExpExec) \ | 44 V(RegExpExec) \ |
| 45 V(StoreBufferOverflow) \ | 45 V(StoreBufferOverflow) \ |
| 46 V(StoreElement) \ | 46 V(StoreElement) \ |
| 47 V(StubFailureTrampoline) \ | 47 V(StubFailureTrampoline) \ |
| 48 V(SubString) \ | 48 V(SubString) \ |
| 49 V(ToString) \ | 49 V(ToString) \ |
| 50 V(ToName) \ | 50 V(ToName) \ |
| 51 V(ToObject) \ | |
| 52 V(StoreICTrampoline) \ | 51 V(StoreICTrampoline) \ |
| 53 V(KeyedStoreICTrampoline) \ | 52 V(KeyedStoreICTrampoline) \ |
| 54 V(StoreIC) \ | 53 V(StoreIC) \ |
| 55 V(KeyedStoreIC) \ | 54 V(KeyedStoreIC) \ |
| 56 V(KeyedLoadIC) \ | 55 V(KeyedLoadIC) \ |
| 57 V(LoadIC) \ | 56 V(LoadIC) \ |
| 58 V(LoadGlobalIC) \ | 57 V(LoadGlobalIC) \ |
| 59 V(FastNewObject) \ | 58 V(FastNewObject) \ |
| 60 V(FastNewRestParameter) \ | 59 V(FastNewRestParameter) \ |
| 61 V(FastNewSloppyArguments) \ | 60 V(FastNewSloppyArguments) \ |
| 62 V(FastNewStrictArguments) \ | 61 V(FastNewStrictArguments) \ |
| 63 /* HydrogenCodeStubs */ \ | 62 /* HydrogenCodeStubs */ \ |
| 64 V(BinaryOpIC) \ | 63 V(BinaryOpIC) \ |
| 65 V(BinaryOpWithAllocationSite) \ | 64 V(BinaryOpWithAllocationSite) \ |
| 66 V(ElementsTransitionAndStore) \ | 65 V(ElementsTransitionAndStore) \ |
| 67 V(FastArrayPush) \ | 66 V(FastArrayPush) \ |
| 68 V(FastCloneRegExp) \ | 67 V(FastCloneRegExp) \ |
| 69 V(FastCloneShallowArray) \ | 68 V(FastCloneShallowArray) \ |
| 70 V(FastFunctionBind) \ | 69 V(FastFunctionBind) \ |
| 71 V(GrowArrayElements) \ | 70 V(GrowArrayElements) \ |
| 72 V(KeyedLoadGeneric) \ | 71 V(KeyedLoadGeneric) \ |
| 73 V(LoadScriptContextField) \ | 72 V(LoadScriptContextField) \ |
| 74 V(LoadDictionaryElement) \ | 73 V(LoadDictionaryElement) \ |
| 75 V(NameDictionaryLookup) \ | 74 V(NameDictionaryLookup) \ |
| 76 V(NumberToString) \ | 75 V(NumberToString) \ |
| 76 V(ToObject) \ |
| 77 V(Typeof) \ | 77 V(Typeof) \ |
| 78 V(RegExpConstructResult) \ | 78 V(RegExpConstructResult) \ |
| 79 V(StoreFastElement) \ | 79 V(StoreFastElement) \ |
| 80 V(StoreGlobalViaContext) \ | 80 V(StoreGlobalViaContext) \ |
| 81 V(StoreScriptContextField) \ | 81 V(StoreScriptContextField) \ |
| 82 V(StringAdd) \ | 82 V(StringAdd) \ |
| 83 V(ToBooleanIC) \ | 83 V(ToBooleanIC) \ |
| 84 V(TransitionElementsKind) \ | 84 V(TransitionElementsKind) \ |
| 85 /* TurboFanCodeStubs */ \ | 85 /* TurboFanCodeStubs */ \ |
| 86 V(AllocateHeapNumber) \ | 86 V(AllocateHeapNumber) \ |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 CodeStubDescriptor(Isolate* isolate, uint32_t stub_key); | 480 CodeStubDescriptor(Isolate* isolate, uint32_t stub_key); |
| 481 | 481 |
| 482 void Initialize(Address deoptimization_handler = NULL, | 482 void Initialize(Address deoptimization_handler = NULL, |
| 483 int hint_stack_parameter_count = -1, | 483 int hint_stack_parameter_count = -1, |
| 484 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | 484 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 485 void Initialize(Register stack_parameter_count, | 485 void Initialize(Register stack_parameter_count, |
| 486 Address deoptimization_handler = NULL, | 486 Address deoptimization_handler = NULL, |
| 487 int hint_stack_parameter_count = -1, | 487 int hint_stack_parameter_count = -1, |
| 488 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | 488 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
| 489 | 489 |
| 490 void SetMissHandler(ExternalReference handler) { | 490 void SetMissHandler(Runtime::FunctionId id) { |
| 491 miss_handler_ = handler; | 491 miss_handler_id_ = id; |
| 492 miss_handler_ = ExternalReference(Runtime::FunctionForId(id), isolate_); |
| 492 has_miss_handler_ = true; | 493 has_miss_handler_ = true; |
| 493 // Our miss handler infrastructure doesn't currently support | 494 // Our miss handler infrastructure doesn't currently support |
| 494 // variable stack parameter counts. | 495 // variable stack parameter counts. |
| 495 DCHECK(!stack_parameter_count_.is_valid()); | 496 DCHECK(!stack_parameter_count_.is_valid()); |
| 496 } | 497 } |
| 497 | 498 |
| 498 void set_call_descriptor(CallInterfaceDescriptor d) { call_descriptor_ = d; } | 499 void set_call_descriptor(CallInterfaceDescriptor d) { call_descriptor_ = d; } |
| 499 CallInterfaceDescriptor call_descriptor() const { return call_descriptor_; } | 500 CallInterfaceDescriptor call_descriptor() const { return call_descriptor_; } |
| 500 | 501 |
| 501 int GetRegisterParameterCount() const { | 502 int GetRegisterParameterCount() const { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 516 | 517 |
| 517 Type* GetParameterType(int index) const { | 518 Type* GetParameterType(int index) const { |
| 518 return call_descriptor().GetParameterType(index); | 519 return call_descriptor().GetParameterType(index); |
| 519 } | 520 } |
| 520 | 521 |
| 521 ExternalReference miss_handler() const { | 522 ExternalReference miss_handler() const { |
| 522 DCHECK(has_miss_handler_); | 523 DCHECK(has_miss_handler_); |
| 523 return miss_handler_; | 524 return miss_handler_; |
| 524 } | 525 } |
| 525 | 526 |
| 527 Runtime::FunctionId miss_handler_id() const { |
| 528 DCHECK(has_miss_handler_); |
| 529 return miss_handler_id_; |
| 530 } |
| 531 |
| 526 bool has_miss_handler() const { | 532 bool has_miss_handler() const { |
| 527 return has_miss_handler_; | 533 return has_miss_handler_; |
| 528 } | 534 } |
| 529 | 535 |
| 530 int GetHandlerParameterCount() const { | 536 int GetHandlerParameterCount() const { |
| 531 int params = GetParameterCount(); | 537 int params = GetParameterCount(); |
| 532 if (PassesArgumentsToDeoptimizationHandler()) { | 538 if (PassesArgumentsToDeoptimizationHandler()) { |
| 533 params += 1; | 539 params += 1; |
| 534 } | 540 } |
| 535 return params; | 541 return params; |
| 536 } | 542 } |
| 537 | 543 |
| 538 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } | 544 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
| 539 Register stack_parameter_count() const { return stack_parameter_count_; } | 545 Register stack_parameter_count() const { return stack_parameter_count_; } |
| 540 StubFunctionMode function_mode() const { return function_mode_; } | 546 StubFunctionMode function_mode() const { return function_mode_; } |
| 541 Address deoptimization_handler() const { return deoptimization_handler_; } | 547 Address deoptimization_handler() const { return deoptimization_handler_; } |
| 542 | 548 |
| 543 private: | 549 private: |
| 544 bool PassesArgumentsToDeoptimizationHandler() const { | 550 bool PassesArgumentsToDeoptimizationHandler() const { |
| 545 return stack_parameter_count_.is_valid(); | 551 return stack_parameter_count_.is_valid(); |
| 546 } | 552 } |
| 547 | 553 |
| 554 Isolate* isolate_; |
| 548 CallInterfaceDescriptor call_descriptor_; | 555 CallInterfaceDescriptor call_descriptor_; |
| 549 Register stack_parameter_count_; | 556 Register stack_parameter_count_; |
| 550 // If hint_stack_parameter_count_ > 0, the code stub can optimize the | 557 // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 551 // return sequence. Default value is -1, which means it is ignored. | 558 // return sequence. Default value is -1, which means it is ignored. |
| 552 int hint_stack_parameter_count_; | 559 int hint_stack_parameter_count_; |
| 553 StubFunctionMode function_mode_; | 560 StubFunctionMode function_mode_; |
| 554 | 561 |
| 555 Address deoptimization_handler_; | 562 Address deoptimization_handler_; |
| 556 | 563 |
| 557 ExternalReference miss_handler_; | 564 ExternalReference miss_handler_; |
| 565 Runtime::FunctionId miss_handler_id_; |
| 558 bool has_miss_handler_; | 566 bool has_miss_handler_; |
| 559 }; | 567 }; |
| 560 | 568 |
| 561 | 569 |
| 562 class HydrogenCodeStub : public CodeStub { | 570 class HydrogenCodeStub : public CodeStub { |
| 563 public: | 571 public: |
| 564 enum InitializationState { | 572 enum InitializationState { |
| 565 UNINITIALIZED, | 573 UNINITIALIZED, |
| 566 INITIALIZED | 574 INITIALIZED |
| 567 }; | 575 }; |
| 568 | 576 |
| 569 template<class SubClass> | 577 template<class SubClass> |
| 570 static Handle<Code> GetUninitialized(Isolate* isolate) { | 578 static Handle<Code> GetUninitialized(Isolate* isolate) { |
| 571 SubClass::GenerateAheadOfTime(isolate); | 579 SubClass::GenerateAheadOfTime(isolate); |
| 572 return SubClass().GetCode(isolate); | 580 return SubClass().GetCode(isolate); |
| 573 } | 581 } |
| 574 | 582 |
| 575 // Retrieve the code for the stub. Generate the code if needed. | 583 // Retrieve the code for the stub. Generate the code if needed. |
| 576 Handle<Code> GenerateCode() override = 0; | 584 Handle<Code> GenerateCode() override = 0; |
| 577 | 585 |
| 578 bool IsUninitialized() const { return IsMissBits::decode(minor_key_); } | 586 bool IsUninitialized() const { return IsMissBits::decode(minor_key_); } |
| 579 | 587 |
| 580 Handle<Code> GenerateLightweightMissCode(ExternalReference miss); | 588 Handle<Code> GenerateLightweightMissCode(ExternalReference miss); |
| 581 | 589 |
| 590 Handle<Code> GenerateRuntimeTailCall(CodeStubDescriptor* descriptor); |
| 591 |
| 582 template<class StateType> | 592 template<class StateType> |
| 583 void TraceTransition(StateType from, StateType to); | 593 void TraceTransition(StateType from, StateType to); |
| 584 | 594 |
| 585 protected: | 595 protected: |
| 586 explicit HydrogenCodeStub(Isolate* isolate, | 596 explicit HydrogenCodeStub(Isolate* isolate, |
| 587 InitializationState state = INITIALIZED) | 597 InitializationState state = INITIALIZED) |
| 588 : CodeStub(isolate) { | 598 : CodeStub(isolate) { |
| 589 minor_key_ = IsMissBits::encode(state == UNINITIALIZED); | 599 minor_key_ = IsMissBits::encode(state == UNINITIALIZED); |
| 590 } | 600 } |
| 591 | 601 |
| (...skipping 2529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3121 #undef DEFINE_HYDROGEN_CODE_STUB | 3131 #undef DEFINE_HYDROGEN_CODE_STUB |
| 3122 #undef DEFINE_CODE_STUB | 3132 #undef DEFINE_CODE_STUB |
| 3123 #undef DEFINE_CODE_STUB_BASE | 3133 #undef DEFINE_CODE_STUB_BASE |
| 3124 | 3134 |
| 3125 extern Representation RepresentationFromType(Type* type); | 3135 extern Representation RepresentationFromType(Type* type); |
| 3126 | 3136 |
| 3127 } // namespace internal | 3137 } // namespace internal |
| 3128 } // namespace v8 | 3138 } // namespace v8 |
| 3129 | 3139 |
| 3130 #endif // V8_CODE_STUBS_H_ | 3140 #endif // V8_CODE_STUBS_H_ |
| OLD | NEW |