OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/simplified-operator.h" | 5 #include "src/compiler/simplified-operator.h" |
6 | 6 |
7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 #include "src/types.h" | 10 #include "src/types.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return OpParameter<CheckTaggedHoleMode>(op); | 212 return OpParameter<CheckTaggedHoleMode>(op); |
213 } | 213 } |
214 | 214 |
215 Type* TypeOf(const Operator* op) { | 215 Type* TypeOf(const Operator* op) { |
216 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode()); | 216 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode()); |
217 return OpParameter<Type*>(op); | 217 return OpParameter<Type*>(op); |
218 } | 218 } |
219 | 219 |
220 BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) { | 220 BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) { |
221 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd || | 221 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd || |
222 op->opcode() == IrOpcode::kSpeculativeNumberSubtract); | 222 op->opcode() == IrOpcode::kSpeculativeNumberSubtract || |
| 223 op->opcode() == IrOpcode::kSpeculativeNumberMultiply || |
| 224 op->opcode() == IrOpcode::kSpeculativeNumberDivide || |
| 225 op->opcode() == IrOpcode::kSpeculativeNumberModulus); |
223 return OpParameter<BinaryOperationHints::Hint>(op); | 226 return OpParameter<BinaryOperationHints::Hint>(op); |
224 } | 227 } |
225 | 228 |
226 CompareOperationHints::Hint CompareOperationHintOf(const Operator* op) { | 229 CompareOperationHints::Hint CompareOperationHintOf(const Operator* op) { |
227 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberEqual || | 230 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberEqual || |
228 op->opcode() == IrOpcode::kSpeculativeNumberLessThan || | 231 op->opcode() == IrOpcode::kSpeculativeNumberLessThan || |
229 op->opcode() == IrOpcode::kSpeculativeNumberLessThanOrEqual); | 232 op->opcode() == IrOpcode::kSpeculativeNumberLessThanOrEqual); |
230 return OpParameter<CompareOperationHints::Hint>(op); | 233 return OpParameter<CompareOperationHints::Hint>(op); |
231 } | 234 } |
232 | 235 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 V(ObjectIsCallable, Operator::kNoProperties, 1) \ | 291 V(ObjectIsCallable, Operator::kNoProperties, 1) \ |
289 V(ObjectIsNumber, Operator::kNoProperties, 1) \ | 292 V(ObjectIsNumber, Operator::kNoProperties, 1) \ |
290 V(ObjectIsReceiver, Operator::kNoProperties, 1) \ | 293 V(ObjectIsReceiver, Operator::kNoProperties, 1) \ |
291 V(ObjectIsSmi, Operator::kNoProperties, 1) \ | 294 V(ObjectIsSmi, Operator::kNoProperties, 1) \ |
292 V(ObjectIsString, Operator::kNoProperties, 1) \ | 295 V(ObjectIsString, Operator::kNoProperties, 1) \ |
293 V(ObjectIsUndetectable, Operator::kNoProperties, 1) \ | 296 V(ObjectIsUndetectable, Operator::kNoProperties, 1) \ |
294 V(StringEqual, Operator::kCommutative, 2) \ | 297 V(StringEqual, Operator::kCommutative, 2) \ |
295 V(StringLessThan, Operator::kNoProperties, 2) \ | 298 V(StringLessThan, Operator::kNoProperties, 2) \ |
296 V(StringLessThanOrEqual, Operator::kNoProperties, 2) | 299 V(StringLessThanOrEqual, Operator::kNoProperties, 2) |
297 | 300 |
| 301 #define SPECULATIVE_BINOP_LIST(V) \ |
| 302 V(SpeculativeNumberAdd) \ |
| 303 V(SpeculativeNumberSubtract) \ |
| 304 V(SpeculativeNumberDivide) \ |
| 305 V(SpeculativeNumberMultiply) \ |
| 306 V(SpeculativeNumberModulus) |
| 307 |
298 #define CHECKED_OP_LIST(V) \ | 308 #define CHECKED_OP_LIST(V) \ |
299 V(CheckedUint32ToInt32) \ | 309 V(CheckedUint32ToInt32) \ |
300 V(CheckedFloat64ToInt32) \ | 310 V(CheckedFloat64ToInt32) \ |
301 V(CheckedTaggedToInt32) \ | 311 V(CheckedTaggedToInt32) \ |
302 V(CheckedTaggedToFloat64) | 312 V(CheckedTaggedToFloat64) |
303 | 313 |
304 struct SimplifiedOperatorGlobalCache final { | 314 struct SimplifiedOperatorGlobalCache final { |
305 #define PURE(Name, properties, input_count) \ | 315 #define PURE(Name, properties, input_count) \ |
306 struct Name##Operator final : public Operator { \ | 316 struct Name##Operator final : public Operator { \ |
307 Name##Operator() \ | 317 Name##Operator() \ |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 #define STORE_BUFFER(Type, type, TYPE, ctype, size) \ | 499 #define STORE_BUFFER(Type, type, TYPE, ctype, size) \ |
490 case kExternal##Type##Array: \ | 500 case kExternal##Type##Array: \ |
491 return &cache_.kStoreBuffer##Type; | 501 return &cache_.kStoreBuffer##Type; |
492 TYPED_ARRAYS(STORE_BUFFER) | 502 TYPED_ARRAYS(STORE_BUFFER) |
493 #undef STORE_BUFFER | 503 #undef STORE_BUFFER |
494 } | 504 } |
495 UNREACHABLE(); | 505 UNREACHABLE(); |
496 return nullptr; | 506 return nullptr; |
497 } | 507 } |
498 | 508 |
499 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberAdd( | 509 #define SPECULATIVE_BINOP_DEF(Name) \ |
500 BinaryOperationHints::Hint hint) { | 510 const Operator* SimplifiedOperatorBuilder::Name( \ |
501 return new (zone()) Operator1<BinaryOperationHints::Hint>( | 511 BinaryOperationHints::Hint hint) { \ |
502 IrOpcode::kSpeculativeNumberAdd, Operator::kPure, "SpeculativeNumberAdd", | 512 return new (zone()) Operator1<BinaryOperationHints::Hint>( \ |
503 2, 1, 1, 1, 1, 1, hint); | 513 IrOpcode::k##Name, Operator::kPure, #Name, 2, 1, 1, 1, 1, 1, hint); \ |
504 } | 514 } |
505 | 515 SPECULATIVE_BINOP_LIST(SPECULATIVE_BINOP_DEF) |
506 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberSubtract( | 516 #undef SPECULATIVE_BINOP_DEF |
507 BinaryOperationHints::Hint hint) { | |
508 return new (zone()) Operator1<BinaryOperationHints::Hint>( | |
509 IrOpcode::kSpeculativeNumberSubtract, Operator::kPure, | |
510 "SpeculativeNumberSubtract", 2, 1, 1, 1, 1, 1, hint); | |
511 } | |
512 | 517 |
513 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberEqual( | 518 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberEqual( |
514 CompareOperationHints::Hint hint) { | 519 CompareOperationHints::Hint hint) { |
515 return new (zone()) Operator1<CompareOperationHints::Hint>( | 520 return new (zone()) Operator1<CompareOperationHints::Hint>( |
516 IrOpcode::kSpeculativeNumberEqual, Operator::kPure, | 521 IrOpcode::kSpeculativeNumberEqual, Operator::kPure, |
517 "SpeculativeNumberEqual", 2, 1, 1, 1, 1, 1, hint); | 522 "SpeculativeNumberEqual", 2, 1, 1, 1, 1, 1, hint); |
518 } | 523 } |
519 | 524 |
520 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberLessThan( | 525 const Operator* SimplifiedOperatorBuilder::SpeculativeNumberLessThan( |
521 CompareOperationHints::Hint hint) { | 526 CompareOperationHints::Hint hint) { |
(...skipping 23 matching lines...) Expand all Loading... |
545 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 550 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
546 #Name, value_input_count, 1, control_input_count, \ | 551 #Name, value_input_count, 1, control_input_count, \ |
547 output_count, 1, 0, access); \ | 552 output_count, 1, 0, access); \ |
548 } | 553 } |
549 ACCESS_OP_LIST(ACCESS) | 554 ACCESS_OP_LIST(ACCESS) |
550 #undef ACCESS | 555 #undef ACCESS |
551 | 556 |
552 } // namespace compiler | 557 } // namespace compiler |
553 } // namespace internal | 558 } // namespace internal |
554 } // namespace v8 | 559 } // namespace v8 |
OLD | NEW |