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/builtins/builtins-global.cc

Issue 2734323004: [cleanup] Refactor remaining builtins-*.cc to use TF_BUILTIN macro (Closed)
Patch Set: drop unused variable Created 3 years, 9 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/builtins/builtins-function.cc ('k') | src/builtins/builtins-internal.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/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 isolate, function, 97 isolate, function,
98 Compiler::GetFunctionFromString(handle(target->native_context(), isolate), 98 Compiler::GetFunctionFromString(handle(target->native_context(), isolate),
99 Handle<String>::cast(x), 99 Handle<String>::cast(x),
100 NO_PARSE_RESTRICTION, kNoSourcePosition)); 100 NO_PARSE_RESTRICTION, kNoSourcePosition));
101 RETURN_RESULT_OR_FAILURE( 101 RETURN_RESULT_OR_FAILURE(
102 isolate, 102 isolate,
103 Execution::Call(isolate, function, target_global_proxy, 0, nullptr)); 103 Execution::Call(isolate, function, target_global_proxy, 0, nullptr));
104 } 104 }
105 105
106 // ES6 section 18.2.2 isFinite ( number ) 106 // ES6 section 18.2.2 isFinite ( number )
107 void Builtins::Generate_GlobalIsFinite(compiler::CodeAssemblerState* state) { 107 TF_BUILTIN(GlobalIsFinite, CodeStubAssembler) {
108 typedef CodeStubAssembler::Label Label; 108 Node* context = Parameter(4);
109 typedef compiler::Node Node;
110 typedef CodeStubAssembler::Variable Variable;
111 CodeStubAssembler assembler(state);
112 109
113 Node* context = assembler.Parameter(4); 110 Label return_true(this), return_false(this);
114
115 Label return_true(&assembler), return_false(&assembler);
116 111
117 // We might need to loop once for ToNumber conversion. 112 // We might need to loop once for ToNumber conversion.
118 Variable var_num(&assembler, MachineRepresentation::kTagged); 113 Variable var_num(this, MachineRepresentation::kTagged);
119 Label loop(&assembler, &var_num); 114 Label loop(this, &var_num);
120 var_num.Bind(assembler.Parameter(1)); 115 var_num.Bind(Parameter(1));
121 assembler.Goto(&loop); 116 Goto(&loop);
122 assembler.Bind(&loop); 117 Bind(&loop);
123 { 118 {
124 // Load the current {num} value.
125 Node* num = var_num.value(); 119 Node* num = var_num.value();
126 120
127 // Check if {num} is a Smi or a HeapObject. 121 // Check if {num} is a Smi or a HeapObject.
128 assembler.GotoIf(assembler.TaggedIsSmi(num), &return_true); 122 GotoIf(TaggedIsSmi(num), &return_true);
129 123
130 // Check if {num} is a HeapNumber. 124 // Check if {num} is a HeapNumber.
131 Label if_numisheapnumber(&assembler), 125 Label if_numisheapnumber(this),
132 if_numisnotheapnumber(&assembler, Label::kDeferred); 126 if_numisnotheapnumber(this, Label::kDeferred);
133 assembler.Branch(assembler.IsHeapNumberMap(assembler.LoadMap(num)), 127 Branch(IsHeapNumberMap(LoadMap(num)), &if_numisheapnumber,
134 &if_numisheapnumber, &if_numisnotheapnumber); 128 &if_numisnotheapnumber);
135 129
136 assembler.Bind(&if_numisheapnumber); 130 Bind(&if_numisheapnumber);
137 { 131 {
138 // Check if {num} contains a finite, non-NaN value. 132 // Check if {num} contains a finite, non-NaN value.
139 Node* num_value = assembler.LoadHeapNumberValue(num); 133 Node* num_value = LoadHeapNumberValue(num);
140 assembler.BranchIfFloat64IsNaN(assembler.Float64Sub(num_value, num_value), 134 BranchIfFloat64IsNaN(Float64Sub(num_value, num_value), &return_false,
141 &return_false, &return_true); 135 &return_true);
142 } 136 }
143 137
144 assembler.Bind(&if_numisnotheapnumber); 138 Bind(&if_numisnotheapnumber);
145 { 139 {
146 // Need to convert {num} to a Number first. 140 // Need to convert {num} to a Number first.
147 Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate()); 141 Callable callable = CodeFactory::NonNumberToNumber(isolate());
148 var_num.Bind(assembler.CallStub(callable, context, num)); 142 var_num.Bind(CallStub(callable, context, num));
149 assembler.Goto(&loop); 143 Goto(&loop);
150 } 144 }
151 } 145 }
152 146
153 assembler.Bind(&return_true); 147 Bind(&return_true);
154 assembler.Return(assembler.BooleanConstant(true)); 148 Return(BooleanConstant(true));
155 149
156 assembler.Bind(&return_false); 150 Bind(&return_false);
157 assembler.Return(assembler.BooleanConstant(false)); 151 Return(BooleanConstant(false));
158 } 152 }
159 153
160 // ES6 section 18.2.3 isNaN ( number ) 154 // ES6 section 18.2.3 isNaN ( number )
161 void Builtins::Generate_GlobalIsNaN(compiler::CodeAssemblerState* state) { 155 TF_BUILTIN(GlobalIsNaN, CodeStubAssembler) {
162 typedef CodeStubAssembler::Label Label; 156 Node* context = Parameter(4);
163 typedef compiler::Node Node;
164 typedef CodeStubAssembler::Variable Variable;
165 CodeStubAssembler assembler(state);
166 157
167 Node* context = assembler.Parameter(4); 158 Label return_true(this), return_false(this);
168
169 Label return_true(&assembler), return_false(&assembler);
170 159
171 // We might need to loop once for ToNumber conversion. 160 // We might need to loop once for ToNumber conversion.
172 Variable var_num(&assembler, MachineRepresentation::kTagged); 161 Variable var_num(this, MachineRepresentation::kTagged);
173 Label loop(&assembler, &var_num); 162 Label loop(this, &var_num);
174 var_num.Bind(assembler.Parameter(1)); 163 var_num.Bind(Parameter(1));
175 assembler.Goto(&loop); 164 Goto(&loop);
176 assembler.Bind(&loop); 165 Bind(&loop);
177 { 166 {
178 // Load the current {num} value.
179 Node* num = var_num.value(); 167 Node* num = var_num.value();
180 168
181 // Check if {num} is a Smi or a HeapObject. 169 // Check if {num} is a Smi or a HeapObject.
182 assembler.GotoIf(assembler.TaggedIsSmi(num), &return_false); 170 GotoIf(TaggedIsSmi(num), &return_false);
183 171
184 // Check if {num} is a HeapNumber. 172 // Check if {num} is a HeapNumber.
185 Label if_numisheapnumber(&assembler), 173 Label if_numisheapnumber(this),
186 if_numisnotheapnumber(&assembler, Label::kDeferred); 174 if_numisnotheapnumber(this, Label::kDeferred);
187 assembler.Branch(assembler.IsHeapNumberMap(assembler.LoadMap(num)), 175 Branch(IsHeapNumberMap(LoadMap(num)), &if_numisheapnumber,
188 &if_numisheapnumber, &if_numisnotheapnumber); 176 &if_numisnotheapnumber);
189 177
190 assembler.Bind(&if_numisheapnumber); 178 Bind(&if_numisheapnumber);
191 { 179 {
192 // Check if {num} contains a NaN. 180 // Check if {num} contains a NaN.
193 Node* num_value = assembler.LoadHeapNumberValue(num); 181 Node* num_value = LoadHeapNumberValue(num);
194 assembler.BranchIfFloat64IsNaN(num_value, &return_true, &return_false); 182 BranchIfFloat64IsNaN(num_value, &return_true, &return_false);
195 } 183 }
196 184
197 assembler.Bind(&if_numisnotheapnumber); 185 Bind(&if_numisnotheapnumber);
198 { 186 {
199 // Need to convert {num} to a Number first. 187 // Need to convert {num} to a Number first.
200 Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate()); 188 Callable callable = CodeFactory::NonNumberToNumber(isolate());
201 var_num.Bind(assembler.CallStub(callable, context, num)); 189 var_num.Bind(CallStub(callable, context, num));
202 assembler.Goto(&loop); 190 Goto(&loop);
203 } 191 }
204 } 192 }
205 193
206 assembler.Bind(&return_true); 194 Bind(&return_true);
207 assembler.Return(assembler.BooleanConstant(true)); 195 Return(BooleanConstant(true));
208 196
209 assembler.Bind(&return_false); 197 Bind(&return_false);
210 assembler.Return(assembler.BooleanConstant(false)); 198 Return(BooleanConstant(false));
211 } 199 }
212 200
213 } // namespace internal 201 } // namespace internal
214 } // namespace v8 202 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-function.cc ('k') | src/builtins/builtins-internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698