OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 7842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7853 Node* one = Float64Constant(1.0); | 7853 Node* one = Float64Constant(1.0); |
7854 Node* finc_result = Float64Add(finc_value, one); | 7854 Node* finc_result = Float64Add(finc_value, one); |
7855 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); | 7855 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); |
7856 Goto(&end); | 7856 Goto(&end); |
7857 } | 7857 } |
7858 | 7858 |
7859 Bind(&end); | 7859 Bind(&end); |
7860 return var_result.value(); | 7860 return var_result.value(); |
7861 } | 7861 } |
7862 | 7862 |
| 7863 Node* CodeStubAssembler::NumberDec(Node* value) { |
| 7864 Variable var_result(this, MachineRepresentation::kTagged), |
| 7865 var_fdec_value(this, MachineRepresentation::kFloat64); |
| 7866 Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this); |
| 7867 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); |
| 7868 |
| 7869 Bind(&if_issmi); |
| 7870 { |
| 7871 // Try fast Smi addition first. |
| 7872 Node* one = SmiConstant(Smi::FromInt(1)); |
| 7873 Node* pair = IntPtrSubWithOverflow(BitcastTaggedToWord(value), |
| 7874 BitcastTaggedToWord(one)); |
| 7875 Node* overflow = Projection(1, pair); |
| 7876 |
| 7877 // Check if the Smi addition overflowed. |
| 7878 Label if_overflow(this), if_notoverflow(this); |
| 7879 Branch(overflow, &if_overflow, &if_notoverflow); |
| 7880 |
| 7881 Bind(&if_notoverflow); |
| 7882 var_result.Bind(BitcastWordToTaggedSigned(Projection(0, pair))); |
| 7883 Goto(&end); |
| 7884 |
| 7885 Bind(&if_overflow); |
| 7886 { |
| 7887 var_fdec_value.Bind(SmiToFloat64(value)); |
| 7888 Goto(&do_fdec); |
| 7889 } |
| 7890 } |
| 7891 |
| 7892 Bind(&if_isnotsmi); |
| 7893 { |
| 7894 // Check if the value is a HeapNumber. |
| 7895 CSA_ASSERT(this, IsHeapNumberMap(LoadMap(value))); |
| 7896 |
| 7897 // Load the HeapNumber value. |
| 7898 var_fdec_value.Bind(LoadHeapNumberValue(value)); |
| 7899 Goto(&do_fdec); |
| 7900 } |
| 7901 |
| 7902 Bind(&do_fdec); |
| 7903 { |
| 7904 Node* fdec_value = var_fdec_value.value(); |
| 7905 Node* minus_one = Float64Constant(-1.0); |
| 7906 Node* fdec_result = Float64Add(fdec_value, minus_one); |
| 7907 var_result.Bind(AllocateHeapNumberWithValue(fdec_result)); |
| 7908 Goto(&end); |
| 7909 } |
| 7910 |
| 7911 Bind(&end); |
| 7912 return var_result.value(); |
| 7913 } |
| 7914 |
7863 void CodeStubAssembler::GotoIfNotNumber(Node* input, Label* is_not_number) { | 7915 void CodeStubAssembler::GotoIfNotNumber(Node* input, Label* is_not_number) { |
7864 Label is_number(this); | 7916 Label is_number(this); |
7865 GotoIf(TaggedIsSmi(input), &is_number); | 7917 GotoIf(TaggedIsSmi(input), &is_number); |
7866 Node* input_map = LoadMap(input); | 7918 Node* input_map = LoadMap(input); |
7867 Branch(IsHeapNumberMap(input_map), &is_number, is_not_number); | 7919 Branch(IsHeapNumberMap(input_map), &is_number, is_not_number); |
7868 Bind(&is_number); | 7920 Bind(&is_number); |
7869 } | 7921 } |
7870 | 7922 |
7871 void CodeStubAssembler::GotoIfNumber(Node* input, Label* is_number) { | 7923 void CodeStubAssembler::GotoIfNumber(Node* input, Label* is_number) { |
7872 GotoIf(TaggedIsSmi(input), is_number); | 7924 GotoIf(TaggedIsSmi(input), is_number); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8287 formatted.c_str(), TENURED); | 8339 formatted.c_str(), TENURED); |
8288 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 8340 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
8289 HeapConstant(string)); | 8341 HeapConstant(string)); |
8290 } | 8342 } |
8291 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); | 8343 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); |
8292 #endif | 8344 #endif |
8293 } | 8345 } |
8294 | 8346 |
8295 } // namespace internal | 8347 } // namespace internal |
8296 } // namespace v8 | 8348 } // namespace v8 |
OLD | NEW |