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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 V(StringLessThan, Operator::kNoProperties, 2) \ | 298 V(StringLessThan, Operator::kNoProperties, 2) \ |
299 V(StringLessThanOrEqual, Operator::kNoProperties, 2) | 299 V(StringLessThanOrEqual, Operator::kNoProperties, 2) |
300 | 300 |
301 #define SPECULATIVE_BINOP_LIST(V) \ | 301 #define SPECULATIVE_BINOP_LIST(V) \ |
302 V(SpeculativeNumberAdd) \ | 302 V(SpeculativeNumberAdd) \ |
303 V(SpeculativeNumberSubtract) \ | 303 V(SpeculativeNumberSubtract) \ |
304 V(SpeculativeNumberDivide) \ | 304 V(SpeculativeNumberDivide) \ |
305 V(SpeculativeNumberMultiply) \ | 305 V(SpeculativeNumberMultiply) \ |
306 V(SpeculativeNumberModulus) | 306 V(SpeculativeNumberModulus) |
307 | 307 |
308 #define CHECKED_OP_LIST(V) \ | 308 #define CHECKED_OP_LIST(V) \ |
309 V(CheckNumber, 1) \ | 309 V(CheckBounds, 2, 1) \ |
310 V(CheckTaggedPointer, 1) \ | 310 V(CheckIf, 1, 0) \ |
311 V(CheckTaggedSigned, 1) \ | 311 V(CheckNumber, 1, 1) \ |
312 V(CheckedInt32Add, 2) \ | 312 V(CheckTaggedPointer, 1, 1) \ |
313 V(CheckedInt32Sub, 2) \ | 313 V(CheckTaggedSigned, 1, 1) \ |
314 V(CheckedUint32ToInt32, 1) \ | 314 V(CheckedInt32Add, 2, 1) \ |
315 V(CheckedFloat64ToInt32, 1) \ | 315 V(CheckedInt32Sub, 2, 1) \ |
316 V(CheckedTaggedToInt32, 1) \ | 316 V(CheckedUint32ToInt32, 1, 1) \ |
317 V(CheckedTaggedToFloat64, 1) | 317 V(CheckedFloat64ToInt32, 1, 1) \ |
| 318 V(CheckedTaggedToInt32, 1, 1) \ |
| 319 V(CheckedTaggedToFloat64, 1, 1) |
318 | 320 |
319 struct SimplifiedOperatorGlobalCache final { | 321 struct SimplifiedOperatorGlobalCache final { |
320 #define PURE(Name, properties, input_count) \ | 322 #define PURE(Name, properties, input_count) \ |
321 struct Name##Operator final : public Operator { \ | 323 struct Name##Operator final : public Operator { \ |
322 Name##Operator() \ | 324 Name##Operator() \ |
323 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 325 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
324 input_count, 0, 0, 1, 0, 0) {} \ | 326 input_count, 0, 0, 1, 0, 0) {} \ |
325 }; \ | 327 }; \ |
326 Name##Operator k##Name; | 328 Name##Operator k##Name; |
327 PURE_OP_LIST(PURE) | 329 PURE_OP_LIST(PURE) |
328 #undef PURE | 330 #undef PURE |
329 | 331 |
330 #define CHECKED(Name, value_input_count) \ | 332 #define CHECKED(Name, value_input_count, value_output_count) \ |
331 struct Name##Operator final : public Operator { \ | 333 struct Name##Operator final : public Operator { \ |
332 Name##Operator() \ | 334 Name##Operator() \ |
333 : Operator(IrOpcode::k##Name, \ | 335 : Operator(IrOpcode::k##Name, \ |
334 Operator::kFoldable | Operator::kNoThrow, #Name, \ | 336 Operator::kFoldable | Operator::kNoThrow, #Name, \ |
335 value_input_count, 1, 1, 1, 1, 0) {} \ | 337 value_input_count, 1, 1, value_output_count, 1, 0) {} \ |
336 }; \ | 338 }; \ |
337 Name##Operator k##Name; | 339 Name##Operator k##Name; |
338 CHECKED_OP_LIST(CHECKED) | 340 CHECKED_OP_LIST(CHECKED) |
339 #undef CHECKED | 341 #undef CHECKED |
340 | 342 |
341 template <CheckFloat64HoleMode kMode> | 343 template <CheckFloat64HoleMode kMode> |
342 struct CheckFloat64HoleNaNOperator final | 344 struct CheckFloat64HoleNaNOperator final |
343 : public Operator1<CheckFloat64HoleMode> { | 345 : public Operator1<CheckFloat64HoleMode> { |
344 CheckFloat64HoleNaNOperator() | 346 CheckFloat64HoleNaNOperator() |
345 : Operator1<CheckFloat64HoleMode>( | 347 : Operator1<CheckFloat64HoleMode>( |
346 IrOpcode::kCheckFloat64Hole, | 348 IrOpcode::kCheckFloat64Hole, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 407 |
406 | 408 |
407 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) | 409 SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone) |
408 : cache_(kCache.Get()), zone_(zone) {} | 410 : cache_(kCache.Get()), zone_(zone) {} |
409 | 411 |
410 #define GET_FROM_CACHE(Name, properties, input_count) \ | 412 #define GET_FROM_CACHE(Name, properties, input_count) \ |
411 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 413 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
412 PURE_OP_LIST(GET_FROM_CACHE) | 414 PURE_OP_LIST(GET_FROM_CACHE) |
413 #undef GET_FROM_CACHE | 415 #undef GET_FROM_CACHE |
414 | 416 |
415 #define GET_FROM_CACHE(Name, value_input_count) \ | 417 #define GET_FROM_CACHE(Name, value_input_count, value_output_count) \ |
416 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 418 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
417 CHECKED_OP_LIST(GET_FROM_CACHE) | 419 CHECKED_OP_LIST(GET_FROM_CACHE) |
418 #undef GET_FROM_CACHE | 420 #undef GET_FROM_CACHE |
419 | 421 |
420 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( | 422 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( |
421 CheckFloat64HoleMode mode) { | 423 CheckFloat64HoleMode mode) { |
422 switch (mode) { | 424 switch (mode) { |
423 case CheckFloat64HoleMode::kAllowReturnHole: | 425 case CheckFloat64HoleMode::kAllowReturnHole: |
424 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; | 426 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; |
425 case CheckFloat64HoleMode::kNeverReturnHole: | 427 case CheckFloat64HoleMode::kNeverReturnHole: |
(...skipping 14 matching lines...) Expand all Loading... |
440 UNREACHABLE(); | 442 UNREACHABLE(); |
441 return nullptr; | 443 return nullptr; |
442 } | 444 } |
443 | 445 |
444 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 446 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
445 return new (zone()) Operator(IrOpcode::kReferenceEqual, | 447 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
446 Operator::kCommutative | Operator::kPure, | 448 Operator::kCommutative | Operator::kPure, |
447 "ReferenceEqual", 2, 0, 0, 1, 0, 0); | 449 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
448 } | 450 } |
449 | 451 |
450 const Operator* SimplifiedOperatorBuilder::CheckBounds() { | |
451 // TODO(bmeurer): Cache this operator. Make it pure! | |
452 return new (zone()) | |
453 Operator(IrOpcode::kCheckBounds, Operator::kFoldable | Operator::kNoThrow, | |
454 "CheckBounds", 2, 1, 1, 1, 1, 0); | |
455 } | |
456 | |
457 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { | 452 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { |
458 switch (pretenure) { | 453 switch (pretenure) { |
459 case NOT_TENURED: | 454 case NOT_TENURED: |
460 return &cache_.kAllocateNotTenuredOperator; | 455 return &cache_.kAllocateNotTenuredOperator; |
461 case TENURED: | 456 case TENURED: |
462 return &cache_.kAllocateTenuredOperator; | 457 return &cache_.kAllocateTenuredOperator; |
463 } | 458 } |
464 UNREACHABLE(); | 459 UNREACHABLE(); |
465 return nullptr; | 460 return nullptr; |
466 } | 461 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 Operator::kNoDeopt | Operator::kNoThrow | properties, \ | 534 Operator::kNoDeopt | Operator::kNoThrow | properties, \ |
540 #Name, value_input_count, 1, control_input_count, \ | 535 #Name, value_input_count, 1, control_input_count, \ |
541 output_count, 1, 0, access); \ | 536 output_count, 1, 0, access); \ |
542 } | 537 } |
543 ACCESS_OP_LIST(ACCESS) | 538 ACCESS_OP_LIST(ACCESS) |
544 #undef ACCESS | 539 #undef ACCESS |
545 | 540 |
546 } // namespace compiler | 541 } // namespace compiler |
547 } // namespace internal | 542 } // namespace internal |
548 } // namespace v8 | 543 } // namespace v8 |
OLD | NEW |