[presubmit] Enable readability/namespace linter checking.
[platform/upstream/v8.git] / src / conversions-inl.h
1 // Copyright 2011 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.
4
5 #ifndef V8_CONVERSIONS_INL_H_
6 #define V8_CONVERSIONS_INL_H_
7
8 #include <float.h>         // Required for DBL_MAX and on Win32 for finite()
9 #include <limits.h>        // Required for INT_MAX etc.
10 #include <stdarg.h>
11 #include <cmath>
12 #include "src/globals.h"       // Required for V8_INFINITY
13 #include "src/unicode-cache-inl.h"
14
15 // ----------------------------------------------------------------------------
16 // Extra POSIX/ANSI functions for Win32/MSVC.
17
18 #include "src/base/bits.h"
19 #include "src/base/platform/platform.h"
20 #include "src/conversions.h"
21 #include "src/double.h"
22 #include "src/objects-inl.h"
23 #include "src/scanner.h"
24 #include "src/strtod.h"
25
26 namespace v8 {
27 namespace internal {
28
29 inline double JunkStringValue() {
30   return bit_cast<double, uint64_t>(kQuietNaNMask);
31 }
32
33
34 inline double SignedZero(bool negative) {
35   return negative ? uint64_to_double(Double::kSignMask) : 0.0;
36 }
37
38
39 // The fast double-to-unsigned-int conversion routine does not guarantee
40 // rounding towards zero, or any reasonable value if the argument is larger
41 // than what fits in an unsigned 32-bit integer.
42 inline unsigned int FastD2UI(double x) {
43   // There is no unsigned version of lrint, so there is no fast path
44   // in this function as there is in FastD2I. Using lrint doesn't work
45   // for values of 2^31 and above.
46
47   // Convert "small enough" doubles to uint32_t by fixing the 32
48   // least significant non-fractional bits in the low 32 bits of the
49   // double, and reading them from there.
50   const double k2Pow52 = 4503599627370496.0;
51   bool negative = x < 0;
52   if (negative) {
53     x = -x;
54   }
55   if (x < k2Pow52) {
56     x += k2Pow52;
57     uint32_t result;
58 #ifndef V8_TARGET_BIG_ENDIAN
59     Address mantissa_ptr = reinterpret_cast<Address>(&x);
60 #else
61     Address mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize;
62 #endif
63     // Copy least significant 32 bits of mantissa.
64     memcpy(&result, mantissa_ptr, sizeof(result));
65     return negative ? ~result + 1 : result;
66   }
67   // Large number (outside uint32 range), Infinity or NaN.
68   return 0x80000000u;  // Return integer indefinite.
69 }
70
71
72 inline float DoubleToFloat32(double x) {
73   // TODO(yanggou): This static_cast is implementation-defined behaviour in C++,
74   // so we may need to do the conversion manually instead to match the spec.
75   volatile float f = static_cast<float>(x);
76   return f;
77 }
78
79
80 inline double DoubleToInteger(double x) {
81   if (std::isnan(x)) return 0;
82   if (!std::isfinite(x) || x == 0) return x;
83   return (x >= 0) ? std::floor(x) : std::ceil(x);
84 }
85
86
87 int32_t DoubleToInt32(double x) {
88   int32_t i = FastD2I(x);
89   if (FastI2D(i) == x) return i;
90   Double d(x);
91   int exponent = d.Exponent();
92   if (exponent < 0) {
93     if (exponent <= -Double::kSignificandSize) return 0;
94     return d.Sign() * static_cast<int32_t>(d.Significand() >> -exponent);
95   } else {
96     if (exponent > 31) return 0;
97     return d.Sign() * static_cast<int32_t>(d.Significand() << exponent);
98   }
99 }
100
101
102 bool IsSmiDouble(double value) {
103   return !IsMinusZero(value) && value >= Smi::kMinValue &&
104          value <= Smi::kMaxValue && value == FastI2D(FastD2I(value));
105 }
106
107
108 bool IsInt32Double(double value) {
109   return !IsMinusZero(value) && value >= kMinInt && value <= kMaxInt &&
110          value == FastI2D(FastD2I(value));
111 }
112
113
114 bool IsUint32Double(double value) {
115   return !IsMinusZero(value) && value >= 0 && value <= kMaxUInt32 &&
116          value == FastUI2D(FastD2UI(value));
117 }
118
119
120 int32_t NumberToInt32(Object* number) {
121   if (number->IsSmi()) return Smi::cast(number)->value();
122   return DoubleToInt32(number->Number());
123 }
124
125
126 uint32_t NumberToUint32(Object* number) {
127   if (number->IsSmi()) return Smi::cast(number)->value();
128   return DoubleToUint32(number->Number());
129 }
130
131
132 bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) {
133   SealHandleScope shs(isolate);
134   if (number->IsSmi()) {
135     int value = Smi::cast(number)->value();
136     DCHECK(static_cast<unsigned>(Smi::kMaxValue) <=
137            std::numeric_limits<size_t>::max());
138     if (value >= 0) {
139       *result = static_cast<size_t>(value);
140       return true;
141     }
142     return false;
143   } else {
144     DCHECK(number->IsHeapNumber());
145     double value = HeapNumber::cast(number)->value();
146     if (value >= 0 && value <= std::numeric_limits<size_t>::max()) {
147       *result = static_cast<size_t>(value);
148       return true;
149     } else {
150       return false;
151     }
152   }
153 }
154
155
156 size_t NumberToSize(Isolate* isolate, Object* number) {
157   size_t result = 0;
158   bool is_valid = TryNumberToSize(isolate, number, &result);
159   CHECK(is_valid);
160   return result;
161 }
162
163
164 uint32_t DoubleToUint32(double x) {
165   return static_cast<uint32_t>(DoubleToInt32(x));
166 }
167
168
169 template <class Iterator, class EndMark>
170 bool SubStringEquals(Iterator* current,
171                      EndMark end,
172                      const char* substring) {
173   DCHECK(**current == *substring);
174   for (substring++; *substring != '\0'; substring++) {
175     ++*current;
176     if (*current == end || **current != *substring) return false;
177   }
178   ++*current;
179   return true;
180 }
181
182
183 // Returns true if a nonspace character has been found and false if the
184 // end was been reached before finding a nonspace character.
185 template <class Iterator, class EndMark>
186 inline bool AdvanceToNonspace(UnicodeCache* unicode_cache,
187                               Iterator* current,
188                               EndMark end) {
189   while (*current != end) {
190     if (!unicode_cache->IsWhiteSpaceOrLineTerminator(**current)) return true;
191     ++*current;
192   }
193   return false;
194 }
195
196
197 // Parsing integers with radix 2, 4, 8, 16, 32. Assumes current != end.
198 template <int radix_log_2, class Iterator, class EndMark>
199 double InternalStringToIntDouble(UnicodeCache* unicode_cache,
200                                  Iterator current,
201                                  EndMark end,
202                                  bool negative,
203                                  bool allow_trailing_junk) {
204   DCHECK(current != end);
205
206   // Skip leading 0s.
207   while (*current == '0') {
208     ++current;
209     if (current == end) return SignedZero(negative);
210   }
211
212   int64_t number = 0;
213   int exponent = 0;
214   const int radix = (1 << radix_log_2);
215
216   do {
217     int digit;
218     if (*current >= '0' && *current <= '9' && *current < '0' + radix) {
219       digit = static_cast<char>(*current) - '0';
220     } else if (radix > 10 && *current >= 'a' && *current < 'a' + radix - 10) {
221       digit = static_cast<char>(*current) - 'a' + 10;
222     } else if (radix > 10 && *current >= 'A' && *current < 'A' + radix - 10) {
223       digit = static_cast<char>(*current) - 'A' + 10;
224     } else {
225       if (allow_trailing_junk ||
226           !AdvanceToNonspace(unicode_cache, &current, end)) {
227         break;
228       } else {
229         return JunkStringValue();
230       }
231     }
232
233     number = number * radix + digit;
234     int overflow = static_cast<int>(number >> 53);
235     if (overflow != 0) {
236       // Overflow occurred. Need to determine which direction to round the
237       // result.
238       int overflow_bits_count = 1;
239       while (overflow > 1) {
240         overflow_bits_count++;
241         overflow >>= 1;
242       }
243
244       int dropped_bits_mask = ((1 << overflow_bits_count) - 1);
245       int dropped_bits = static_cast<int>(number) & dropped_bits_mask;
246       number >>= overflow_bits_count;
247       exponent = overflow_bits_count;
248
249       bool zero_tail = true;
250       while (true) {
251         ++current;
252         if (current == end || !isDigit(*current, radix)) break;
253         zero_tail = zero_tail && *current == '0';
254         exponent += radix_log_2;
255       }
256
257       if (!allow_trailing_junk &&
258           AdvanceToNonspace(unicode_cache, &current, end)) {
259         return JunkStringValue();
260       }
261
262       int middle_value = (1 << (overflow_bits_count - 1));
263       if (dropped_bits > middle_value) {
264         number++;  // Rounding up.
265       } else if (dropped_bits == middle_value) {
266         // Rounding to even to consistency with decimals: half-way case rounds
267         // up if significant part is odd and down otherwise.
268         if ((number & 1) != 0 || !zero_tail) {
269           number++;  // Rounding up.
270         }
271       }
272
273       // Rounding up may cause overflow.
274       if ((number & (static_cast<int64_t>(1) << 53)) != 0) {
275         exponent++;
276         number >>= 1;
277       }
278       break;
279     }
280     ++current;
281   } while (current != end);
282
283   DCHECK(number < ((int64_t)1 << 53));
284   DCHECK(static_cast<int64_t>(static_cast<double>(number)) == number);
285
286   if (exponent == 0) {
287     if (negative) {
288       if (number == 0) return -0.0;
289       number = -number;
290     }
291     return static_cast<double>(number);
292   }
293
294   DCHECK(number != 0);
295   return std::ldexp(static_cast<double>(negative ? -number : number), exponent);
296 }
297
298
299 template <class Iterator, class EndMark>
300 double InternalStringToInt(UnicodeCache* unicode_cache,
301                            Iterator current,
302                            EndMark end,
303                            int radix) {
304   const bool allow_trailing_junk = true;
305   const double empty_string_val = JunkStringValue();
306
307   if (!AdvanceToNonspace(unicode_cache, &current, end)) {
308     return empty_string_val;
309   }
310
311   bool negative = false;
312   bool leading_zero = false;
313
314   if (*current == '+') {
315     // Ignore leading sign; skip following spaces.
316     ++current;
317     if (current == end) {
318       return JunkStringValue();
319     }
320   } else if (*current == '-') {
321     ++current;
322     if (current == end) {
323       return JunkStringValue();
324     }
325     negative = true;
326   }
327
328   if (radix == 0) {
329     // Radix detection.
330     radix = 10;
331     if (*current == '0') {
332       ++current;
333       if (current == end) return SignedZero(negative);
334       if (*current == 'x' || *current == 'X') {
335         radix = 16;
336         ++current;
337         if (current == end) return JunkStringValue();
338       } else {
339         leading_zero = true;
340       }
341     }
342   } else if (radix == 16) {
343     if (*current == '0') {
344       // Allow "0x" prefix.
345       ++current;
346       if (current == end) return SignedZero(negative);
347       if (*current == 'x' || *current == 'X') {
348         ++current;
349         if (current == end) return JunkStringValue();
350       } else {
351         leading_zero = true;
352       }
353     }
354   }
355
356   if (radix < 2 || radix > 36) return JunkStringValue();
357
358   // Skip leading zeros.
359   while (*current == '0') {
360     leading_zero = true;
361     ++current;
362     if (current == end) return SignedZero(negative);
363   }
364
365   if (!leading_zero && !isDigit(*current, radix)) {
366     return JunkStringValue();
367   }
368
369   if (base::bits::IsPowerOfTwo32(radix)) {
370     switch (radix) {
371       case 2:
372         return InternalStringToIntDouble<1>(
373             unicode_cache, current, end, negative, allow_trailing_junk);
374       case 4:
375         return InternalStringToIntDouble<2>(
376             unicode_cache, current, end, negative, allow_trailing_junk);
377       case 8:
378         return InternalStringToIntDouble<3>(
379             unicode_cache, current, end, negative, allow_trailing_junk);
380
381       case 16:
382         return InternalStringToIntDouble<4>(
383             unicode_cache, current, end, negative, allow_trailing_junk);
384
385       case 32:
386         return InternalStringToIntDouble<5>(
387             unicode_cache, current, end, negative, allow_trailing_junk);
388       default:
389         UNREACHABLE();
390     }
391   }
392
393   if (radix == 10) {
394     // Parsing with strtod.
395     const int kMaxSignificantDigits = 309;  // Doubles are less than 1.8e308.
396     // The buffer may contain up to kMaxSignificantDigits + 1 digits and a zero
397     // end.
398     const int kBufferSize = kMaxSignificantDigits + 2;
399     char buffer[kBufferSize];
400     int buffer_pos = 0;
401     while (*current >= '0' && *current <= '9') {
402       if (buffer_pos <= kMaxSignificantDigits) {
403         // If the number has more than kMaxSignificantDigits it will be parsed
404         // as infinity.
405         DCHECK(buffer_pos < kBufferSize);
406         buffer[buffer_pos++] = static_cast<char>(*current);
407       }
408       ++current;
409       if (current == end) break;
410     }
411
412     if (!allow_trailing_junk &&
413         AdvanceToNonspace(unicode_cache, &current, end)) {
414       return JunkStringValue();
415     }
416
417     SLOW_DCHECK(buffer_pos < kBufferSize);
418     buffer[buffer_pos] = '\0';
419     Vector<const char> buffer_vector(buffer, buffer_pos);
420     return negative ? -Strtod(buffer_vector, 0) : Strtod(buffer_vector, 0);
421   }
422
423   // The following code causes accumulating rounding error for numbers greater
424   // than ~2^56. It's explicitly allowed in the spec: "if R is not 2, 4, 8, 10,
425   // 16, or 32, then mathInt may be an implementation-dependent approximation to
426   // the mathematical integer value" (15.1.2.2).
427
428   int lim_0 = '0' + (radix < 10 ? radix : 10);
429   int lim_a = 'a' + (radix - 10);
430   int lim_A = 'A' + (radix - 10);
431
432   // NOTE: The code for computing the value may seem a bit complex at
433   // first glance. It is structured to use 32-bit multiply-and-add
434   // loops as long as possible to avoid loosing precision.
435
436   double v = 0.0;
437   bool done = false;
438   do {
439     // Parse the longest part of the string starting at index j
440     // possible while keeping the multiplier, and thus the part
441     // itself, within 32 bits.
442     unsigned int part = 0, multiplier = 1;
443     while (true) {
444       int d;
445       if (*current >= '0' && *current < lim_0) {
446         d = *current - '0';
447       } else if (*current >= 'a' && *current < lim_a) {
448         d = *current - 'a' + 10;
449       } else if (*current >= 'A' && *current < lim_A) {
450         d = *current - 'A' + 10;
451       } else {
452         done = true;
453         break;
454       }
455
456       // Update the value of the part as long as the multiplier fits
457       // in 32 bits. When we can't guarantee that the next iteration
458       // will not overflow the multiplier, we stop parsing the part
459       // by leaving the loop.
460       const unsigned int kMaximumMultiplier = 0xffffffffU / 36;
461       uint32_t m = multiplier * radix;
462       if (m > kMaximumMultiplier) break;
463       part = part * radix + d;
464       multiplier = m;
465       DCHECK(multiplier > part);
466
467       ++current;
468       if (current == end) {
469         done = true;
470         break;
471       }
472     }
473
474     // Update the value and skip the part in the string.
475     v = v * multiplier + part;
476   } while (!done);
477
478   if (!allow_trailing_junk &&
479       AdvanceToNonspace(unicode_cache, &current, end)) {
480     return JunkStringValue();
481   }
482
483   return negative ? -v : v;
484 }
485
486
487 // Converts a string to a double value. Assumes the Iterator supports
488 // the following operations:
489 // 1. current == end (other ops are not allowed), current != end.
490 // 2. *current - gets the current character in the sequence.
491 // 3. ++current (advances the position).
492 template <class Iterator, class EndMark>
493 double InternalStringToDouble(UnicodeCache* unicode_cache,
494                               Iterator current,
495                               EndMark end,
496                               int flags,
497                               double empty_string_val) {
498   // To make sure that iterator dereferencing is valid the following
499   // convention is used:
500   // 1. Each '++current' statement is followed by check for equality to 'end'.
501   // 2. If AdvanceToNonspace returned false then current == end.
502   // 3. If 'current' becomes be equal to 'end' the function returns or goes to
503   // 'parsing_done'.
504   // 4. 'current' is not dereferenced after the 'parsing_done' label.
505   // 5. Code before 'parsing_done' may rely on 'current != end'.
506   if (!AdvanceToNonspace(unicode_cache, &current, end)) {
507     return empty_string_val;
508   }
509
510   const bool allow_trailing_junk = (flags & ALLOW_TRAILING_JUNK) != 0;
511
512   // The longest form of simplified number is: "-<significant digits>'.1eXXX\0".
513   const int kBufferSize = kMaxSignificantDigits + 10;
514   char buffer[kBufferSize];  // NOLINT: size is known at compile time.
515   int buffer_pos = 0;
516
517   // Exponent will be adjusted if insignificant digits of the integer part
518   // or insignificant leading zeros of the fractional part are dropped.
519   int exponent = 0;
520   int significant_digits = 0;
521   int insignificant_digits = 0;
522   bool nonzero_digit_dropped = false;
523
524   enum Sign {
525     NONE,
526     NEGATIVE,
527     POSITIVE
528   };
529
530   Sign sign = NONE;
531
532   if (*current == '+') {
533     // Ignore leading sign.
534     ++current;
535     if (current == end) return JunkStringValue();
536     sign = POSITIVE;
537   } else if (*current == '-') {
538     ++current;
539     if (current == end) return JunkStringValue();
540     sign = NEGATIVE;
541   }
542
543   static const char kInfinityString[] = "Infinity";
544   if (*current == kInfinityString[0]) {
545     if (!SubStringEquals(&current, end, kInfinityString)) {
546       return JunkStringValue();
547     }
548
549     if (!allow_trailing_junk &&
550         AdvanceToNonspace(unicode_cache, &current, end)) {
551       return JunkStringValue();
552     }
553
554     DCHECK(buffer_pos == 0);
555     return (sign == NEGATIVE) ? -V8_INFINITY : V8_INFINITY;
556   }
557
558   bool leading_zero = false;
559   if (*current == '0') {
560     ++current;
561     if (current == end) return SignedZero(sign == NEGATIVE);
562
563     leading_zero = true;
564
565     // It could be hexadecimal value.
566     if ((flags & ALLOW_HEX) && (*current == 'x' || *current == 'X')) {
567       ++current;
568       if (current == end || !isDigit(*current, 16) || sign != NONE) {
569         return JunkStringValue();  // "0x".
570       }
571
572       return InternalStringToIntDouble<4>(unicode_cache,
573                                           current,
574                                           end,
575                                           false,
576                                           allow_trailing_junk);
577
578     // It could be an explicit octal value.
579     } else if ((flags & ALLOW_OCTAL) && (*current == 'o' || *current == 'O')) {
580       ++current;
581       if (current == end || !isDigit(*current, 8) || sign != NONE) {
582         return JunkStringValue();  // "0o".
583       }
584
585       return InternalStringToIntDouble<3>(unicode_cache,
586                                           current,
587                                           end,
588                                           false,
589                                           allow_trailing_junk);
590
591     // It could be a binary value.
592     } else if ((flags & ALLOW_BINARY) && (*current == 'b' || *current == 'B')) {
593       ++current;
594       if (current == end || !isBinaryDigit(*current) || sign != NONE) {
595         return JunkStringValue();  // "0b".
596       }
597
598       return InternalStringToIntDouble<1>(unicode_cache,
599                                           current,
600                                           end,
601                                           false,
602                                           allow_trailing_junk);
603     }
604
605     // Ignore leading zeros in the integer part.
606     while (*current == '0') {
607       ++current;
608       if (current == end) return SignedZero(sign == NEGATIVE);
609     }
610   }
611
612   bool octal = leading_zero && (flags & ALLOW_IMPLICIT_OCTAL) != 0;
613
614   // Copy significant digits of the integer part (if any) to the buffer.
615   while (*current >= '0' && *current <= '9') {
616     if (significant_digits < kMaxSignificantDigits) {
617       DCHECK(buffer_pos < kBufferSize);
618       buffer[buffer_pos++] = static_cast<char>(*current);
619       significant_digits++;
620       // Will later check if it's an octal in the buffer.
621     } else {
622       insignificant_digits++;  // Move the digit into the exponential part.
623       nonzero_digit_dropped = nonzero_digit_dropped || *current != '0';
624     }
625     octal = octal && *current < '8';
626     ++current;
627     if (current == end) goto parsing_done;
628   }
629
630   if (significant_digits == 0) {
631     octal = false;
632   }
633
634   if (*current == '.') {
635     if (octal && !allow_trailing_junk) return JunkStringValue();
636     if (octal) goto parsing_done;
637
638     ++current;
639     if (current == end) {
640       if (significant_digits == 0 && !leading_zero) {
641         return JunkStringValue();
642       } else {
643         goto parsing_done;
644       }
645     }
646
647     if (significant_digits == 0) {
648       // octal = false;
649       // Integer part consists of 0 or is absent. Significant digits start after
650       // leading zeros (if any).
651       while (*current == '0') {
652         ++current;
653         if (current == end) return SignedZero(sign == NEGATIVE);
654         exponent--;  // Move this 0 into the exponent.
655       }
656     }
657
658     // There is a fractional part.  We don't emit a '.', but adjust the exponent
659     // instead.
660     while (*current >= '0' && *current <= '9') {
661       if (significant_digits < kMaxSignificantDigits) {
662         DCHECK(buffer_pos < kBufferSize);
663         buffer[buffer_pos++] = static_cast<char>(*current);
664         significant_digits++;
665         exponent--;
666       } else {
667         // Ignore insignificant digits in the fractional part.
668         nonzero_digit_dropped = nonzero_digit_dropped || *current != '0';
669       }
670       ++current;
671       if (current == end) goto parsing_done;
672     }
673   }
674
675   if (!leading_zero && exponent == 0 && significant_digits == 0) {
676     // If leading_zeros is true then the string contains zeros.
677     // If exponent < 0 then string was [+-]\.0*...
678     // If significant_digits != 0 the string is not equal to 0.
679     // Otherwise there are no digits in the string.
680     return JunkStringValue();
681   }
682
683   // Parse exponential part.
684   if (*current == 'e' || *current == 'E') {
685     if (octal) return JunkStringValue();
686     ++current;
687     if (current == end) {
688       if (allow_trailing_junk) {
689         goto parsing_done;
690       } else {
691         return JunkStringValue();
692       }
693     }
694     char sign = '+';
695     if (*current == '+' || *current == '-') {
696       sign = static_cast<char>(*current);
697       ++current;
698       if (current == end) {
699         if (allow_trailing_junk) {
700           goto parsing_done;
701         } else {
702           return JunkStringValue();
703         }
704       }
705     }
706
707     if (current == end || *current < '0' || *current > '9') {
708       if (allow_trailing_junk) {
709         goto parsing_done;
710       } else {
711         return JunkStringValue();
712       }
713     }
714
715     const int max_exponent = INT_MAX / 2;
716     DCHECK(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2);
717     int num = 0;
718     do {
719       // Check overflow.
720       int digit = *current - '0';
721       if (num >= max_exponent / 10
722           && !(num == max_exponent / 10 && digit <= max_exponent % 10)) {
723         num = max_exponent;
724       } else {
725         num = num * 10 + digit;
726       }
727       ++current;
728     } while (current != end && *current >= '0' && *current <= '9');
729
730     exponent += (sign == '-' ? -num : num);
731   }
732
733   if (!allow_trailing_junk &&
734       AdvanceToNonspace(unicode_cache, &current, end)) {
735     return JunkStringValue();
736   }
737
738   parsing_done:
739   exponent += insignificant_digits;
740
741   if (octal) {
742     return InternalStringToIntDouble<3>(unicode_cache,
743                                         buffer,
744                                         buffer + buffer_pos,
745                                         sign == NEGATIVE,
746                                         allow_trailing_junk);
747   }
748
749   if (nonzero_digit_dropped) {
750     buffer[buffer_pos++] = '1';
751     exponent--;
752   }
753
754   SLOW_DCHECK(buffer_pos < kBufferSize);
755   buffer[buffer_pos] = '\0';
756
757   double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
758   return (sign == NEGATIVE) ? -converted : converted;
759 }
760
761 }  // namespace internal
762 }  // namespace v8
763
764 #endif  // V8_CONVERSIONS_INL_H_