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/globals.h" | 11 #include "src/globals.h" |
12 #include "src/objects.h" | 12 #include "src/objects.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 class CallInterfaceDescriptor; | 17 class CallInterfaceDescriptor; |
18 class StatsCounter; | 18 class StatsCounter; |
19 class StubCache; | 19 class StubCache; |
20 | 20 |
21 enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; | 21 enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; |
22 | 22 |
23 #define HEAP_CONSTANT_LIST(V) \ | 23 #define HEAP_CONSTANT_LIST(V) \ |
24 V(AccessorPairMap, AccessorPairMap) \ | 24 V(BooleanMap, BooleanMap) \ |
25 V(BooleanMap, BooleanMap) \ | 25 V(CodeMap, CodeMap) \ |
26 V(CodeMap, CodeMap) \ | 26 V(empty_string, EmptyString) \ |
27 V(empty_string, EmptyString) \ | 27 V(EmptyFixedArray, EmptyFixedArray) \ |
28 V(EmptyFixedArray, EmptyFixedArray) \ | 28 V(FalseValue, False) \ |
29 V(FalseValue, False) \ | 29 V(FixedArrayMap, FixedArrayMap) \ |
30 V(FixedArrayMap, FixedArrayMap) \ | 30 V(FixedCOWArrayMap, FixedCOWArrayMap) \ |
31 V(FixedCOWArrayMap, FixedCOWArrayMap) \ | 31 V(FixedDoubleArrayMap, FixedDoubleArrayMap) \ |
32 V(FixedDoubleArrayMap, FixedDoubleArrayMap) \ | 32 V(HeapNumberMap, HeapNumberMap) \ |
33 V(FunctionTemplateInfoMap, FunctionTemplateInfoMap) \ | 33 V(MinusZeroValue, MinusZero) \ |
34 V(HeapNumberMap, HeapNumberMap) \ | 34 V(NanValue, Nan) \ |
35 V(MinusZeroValue, MinusZero) \ | 35 V(NullValue, Null) \ |
36 V(NanValue, Nan) \ | 36 V(TheHoleValue, TheHole) \ |
37 V(NullValue, Null) \ | 37 V(TrueValue, True) \ |
38 V(SymbolMap, SymbolMap) \ | |
39 V(TheHoleValue, TheHole) \ | |
40 V(TrueValue, True) \ | |
41 V(UndefinedValue, Undefined) | 38 V(UndefinedValue, Undefined) |
42 | 39 |
43 // Provides JavaScript-specific "macro-assembler" functionality on top of the | 40 // Provides JavaScript-specific "macro-assembler" functionality on top of the |
44 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, | 41 // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, |
45 // it's possible to add JavaScript-specific useful CodeAssembler "macros" | 42 // it's possible to add JavaScript-specific useful CodeAssembler "macros" |
46 // without modifying files in the compiler directory (and requiring a review | 43 // without modifying files in the compiler directory (and requiring a review |
47 // from a compiler directory OWNER). | 44 // from a compiler directory OWNER). |
48 class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { | 45 class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { |
49 public: | 46 public: |
50 CodeStubAssembler(compiler::CodeAssemblerState* state) | 47 CodeStubAssembler(compiler::CodeAssemblerState* state) |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 compiler::Node* object, compiler::Node* offset, compiler::Node* value, | 350 compiler::Node* object, compiler::Node* offset, compiler::Node* value, |
354 MachineRepresentation rep = MachineRepresentation::kTagged); | 351 MachineRepresentation rep = MachineRepresentation::kTagged); |
355 // Store the Map of an HeapObject. | 352 // Store the Map of an HeapObject. |
356 compiler::Node* StoreMapNoWriteBarrier(compiler::Node* object, | 353 compiler::Node* StoreMapNoWriteBarrier(compiler::Node* object, |
357 compiler::Node* map); | 354 compiler::Node* map); |
358 compiler::Node* StoreObjectFieldRoot(compiler::Node* object, int offset, | 355 compiler::Node* StoreObjectFieldRoot(compiler::Node* object, int offset, |
359 Heap::RootListIndex root); | 356 Heap::RootListIndex root); |
360 // Store an array element to a FixedArray. | 357 // Store an array element to a FixedArray. |
361 compiler::Node* StoreFixedArrayElement( | 358 compiler::Node* StoreFixedArrayElement( |
362 compiler::Node* object, int index, compiler::Node* value, | 359 compiler::Node* object, int index, compiler::Node* value, |
363 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) { | 360 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
364 return StoreFixedArrayElement(object, IntPtrConstant(index), value, | 361 ParameterMode parameter_mode = INTEGER_PARAMETERS) { |
365 barrier_mode, 0, INTPTR_PARAMETERS); | 362 return StoreFixedArrayElement(object, Int32Constant(index), value, |
| 363 barrier_mode, parameter_mode); |
366 } | 364 } |
367 | 365 |
368 compiler::Node* StoreFixedArrayElement( | 366 compiler::Node* StoreFixedArrayElement( |
369 compiler::Node* object, compiler::Node* index, compiler::Node* value, | 367 compiler::Node* object, compiler::Node* index, compiler::Node* value, |
370 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 368 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
371 int additional_offset = 0, | |
372 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 369 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
373 | 370 |
374 compiler::Node* StoreFixedDoubleArrayElement( | 371 compiler::Node* StoreFixedDoubleArrayElement( |
375 compiler::Node* object, compiler::Node* index, compiler::Node* value, | 372 compiler::Node* object, compiler::Node* index, compiler::Node* value, |
376 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 373 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
377 | 374 |
378 void StoreFieldsNoWriteBarrier(compiler::Node* start_address, | 375 void StoreFieldsNoWriteBarrier(compiler::Node* start_address, |
379 compiler::Node* end_address, | 376 compiler::Node* end_address, |
380 compiler::Node* value); | 377 compiler::Node* value); |
381 | 378 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // See Dictionary::EntryToIndex(). | 755 // See Dictionary::EntryToIndex(). |
759 template <typename Dictionary> | 756 template <typename Dictionary> |
760 compiler::Node* EntryToIndex(compiler::Node* entry, int field_index); | 757 compiler::Node* EntryToIndex(compiler::Node* entry, int field_index); |
761 template <typename Dictionary> | 758 template <typename Dictionary> |
762 compiler::Node* EntryToIndex(compiler::Node* entry) { | 759 compiler::Node* EntryToIndex(compiler::Node* entry) { |
763 return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex); | 760 return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex); |
764 } | 761 } |
765 // Calculate a valid size for the a hash table. | 762 // Calculate a valid size for the a hash table. |
766 compiler::Node* HashTableComputeCapacity(compiler::Node* at_least_space_for); | 763 compiler::Node* HashTableComputeCapacity(compiler::Node* at_least_space_for); |
767 | 764 |
768 template <class Dictionary> | |
769 compiler::Node* GetNumberOfElements(compiler::Node* dictionary); | |
770 | |
771 template <class Dictionary> | |
772 void SetNumberOfElements(compiler::Node* dictionary, | |
773 compiler::Node* num_elements_smi); | |
774 | |
775 template <class Dictionary> | |
776 compiler::Node* GetCapacity(compiler::Node* dictionary); | |
777 | |
778 template <class Dictionary> | |
779 compiler::Node* GetNextEnumerationIndex(compiler::Node* dictionary); | |
780 | |
781 template <class Dictionary> | |
782 void SetNextEnumerationIndex(compiler::Node* dictionary, | |
783 compiler::Node* next_enum_index_smi); | |
784 | |
785 // Looks up an entry in a NameDictionaryBase successor. If the entry is found | 765 // Looks up an entry in a NameDictionaryBase successor. If the entry is found |
786 // control goes to {if_found} and {var_name_index} contains an index of the | 766 // control goes to {if_found} and {var_name_index} contains an index of the |
787 // key field of the entry found. If the key is not found control goes to | 767 // key field of the entry found. If the key is not found control goes to |
788 // {if_not_found}. | 768 // {if_not_found}. |
789 static const int kInlinedDictionaryProbes = 4; | 769 static const int kInlinedDictionaryProbes = 4; |
790 enum LookupMode { kFindExisting, kFindInsertionIndex }; | |
791 template <typename Dictionary> | 770 template <typename Dictionary> |
792 void NameDictionaryLookup(compiler::Node* dictionary, | 771 void NameDictionaryLookup(compiler::Node* dictionary, |
793 compiler::Node* unique_name, Label* if_found, | 772 compiler::Node* unique_name, Label* if_found, |
794 Variable* var_name_index, Label* if_not_found, | 773 Variable* var_name_index, Label* if_not_found, |
795 int inlined_probes = kInlinedDictionaryProbes, | 774 int inlined_probes = kInlinedDictionaryProbes); |
796 LookupMode mode = kFindExisting); | |
797 | 775 |
798 compiler::Node* ComputeIntegerHash(compiler::Node* key, compiler::Node* seed); | 776 compiler::Node* ComputeIntegerHash(compiler::Node* key, compiler::Node* seed); |
799 | 777 |
800 template <typename Dictionary> | 778 template <typename Dictionary> |
801 void NumberDictionaryLookup(compiler::Node* dictionary, | 779 void NumberDictionaryLookup(compiler::Node* dictionary, |
802 compiler::Node* intptr_index, Label* if_found, | 780 compiler::Node* intptr_index, Label* if_found, |
803 Variable* var_entry, Label* if_not_found); | 781 Variable* var_entry, Label* if_not_found); |
804 | 782 |
805 template <class Dictionary> | |
806 void FindInsertionEntry(compiler::Node* dictionary, compiler::Node* key, | |
807 Variable* var_key_index); | |
808 | |
809 template <class Dictionary> | |
810 void InsertEntry(compiler::Node* dictionary, compiler::Node* key, | |
811 compiler::Node* value, compiler::Node* index, | |
812 compiler::Node* enum_index); | |
813 | |
814 template <class Dictionary> | |
815 void Add(compiler::Node* dictionary, compiler::Node* key, | |
816 compiler::Node* value, Label* bailout); | |
817 | |
818 // Tries to check if {object} has own {unique_name} property. | 783 // Tries to check if {object} has own {unique_name} property. |
819 void TryHasOwnProperty(compiler::Node* object, compiler::Node* map, | 784 void TryHasOwnProperty(compiler::Node* object, compiler::Node* map, |
820 compiler::Node* instance_type, | 785 compiler::Node* instance_type, |
821 compiler::Node* unique_name, Label* if_found, | 786 compiler::Node* unique_name, Label* if_found, |
822 Label* if_not_found, Label* if_bailout); | 787 Label* if_not_found, Label* if_bailout); |
823 | 788 |
824 // Tries to get {object}'s own {unique_name} property value. If the property | 789 // Tries to get {object}'s own {unique_name} property value. If the property |
825 // is an accessor then it also calls a getter. If the property is a double | 790 // is an accessor then it also calls a getter. If the property is a double |
826 // field it re-wraps value in an immutable heap number. | 791 // field it re-wraps value in an immutable heap number. |
827 void TryGetOwnProperty(compiler::Node* context, compiler::Node* receiver, | 792 void TryGetOwnProperty(compiler::Node* context, compiler::Node* receiver, |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 } | 1175 } |
1211 #else | 1176 #else |
1212 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 1177 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |
1213 #endif | 1178 #endif |
1214 | 1179 |
1215 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1180 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
1216 | 1181 |
1217 } // namespace internal | 1182 } // namespace internal |
1218 } // namespace v8 | 1183 } // namespace v8 |
1219 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1184 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |