Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: src/code-stub-assembler.cc

Issue 2380543002: [stubs] Don't unconditionally canonicalize in ChangeFloat64ToTagged. (Closed)
Patch Set: REBASE Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 #include "src/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/frames.h" 8 #include "src/frames.h"
9 #include "src/ic/handler-configuration.h" 9 #include "src/ic/handler-configuration.h"
10 #include "src/ic/stub-cache.h" 10 #include "src/ic/stub-cache.h"
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 } 1863 }
1864 Bind(&done_loop); 1864 Bind(&done_loop);
1865 return var_result.value(); 1865 return var_result.value();
1866 } 1866 }
1867 1867
1868 Node* CodeStubAssembler::TruncateHeapNumberValueToWord32(Node* object) { 1868 Node* CodeStubAssembler::TruncateHeapNumberValueToWord32(Node* object) {
1869 Node* value = LoadHeapNumberValue(object); 1869 Node* value = LoadHeapNumberValue(object);
1870 return TruncateFloat64ToWord32(value); 1870 return TruncateFloat64ToWord32(value);
1871 } 1871 }
1872 1872
1873 Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value) { 1873 Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value,
1874 Node* value32 = RoundFloat64ToInt32(value); 1874 CanonicalizationMode mode) {
1875 Node* value64 = ChangeInt32ToFloat64(value32); 1875 switch (mode) {
1876 case CanonicalizationMode::kDontCanonicalize: {
1877 return AllocateHeapNumberWithValue(value);
1878 }
1879 case CanonicalizationMode::kCanonicalize: {
1880 Node* value32 = RoundFloat64ToInt32(value);
1881 Node* value64 = ChangeInt32ToFloat64(value32);
1876 1882
1877 Label if_valueisint32(this), if_valueisheapnumber(this), if_join(this); 1883 Label if_valueisint32(this), if_valueisheapnumber(this), if_join(this);
1878 1884
1879 Label if_valueisequal(this), if_valueisnotequal(this); 1885 Label if_valueisequal(this), if_valueisnotequal(this);
1880 Branch(Float64Equal(value, value64), &if_valueisequal, &if_valueisnotequal); 1886 Branch(Float64Equal(value, value64), &if_valueisequal,
1881 Bind(&if_valueisequal); 1887 &if_valueisnotequal);
1882 { 1888 Bind(&if_valueisequal);
1883 GotoUnless(Word32Equal(value32, Int32Constant(0)), &if_valueisint32); 1889 {
1884 BranchIfInt32LessThan(Float64ExtractHighWord32(value), Int32Constant(0), 1890 GotoUnless(Word32Equal(value32, Int32Constant(0)), &if_valueisint32);
1885 &if_valueisheapnumber, &if_valueisint32); 1891 BranchIfInt32LessThan(Float64ExtractHighWord32(value), Int32Constant(0),
1886 } 1892 &if_valueisheapnumber, &if_valueisint32);
1887 Bind(&if_valueisnotequal); 1893 }
1888 Goto(&if_valueisheapnumber); 1894 Bind(&if_valueisnotequal);
1895 Goto(&if_valueisheapnumber);
1889 1896
1890 Variable var_result(this, MachineRepresentation::kTagged); 1897 Variable var_result(this, MachineRepresentation::kTagged);
1891 Bind(&if_valueisint32); 1898 Bind(&if_valueisint32);
1892 {
1893 if (Is64()) {
1894 Node* result = SmiTag(ChangeInt32ToInt64(value32));
1895 var_result.Bind(result);
1896 Goto(&if_join);
1897 } else {
1898 Node* pair = Int32AddWithOverflow(value32, value32);
1899 Node* overflow = Projection(1, pair);
1900 Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
1901 Branch(overflow, &if_overflow, &if_notoverflow);
1902 Bind(&if_overflow);
1903 Goto(&if_valueisheapnumber);
1904 Bind(&if_notoverflow);
1905 { 1899 {
1906 Node* result = Projection(0, pair); 1900 if (Is64()) {
1901 Node* result = SmiTag(ChangeInt32ToInt64(value32));
1902 var_result.Bind(result);
1903 Goto(&if_join);
1904 } else {
1905 Node* pair = Int32AddWithOverflow(value32, value32);
1906 Node* overflow = Projection(1, pair);
1907 Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
1908 Branch(overflow, &if_overflow, &if_notoverflow);
1909 Bind(&if_overflow);
1910 Goto(&if_valueisheapnumber);
1911 Bind(&if_notoverflow);
1912 {
1913 Node* result = Projection(0, pair);
1914 var_result.Bind(result);
1915 Goto(&if_join);
1916 }
1917 }
1918 }
1919 Bind(&if_valueisheapnumber);
1920 {
1921 Node* result = AllocateHeapNumberWithValue(value);
1907 var_result.Bind(result); 1922 var_result.Bind(result);
1908 Goto(&if_join); 1923 Goto(&if_join);
1909 } 1924 }
1925 Bind(&if_join);
1926 return var_result.value();
1910 } 1927 }
1911 } 1928 }
1912 Bind(&if_valueisheapnumber); 1929 UNREACHABLE();
1913 { 1930 return nullptr;
1914 Node* result = AllocateHeapNumberWithValue(value);
1915 var_result.Bind(result);
1916 Goto(&if_join);
1917 }
1918 Bind(&if_join);
1919 return var_result.value();
1920 } 1931 }
1921 1932
1922 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) { 1933 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) {
1923 if (Is64()) { 1934 if (Is64()) {
1924 return SmiTag(ChangeInt32ToInt64(value)); 1935 return SmiTag(ChangeInt32ToInt64(value));
1925 } 1936 }
1926 Variable var_result(this, MachineRepresentation::kTagged); 1937 Variable var_result(this, MachineRepresentation::kTagged);
1927 Node* pair = Int32AddWithOverflow(value, value); 1938 Node* pair = Int32AddWithOverflow(value, value);
1928 Node* overflow = Projection(1, pair); 1939 Node* overflow = Projection(1, pair);
1929 Label if_overflow(this, Label::kDeferred), if_notoverflow(this), 1940 Label if_overflow(this, Label::kDeferred), if_notoverflow(this),
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 { 2636 {
2626 // Load the floating-point value of {arg}. 2637 // Load the floating-point value of {arg}.
2627 Node* arg_value = LoadHeapNumberValue(arg); 2638 Node* arg_value = LoadHeapNumberValue(arg);
2628 2639
2629 // Check if {arg} is NaN. 2640 // Check if {arg} is NaN.
2630 GotoUnless(Float64Equal(arg_value, arg_value), &return_zero); 2641 GotoUnless(Float64Equal(arg_value, arg_value), &return_zero);
2631 2642
2632 // Truncate {arg} towards zero. 2643 // Truncate {arg} towards zero.
2633 Node* value = Float64Trunc(arg_value); 2644 Node* value = Float64Trunc(arg_value);
2634 2645
2635 if (mode == kTruncateMinusZero) { 2646 // Perform optional minus zero truncation.
2636 // Truncate -0.0 to 0. 2647 switch (mode) {
2637 GotoIf(Float64Equal(value, Float64Constant(0.0)), &return_zero); 2648 case kNoTruncation:
2649 break;
2650 case kTruncateMinusZero: {
2651 // Truncate -0.0 to 0.
2652 GotoIf(Float64Equal(value, Float64Constant(0.0)), &return_zero);
2653 break;
2654 }
2638 } 2655 }
2639 2656
2640 var_arg.Bind(ChangeFloat64ToTagged(value)); 2657 // Tag the {value} using Smi canonicalization, i.e. if {value} can be
2658 // represented as a Smi, then this will produce a Smi.
2659 var_arg.Bind(
2660 ChangeFloat64ToTagged(value, CanonicalizationMode::kCanonicalize));
2641 Goto(&out); 2661 Goto(&out);
2642 } 2662 }
2643 2663
2644 Bind(&if_argisnotheapnumber); 2664 Bind(&if_argisnotheapnumber);
2645 { 2665 {
2646 // Need to convert {arg} to a Number first. 2666 // Need to convert {arg} to a Number first.
2647 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 2667 Callable callable = CodeFactory::NonNumberToNumber(isolate());
2648 var_arg.Bind(CallStub(callable, context, arg)); 2668 var_arg.Bind(CallStub(callable, context, arg));
2649 Goto(&loop); 2669 Goto(&loop);
2650 } 2670 }
(...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after
5308 Heap::kTheHoleValueRootIndex); 5328 Heap::kTheHoleValueRootIndex);
5309 5329
5310 // Store the WeakCell in the feedback vector. 5330 // Store the WeakCell in the feedback vector.
5311 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 5331 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
5312 CodeStubAssembler::SMI_PARAMETERS); 5332 CodeStubAssembler::SMI_PARAMETERS);
5313 return cell; 5333 return cell;
5314 } 5334 }
5315 5335
5316 } // namespace internal 5336 } // namespace internal
5317 } // namespace v8 5337 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698