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

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

Issue 2361363002: [stubs] Add TruncationMode argument to ToInteger (Closed)
Patch Set: Simplify 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 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 { 2978 {
2979 var_result.Bind(NonNumberToNumber(context, input)); 2979 var_result.Bind(NonNumberToNumber(context, input));
2980 Goto(&end); 2980 Goto(&end);
2981 } 2981 }
2982 } 2982 }
2983 2983
2984 Bind(&end); 2984 Bind(&end);
2985 return var_result.value(); 2985 return var_result.value();
2986 } 2986 }
2987 2987
2988 Node* CodeStubAssembler::ToInteger(Node* context, Node* input) { 2988 Node* CodeStubAssembler::ToInteger(Node* context, Node* input,
2989 ToIntegerTruncationMode mode) {
2989 // We might need to loop once for ToNumber conversion. 2990 // We might need to loop once for ToNumber conversion.
2990 Variable var_arg(this, MachineRepresentation::kTagged); 2991 Variable var_arg(this, MachineRepresentation::kTagged);
2991 Label loop(this, &var_arg), out(this); 2992 Label loop(this, &var_arg), out(this);
2992 var_arg.Bind(input); 2993 var_arg.Bind(input);
2993 Goto(&loop); 2994 Goto(&loop);
2994 Bind(&loop); 2995 Bind(&loop);
2995 { 2996 {
2996 // Shared entry points. 2997 // Shared entry points.
2997 Label return_zero(this, Label::kDeferred); 2998 Label return_zero(this, Label::kDeferred);
2998 2999
(...skipping 12 matching lines...) Expand all
3011 Bind(&if_argisheapnumber); 3012 Bind(&if_argisheapnumber);
3012 { 3013 {
3013 // Load the floating-point value of {arg}. 3014 // Load the floating-point value of {arg}.
3014 Node* arg_value = LoadHeapNumberValue(arg); 3015 Node* arg_value = LoadHeapNumberValue(arg);
3015 3016
3016 // Check if {arg} is NaN. 3017 // Check if {arg} is NaN.
3017 GotoUnless(Float64Equal(arg_value, arg_value), &return_zero); 3018 GotoUnless(Float64Equal(arg_value, arg_value), &return_zero);
3018 3019
3019 // Truncate {arg} towards zero. 3020 // Truncate {arg} towards zero.
3020 Node* value = Float64Trunc(arg_value); 3021 Node* value = Float64Trunc(arg_value);
3022
3023 if (mode == kTruncateMinusZero) {
3024 // Truncate -0.0 to 0.
3025 GotoIf(Float64Equal(value, Float64Constant(0.0)), &return_zero);
3026 }
3027
3021 var_arg.Bind(ChangeFloat64ToTagged(value)); 3028 var_arg.Bind(ChangeFloat64ToTagged(value));
3022 Goto(&out); 3029 Goto(&out);
3023 } 3030 }
3024 3031
3025 Bind(&if_argisnotheapnumber); 3032 Bind(&if_argisnotheapnumber);
3026 { 3033 {
3027 // Need to convert {arg} to a Number first. 3034 // Need to convert {arg} to a Number first.
3028 Callable callable = CodeFactory::NonNumberToNumber(isolate()); 3035 Callable callable = CodeFactory::NonNumberToNumber(isolate());
3029 var_arg.Bind(CallStub(callable, context, arg)); 3036 var_arg.Bind(CallStub(callable, context, arg));
3030 Goto(&loop); 3037 Goto(&loop);
(...skipping 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after
5587 Heap::kTheHoleValueRootIndex); 5594 Heap::kTheHoleValueRootIndex);
5588 5595
5589 // Store the WeakCell in the feedback vector. 5596 // Store the WeakCell in the feedback vector.
5590 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 5597 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
5591 CodeStubAssembler::SMI_PARAMETERS); 5598 CodeStubAssembler::SMI_PARAMETERS);
5592 return cell; 5599 return cell;
5593 } 5600 }
5594 5601
5595 } // namespace internal 5602 } // namespace internal
5596 } // namespace v8 5603 } // 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