| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   154  |   154  | 
|   155  |   155  | 
|   156 Node* CodeStubAssembler::SmiTag(Node* value) { |   156 Node* CodeStubAssembler::SmiTag(Node* value) { | 
|   157   return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); |   157   return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); | 
|   158 } |   158 } | 
|   159  |   159  | 
|   160 Node* CodeStubAssembler::SmiUntag(Node* value) { |   160 Node* CodeStubAssembler::SmiUntag(Node* value) { | 
|   161   return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); |   161   return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); | 
|   162 } |   162 } | 
|   163  |   163  | 
|   164 Node* CodeStubAssembler::SmiToInt32(Node* value) { |   164 Node* CodeStubAssembler::SmiToWord32(Node* value) { | 
|   165   Node* result = raw_assembler_->WordSar(value, SmiShiftBitsConstant()); |   165   Node* result = raw_assembler_->WordSar(value, SmiShiftBitsConstant()); | 
|   166   if (raw_assembler_->machine()->Is64()) { |   166   if (raw_assembler_->machine()->Is64()) { | 
|   167     result = raw_assembler_->TruncateInt64ToInt32(result); |   167     result = raw_assembler_->TruncateInt64ToInt32(result); | 
|   168   } |   168   } | 
|   169   return result; |   169   return result; | 
|   170 } |   170 } | 
|   171  |   171  | 
|   172 Node* CodeStubAssembler::SmiToFloat64(Node* value) { |   172 Node* CodeStubAssembler::SmiToFloat64(Node* value) { | 
|   173   return ChangeInt32ToFloat64(SmiUntag(value)); |   173   return ChangeInt32ToFloat64(SmiUntag(value)); | 
|   174 } |   174 } | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   252   return Load(MachineType::Float64(), object, |   252   return Load(MachineType::Float64(), object, | 
|   253               IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag)); |   253               IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag)); | 
|   254 } |   254 } | 
|   255  |   255  | 
|   256 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |   256 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 
|   257   return StoreNoWriteBarrier( |   257   return StoreNoWriteBarrier( | 
|   258       MachineRepresentation::kFloat64, object, |   258       MachineRepresentation::kFloat64, object, | 
|   259       IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); |   259       IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value); | 
|   260 } |   260 } | 
|   261  |   261  | 
|   262 Node* CodeStubAssembler::TruncateHeapNumberValueToInt32(Node* object) { |   262 Node* CodeStubAssembler::TruncateHeapNumberValueToWord32(Node* object) { | 
|   263   Node* value = LoadHeapNumberValue(object); |   263   Node* value = LoadHeapNumberValue(object); | 
|   264   return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript, |   264   return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript, | 
|   265                                                 value); |   265                                                 value); | 
|   266 } |   266 } | 
|   267  |   267  | 
|   268 Node* CodeStubAssembler::LoadMapBitField(Node* map) { |   268 Node* CodeStubAssembler::LoadMapBitField(Node* map) { | 
|   269   return Load(MachineType::Uint8(), map, |   269   return Load(MachineType::Uint8(), map, | 
|   270               IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag)); |   270               IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag)); | 
|   271 } |   271 } | 
|   272  |   272  | 
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   530   Bind(&if_notoverflow); |   530   Bind(&if_notoverflow); | 
|   531   { |   531   { | 
|   532     Node* result = Projection(0, pair); |   532     Node* result = Projection(0, pair); | 
|   533     var_result.Bind(result); |   533     var_result.Bind(result); | 
|   534   } |   534   } | 
|   535   Goto(&if_join); |   535   Goto(&if_join); | 
|   536   Bind(&if_join); |   536   Bind(&if_join); | 
|   537   return var_result.value(); |   537   return var_result.value(); | 
|   538 } |   538 } | 
|   539  |   539  | 
 |   540 Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) { | 
 |   541   // We might need to loop once due to ToNumber conversion. | 
 |   542   Variable var_value(this, MachineRepresentation::kTagged), | 
 |   543       var_result(this, MachineRepresentation::kFloat64); | 
 |   544   Label loop(this, &var_value), done_loop(this, &var_result); | 
 |   545   var_value.Bind(value); | 
 |   546   Goto(&loop); | 
 |   547   Bind(&loop); | 
 |   548   { | 
 |   549     // Load the current {value}. | 
 |   550     value = var_value.value(); | 
 |   551  | 
 |   552     // Check if the {value} is a Smi or a HeapObject. | 
 |   553     Label if_valueissmi(this), if_valueisnotsmi(this); | 
 |   554     Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi); | 
 |   555  | 
 |   556     Bind(&if_valueissmi); | 
 |   557     { | 
 |   558       // Convert the Smi {value}. | 
 |   559       var_result.Bind(SmiToFloat64(value)); | 
 |   560       Goto(&done_loop); | 
 |   561     } | 
 |   562  | 
 |   563     Bind(&if_valueisnotsmi); | 
 |   564     { | 
 |   565       // Check if {value} is a HeapNumber. | 
 |   566       Label if_valueisheapnumber(this), | 
 |   567           if_valueisnotheapnumber(this, Label::kDeferred); | 
 |   568       Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()), | 
 |   569              &if_valueisheapnumber, &if_valueisnotheapnumber); | 
 |   570  | 
 |   571       Bind(&if_valueisheapnumber); | 
 |   572       { | 
 |   573         // Load the floating point value. | 
 |   574         var_result.Bind(LoadHeapNumberValue(value)); | 
 |   575         Goto(&done_loop); | 
 |   576       } | 
 |   577  | 
 |   578       Bind(&if_valueisnotheapnumber); | 
 |   579       { | 
 |   580         // Convert the {value} to a Number first. | 
 |   581         Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 
 |   582         var_value.Bind(CallStub(callable, context, value)); | 
 |   583         Goto(&loop); | 
 |   584       } | 
 |   585     } | 
 |   586   } | 
 |   587   Bind(&done_loop); | 
 |   588   return var_result.value(); | 
 |   589 } | 
 |   590  | 
 |   591 Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) { | 
 |   592   // We might need to loop once due to ToNumber conversion. | 
 |   593   Variable var_value(this, MachineRepresentation::kTagged), | 
 |   594       var_result(this, MachineRepresentation::kWord32); | 
 |   595   Label loop(this, &var_value), done_loop(this, &var_result); | 
 |   596   var_value.Bind(value); | 
 |   597   Goto(&loop); | 
 |   598   Bind(&loop); | 
 |   599   { | 
 |   600     // Load the current {value}. | 
 |   601     value = var_value.value(); | 
 |   602  | 
 |   603     // Check if the {value} is a Smi or a HeapObject. | 
 |   604     Label if_valueissmi(this), if_valueisnotsmi(this); | 
 |   605     Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi); | 
 |   606  | 
 |   607     Bind(&if_valueissmi); | 
 |   608     { | 
 |   609       // Convert the Smi {value}. | 
 |   610       var_result.Bind(SmiToWord32(value)); | 
 |   611       Goto(&done_loop); | 
 |   612     } | 
 |   613  | 
 |   614     Bind(&if_valueisnotsmi); | 
 |   615     { | 
 |   616       // Check if {value} is a HeapNumber. | 
 |   617       Label if_valueisheapnumber(this), | 
 |   618           if_valueisnotheapnumber(this, Label::kDeferred); | 
 |   619       Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()), | 
 |   620              &if_valueisheapnumber, &if_valueisnotheapnumber); | 
 |   621  | 
 |   622       Bind(&if_valueisheapnumber); | 
 |   623       { | 
 |   624         // Truncate the floating point value. | 
 |   625         var_result.Bind(TruncateHeapNumberValueToWord32(value)); | 
 |   626         Goto(&done_loop); | 
 |   627       } | 
 |   628  | 
 |   629       Bind(&if_valueisnotheapnumber); | 
 |   630       { | 
 |   631         // Convert the {value} to a Number first. | 
 |   632         Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 
 |   633         var_value.Bind(CallStub(callable, context, value)); | 
 |   634         Goto(&loop); | 
 |   635       } | 
 |   636     } | 
 |   637   } | 
 |   638   Bind(&done_loop); | 
 |   639   return var_result.value(); | 
 |   640 } | 
 |   641  | 
|   540 void CodeStubAssembler::BranchIf(Node* condition, Label* if_true, |   642 void CodeStubAssembler::BranchIf(Node* condition, Label* if_true, | 
|   541                                  Label* if_false) { |   643                                  Label* if_false) { | 
|   542   Label if_condition_is_true(this), if_condition_is_false(this); |   644   Label if_condition_is_true(this), if_condition_is_false(this); | 
|   543   Branch(condition, &if_condition_is_true, &if_condition_is_false); |   645   Branch(condition, &if_condition_is_true, &if_condition_is_false); | 
|   544   Bind(&if_condition_is_true); |   646   Bind(&if_condition_is_true); | 
|   545   Goto(if_true); |   647   Goto(if_true); | 
|   546   Bind(&if_condition_is_false); |   648   Bind(&if_condition_is_false); | 
|   547   Goto(if_false); |   649   Goto(if_false); | 
|   548 } |   650 } | 
|   549  |   651  | 
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   948       } |  1050       } | 
|   949     } |  1051     } | 
|   950   } |  1052   } | 
|   951  |  1053  | 
|   952   bound_ = true; |  1054   bound_ = true; | 
|   953 } |  1055 } | 
|   954  |  1056  | 
|   955 }  // namespace compiler |  1057 }  // namespace compiler | 
|   956 }  // namespace internal |  1058 }  // namespace internal | 
|   957 }  // namespace v8 |  1059 }  // namespace v8 | 
| OLD | NEW |