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
3 // found in the LICENSE file.
5 // This files contains runtime support implemented in JavaScript.
7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'.
12 // The following declarations are shared with other native JS files.
13 // They are all declared at this one spot to avoid redeclaration errors.
16 var $nonNumberToNumber;
17 var $nonStringToString;
23 var $toPositiveInteger;
27 (function(global, utils) {
29 %CheckIsBootstrapping();
31 var GlobalArray = global.Array;
32 var GlobalBoolean = global.Boolean;
33 var GlobalString = global.String;
34 var GlobalNumber = global.Number;
35 var isConcatSpreadableSymbol =
36 utils.ImportNow("is_concat_spreadable_symbol");
38 // ----------------------------------------------------------------------------
40 /* -----------------------------------
41 - - - C o m p a r i s o n - - -
42 -----------------------------------
45 // ECMA-262 Section 11.9.3.
47 if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y);
53 if (IS_NUMBER(y)) return %NumberEquals(x, y);
54 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
55 if (!IS_SPEC_OBJECT(y)) {
56 if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal
58 return %NumberEquals(x, %to_number_fun(y));
60 y = %to_primitive(y, NO_HINT);
62 } else if (IS_STRING(x)) {
64 if (IS_STRING(y)) return %StringEquals(x, y);
65 if (IS_NUMBER(y)) return %NumberEquals(%to_number_fun(x), y);
67 return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
69 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
70 if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal
71 y = %to_primitive(y, NO_HINT);
73 } else if (IS_SYMBOL(x)) {
74 if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1;
75 return 1; // not equal
76 } else if (IS_BOOLEAN(x)) {
77 if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
78 if (IS_NULL_OR_UNDEFINED(y)) return 1;
79 if (IS_NUMBER(y)) return %NumberEquals(%to_number_fun(x), y);
81 return %NumberEquals(%to_number_fun(x), %to_number_fun(y));
83 if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal
85 x = %to_number_fun(x);
86 y = %to_primitive(y, NO_HINT);
87 } else if (IS_NULL_OR_UNDEFINED(x)) {
88 return IS_NULL_OR_UNDEFINED(y) ? 0 : 1;
89 } else if (IS_SIMD_VALUE(x)) {
90 if (!IS_SIMD_VALUE(y)) return 1; // not equal
91 return %SimdEquals(x, y);
94 if (IS_SPEC_OBJECT(y)) return %_ObjectEquals(x, y) ? 0 : 1;
95 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
97 y = %to_number_fun(y);
98 } else if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) {
99 return 1; // not equal
101 x = %to_primitive(x, NO_HINT);
107 // ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as
108 // the result when either (or both) the operands are NaN.
109 function COMPARE(x, ncr) {
112 // Fast cases for string, numbers and undefined compares.
113 if (IS_STRING(this)) {
114 if (IS_STRING(x)) return %_StringCompare(this, x);
115 if (IS_UNDEFINED(x)) return ncr;
117 } else if (IS_NUMBER(this)) {
118 if (IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
119 if (IS_UNDEFINED(x)) return ncr;
121 } else if (IS_UNDEFINED(this)) {
122 if (!IS_UNDEFINED(x)) {
123 %to_primitive(x, NUMBER_HINT);
126 } else if (IS_UNDEFINED(x)) {
127 %to_primitive(this, NUMBER_HINT);
130 left = %to_primitive(this, NUMBER_HINT);
133 right = %to_primitive(x, NUMBER_HINT);
134 if (IS_STRING(left) && IS_STRING(right)) {
135 return %_StringCompare(left, right);
137 var left_number = %to_number_fun(left);
138 var right_number = %to_number_fun(right);
139 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr;
140 return %NumberCompare(left_number, right_number, ncr);
144 // Strong mode COMPARE throws if an implicit conversion would be performed
145 function COMPARE_STRONG(x, ncr) {
146 if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
147 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
149 throw %make_type_error(kStrongImplicitConversion);
154 /* -----------------------------------
155 - - - A r i t h m e t i c - - -
156 -----------------------------------
159 // ECMA-262, section 11.6.1, page 50.
161 // Fast case: Check for number operands and do the addition.
162 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x);
163 if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
165 // Default implementation.
166 var a = %to_primitive(this, NO_HINT);
167 var b = %to_primitive(x, NO_HINT);
170 return %_StringAdd(a, %to_string_fun(b));
171 } else if (IS_STRING(b)) {
172 return %_StringAdd(%non_string_to_string(a), b);
174 return %NumberAdd(%to_number_fun(a), %to_number_fun(b));
179 // Strong mode ADD throws if an implicit conversion would be performed
180 function ADD_STRONG(x) {
181 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x);
182 if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
184 throw %make_type_error(kStrongImplicitConversion);
188 // Left operand (this) is already a string.
189 function STRING_ADD_LEFT(y) {
191 if (IS_STRING_WRAPPER(y) && %_IsStringWrapperSafeForDefaultValueOf(y)) {
195 ? %_NumberToString(y)
196 : %to_string_fun(%to_primitive(y, NO_HINT));
199 return %_StringAdd(this, y);
203 // Right operand (y) is already a string.
204 function STRING_ADD_RIGHT(y) {
207 if (IS_STRING_WRAPPER(x) && %_IsStringWrapperSafeForDefaultValueOf(x)) {
211 ? %_NumberToString(x)
212 : %to_string_fun(%to_primitive(x, NO_HINT));
215 return %_StringAdd(x, y);
219 // ECMA-262, section 11.6.2, page 50.
221 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
222 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
223 return %NumberSub(x, y);
227 // Strong mode SUB throws if an implicit conversion would be performed
228 function SUB_STRONG(y) {
229 if (IS_NUMBER(this) && IS_NUMBER(y)) {
230 return %NumberSub(this, y);
232 throw %make_type_error(kStrongImplicitConversion);
236 // ECMA-262, section 11.5.1, page 48.
238 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
239 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
240 return %NumberMul(x, y);
244 // Strong mode MUL throws if an implicit conversion would be performed
245 function MUL_STRONG(y) {
246 if (IS_NUMBER(this) && IS_NUMBER(y)) {
247 return %NumberMul(this, y);
249 throw %make_type_error(kStrongImplicitConversion);
253 // ECMA-262, section 11.5.2, page 49.
255 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
256 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
257 return %NumberDiv(x, y);
261 // Strong mode DIV throws if an implicit conversion would be performed
262 function DIV_STRONG(y) {
263 if (IS_NUMBER(this) && IS_NUMBER(y)) {
264 return %NumberDiv(this, y);
266 throw %make_type_error(kStrongImplicitConversion);
270 // ECMA-262, section 11.5.3, page 49.
272 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
273 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
274 return %NumberMod(x, y);
278 // Strong mode MOD throws if an implicit conversion would be performed
279 function MOD_STRONG(y) {
280 if (IS_NUMBER(this) && IS_NUMBER(y)) {
281 return %NumberMod(this, y);
283 throw %make_type_error(kStrongImplicitConversion);
287 /* -------------------------------------------
288 - - - B i t o p e r a t i o n s - - -
289 -------------------------------------------
292 // ECMA-262, section 11.10, page 57.
294 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
295 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
296 return %NumberOr(x, y);
300 // Strong mode BIT_OR throws if an implicit conversion would be performed
301 function BIT_OR_STRONG(y) {
302 if (IS_NUMBER(this) && IS_NUMBER(y)) {
303 return %NumberOr(this, y);
305 throw %make_type_error(kStrongImplicitConversion);
309 // ECMA-262, section 11.10, page 57.
310 function BIT_AND(y) {
312 if (IS_NUMBER(this)) {
314 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
316 x = %non_number_to_number(this);
317 // Make sure to convert the right operand to a number before
318 // bailing out in the fast case, but after converting the
319 // left operand. This ensures that valueOf methods on the right
320 // operand are always executed.
321 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
322 // Optimize for the case where we end up AND'ing a value
323 // that doesn't convert to a number. This is common in
324 // certain benchmarks.
325 if (NUMBER_IS_NAN(x)) return 0;
327 return %NumberAnd(x, y);
331 // Strong mode BIT_AND throws if an implicit conversion would be performed
332 function BIT_AND_STRONG(y) {
333 if (IS_NUMBER(this) && IS_NUMBER(y)) {
334 return %NumberAnd(this, y);
336 throw %make_type_error(kStrongImplicitConversion);
340 // ECMA-262, section 11.10, page 57.
341 function BIT_XOR(y) {
342 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
343 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
344 return %NumberXor(x, y);
348 // Strong mode BIT_XOR throws if an implicit conversion would be performed
349 function BIT_XOR_STRONG(y) {
350 if (IS_NUMBER(this) && IS_NUMBER(y)) {
351 return %NumberXor(this, y);
353 throw %make_type_error(kStrongImplicitConversion);
357 // ECMA-262, section 11.7.1, page 51.
359 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
360 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
361 return %NumberShl(x, y);
365 // Strong mode SHL throws if an implicit conversion would be performed
366 function SHL_STRONG(y) {
367 if (IS_NUMBER(this) && IS_NUMBER(y)) {
368 return %NumberShl(this, y);
370 throw %make_type_error(kStrongImplicitConversion);
374 // ECMA-262, section 11.7.2, page 51.
377 if (IS_NUMBER(this)) {
379 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
381 x = %non_number_to_number(this);
382 // Make sure to convert the right operand to a number before
383 // bailing out in the fast case, but after converting the
384 // left operand. This ensures that valueOf methods on the right
385 // operand are always executed.
386 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
387 // Optimize for the case where we end up shifting a value
388 // that doesn't convert to a number. This is common in
389 // certain benchmarks.
390 if (NUMBER_IS_NAN(x)) return 0;
392 return %NumberSar(x, y);
396 // Strong mode SAR throws if an implicit conversion would be performed
397 function SAR_STRONG(y) {
398 if (IS_NUMBER(this) && IS_NUMBER(y)) {
399 return %NumberSar(this, y);
401 throw %make_type_error(kStrongImplicitConversion);
405 // ECMA-262, section 11.7.3, page 52.
407 var x = IS_NUMBER(this) ? this : %non_number_to_number(this);
408 if (!IS_NUMBER(y)) y = %non_number_to_number(y);
409 return %NumberShr(x, y);
413 // Strong mode SHR throws if an implicit conversion would be performed
414 function SHR_STRONG(y) {
415 if (IS_NUMBER(this) && IS_NUMBER(y)) {
416 return %NumberShr(this, y);
418 throw %make_type_error(kStrongImplicitConversion);
422 /* -----------------------------
423 - - - H e l p e r s - - -
424 -----------------------------
427 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
428 var delegate = %GetConstructorDelegate(this);
429 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
433 function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR () {
435 var trap = %GetConstructTrap(proxy);
436 return %Apply(trap, this, arguments, 0, %_ArgumentsLength());
440 function APPLY_PREPARE(args) {
443 // First check that the receiver is callable.
444 if (!IS_CALLABLE(this)) {
445 throw %make_type_error(kApplyNonFunction, %to_string_fun(this),
449 // First check whether length is a positive Smi and args is an
450 // array. This is the fast case. If this fails, we do the slow case
451 // that takes care of more eventualities.
452 if (IS_ARRAY(args)) {
453 length = args.length;
454 if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength) {
459 length = (args == null) ? 0 : TO_UINT32(args.length);
461 // We can handle any number of apply arguments if the stack is
462 // big enough, but sanity check the value to avoid overflow when
463 // multiplying with pointer size.
464 if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
466 // Make sure the arguments list has the right type.
467 if (args != null && !IS_SPEC_OBJECT(args)) {
468 throw %make_type_error(kWrongArgs, "Function.prototype.apply");
471 // Return the length which is the number of arguments to copy to the
472 // stack. It is guaranteed to be a small integer at this point.
477 function REFLECT_APPLY_PREPARE(args) {
480 // First check that the receiver is callable.
481 if (!IS_CALLABLE(this)) {
482 throw %make_type_error(kApplyNonFunction, %to_string_fun(this),
486 // First check whether length is a positive Smi and args is an
487 // array. This is the fast case. If this fails, we do the slow case
488 // that takes care of more eventualities.
489 if (IS_ARRAY(args)) {
490 length = args.length;
491 if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength) {
496 if (!IS_SPEC_OBJECT(args)) {
497 throw %make_type_error(kWrongArgs, "Reflect.apply");
500 length = %to_length_fun(args.length);
502 // We can handle any number of apply arguments if the stack is
503 // big enough, but sanity check the value to avoid overflow when
504 // multiplying with pointer size.
505 if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
507 // Return the length which is the number of arguments to copy to the
508 // stack. It is guaranteed to be a small integer at this point.
513 function REFLECT_CONSTRUCT_PREPARE(
516 var ctorOk = IS_CALLABLE(this) && %IsConstructor(this);
517 var newTargetOk = IS_CALLABLE(newTarget) && %IsConstructor(newTarget);
519 // First check whether length is a positive Smi and args is an
520 // array. This is the fast case. If this fails, we do the slow case
521 // that takes care of more eventualities.
522 if (IS_ARRAY(args)) {
523 length = args.length;
524 if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength &&
525 ctorOk && newTargetOk) {
531 if (!IS_CALLABLE(this)) {
532 throw %make_type_error(kCalledNonCallable, %to_string_fun(this));
534 throw %make_type_error(kNotConstructor, %to_string_fun(this));
539 if (!IS_CALLABLE(newTarget)) {
540 throw %make_type_error(kCalledNonCallable, %to_string_fun(newTarget));
542 throw %make_type_error(kNotConstructor, %to_string_fun(newTarget));
546 if (!IS_SPEC_OBJECT(args)) {
547 throw %make_type_error(kWrongArgs, "Reflect.construct");
550 length = %to_length_fun(args.length);
552 // We can handle any number of apply arguments if the stack is
553 // big enough, but sanity check the value to avoid overflow when
554 // multiplying with pointer size.
555 if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
557 // Return the length which is the number of arguments to copy to the
558 // stack. It is guaranteed to be a small integer at this point.
563 function CONCAT_ITERABLE_TO_ARRAY(iterable) {
564 return %concat_iterable_to_array(this, iterable);
568 function STACK_OVERFLOW(length) {
569 throw %make_range_error(kStackOverflow);
573 /* -------------------------------------
574 - - - C o n v e r s i o n s - - -
575 -------------------------------------
578 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint,
579 // (1) for number hint, and (2) for string hint.
580 function ToPrimitive(x, hint) {
581 if (!IS_SPEC_OBJECT(x)) return x;
582 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
583 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x);
587 // ECMA-262, section 9.2, page 30
588 function ToBoolean(x) {
589 if (IS_BOOLEAN(x)) return x;
590 if (IS_STRING(x)) return x.length != 0;
591 if (x == null) return false;
592 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x));
597 // ECMA-262, section 9.3, page 31.
598 function ToNumber(x) {
599 if (IS_NUMBER(x)) return x;
601 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x)
602 : %StringToNumber(x);
604 if (IS_BOOLEAN(x)) return x ? 1 : 0;
605 if (IS_UNDEFINED(x)) return NAN;
606 // Types that can't be converted to number are caught in DefaultNumber.
607 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x));
610 function NonNumberToNumber(x) {
612 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x)
613 : %StringToNumber(x);
615 if (IS_BOOLEAN(x)) return x ? 1 : 0;
616 if (IS_UNDEFINED(x)) return NAN;
617 // Types that can't be converted to number are caught in DefaultNumber.
618 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x));
622 // ECMA-262, section 9.8, page 35.
623 function ToString(x) {
624 if (IS_STRING(x)) return x;
625 if (IS_NUMBER(x)) return %_NumberToString(x);
626 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
627 if (IS_UNDEFINED(x)) return 'undefined';
628 // Types that can't be converted to string are caught in DefaultString.
629 return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
632 function NonStringToString(x) {
633 if (IS_NUMBER(x)) return %_NumberToString(x);
634 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
635 if (IS_UNDEFINED(x)) return 'undefined';
636 // Types that can't be converted to string are caught in DefaultString.
637 return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
641 // ECMA-262, section 9.4, page 34.
642 function ToInteger(x) {
643 if (%_IsSmi(x)) return x;
644 return %NumberToInteger(ToNumber(x));
648 // ES6, draft 08-24-14, section 7.1.15
649 function ToLength(arg) {
650 arg = ToInteger(arg);
651 if (arg < 0) return 0;
652 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg
653 : GlobalNumber.MAX_SAFE_INTEGER;
658 function SameValue(x, y) {
659 if (typeof x != typeof y) return false;
661 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
662 // x is +0 and y is -0 or vice versa.
663 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
667 if (IS_SIMD_VALUE(x)) return %SimdSameValue(x, y);
672 // ES6, section 7.2.4
673 function SameValueZero(x, y) {
674 if (typeof x != typeof y) return false;
676 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
678 if (IS_SIMD_VALUE(x)) return %SimdSameValueZero(x, y);
683 function ConcatIterableToArray(target, iterable) {
684 var index = target.length;
685 for (var element of iterable) {
686 %AddElement(target, index++, element);
692 /* ---------------------------------
693 - - - U t i l i t i e s - - -
694 ---------------------------------
697 // Returns if the given x is a primitive value - not an object or a
699 function IsPrimitive(x) {
700 // Even though the type of null is "object", null is still
701 // considered a primitive value. IS_SPEC_OBJECT handles this correctly
702 // (i.e., it will return false if x is null).
703 return !IS_SPEC_OBJECT(x);
707 // ES6, draft 10-14-14, section 22.1.3.1.1
708 function IsConcatSpreadable(O) {
709 if (!IS_SPEC_OBJECT(O)) return false;
710 var spreadable = O[isConcatSpreadableSymbol];
711 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O);
712 return ToBoolean(spreadable);
716 // ECMA-262, section 8.6.2.6, page 28.
717 function DefaultNumber(x) {
718 var valueOf = x.valueOf;
719 if (IS_CALLABLE(valueOf)) {
720 var v = %_CallFunction(x, valueOf);
721 if (IS_SYMBOL(v)) throw MakeTypeError(kSymbolToNumber);
722 if (IS_SIMD_VALUE(x)) throw MakeTypeError(kSimdToNumber);
723 if (IsPrimitive(v)) return v;
725 var toString = x.toString;
726 if (IS_CALLABLE(toString)) {
727 var s = %_CallFunction(x, toString);
728 if (IsPrimitive(s)) return s;
730 throw MakeTypeError(kCannotConvertToPrimitive);
733 // ECMA-262, section 8.6.2.6, page 28.
734 function DefaultString(x) {
735 if (!IS_SYMBOL_WRAPPER(x)) {
736 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString);
737 var toString = x.toString;
738 if (IS_CALLABLE(toString)) {
739 var s = %_CallFunction(x, toString);
740 if (IsPrimitive(s)) return s;
743 var valueOf = x.valueOf;
744 if (IS_CALLABLE(valueOf)) {
745 var v = %_CallFunction(x, valueOf);
746 if (IsPrimitive(v)) return v;
749 throw MakeTypeError(kCannotConvertToPrimitive);
752 function ToPositiveInteger(x, rangeErrorIndex) {
753 var i = TO_INTEGER_MAP_MINUS_ZERO(x);
754 if (i < 0) throw MakeRangeError(rangeErrorIndex);
758 //----------------------------------------------------------------------------
760 // NOTE: Setting the prototype for Array must take place as early as
761 // possible due to code generation for array literals. When
762 // generating code for a array literal a boilerplate array is created
763 // that is cloned when running the code. It is essential that the
764 // boilerplate gets the right prototype.
765 %FunctionSetPrototype(GlobalArray, new GlobalArray(0));
767 // ----------------------------------------------------------------------------
770 $defaultString = DefaultString;
771 $NaN = %GetRootNaN();
772 $nonNumberToNumber = NonNumberToNumber;
773 $nonStringToString = NonStringToString;
774 $sameValue = SameValue;
775 $sameValueZero = SameValueZero;
776 $toInteger = ToInteger;
777 $toLength = ToLength;
778 $toNumber = ToNumber;
779 $toPositiveInteger = ToPositiveInteger;
780 $toPrimitive = ToPrimitive;
781 $toString = ToString;
785 "add_strong_builtin", ADD_STRONG,
786 "apply_prepare_builtin", APPLY_PREPARE,
787 "bit_and_builtin", BIT_AND,
788 "bit_and_strong_builtin", BIT_AND_STRONG,
789 "bit_or_builtin", BIT_OR,
790 "bit_or_strong_builtin", BIT_OR_STRONG,
791 "bit_xor_builtin", BIT_XOR,
792 "bit_xor_strong_builtin", BIT_XOR_STRONG,
793 "call_function_proxy_as_constructor_builtin", CALL_FUNCTION_PROXY_AS_CONSTRUCTOR,
794 "call_non_function_as_constructor_builtin", CALL_NON_FUNCTION_AS_CONSTRUCTOR,
795 "compare_builtin", COMPARE,
796 "compare_strong_builtin", COMPARE_STRONG,
797 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
799 "div_strong_builtin", DIV_STRONG,
800 "equals_builtin", EQUALS,
802 "mod_strong_builtin", MOD_STRONG,
804 "mul_strong_builtin", MUL_STRONG,
805 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE,
806 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE,
808 "sar_strong_builtin", SAR_STRONG,
810 "shl_strong_builtin", SHL_STRONG,
812 "shr_strong_builtin", SHR_STRONG,
813 "stack_overflow_builtin", STACK_OVERFLOW,
814 "string_add_left_builtin", STRING_ADD_LEFT,
815 "string_add_right_builtin", STRING_ADD_RIGHT,
817 "sub_strong_builtin", SUB_STRONG,
821 "concat_iterable_to_array", ConcatIterableToArray,
822 "non_number_to_number", NonNumberToNumber,
823 "non_string_to_string", NonStringToString,
824 "to_integer_fun", ToInteger,
825 "to_length_fun", ToLength,
826 "to_number_fun", ToNumber,
827 "to_primitive", ToPrimitive,
828 "to_string_fun", ToString,
831 utils.Export(function(to) {
832 to.ToBoolean = ToBoolean;
833 to.ToLength = ToLength;
834 to.ToNumber = ToNumber;
835 to.ToPrimitive = ToPrimitive;
836 to.ToString = ToString;