| OLD | NEW | 
|    1 // Copyright 2014 the V8 project authors. All rights reserved. |    1 // Copyright 2014 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/change-lowering.h" |    5 #include "src/compiler/change-lowering.h" | 
|    6 #include "src/compiler/js-graph.h" |    6 #include "src/compiler/js-graph.h" | 
|    7 #include "src/compiler/node-properties-inl.h" |    7 #include "src/compiler/node-properties-inl.h" | 
|    8 #include "src/compiler/simplified-operator.h" |    8 #include "src/compiler/simplified-operator.h" | 
|    9 #include "src/compiler/typer.h" |    9 #include "src/compiler/typer.h" | 
|   10 #include "test/compiler-unittests/graph-unittest.h" |   10 #include "test/compiler-unittests/graph-unittest.h" | 
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  282                 IsControlEffect(CaptureEq(&if_true)))), |  282                 IsControlEffect(CaptureEq(&if_true)))), | 
|  283             IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), |  283             IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), | 
|  284             IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |  284             IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 
|  285                     IsIfFalse(AllOf( |  285                     IsIfFalse(AllOf( | 
|  286                         CaptureEq(&branch), |  286                         CaptureEq(&branch), | 
|  287                         IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), |  287                         IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), | 
|  288                                  graph()->start())))))); |  288                                  graph()->start())))))); | 
|  289 } |  289 } | 
|  290  |  290  | 
|  291  |  291  | 
 |  292 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { | 
 |  293   STATIC_ASSERT(kSmiTag == 0); | 
 |  294   STATIC_ASSERT(kSmiTagSize == 1); | 
 |  295  | 
 |  296   Node* val = Parameter(0); | 
 |  297   Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); | 
 |  298   Reduction reduction = Reduce(node); | 
 |  299   ASSERT_TRUE(reduction.Changed()); | 
 |  300  | 
 |  301   Node* phi = reduction.replacement(); | 
 |  302   Capture<Node*> branch, if_true; | 
 |  303   EXPECT_THAT( | 
 |  304       phi, | 
 |  305       IsPhi(IsTruncateFloat64ToInt32(IsLoad( | 
 |  306                 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), | 
 |  307                 IsControlEffect(CaptureEq(&if_true)))), | 
 |  308             IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), | 
 |  309             IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 
 |  310                     IsIfFalse(AllOf( | 
 |  311                         CaptureEq(&branch), | 
 |  312                         IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), | 
 |  313                                  graph()->start())))))); | 
 |  314 } | 
 |  315  | 
 |  316  | 
|  292 TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { |  317 TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { | 
|  293   STATIC_ASSERT(kSmiTag == 0); |  318   STATIC_ASSERT(kSmiTag == 0); | 
|  294   STATIC_ASSERT(kSmiTagSize == 1); |  319   STATIC_ASSERT(kSmiTagSize == 1); | 
|  295  |  320  | 
|  296   Node* val = Parameter(0); |  321   Node* val = Parameter(0); | 
|  297   Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val); |  322   Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val); | 
|  298   Reduction reduction = Reduce(node); |  323   Reduction reduction = Reduce(node); | 
|  299   ASSERT_TRUE(reduction.Changed()); |  324   ASSERT_TRUE(reduction.Changed()); | 
|  300  |  325  | 
|  301   Node* phi = reduction.replacement(); |  326   Node* phi = reduction.replacement(); | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  392             IsTruncateInt64ToInt32( |  417             IsTruncateInt64ToInt32( | 
|  393                 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), |  418                 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), | 
|  394             IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |  419             IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 
|  395                     IsIfFalse(AllOf( |  420                     IsIfFalse(AllOf( | 
|  396                         CaptureEq(&branch), |  421                         CaptureEq(&branch), | 
|  397                         IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), |  422                         IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), | 
|  398                                  graph()->start())))))); |  423                                  graph()->start())))))); | 
|  399 } |  424 } | 
|  400  |  425  | 
|  401  |  426  | 
 |  427 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { | 
 |  428   STATIC_ASSERT(kSmiTag == 0); | 
 |  429   STATIC_ASSERT(kSmiTagSize == 1); | 
 |  430  | 
 |  431   Node* val = Parameter(0); | 
 |  432   Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); | 
 |  433   Reduction reduction = Reduce(node); | 
 |  434   ASSERT_TRUE(reduction.Changed()); | 
 |  435  | 
 |  436   Node* phi = reduction.replacement(); | 
 |  437   Capture<Node*> branch, if_true; | 
 |  438   EXPECT_THAT( | 
 |  439       phi, | 
 |  440       IsPhi(IsTruncateFloat64ToInt32(IsLoad( | 
 |  441                 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), | 
 |  442                 IsControlEffect(CaptureEq(&if_true)))), | 
 |  443             IsTruncateInt64ToInt32( | 
 |  444                 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), | 
 |  445             IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 
 |  446                     IsIfFalse(AllOf( | 
 |  447                         CaptureEq(&branch), | 
 |  448                         IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), | 
 |  449                                  graph()->start())))))); | 
 |  450 } | 
 |  451  | 
 |  452  | 
|  402 TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) { |  453 TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) { | 
|  403   STATIC_ASSERT(kSmiTag == 0); |  454   STATIC_ASSERT(kSmiTag == 0); | 
|  404   STATIC_ASSERT(kSmiTagSize == 1); |  455   STATIC_ASSERT(kSmiTagSize == 1); | 
|  405  |  456  | 
|  406   Node* val = Parameter(0); |  457   Node* val = Parameter(0); | 
|  407   Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val); |  458   Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val); | 
|  408   Reduction reduction = Reduce(node); |  459   Reduction reduction = Reduce(node); | 
|  409   ASSERT_TRUE(reduction.Changed()); |  460   ASSERT_TRUE(reduction.Changed()); | 
|  410  |  461  | 
|  411   Node* phi = reduction.replacement(); |  462   Node* phi = reduction.replacement(); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  426               IsIfTrue(AllOf(CaptureEq(&branch), |  477               IsIfTrue(AllOf(CaptureEq(&branch), | 
|  427                              IsBranch(IsUint32LessThanOrEqual( |  478                              IsBranch(IsUint32LessThanOrEqual( | 
|  428                                           val, IsInt32Constant(SmiMaxValue())), |  479                                           val, IsInt32Constant(SmiMaxValue())), | 
|  429                                       graph()->start()))), |  480                                       graph()->start()))), | 
|  430               AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |  481               AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 
|  431 } |  482 } | 
|  432  |  483  | 
|  433 }  // namespace compiler |  484 }  // namespace compiler | 
|  434 }  // namespace internal |  485 }  // namespace internal | 
|  435 }  // namespace v8 |  486 }  // namespace v8 | 
| OLD | NEW |