OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
11 #include "src/objects.h" | 11 #include "src/objects.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 class CallInterfaceDescriptor; | 16 class CallInterfaceDescriptor; |
17 class StatsCounter; | 17 class StatsCounter; |
18 class StubCache; | 18 class StubCache; |
19 | 19 |
20 enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; | 20 enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; |
21 | 21 |
22 // Provides JavaScript-specific "macro-assembler" functionality on top of the | 22 // Provides JavaScript-specific "macro-assembler" functionality on top of the |
23 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, | 23 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, |
24 // it's possible to add JavaScript-specific useful CodeAssembler "macros" | 24 // it's possible to add JavaScript-specific useful CodeAssembler "macros" |
25 // without modifying files in the compiler directory (and requiring a review | 25 // without modifying files in the compiler directory (and requiring a review |
26 // from a compiler directory OWNER). | 26 // from a compiler directory OWNER). |
27 class CodeStubAssembler : public compiler::CodeAssembler { | 27 class CodeStubAssembler : public compiler::CodeAssembler { |
28 public: | 28 public: |
| 29 class VectorSlotPair final { |
| 30 public: |
| 31 VectorSlotPair() : vector_(nullptr), index_(nullptr) {} |
| 32 VectorSlotPair(compiler::Node* vector, compiler::Node* index) |
| 33 : vector_(vector), index_(index) { |
| 34 DCHECK_NOT_NULL(vector); |
| 35 DCHECK_NOT_NULL(index); |
| 36 } |
| 37 |
| 38 bool IsValid() const { return vector_ != nullptr; } |
| 39 compiler::Node* vector() const { return vector_; } |
| 40 compiler::Node* index() const { return index_; } |
| 41 |
| 42 private: |
| 43 compiler::Node* const vector_; |
| 44 compiler::Node* const index_; |
| 45 }; |
| 46 |
29 // Create with CallStub linkage. | 47 // Create with CallStub linkage. |
30 // |result_size| specifies the number of results returned by the stub. | 48 // |result_size| specifies the number of results returned by the stub. |
31 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. | 49 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
32 CodeStubAssembler(Isolate* isolate, Zone* zone, | 50 CodeStubAssembler(Isolate* isolate, Zone* zone, |
33 const CallInterfaceDescriptor& descriptor, | 51 const CallInterfaceDescriptor& descriptor, |
34 Code::Flags flags, const char* name, | 52 Code::Flags flags, const char* name, |
35 size_t result_size = 1); | 53 size_t result_size = 1); |
36 | 54 |
37 // Create with JSCall linkage. | 55 // Create with JSCall linkage. |
38 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, | 56 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 // Upon reaching the end of prototype chain the control goes to {if_end}. | 638 // Upon reaching the end of prototype chain the control goes to {if_end}. |
621 // If it can't handle the case {receiver}/{key} case then the control goes | 639 // If it can't handle the case {receiver}/{key} case then the control goes |
622 // to {if_bailout}. | 640 // to {if_bailout}. |
623 void TryPrototypeChainLookup(compiler::Node* receiver, compiler::Node* key, | 641 void TryPrototypeChainLookup(compiler::Node* receiver, compiler::Node* key, |
624 LookupInHolder& lookup_property_in_holder, | 642 LookupInHolder& lookup_property_in_holder, |
625 LookupInHolder& lookup_element_in_holder, | 643 LookupInHolder& lookup_element_in_holder, |
626 Label* if_end, Label* if_bailout); | 644 Label* if_end, Label* if_bailout); |
627 | 645 |
628 // Instanceof helpers. | 646 // Instanceof helpers. |
629 // ES6 section 7.3.19 OrdinaryHasInstance (C, O) | 647 // ES6 section 7.3.19 OrdinaryHasInstance (C, O) |
630 compiler::Node* OrdinaryHasInstance(compiler::Node* context, | 648 compiler::Node* OrdinaryHasInstance( |
631 compiler::Node* callable, | 649 compiler::Node* context, compiler::Node* callable, compiler::Node* object, |
632 compiler::Node* object); | 650 VectorSlotPair feedback = VectorSlotPair()); |
633 | 651 |
634 // LoadIC helpers. | 652 // LoadIC helpers. |
635 struct LoadICParameters { | 653 struct LoadICParameters { |
636 LoadICParameters(compiler::Node* context, compiler::Node* receiver, | 654 LoadICParameters(compiler::Node* context, compiler::Node* receiver, |
637 compiler::Node* name, compiler::Node* slot, | 655 compiler::Node* name, compiler::Node* slot, |
638 compiler::Node* vector) | 656 compiler::Node* vector) |
639 : context(context), | 657 : context(context), |
640 receiver(receiver), | 658 receiver(receiver), |
641 name(name), | 659 name(name), |
642 slot(slot), | 660 slot(slot), |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 Label* bailout); | 861 Label* bailout); |
844 | 862 |
845 static const int kElementLoopUnrollThreshold = 8; | 863 static const int kElementLoopUnrollThreshold = 8; |
846 }; | 864 }; |
847 | 865 |
848 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 866 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
849 | 867 |
850 } // namespace internal | 868 } // namespace internal |
851 } // namespace v8 | 869 } // namespace v8 |
852 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 870 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |