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

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

Issue 2532403002: [regexp] Migrate @@split to TurboFan (Closed)
Patch Set: Address comments Created 4 years 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
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 #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 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after
3756 { 3756 {
3757 var_result.Bind(NonNumberToNumber(context, input)); 3757 var_result.Bind(NonNumberToNumber(context, input));
3758 Goto(&end); 3758 Goto(&end);
3759 } 3759 }
3760 } 3760 }
3761 3761
3762 Bind(&end); 3762 Bind(&end);
3763 return var_result.value(); 3763 return var_result.value();
3764 } 3764 }
3765 3765
3766 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) {
3767 Node* const float_zero = Float64Constant(0.0);
3768 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32));
3769
3770 Label out(this);
3771
3772 Variable var_result(this, MachineRepresentation::kTagged);
3773 var_result.Bind(input);
3774
3775 // Early exit for positive smis.
3776 {
3777 Label next(this, Label::kDeferred);
3778 Branch(WordIsPositiveSmi(input), &out, &next);
Igor Sheludko 2016/11/30 20:47:31 Maybe add a TODO that we can combine this with ToN
jgruber 2016/12/01 07:56:24 Done.
3779 Bind(&next);
3780 }
3781
3782 Node* const number = ToNumber(context, input);
3783 var_result.Bind(number);
3784
3785 // Perhaps we have a positive smi now.
3786 {
3787 Label next(this, Label::kDeferred);
3788 Branch(WordIsPositiveSmi(number), &out, &next);
3789 Bind(&next);
3790 }
3791
3792 Label if_isnegativesmi(this), if_isheapnumber(this);
3793 Branch(TaggedIsSmi(number), &if_isnegativesmi, &if_isheapnumber);
3794
3795 Bind(&if_isnegativesmi);
3796 {
3797 // floor({input}) mod 2^32 === {input} + 2^32.
3798 Node* const float_number = SmiToFloat64(number);
3799 Node* const float_result = Float64Add(float_number, float_two_32);
3800 Node* const result = ChangeFloat64ToTagged(float_result);
3801 var_result.Bind(result);
3802 Goto(&out);
3803 }
3804
3805 Bind(&if_isheapnumber);
3806 {
3807 Label return_zero(this);
3808 Node* const value = LoadHeapNumberValue(number);
3809
3810 {
3811 // +-0.
3812 Label next(this);
3813 Branch(Float64Equal(value, float_zero), &return_zero, &next);
3814 Bind(&next);
3815 }
3816
3817 {
3818 // NaN.
3819 Label next(this);
3820 Branch(Float64Equal(value, value), &next, &return_zero);
3821 Bind(&next);
3822 }
3823
3824 {
3825 // +Infinity.
3826 Label next(this);
3827 Node* const positive_infinity =
3828 Float64Constant(std::numeric_limits<double>::infinity());
3829 Branch(Float64Equal(value, positive_infinity), &return_zero, &next);
3830 Bind(&next);
3831 }
3832
3833 {
3834 // -Infinity.
3835 Label next(this);
3836 Node* const negative_infinity =
3837 Float64Constant(-1.0 * std::numeric_limits<double>::infinity());
3838 Branch(Float64Equal(value, negative_infinity), &return_zero, &next);
3839 Bind(&next);
3840 }
3841
3842 // Return floor({input}) mod 2^32 (assuming mod semantics that always return
3843 // positive results).
3844 {
3845 Node* x = Float64Floor(value);
3846 x = Float64Mod(x, float_two_32);
3847 x = Float64Add(x, float_two_32);
3848 x = Float64Mod(x, float_two_32);
3849
3850 Node* const result = ChangeFloat64ToTagged(x);
3851 var_result.Bind(result);
3852 Goto(&out);
3853 }
3854
3855 Bind(&return_zero);
3856 {
3857 var_result.Bind(SmiConstant(Smi::kZero));
3858 Goto(&out);
3859 }
3860 }
3861
3862 Bind(&out);
3863 return var_result.value();
3864 }
3865
3766 Node* CodeStubAssembler::ToString(Node* context, Node* input) { 3866 Node* CodeStubAssembler::ToString(Node* context, Node* input) {
3767 Label is_number(this); 3867 Label is_number(this);
3768 Label runtime(this, Label::kDeferred); 3868 Label runtime(this, Label::kDeferred);
3769 Variable result(this, MachineRepresentation::kTagged); 3869 Variable result(this, MachineRepresentation::kTagged);
3770 Label done(this, &result); 3870 Label done(this, &result);
3771 3871
3772 GotoIf(TaggedIsSmi(input), &is_number); 3872 GotoIf(TaggedIsSmi(input), &is_number);
3773 3873
3774 Node* input_map = LoadMap(input); 3874 Node* input_map = LoadMap(input);
3775 Node* input_instance_type = LoadMapInstanceType(input_map); 3875 Node* input_instance_type = LoadMapInstanceType(input_map);
(...skipping 4073 matching lines...) Expand 10 before | Expand all | Expand 10 after
7849 7949
7850 Node* CodeStubAssembler::IsDebugActive() { 7950 Node* CodeStubAssembler::IsDebugActive() {
7851 Node* is_debug_active = Load( 7951 Node* is_debug_active = Load(
7852 MachineType::Uint8(), 7952 MachineType::Uint8(),
7853 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); 7953 ExternalConstant(ExternalReference::debug_is_active_address(isolate())));
7854 return WordNotEqual(is_debug_active, Int32Constant(0)); 7954 return WordNotEqual(is_debug_active, Int32Constant(0));
7855 } 7955 }
7856 7956
7857 } // namespace internal 7957 } // namespace internal
7858 } // namespace v8 7958 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698