Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/code-stub-assembler.h

Issue 2573573004: [stubs] Enable graph verification for builtins. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ParameterMode OptimalParameterMode() const { 78 ParameterMode OptimalParameterMode() const {
79 return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS; 79 return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS;
80 } 80 }
81 81
82 MachineRepresentation OptimalParameterRepresentation() const { 82 MachineRepresentation OptimalParameterRepresentation() const {
83 return OptimalParameterMode() == INTPTR_PARAMETERS 83 return OptimalParameterMode() == INTPTR_PARAMETERS
84 ? MachineType::PointerRepresentation() 84 ? MachineType::PointerRepresentation()
85 : MachineRepresentation::kTaggedSigned; 85 : MachineRepresentation::kTaggedSigned;
86 } 86 }
87 87
88 Node* UntagParameter(Node* value, ParameterMode mode) { 88 Node* ParameterToWord(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* WordToParameter(Node* value, ParameterMode mode) {
94 if (mode == SMI_PARAMETERS) value = SmiTag(value);
95 return value;
96 }
97
98 Node* ParameterToTagged(Node* value, ParameterMode mode) {
94 if (mode != SMI_PARAMETERS) value = SmiTag(value); 99 if (mode != SMI_PARAMETERS) value = SmiTag(value);
95 return value; 100 return value;
96 } 101 }
97 102
103 Node* TaggedToParameter(Node* value, ParameterMode mode) {
104 if (mode != SMI_PARAMETERS) value = SmiUntag(value);
105 return value;
106 }
107
98 #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName, Int32OpName) \ 108 #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName, Int32OpName) \
99 Node* OpName(Node* a, Node* b, ParameterMode mode) { \ 109 Node* OpName(Node* a, Node* b, ParameterMode mode) { \
100 if (mode == SMI_PARAMETERS) { \ 110 if (mode == SMI_PARAMETERS) { \
101 return SmiOpName(a, b); \ 111 return SmiOpName(a, b); \
102 } else if (mode == INTPTR_PARAMETERS) { \ 112 } else if (mode == INTPTR_PARAMETERS) { \
103 return IntPtrOpName(a, b); \ 113 return IntPtrOpName(a, b); \
104 } else { \ 114 } else { \
105 DCHECK_EQ(INTEGER_PARAMETERS, mode); \ 115 DCHECK_EQ(INTEGER_PARAMETERS, mode); \
106 return Int32OpName(a, b); \ 116 return Int32OpName(a, b); \
107 } \ 117 } \
108 } 118 }
109 PARAMETER_BINOP(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd, Int32Add) 119 PARAMETER_BINOP(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd, Int32Add)
110 PARAMETER_BINOP(IntPtrOrSmiLessThan, IntPtrLessThan, SmiLessThan, 120 PARAMETER_BINOP(IntPtrOrSmiLessThan, IntPtrLessThan, SmiLessThan,
111 Int32LessThan) 121 Int32LessThan)
112 PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan, 122 PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan,
113 Int32GreaterThan) 123 Int32GreaterThan)
124 PARAMETER_BINOP(IntPtrOrSmiGreaterThanOrEqual, IntPtrGreaterThanOrEqual,
125 SmiGreaterThanOrEqual, Int32GreaterThanOrEqual)
114 PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow, 126 PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow,
115 Uint32LessThan) 127 Uint32LessThan)
116 PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual, 128 PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual,
117 SmiAboveOrEqual, Uint32GreaterThanOrEqual) 129 SmiAboveOrEqual, Uint32GreaterThanOrEqual)
118 #undef PARAMETER_BINOP 130 #undef PARAMETER_BINOP
119 131
120 Node* NoContextConstant(); 132 Node* NoContextConstant();
121 #define HEAP_CONSTANT_ACCESSOR(rootName, name) Node* name##Constant(); 133 #define HEAP_CONSTANT_ACCESSOR(rootName, name) Node* name##Constant();
122 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR) 134 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR)
123 #undef HEAP_CONSTANT_ACCESSOR 135 #undef HEAP_CONSTANT_ACCESSOR
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 Node* SmiOpName(Node* a, Node* b) { \ 195 Node* SmiOpName(Node* a, Node* b) { \
184 return IntPtrOpName(BitcastTaggedToWord(a), BitcastTaggedToWord(b)); \ 196 return IntPtrOpName(BitcastTaggedToWord(a), BitcastTaggedToWord(b)); \
185 } 197 }
186 SMI_COMPARISON_OP(SmiEqual, WordEqual) 198 SMI_COMPARISON_OP(SmiEqual, WordEqual)
187 SMI_COMPARISON_OP(SmiAbove, UintPtrGreaterThan) 199 SMI_COMPARISON_OP(SmiAbove, UintPtrGreaterThan)
188 SMI_COMPARISON_OP(SmiAboveOrEqual, UintPtrGreaterThanOrEqual) 200 SMI_COMPARISON_OP(SmiAboveOrEqual, UintPtrGreaterThanOrEqual)
189 SMI_COMPARISON_OP(SmiBelow, UintPtrLessThan) 201 SMI_COMPARISON_OP(SmiBelow, UintPtrLessThan)
190 SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan) 202 SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan)
191 SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual) 203 SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual)
192 SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan) 204 SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan)
205 SMI_COMPARISON_OP(SmiGreaterThanOrEqual, IntPtrGreaterThanOrEqual)
193 #undef SMI_COMPARISON_OP 206 #undef SMI_COMPARISON_OP
194 Node* SmiMax(Node* a, Node* b); 207 Node* SmiMax(Node* a, Node* b);
195 Node* SmiMin(Node* a, Node* b); 208 Node* SmiMin(Node* a, Node* b);
196 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. 209 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi.
197 Node* SmiMod(Node* a, Node* b); 210 Node* SmiMod(Node* a, Node* b);
198 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. 211 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi.
199 Node* SmiMul(Node* a, Node* b); 212 Node* SmiMul(Node* a, Node* b);
200 213
201 // Smi | HeapNumber operations. 214 // Smi | HeapNumber operations.
202 Node* NumberInc(Node* value); 215 Node* NumberInc(Node* value);
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 763
751 // Returns true if any of the mask's bits in given |word32| are set. 764 // Returns true if any of the mask's bits in given |word32| are set.
752 Node* IsSetWord32(Node* word32, uint32_t mask) { 765 Node* IsSetWord32(Node* word32, uint32_t mask) {
753 return Word32NotEqual(Word32And(word32, Int32Constant(mask)), 766 return Word32NotEqual(Word32And(word32, Int32Constant(mask)),
754 Int32Constant(0)); 767 Int32Constant(0));
755 } 768 }
756 769
757 // Returns true if any of the |T|'s bits in given |word| are set. 770 // Returns true if any of the |T|'s bits in given |word| are set.
758 template <typename T> 771 template <typename T>
759 Node* IsSetWord(Node* word) { 772 Node* IsSetWord(Node* word) {
760 return WordNotEqual(WordAnd(word, IntPtrConstant(T::kMask)), 773 return IsSetWord(word, T::kMask);
761 IntPtrConstant(0));
762 } 774 }
763 775
764 // Returns true if any of the mask's bits in given |word| are set. 776 // Returns true if any of the mask's bits in given |word| are set.
765 Node* IsSetWord(Node* word, uint32_t mask) { 777 Node* IsSetWord(Node* word, uint32_t mask) {
766 return WordNotEqual(WordAnd(word, Int32Constant(mask)), Int32Constant(0)); 778 return WordNotEqual(WordAnd(word, IntPtrConstant(mask)), IntPtrConstant(0));
767 } 779 }
768 780
769 void SetCounter(StatsCounter* counter, int value); 781 void SetCounter(StatsCounter* counter, int value);
770 void IncrementCounter(StatsCounter* counter, int delta); 782 void IncrementCounter(StatsCounter* counter, int delta);
771 void DecrementCounter(StatsCounter* counter, int delta); 783 void DecrementCounter(StatsCounter* counter, int delta);
772 784
773 void Increment(Variable& variable, int value = 1, 785 void Increment(Variable& variable, int value = 1,
774 ParameterMode mode = INTPTR_PARAMETERS); 786 ParameterMode mode = INTPTR_PARAMETERS);
775 787
776 // Generates "if (false) goto label" code. Useful for marking a label as 788 // Generates "if (false) goto label" code. Useful for marking a label as
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 Node* AllocateConsString(Heap::RootListIndex map_root_index, Node* length, 1144 Node* AllocateConsString(Heap::RootListIndex map_root_index, Node* length,
1133 Node* first, Node* second, AllocationFlags flags); 1145 Node* first, Node* second, AllocationFlags flags);
1134 1146
1135 static const int kElementLoopUnrollThreshold = 8; 1147 static const int kElementLoopUnrollThreshold = 8;
1136 }; 1148 };
1137 1149
1138 class CodeStubArguments { 1150 class CodeStubArguments {
1139 public: 1151 public:
1140 typedef compiler::Node Node; 1152 typedef compiler::Node Node;
1141 1153
1142 // |argc| specifies the number of arguments passed to the builtin excluding 1154 // |argc| is an uint32 value which specifies the number of arguments passed
1143 // the receiver. 1155 // to the builtin excluding the receiver.
1144 CodeStubArguments(CodeStubAssembler* assembler, Node* argc, 1156 CodeStubArguments(CodeStubAssembler* assembler, Node* argc);
1145 CodeStubAssembler::ParameterMode mode =
1146 CodeStubAssembler::INTPTR_PARAMETERS);
1147 1157
1148 Node* GetReceiver() const; 1158 Node* GetReceiver() const;
1149 1159
1150 // |index| is zero-based and does not include the receiver 1160 // |index| is zero-based and does not include the receiver
1151 Node* AtIndex(Node* index, CodeStubAssembler::ParameterMode mode = 1161 Node* AtIndex(Node* index, CodeStubAssembler::ParameterMode mode =
1152 CodeStubAssembler::INTPTR_PARAMETERS) const; 1162 CodeStubAssembler::INTPTR_PARAMETERS) const;
1153 1163
1154 Node* AtIndex(int index) const; 1164 Node* AtIndex(int index) const;
1155 1165
1156 Node* GetLength() const { return argc_; } 1166 Node* GetLength() const { return argc_; }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 } 1206 }
1197 #else 1207 #else
1198 #define CSA_SLOW_ASSERT(csa, x) ((void)0) 1208 #define CSA_SLOW_ASSERT(csa, x) ((void)0)
1199 #endif 1209 #endif
1200 1210
1201 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); 1211 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags);
1202 1212
1203 } // namespace internal 1213 } // namespace internal
1204 } // namespace v8 1214 } // namespace v8
1205 #endif // V8_CODE_STUB_ASSEMBLER_H_ 1215 #endif // V8_CODE_STUB_ASSEMBLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698