| 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" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 Node* UntagParameter(Node* value, ParameterMode mode) { | 88 Node* UntagParameter(Node* value, ParameterMode mode) { |
| 89 if (mode != SMI_PARAMETERS) value = SmiUntag(value); | 89 if (mode != SMI_PARAMETERS) value = SmiUntag(value); |
| 90 return value; | 90 return value; |
| 91 } | 91 } |
| 92 | 92 |
| 93 Node* TagParameter(Node* value, ParameterMode mode) { | 93 Node* TagParameter(Node* value, ParameterMode mode) { |
| 94 if (mode != SMI_PARAMETERS) value = SmiTag(value); | 94 if (mode != SMI_PARAMETERS) value = SmiTag(value); |
| 95 return value; | 95 return value; |
| 96 } | 96 } |
| 97 | 97 |
| 98 #define PARAMETER_BINARY_OPERATION(OpName, IntPtrOpName, SmiOpName, \ | 98 #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName, Int32OpName) \ |
| 99 Int32OpName) \ | 99 Node* OpName(Node* a, Node* b, ParameterMode mode) { \ |
| 100 Node* OpName(Node* value1, Node* value2, ParameterMode mode) { \ | 100 if (mode == SMI_PARAMETERS) { \ |
| 101 if (mode == SMI_PARAMETERS) { \ | 101 return SmiOpName(a, b); \ |
| 102 return SmiOpName(value1, value2); \ | 102 } else if (mode == INTPTR_PARAMETERS) { \ |
| 103 } else if (mode == INTPTR_PARAMETERS) { \ | 103 return IntPtrOpName(a, b); \ |
| 104 return IntPtrOpName(value1, value2); \ | 104 } else { \ |
| 105 } else { \ | 105 DCHECK_EQ(INTEGER_PARAMETERS, mode); \ |
| 106 DCHECK_EQ(INTEGER_PARAMETERS, mode); \ | 106 return Int32OpName(a, b); \ |
| 107 return Int32OpName(value1, value2); \ | 107 } \ |
| 108 } \ | |
| 109 } | 108 } |
| 110 PARAMETER_BINARY_OPERATION(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd, Int32Add) | 109 PARAMETER_BINOP(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd, Int32Add) |
| 111 PARAMETER_BINARY_OPERATION(IntPtrOrSmiLessThan, IntPtrLessThan, SmiLessThan, | 110 PARAMETER_BINOP(IntPtrOrSmiLessThan, IntPtrLessThan, SmiLessThan, |
| 112 Int32LessThan) | 111 Int32LessThan) |
| 113 PARAMETER_BINARY_OPERATION(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, | 112 PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan, |
| 114 SmiGreaterThan, Int32GreaterThan) | 113 Int32GreaterThan) |
| 115 PARAMETER_BINARY_OPERATION(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow, | 114 PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow, |
| 116 Uint32LessThan) | 115 Uint32LessThan) |
| 117 | 116 PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual, |
| 118 #undef PARAMETER_BINARY_OPERATION | 117 SmiAboveOrEqual, Uint32GreaterThanOrEqual) |
| 118 #undef PARAMETER_BINOP |
| 119 | 119 |
| 120 Node* NoContextConstant(); | 120 Node* NoContextConstant(); |
| 121 #define HEAP_CONSTANT_ACCESSOR(rootName, name) Node* name##Constant(); | 121 #define HEAP_CONSTANT_ACCESSOR(rootName, name) Node* name##Constant(); |
| 122 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR) | 122 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR) |
| 123 #undef HEAP_CONSTANT_ACCESSOR | 123 #undef HEAP_CONSTANT_ACCESSOR |
| 124 | 124 |
| 125 #define HEAP_CONSTANT_TEST(rootName, name) Node* Is##name(Node* value); | 125 #define HEAP_CONSTANT_TEST(rootName, name) Node* Is##name(Node* value); |
| 126 HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) | 126 HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) |
| 127 #undef HEAP_CONSTANT_TEST | 127 #undef HEAP_CONSTANT_TEST |
| 128 | 128 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 150 Node* SmiUntag(Node* value); | 150 Node* SmiUntag(Node* value); |
| 151 | 151 |
| 152 // Smi conversions. | 152 // Smi conversions. |
| 153 Node* SmiToFloat64(Node* value); | 153 Node* SmiToFloat64(Node* value); |
| 154 Node* SmiFromWord(Node* value) { return SmiTag(value); } | 154 Node* SmiFromWord(Node* value) { return SmiTag(value); } |
| 155 Node* SmiFromWord32(Node* value); | 155 Node* SmiFromWord32(Node* value); |
| 156 Node* SmiToWord(Node* value) { return SmiUntag(value); } | 156 Node* SmiToWord(Node* value) { return SmiUntag(value); } |
| 157 Node* SmiToWord32(Node* value); | 157 Node* SmiToWord32(Node* value); |
| 158 | 158 |
| 159 // Smi operations. | 159 // Smi operations. |
| 160 Node* SmiAdd(Node* a, Node* b); | 160 #define SMI_ARITHMETIC_BINOP(SmiOpName, IntPtrOpName) \ |
| 161 Node* SmiSub(Node* a, Node* b); | 161 Node* SmiOpName(Node* a, Node* b) { \ |
| 162 Node* SmiEqual(Node* a, Node* b); | 162 return BitcastWordToTaggedSigned( \ |
| 163 Node* SmiAbove(Node* a, Node* b); | 163 IntPtrOpName(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); \ |
| 164 Node* SmiAboveOrEqual(Node* a, Node* b); | 164 } |
| 165 Node* SmiBelow(Node* a, Node* b); | 165 SMI_ARITHMETIC_BINOP(SmiAdd, IntPtrAdd) |
| 166 Node* SmiLessThan(Node* a, Node* b); | 166 SMI_ARITHMETIC_BINOP(SmiSub, IntPtrSub) |
| 167 Node* SmiLessThanOrEqual(Node* a, Node* b); | 167 SMI_ARITHMETIC_BINOP(SmiAnd, WordAnd) |
| 168 Node* SmiGreaterThan(Node* a, Node* b); | 168 SMI_ARITHMETIC_BINOP(SmiOr, WordOr) |
| 169 |
| 170 #define SMI_SHIFT_OP(SmiOpName, IntPtrOpName) \ |
| 171 Node* SmiOpName(Node* a, int shift) { \ |
| 172 return BitcastWordToTaggedSigned( \ |
| 173 IntPtrOpName(BitcastTaggedToWord(a), shift)); \ |
| 174 } \ |
| 175 SMI_ARITHMETIC_BINOP(SmiOpName, IntPtrOpName) |
| 176 |
| 177 SMI_SHIFT_OP(SmiShl, WordShl) |
| 178 SMI_SHIFT_OP(SmiShr, WordShr) |
| 179 #undef SMI_SHIFT_OP |
| 180 #undef SMI_ARITHMETIC_BINOP |
| 181 |
| 182 #define SMI_COMPARISON_OP(SmiOpName, IntPtrOpName) \ |
| 183 Node* SmiOpName(Node* a, Node* b) { \ |
| 184 return IntPtrOpName(BitcastTaggedToWord(a), BitcastTaggedToWord(b)); \ |
| 185 } |
| 186 SMI_COMPARISON_OP(SmiEqual, WordEqual) |
| 187 SMI_COMPARISON_OP(SmiAbove, UintPtrGreaterThan) |
| 188 SMI_COMPARISON_OP(SmiAboveOrEqual, UintPtrGreaterThanOrEqual) |
| 189 SMI_COMPARISON_OP(SmiBelow, UintPtrLessThan) |
| 190 SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan) |
| 191 SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual) |
| 192 SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan) |
| 193 #undef SMI_COMPARISON_OP |
| 169 Node* SmiMax(Node* a, Node* b); | 194 Node* SmiMax(Node* a, Node* b); |
| 170 Node* SmiMin(Node* a, Node* b); | 195 Node* SmiMin(Node* a, Node* b); |
| 171 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. | 196 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
| 172 Node* SmiMod(Node* a, Node* b); | 197 Node* SmiMod(Node* a, Node* b); |
| 173 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. | 198 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
| 174 Node* SmiMul(Node* a, Node* b); | 199 Node* SmiMul(Node* a, Node* b); |
| 175 Node* SmiOr(Node* a, Node* b) { | |
| 176 return BitcastWordToTaggedSigned( | |
| 177 WordOr(BitcastTaggedToWord(a), BitcastTaggedToWord(b))); | |
| 178 } | |
| 179 | 200 |
| 180 // Smi | HeapNumber operations. | 201 // Smi | HeapNumber operations. |
| 181 Node* NumberInc(Node* value); | 202 Node* NumberInc(Node* value); |
| 182 void GotoIfNotNumber(Node* value, Label* is_not_number); | 203 void GotoIfNotNumber(Node* value, Label* is_not_number); |
| 183 void GotoIfNumber(Node* value, Label* is_number); | 204 void GotoIfNumber(Node* value, Label* is_number); |
| 184 | 205 |
| 185 // Allocate an object of the given size. | 206 // Allocate an object of the given size. |
| 186 Node* Allocate(Node* size, AllocationFlags flags = kNone); | 207 Node* Allocate(Node* size, AllocationFlags flags = kNone); |
| 187 Node* Allocate(int size, AllocationFlags flags = kNone); | 208 Node* Allocate(int size, AllocationFlags flags = kNone); |
| 188 Node* InnerAllocate(Node* previous, int offset); | 209 Node* InnerAllocate(Node* previous, int offset); |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 return DecodeWord(word, T::kShift, T::kMask); | 722 return DecodeWord(word, T::kShift, T::kMask); |
| 702 } | 723 } |
| 703 | 724 |
| 704 // Returns a node that contains a decoded (unsigned!) value of a bit | 725 // Returns a node that contains a decoded (unsigned!) value of a bit |
| 705 // field |T| in |word32|. Returns result as a word-size node. | 726 // field |T| in |word32|. Returns result as a word-size node. |
| 706 template <typename T> | 727 template <typename T> |
| 707 Node* DecodeWordFromWord32(Node* word32) { | 728 Node* DecodeWordFromWord32(Node* word32) { |
| 708 return DecodeWord<T>(ChangeUint32ToWord(word32)); | 729 return DecodeWord<T>(ChangeUint32ToWord(word32)); |
| 709 } | 730 } |
| 710 | 731 |
| 732 // Returns a node that contains a decoded (unsigned!) value of a bit |
| 733 // field |T| in |word|. Returns result as an uint32 node. |
| 734 template <typename T> |
| 735 Node* DecodeWord32FromWord(Node* word) { |
| 736 return TruncateWordToWord32(DecodeWord<T>(word)); |
| 737 } |
| 738 |
| 711 // Decodes an unsigned (!) value from |word32| to an uint32 node. | 739 // Decodes an unsigned (!) value from |word32| to an uint32 node. |
| 712 Node* DecodeWord32(Node* word32, uint32_t shift, uint32_t mask); | 740 Node* DecodeWord32(Node* word32, uint32_t shift, uint32_t mask); |
| 713 | 741 |
| 714 // Decodes an unsigned (!) value from |word| to a word-size node. | 742 // Decodes an unsigned (!) value from |word| to a word-size node. |
| 715 Node* DecodeWord(Node* word, uint32_t shift, uint32_t mask); | 743 Node* DecodeWord(Node* word, uint32_t shift, uint32_t mask); |
| 716 | 744 |
| 717 // Returns true if any of the |T|'s bits in given |word32| are set. | 745 // Returns true if any of the |T|'s bits in given |word32| are set. |
| 718 template <typename T> | 746 template <typename T> |
| 719 Node* IsSetWord32(Node* word32) { | 747 Node* IsSetWord32(Node* word32) { |
| 720 return IsSetWord32(word32, T::kMask); | 748 return IsSetWord32(word32, T::kMask); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 Node* unique_name, Label* if_found_fast, | 882 Node* unique_name, Label* if_found_fast, |
| 855 Label* if_found_dict, Label* if_found_global, | 883 Label* if_found_dict, Label* if_found_global, |
| 856 Variable* var_meta_storage, Variable* var_name_index, | 884 Variable* var_meta_storage, Variable* var_name_index, |
| 857 Label* if_not_found, Label* if_bailout); | 885 Label* if_not_found, Label* if_bailout); |
| 858 | 886 |
| 859 void TryLookupElement(Node* object, Node* map, Node* instance_type, | 887 void TryLookupElement(Node* object, Node* map, Node* instance_type, |
| 860 Node* intptr_index, Label* if_found, | 888 Node* intptr_index, Label* if_found, |
| 861 Label* if_not_found, Label* if_bailout); | 889 Label* if_not_found, Label* if_bailout); |
| 862 | 890 |
| 863 // This is a type of a lookup in holder generator function. In case of a | 891 // This is a type of a lookup in holder generator function. In case of a |
| 864 // property lookup the {key} is guaranteed to be a unique name and in case of | 892 // property lookup the {key} is guaranteed to be an unique name and in case of |
| 865 // element lookup the key is an Int32 index. | 893 // element lookup the key is an Int32 index. |
| 866 typedef std::function<void(Node* receiver, Node* holder, Node* map, | 894 typedef std::function<void(Node* receiver, Node* holder, Node* map, |
| 867 Node* instance_type, Node* key, Label* next_holder, | 895 Node* instance_type, Node* key, Label* next_holder, |
| 868 Label* if_bailout)> | 896 Label* if_bailout)> |
| 869 LookupInHolder; | 897 LookupInHolder; |
| 870 | 898 |
| 871 // Generic property prototype chain lookup generator. | 899 // Generic property prototype chain lookup generator. |
| 872 // For properties it generates lookup using given {lookup_property_in_holder} | 900 // For properties it generates lookup using given {lookup_property_in_holder} |
| 873 // and for elements it uses {lookup_element_in_holder}. | 901 // and for elements it uses {lookup_element_in_holder}. |
| 874 // Upon reaching the end of prototype chain the control goes to {if_end}. | 902 // Upon reaching the end of prototype chain the control goes to {if_end}. |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 } | 1183 } |
| 1156 #else | 1184 #else |
| 1157 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 1185 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |
| 1158 #endif | 1186 #endif |
| 1159 | 1187 |
| 1160 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1188 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
| 1161 | 1189 |
| 1162 } // namespace internal | 1190 } // namespace internal |
| 1163 } // namespace v8 | 1191 } // namespace v8 |
| 1164 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1192 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |