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 enum class IterationKind { kKeys, kValues, kEntries }; |
| 24 |
23 #define HEAP_CONSTANT_LIST(V) \ | 25 #define HEAP_CONSTANT_LIST(V) \ |
24 V(BooleanMap, BooleanMap) \ | 26 V(BooleanMap, BooleanMap) \ |
25 V(empty_string, EmptyString) \ | 27 V(empty_string, EmptyString) \ |
26 V(EmptyFixedArray, EmptyFixedArray) \ | 28 V(EmptyFixedArray, EmptyFixedArray) \ |
27 V(FalseValue, False) \ | 29 V(FalseValue, False) \ |
28 V(FixedArrayMap, FixedArrayMap) \ | 30 V(FixedArrayMap, FixedArrayMap) \ |
29 V(FixedCOWArrayMap, FixedCOWArrayMap) \ | 31 V(FixedCOWArrayMap, FixedCOWArrayMap) \ |
30 V(FixedDoubleArrayMap, FixedDoubleArrayMap) \ | 32 V(FixedDoubleArrayMap, FixedDoubleArrayMap) \ |
31 V(HeapNumberMap, HeapNumberMap) \ | 33 V(HeapNumberMap, HeapNumberMap) \ |
32 V(MinusZeroValue, MinusZero) \ | 34 V(MinusZeroValue, MinusZero) \ |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); | 135 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); |
134 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. | 136 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
135 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); | 137 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); |
136 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. | 138 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
137 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); | 139 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); |
138 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { | 140 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { |
139 return BitcastWordToTaggedSigned( | 141 return BitcastWordToTaggedSigned( |
140 WordOr(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); | 142 WordOr(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); |
141 } | 143 } |
142 | 144 |
| 145 // Smi | HeapNumber operations. |
| 146 compiler::Node* NumberInc(compiler::Node* value); |
| 147 |
143 // Allocate an object of the given size. | 148 // Allocate an object of the given size. |
144 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); | 149 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); |
145 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); | 150 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); |
146 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); | 151 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); |
147 compiler::Node* InnerAllocate(compiler::Node* previous, | 152 compiler::Node* InnerAllocate(compiler::Node* previous, |
148 compiler::Node* offset); | 153 compiler::Node* offset); |
149 | 154 |
150 void Assert(compiler::Node* condition, const char* string = nullptr, | 155 void Assert(compiler::Node* condition, const char* string = nullptr, |
151 const char* file = nullptr, int line = 0); | 156 const char* file = nullptr, int line = 0); |
152 | 157 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 int additional_offset = 0, | 294 int additional_offset = 0, |
290 ParameterMode parameter_mode = INTEGER_PARAMETERS, | 295 ParameterMode parameter_mode = INTEGER_PARAMETERS, |
291 Label* if_hole = nullptr); | 296 Label* if_hole = nullptr); |
292 | 297 |
293 // Load Float64 value by |base| + |offset| address. If the value is a double | 298 // Load Float64 value by |base| + |offset| address. If the value is a double |
294 // hole then jump to |if_hole|. If |machine_type| is None then only the hole | 299 // hole then jump to |if_hole|. If |machine_type| is None then only the hole |
295 // check is generated. | 300 // check is generated. |
296 compiler::Node* LoadDoubleWithHoleCheck( | 301 compiler::Node* LoadDoubleWithHoleCheck( |
297 compiler::Node* base, compiler::Node* offset, Label* if_hole, | 302 compiler::Node* base, compiler::Node* offset, Label* if_hole, |
298 MachineType machine_type = MachineType::Float64()); | 303 MachineType machine_type = MachineType::Float64()); |
| 304 compiler::Node* LoadFixedTypedArrayElement( |
| 305 compiler::Node* data_pointer, compiler::Node* index_node, |
| 306 ElementsKind elements_kind, |
| 307 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
299 | 308 |
300 // Context manipulation | 309 // Context manipulation |
301 compiler::Node* LoadContextElement(compiler::Node* context, int slot_index); | 310 compiler::Node* LoadContextElement(compiler::Node* context, int slot_index); |
302 compiler::Node* StoreContextElement(compiler::Node* context, int slot_index, | 311 compiler::Node* StoreContextElement(compiler::Node* context, int slot_index, |
303 compiler::Node* value); | 312 compiler::Node* value); |
304 compiler::Node* LoadNativeContext(compiler::Node* context); | 313 compiler::Node* LoadNativeContext(compiler::Node* context); |
305 | 314 |
306 compiler::Node* LoadJSArrayElementsMap(ElementsKind kind, | 315 compiler::Node* LoadJSArrayElementsMap(ElementsKind kind, |
307 compiler::Node* native_context); | 316 compiler::Node* native_context); |
308 | 317 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 compiler::Node* AllocateJSArray( | 409 compiler::Node* AllocateJSArray( |
401 ElementsKind kind, compiler::Node* array_map, compiler::Node* capacity, | 410 ElementsKind kind, compiler::Node* array_map, compiler::Node* capacity, |
402 compiler::Node* length, compiler::Node* allocation_site = nullptr, | 411 compiler::Node* length, compiler::Node* allocation_site = nullptr, |
403 ParameterMode capacity_mode = INTEGER_PARAMETERS); | 412 ParameterMode capacity_mode = INTEGER_PARAMETERS); |
404 | 413 |
405 compiler::Node* AllocateFixedArray(ElementsKind kind, | 414 compiler::Node* AllocateFixedArray(ElementsKind kind, |
406 compiler::Node* capacity, | 415 compiler::Node* capacity, |
407 ParameterMode mode = INTEGER_PARAMETERS, | 416 ParameterMode mode = INTEGER_PARAMETERS, |
408 AllocationFlags flags = kNone); | 417 AllocationFlags flags = kNone); |
409 | 418 |
| 419 // Perform CreateArrayIterator (ES6 #sec-createarrayiterator). |
| 420 compiler::Node* CreateArrayIterator(compiler::Node* array, |
| 421 compiler::Node* array_map, |
| 422 compiler::Node* array_type, |
| 423 compiler::Node* context, |
| 424 IterationKind mode); |
| 425 |
| 426 compiler::Node* AllocateJSArrayIterator(compiler::Node* array, |
| 427 compiler::Node* array_map, |
| 428 compiler::Node* map); |
| 429 |
410 void FillFixedArrayWithValue(ElementsKind kind, compiler::Node* array, | 430 void FillFixedArrayWithValue(ElementsKind kind, compiler::Node* array, |
411 compiler::Node* from_index, | 431 compiler::Node* from_index, |
412 compiler::Node* to_index, | 432 compiler::Node* to_index, |
413 Heap::RootListIndex value_root_index, | 433 Heap::RootListIndex value_root_index, |
414 ParameterMode mode = INTEGER_PARAMETERS); | 434 ParameterMode mode = INTEGER_PARAMETERS); |
415 | 435 |
416 // Copies all elements from |from_array| of |length| size to | 436 // Copies all elements from |from_array| of |length| size to |
417 // |to_array| of the same size respecting the elements kind. | 437 // |to_array| of the same size respecting the elements kind. |
418 void CopyFixedArrayElements( | 438 void CopyFixedArrayElements( |
419 ElementsKind kind, compiler::Node* from_array, compiler::Node* to_array, | 439 ElementsKind kind, compiler::Node* from_array, compiler::Node* to_array, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 kLessThan, | 921 kLessThan, |
902 kLessThanOrEqual, | 922 kLessThanOrEqual, |
903 kGreaterThan, | 923 kGreaterThan, |
904 kGreaterThanOrEqual | 924 kGreaterThanOrEqual |
905 }; | 925 }; |
906 | 926 |
907 compiler::Node* RelationalComparison(RelationalComparisonMode mode, | 927 compiler::Node* RelationalComparison(RelationalComparisonMode mode, |
908 compiler::Node* lhs, compiler::Node* rhs, | 928 compiler::Node* lhs, compiler::Node* rhs, |
909 compiler::Node* context); | 929 compiler::Node* context); |
910 | 930 |
| 931 void BranchIfNumericRelationalComparison(RelationalComparisonMode mode, |
| 932 compiler::Node* lhs, |
| 933 compiler::Node* rhs, Label* if_true, |
| 934 Label* if_false); |
| 935 |
| 936 void GotoUnlessNumberLessThan(compiler::Node* lhs, compiler::Node* rhs, |
| 937 Label* if_false); |
| 938 |
911 enum ResultMode { kDontNegateResult, kNegateResult }; | 939 enum ResultMode { kDontNegateResult, kNegateResult }; |
912 | 940 |
913 compiler::Node* Equal(ResultMode mode, compiler::Node* lhs, | 941 compiler::Node* Equal(ResultMode mode, compiler::Node* lhs, |
914 compiler::Node* rhs, compiler::Node* context); | 942 compiler::Node* rhs, compiler::Node* context); |
915 | 943 |
916 compiler::Node* StrictEqual(ResultMode mode, compiler::Node* lhs, | 944 compiler::Node* StrictEqual(ResultMode mode, compiler::Node* lhs, |
917 compiler::Node* rhs, compiler::Node* context); | 945 compiler::Node* rhs, compiler::Node* context); |
918 | 946 |
919 compiler::Node* HasProperty( | 947 compiler::Node* HasProperty( |
920 compiler::Node* object, compiler::Node* key, compiler::Node* context, | 948 compiler::Node* object, compiler::Node* key, compiler::Node* context, |
921 Runtime::FunctionId fallback_runtime_function_id = Runtime::kHasProperty); | 949 Runtime::FunctionId fallback_runtime_function_id = Runtime::kHasProperty); |
922 compiler::Node* ForInFilter(compiler::Node* key, compiler::Node* object, | 950 compiler::Node* ForInFilter(compiler::Node* key, compiler::Node* object, |
923 compiler::Node* context); | 951 compiler::Node* context); |
924 | 952 |
925 compiler::Node* Typeof(compiler::Node* value, compiler::Node* context); | 953 compiler::Node* Typeof(compiler::Node* value, compiler::Node* context); |
926 | 954 |
927 compiler::Node* InstanceOf(compiler::Node* object, compiler::Node* callable, | 955 compiler::Node* InstanceOf(compiler::Node* object, compiler::Node* callable, |
928 compiler::Node* context); | 956 compiler::Node* context); |
929 | 957 |
| 958 // TypedArray/ArrayBuffer helpers |
| 959 compiler::Node* IsDetachedBuffer(compiler::Node* buffer); |
| 960 |
930 private: | 961 private: |
931 enum ElementSupport { kOnlyProperties, kSupportElements }; | 962 enum ElementSupport { kOnlyProperties, kSupportElements }; |
932 | 963 |
933 void DescriptorLookupLinear(compiler::Node* unique_name, | 964 void DescriptorLookupLinear(compiler::Node* unique_name, |
934 compiler::Node* descriptors, compiler::Node* nof, | 965 compiler::Node* descriptors, compiler::Node* nof, |
935 Label* if_found, Variable* var_name_index, | 966 Label* if_found, Variable* var_name_index, |
936 Label* if_not_found); | 967 Label* if_not_found); |
937 compiler::Node* CallGetterIfAccessor(compiler::Node* value, | 968 compiler::Node* CallGetterIfAccessor(compiler::Node* value, |
938 compiler::Node* details, | 969 compiler::Node* details, |
939 compiler::Node* context, | 970 compiler::Node* context, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 static const int kElementLoopUnrollThreshold = 8; | 1022 static const int kElementLoopUnrollThreshold = 8; |
992 }; | 1023 }; |
993 | 1024 |
994 #define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__) | 1025 #define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__) |
995 | 1026 |
996 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1027 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
997 | 1028 |
998 } // namespace internal | 1029 } // namespace internal |
999 } // namespace v8 | 1030 } // namespace v8 |
1000 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1031 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |