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

Side by Side Diff: src/runtime.js

Issue 1400463002: [builtins] Drop useless ToBoolean JavaScript builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 function CONCAT_ITERABLE_TO_ARRAY(iterable) { 159 function CONCAT_ITERABLE_TO_ARRAY(iterable) {
160 return %concat_iterable_to_array(this, iterable); 160 return %concat_iterable_to_array(this, iterable);
161 }; 161 };
162 162
163 163
164 /* ------------------------------------- 164 /* -------------------------------------
165 - - - C o n v e r s i o n s - - - 165 - - - C o n v e r s i o n s - - -
166 ------------------------------------- 166 -------------------------------------
167 */ 167 */
168 168
169 // ECMA-262, section 9.2, page 30
170 function ToBoolean(x) {
171 if (IS_BOOLEAN(x)) return x;
172 if (IS_STRING(x)) return x.length != 0;
173 if (x == null) return false;
174 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x));
175 return true;
176 }
177
178
179 // ES5, section 9.12 169 // ES5, section 9.12
180 function SameValue(x, y) { 170 function SameValue(x, y) {
181 if (typeof x != typeof y) return false; 171 if (typeof x != typeof y) return false;
182 if (IS_NUMBER(x)) { 172 if (IS_NUMBER(x)) {
183 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 173 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
184 // x is +0 and y is -0 or vice versa. 174 // x is +0 and y is -0 or vice versa.
185 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 175 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
186 return false; 176 return false;
187 } 177 }
188 } 178 }
(...skipping 26 matching lines...) Expand all
215 - - - U t i l i t i e s - - - 205 - - - U t i l i t i e s - - -
216 --------------------------------- 206 ---------------------------------
217 */ 207 */
218 208
219 209
220 // ES6, draft 10-14-14, section 22.1.3.1.1 210 // ES6, draft 10-14-14, section 22.1.3.1.1
221 function IsConcatSpreadable(O) { 211 function IsConcatSpreadable(O) {
222 if (!IS_SPEC_OBJECT(O)) return false; 212 if (!IS_SPEC_OBJECT(O)) return false;
223 var spreadable = O[isConcatSpreadableSymbol]; 213 var spreadable = O[isConcatSpreadableSymbol];
224 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); 214 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O);
225 return ToBoolean(spreadable); 215 return TO_BOOLEAN(spreadable);
226 } 216 }
227 217
228 218
229 function ToPositiveInteger(x, rangeErrorIndex) { 219 function ToPositiveInteger(x, rangeErrorIndex) {
230 var i = TO_INTEGER_MAP_MINUS_ZERO(x); 220 var i = TO_INTEGER_MAP_MINUS_ZERO(x);
231 if (i < 0) throw MakeRangeError(rangeErrorIndex); 221 if (i < 0) throw MakeRangeError(rangeErrorIndex);
232 return i; 222 return i;
233 } 223 }
234 224
235 //---------------------------------------------------------------------------- 225 //----------------------------------------------------------------------------
(...skipping 17 matching lines...) Expand all
253 "apply_prepare_builtin", APPLY_PREPARE, 243 "apply_prepare_builtin", APPLY_PREPARE,
254 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, 244 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
255 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, 245 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE,
256 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, 246 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE,
257 ]); 247 ]);
258 248
259 %InstallToContext([ 249 %InstallToContext([
260 "concat_iterable_to_array", ConcatIterableToArray, 250 "concat_iterable_to_array", ConcatIterableToArray,
261 ]); 251 ]);
262 252
263 utils.Export(function(to) {
264 to.ToBoolean = ToBoolean;
265 });
266
267 }) 253 })
OLDNEW
« src/macros.py ('K') | « src/prologue.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698