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

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

Issue 2364473006: [stubs] Extract ToInteger to CodeStubAssembler (Closed)
Patch Set: 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') | src/code-stubs.cc » ('j') | 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) {
2989 // We might need to loop once for ToNumber conversion.
2990 Variable var_arg(this, MachineRepresentation::kTagged);
2991 Label loop(this, &var_arg), out(this);
2992 var_arg.Bind(input);
2993 Goto(&loop);
2994 Bind(&loop);
2995 {
2996 // Shared entry points.
2997 Label return_zero(this, Label::kDeferred);
2998
2999 // Load the current {arg} value.
3000 Node* arg = var_arg.value();
3001
3002 // Check if {arg} is a Smi.
3003 GotoIf(WordIsSmi(arg), &out);
3004
3005 // Check if {arg} is a HeapNumber.
3006 Label if_argisheapnumber(this),
3007 if_argisnotheapnumber(this, Label::kDeferred);
3008 Branch(WordEqual(LoadMap(arg), HeapNumberMapConstant()),
3009 &if_argisheapnumber, &if_argisnotheapnumber);
3010
3011 Bind(&if_argisheapnumber);
3012 {
3013 // Load the floating-point value of {arg}.
3014 Node* arg_value = LoadHeapNumberValue(arg);
3015
3016 // Check if {arg} is NaN.
3017 GotoUnless(Float64Equal(arg_value, arg_value), &return_zero);
3018
3019 // Truncate {arg} towards zero.
3020 Node* value = Float64Trunc(arg_value);
3021 var_arg.Bind(ChangeFloat64ToTagged(value));
3022 Goto(&out);
3023 }
3024
3025 Bind(&if_argisnotheapnumber);
3026 {
3027 // Need to convert {arg} to a Number first.
3028 Callable callable = CodeFactory::NonNumberToNumber(isolate());
3029 var_arg.Bind(CallStub(callable, context, arg));
3030 Goto(&loop);
3031 }
3032
3033 Bind(&return_zero);
3034 var_arg.Bind(SmiConstant(Smi::FromInt(0)));
3035 Goto(&out);
3036 }
3037
3038 Bind(&out);
3039 return var_arg.value();
3040 }
3041
2988 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, 3042 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
2989 uint32_t mask) { 3043 uint32_t mask) {
2990 return Word32Shr(Word32And(word32, Int32Constant(mask)), 3044 return Word32Shr(Word32And(word32, Int32Constant(mask)),
2991 static_cast<int>(shift)); 3045 static_cast<int>(shift));
2992 } 3046 }
2993 3047
2994 void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) { 3048 void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) {
2995 if (FLAG_native_code_counters && counter->Enabled()) { 3049 if (FLAG_native_code_counters && counter->Enabled()) {
2996 Node* counter_address = ExternalConstant(ExternalReference(counter)); 3050 Node* counter_address = ExternalConstant(ExternalReference(counter));
2997 StoreNoWriteBarrier(MachineRepresentation::kWord32, counter_address, 3051 StoreNoWriteBarrier(MachineRepresentation::kWord32, counter_address,
(...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after
5533 Heap::kTheHoleValueRootIndex); 5587 Heap::kTheHoleValueRootIndex);
5534 5588
5535 // Store the WeakCell in the feedback vector. 5589 // Store the WeakCell in the feedback vector.
5536 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 5590 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
5537 CodeStubAssembler::SMI_PARAMETERS); 5591 CodeStubAssembler::SMI_PARAMETERS);
5538 return cell; 5592 return cell;
5539 } 5593 }
5540 5594
5541 } // namespace internal 5595 } // namespace internal
5542 } // namespace v8 5596 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698