OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/compiler/code-stub-assembler.h" | 5 #include "src/compiler/code-stub-assembler.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Node* CodeStubAssembler::SmiEqual(Node* a, Node* b) { return WordEqual(a, b); } | 164 Node* CodeStubAssembler::SmiEqual(Node* a, Node* b) { return WordEqual(a, b); } |
165 | 165 |
166 Node* CodeStubAssembler::SmiLessThan(Node* a, Node* b) { | 166 Node* CodeStubAssembler::SmiLessThan(Node* a, Node* b) { |
167 return IntPtrLessThan(a, b); | 167 return IntPtrLessThan(a, b); |
168 } | 168 } |
169 | 169 |
170 Node* CodeStubAssembler::SmiLessThanOrEqual(Node* a, Node* b) { | 170 Node* CodeStubAssembler::SmiLessThanOrEqual(Node* a, Node* b) { |
171 return IntPtrLessThanOrEqual(a, b); | 171 return IntPtrLessThanOrEqual(a, b); |
172 } | 172 } |
173 | 173 |
| 174 Node* CodeStubAssembler::SmiMin(Node* a, Node* b) { |
| 175 // TODO(bmeurer): Consider using Select once available. |
| 176 Variable min(this, MachineRepresentation::kTagged); |
| 177 Label if_a(this), if_b(this), join(this); |
| 178 BranchIfSmiLessThan(a, b, &if_a, &if_b); |
| 179 Bind(&if_a); |
| 180 min.Bind(a); |
| 181 Goto(&join); |
| 182 Bind(&if_b); |
| 183 min.Bind(b); |
| 184 Goto(&join); |
| 185 Bind(&join); |
| 186 return min.value(); |
| 187 } |
| 188 |
174 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \ | 189 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \ |
175 Node* CodeStubAssembler::name(Node* a, Node* b) { \ | 190 Node* CodeStubAssembler::name(Node* a, Node* b) { \ |
176 return raw_assembler_->name(a, b); \ | 191 return raw_assembler_->name(a, b); \ |
177 } | 192 } |
178 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP) | 193 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP) |
179 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP | 194 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP |
180 | 195 |
181 Node* CodeStubAssembler::WordShl(Node* value, int shift) { | 196 Node* CodeStubAssembler::WordShl(Node* value, int shift) { |
182 return raw_assembler_->WordShl(value, IntPtrConstant(shift)); | 197 return raw_assembler_->WordShl(value, IntPtrConstant(shift)); |
183 } | 198 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 return LoadMapInstanceType(LoadObjectField(object, HeapObject::kMapOffset)); | 432 return LoadMapInstanceType(LoadObjectField(object, HeapObject::kMapOffset)); |
418 } | 433 } |
419 | 434 |
420 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, | 435 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, |
421 uint32_t mask) { | 436 uint32_t mask) { |
422 return raw_assembler_->Word32Shr( | 437 return raw_assembler_->Word32Shr( |
423 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)), | 438 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)), |
424 raw_assembler_->Int32Constant(shift)); | 439 raw_assembler_->Int32Constant(shift)); |
425 } | 440 } |
426 | 441 |
| 442 void CodeStubAssembler::BranchIfInt32LessThan(Node* a, Node* b, Label* if_true, |
| 443 Label* if_false) { |
| 444 Label if_lessthan(this), if_notlessthan(this); |
| 445 Branch(Int32LessThan(a, b), &if_lessthan, &if_notlessthan); |
| 446 Bind(&if_lessthan); |
| 447 Goto(if_true); |
| 448 Bind(&if_notlessthan); |
| 449 Goto(if_false); |
| 450 } |
| 451 |
427 void CodeStubAssembler::BranchIfSmiLessThan(Node* a, Node* b, Label* if_true, | 452 void CodeStubAssembler::BranchIfSmiLessThan(Node* a, Node* b, Label* if_true, |
428 Label* if_false) { | 453 Label* if_false) { |
429 Label if_lessthan(this), if_notlessthan(this); | 454 Label if_lessthan(this), if_notlessthan(this); |
430 Branch(SmiLessThan(a, b), &if_lessthan, &if_notlessthan); | 455 Branch(SmiLessThan(a, b), &if_lessthan, &if_notlessthan); |
431 Bind(&if_lessthan); | 456 Bind(&if_lessthan); |
432 Goto(if_true); | 457 Goto(if_true); |
433 Bind(&if_notlessthan); | 458 Bind(&if_notlessthan); |
434 Goto(if_false); | 459 Goto(if_false); |
435 } | 460 } |
436 | 461 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 } | 927 } |
903 } | 928 } |
904 } | 929 } |
905 | 930 |
906 bound_ = true; | 931 bound_ = true; |
907 } | 932 } |
908 | 933 |
909 } // namespace compiler | 934 } // namespace compiler |
910 } // namespace internal | 935 } // namespace internal |
911 } // namespace v8 | 936 } // namespace v8 |
OLD | NEW |