38 using namespace v8::internal;
 
   45 static double StrtodChar(
const char* str, 
int exponent) {
 
   46   return Strtod(StringToVector(str), exponent);
 
   53   vector = StringToVector(
"0");
 
   60   vector = StringToVector(
"1");
 
   79   vector = StringToVector(
"2");
 
   98   vector = StringToVector(
"9");
 
  117   vector = StringToVector(
"12345");
 
  139   vector = StringToVector(
"12345678901234");
 
  161   vector = StringToVector(
"123456789012345");
 
  181   CHECK_EQ(0.0, StrtodChar(
"0", 12345));
 
  182   CHECK_EQ(0.0, StrtodChar(
"", 1324));
 
  183   CHECK_EQ(0.0, StrtodChar(
"000000000", 123));
 
  184   CHECK_EQ(0.0, StrtodChar(
"2", -324));
 
  185   CHECK_EQ(4e-324, StrtodChar(
"3", -324));
 
  189   CHECK_EQ(0.0, StrtodChar(
"1", -325));
 
  190   CHECK_EQ(0.0, StrtodChar(
"1", -325));
 
  191   CHECK_EQ(0.0, StrtodChar(
"20000", -328));
 
  192   CHECK_EQ(40000e-328, StrtodChar(
"30000", -328));
 
  193   CHECK_EQ(0.0, StrtodChar(
"10000", -329));
 
  194   CHECK_EQ(0.0, StrtodChar(
"90000", -329));
 
  195   CHECK_EQ(0.0, StrtodChar(
"000000001", -325));
 
  196   CHECK_EQ(0.0, StrtodChar(
"000000001", -325));
 
  197   CHECK_EQ(0.0, StrtodChar(
"0000000020000", -328));
 
  198   CHECK_EQ(40000e-328, StrtodChar(
"00000030000", -328));
 
  199   CHECK_EQ(0.0, StrtodChar(
"0000000010000", -329));
 
  200   CHECK_EQ(0.0, StrtodChar(
"0000000090000", -329));
 
  206   CHECK_EQ(1e308, StrtodChar(
"1", 308));
 
  207   CHECK_EQ(1234e305, StrtodChar(
"1234", 305));
 
  208   CHECK_EQ(1234e304, StrtodChar(
"1234", 304));
 
  210   CHECK_EQ(17e307, StrtodChar(
"17", 307));
 
  212   CHECK_EQ(1e308, StrtodChar(
"00000001", 308));
 
  213   CHECK_EQ(1234e305, StrtodChar(
"00000001234", 305));
 
  214   CHECK_EQ(1234e304, StrtodChar(
"000000001234", 304));
 
  216   CHECK_EQ(17e307, StrtodChar(
"0000000017", 307));
 
  218   CHECK_EQ(1e308, StrtodChar(
"100000", 303));
 
  219   CHECK_EQ(1234e305, StrtodChar(
"123400000", 300));
 
  220   CHECK_EQ(1234e304, StrtodChar(
"123400000", 299));
 
  222   CHECK_EQ(17e307, StrtodChar(
"170000000", 300));
 
  224   CHECK_EQ(1e308, StrtodChar(
"000000000000100000", 303));
 
  225   CHECK_EQ(1234e305, StrtodChar(
"00000000123400000", 300));
 
  226   CHECK_EQ(1234e304, StrtodChar(
"0000000123400000", 299));
 
  228   CHECK_EQ(17e307, StrtodChar(
"00000000170000000", 300));
 
  229   CHECK_EQ(1.7976931348623157E+308, StrtodChar(
"17976931348623157", 292));
 
  230   CHECK_EQ(1.7976931348623158E+308, StrtodChar(
"17976931348623158", 292));
 
  237   CHECK_EQ(89255e-22, StrtodChar(
"89255", -22));
 
  240   CHECK_EQ(358416272e-33, StrtodChar(
"358416272", -33));
 
  241   CHECK_EQ(104110013277974872254e-225,
 
  242            StrtodChar(
"104110013277974872254", -225));
 
  244   CHECK_EQ(123456789e108, StrtodChar(
"123456789", 108));
 
  245   CHECK_EQ(123456789e109, StrtodChar(
"123456789", 109));
 
  246   CHECK_EQ(123456789e110, StrtodChar(
"123456789", 110));
 
  247   CHECK_EQ(123456789e111, StrtodChar(
"123456789", 111));
 
  248   CHECK_EQ(123456789e112, StrtodChar(
"123456789", 112));
 
  249   CHECK_EQ(123456789e113, StrtodChar(
"123456789", 113));
 
  250   CHECK_EQ(123456789e114, StrtodChar(
"123456789", 114));
 
  251   CHECK_EQ(123456789e115, StrtodChar(
"123456789", 115));
 
  253   CHECK_EQ(1234567890123456789012345e108,
 
  254            StrtodChar(
"1234567890123456789012345", 108));
 
  255   CHECK_EQ(1234567890123456789012345e109,
 
  256            StrtodChar(
"1234567890123456789012345", 109));
 
  257   CHECK_EQ(1234567890123456789012345e110,
 
  258            StrtodChar(
"1234567890123456789012345", 110));
 
  259   CHECK_EQ(1234567890123456789012345e111,
 
  260            StrtodChar(
"1234567890123456789012345", 111));
 
  261   CHECK_EQ(1234567890123456789012345e112,
 
  262            StrtodChar(
"1234567890123456789012345", 112));
 
  263   CHECK_EQ(1234567890123456789012345e113,
 
  264            StrtodChar(
"1234567890123456789012345", 113));
 
  265   CHECK_EQ(1234567890123456789012345e114,
 
  266            StrtodChar(
"1234567890123456789012345", 114));
 
  267   CHECK_EQ(1234567890123456789012345e115,
 
  268            StrtodChar(
"1234567890123456789012345", 115));
 
  270   CHECK_EQ(1234567890123456789052345e108,
 
  271            StrtodChar(
"1234567890123456789052345", 108));
 
  272   CHECK_EQ(1234567890123456789052345e109,
 
  273            StrtodChar(
"1234567890123456789052345", 109));
 
  274   CHECK_EQ(1234567890123456789052345e110,
 
  275            StrtodChar(
"1234567890123456789052345", 110));
 
  276   CHECK_EQ(1234567890123456789052345e111,
 
  277            StrtodChar(
"1234567890123456789052345", 111));
 
  278   CHECK_EQ(1234567890123456789052345e112,
 
  279            StrtodChar(
"1234567890123456789052345", 112));
 
  280   CHECK_EQ(1234567890123456789052345e113,
 
  281            StrtodChar(
"1234567890123456789052345", 113));
 
  282   CHECK_EQ(1234567890123456789052345e114,
 
  283            StrtodChar(
"1234567890123456789052345", 114));
 
  284   CHECK_EQ(1234567890123456789052345e115,
 
  285            StrtodChar(
"1234567890123456789052345", 115));
 
  288            StrtodChar(
"5445618932859895362967233318697132813618813095743952975" 
  289                       "4392982234069699615600475529427176366709107287468930197" 
  290                       "8628345413991790019316974825934906752493984055268219809" 
  291                       "5012176093045431437495773903922425632551857520884625114" 
  292                       "6241265881735209066709685420744388526014389929047617597" 
  293                       "0302268848374508109029268898695825171158085457567481507" 
  294                       "4162979705098246243690189880319928315307816832576838178" 
  295                       "2563074014542859888710209237525873301724479666744537857" 
  296                       "9026553346649664045621387124193095870305991178772256504" 
  297                       "4368663670643970181259143319016472430928902201239474588" 
  298                       "1392338901353291306607057623202353588698746085415097902" 
  299                       "6640064319118728664842287477491068264828851624402189317" 
  300                       "2769161449825765517353755844373640588822904791244190695" 
  301                       "2998382932630754670573838138825217065450843010498555058" 
  302                       "88186560731", -1035));
 
  309   CHECK_EQ(72057594037927928.0, StrtodChar(
"72057594037927928", 0));
 
  310   CHECK_EQ(72057594037927936.0, StrtodChar(
"72057594037927936", 0));
 
  311   CHECK_EQ(72057594037927936.0, StrtodChar(
"72057594037927932", 0));
 
  312   CHECK_EQ(72057594037927928.0, StrtodChar(
"7205759403792793199999", -5));
 
  313   CHECK_EQ(72057594037927936.0, StrtodChar(
"7205759403792793200001", -5));
 
  318   CHECK_EQ(9223372036854774784.0, StrtodChar(
"9223372036854774784", 0));
 
  319   CHECK_EQ(9223372036854775808.0, StrtodChar(
"9223372036854775808", 0));
 
  320   CHECK_EQ(9223372036854775808.0, StrtodChar(
"9223372036854775296", 0));
 
  321   CHECK_EQ(9223372036854774784.0, StrtodChar(
"922337203685477529599999", -5));
 
  322   CHECK_EQ(9223372036854775808.0, StrtodChar(
"922337203685477529600001", -5));
 
  327   CHECK_EQ(10141204801825834086073718800384.0,
 
  328            StrtodChar(
"10141204801825834086073718800384", 0));
 
  329   CHECK_EQ(10141204801825835211973625643008.0,
 
  330            StrtodChar(
"10141204801825835211973625643008", 0));
 
  331   CHECK_EQ(10141204801825835211973625643008.0,
 
  332            StrtodChar(
"10141204801825834649023672221696", 0));
 
  333   CHECK_EQ(10141204801825834086073718800384.0,
 
  334            StrtodChar(
"1014120480182583464902367222169599999", -5));
 
  335   CHECK_EQ(10141204801825835211973625643008.0,
 
  336            StrtodChar(
"1014120480182583464902367222169600001", -5));
 
  342   CHECK_EQ(5708990770823838890407843763683279797179383808.0,
 
  343            StrtodChar(
"5708990770823838890407843763683279797179383808", 0));
 
  344   CHECK_EQ(5708990770823839524233143877797980545530986496.0,
 
  345            StrtodChar(
"5708990770823839524233143877797980545530986496", 0));
 
  346   CHECK_EQ(5708990770823839524233143877797980545530986496.0,
 
  347            StrtodChar(
"5708990770823839207320493820740630171355185152", 0));
 
  348   CHECK_EQ(5708990770823838890407843763683279797179383808.0,
 
  349            StrtodChar(
"5708990770823839207320493820740630171355185151999", -3));
 
  350   CHECK_EQ(5708990770823839524233143877797980545530986496.0,
 
  351            StrtodChar(
"5708990770823839207320493820740630171355185152001", -3));
 
  355   CHECK_EQ(2.225073858507201e-308, StrtodChar(
"22250738585072011", -324));
 
  356   CHECK_EQ(2.22507385850720138309e-308,
 
  357            StrtodChar(
"22250738585072011360574097967091319759348195463516456480" 
  358                       "23426109724822222021076945516529523908135087914149158913" 
  359                       "03962110687008643869459464552765720740782062174337998814" 
  360                       "10632673292535522868813721490129811224514518898490572223" 
  361                       "07285255133155755015914397476397983411801999323962548289" 
  362                       "01710708185069063066665599493827577257201576306269066333" 
  363                       "26475653000092458883164330377797918696120494973903778297" 
  364                       "04905051080609940730262937128958950003583799967207254304" 
  365                       "36028407889577179615094551674824347103070260914462157228" 
  366                       "98802581825451803257070188608721131280795122334262883686" 
  367                       "22321503775666622503982534335974568884423900265498198385" 
  368                       "48794829220689472168983109969836584681402285424333066033" 
  369                       "98508864458040010349339704275671864433837704860378616227" 
  370                       "71738545623065874679014086723327636718751", -1076));
 
  374 static int CompareBignumToDiyFp(
const Bignum& bignum_digits,
 
  381   if (bignum_exponent >= 0) {
 
  386   if (diy_fp.
e() >= 0) {
 
  398   DiyFp lower_boundary;
 
  399   DiyFp upper_boundary;
 
  402   if (to_check == 0.0) {
 
  403     const double kMinDouble = 4e-324;
 
  406     d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
 
  407     return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) <= 0;
 
  410     const double kMaxDouble = 1.7976931348623157e308;
 
  413     d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
 
  414     return CompareBignumToDiyFp(input_digits, exponent, upper_boundary) >= 0;
 
  417   d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
 
  418   if ((d.Significand() & 1) == 0) {
 
  419     return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) >= 0 &&
 
  420         CompareBignumToDiyFp(input_digits, exponent, upper_boundary) <= 0;
 
  422     return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) > 0 &&
 
  423         CompareBignumToDiyFp(input_digits, exponent, upper_boundary) < 0;
 
  429 static uint32_t DeterministicRandom() {
 
  431   static uint32_t 
hi = 0;
 
  432   static uint32_t 
lo = 0;
 
  436   if (hi == 0) hi = 0xbfe166e7;
 
  437   if (lo == 0) lo = 0x64d1c3c9;
 
  440   hi = 36969 * (hi & 0xFFFF) + (hi >> 16);
 
  441   lo = 18273 * (lo & 0xFFFF) + (lo >> 16);
 
  442   return (hi << 16) + (lo & 0xFFFF);
 
  446 static const int kBufferSize = 1024;
 
  447 static const int kShortStrtodRandomCount = 2;
 
  448 static const int kLargeStrtodRandomCount = 2;
 
  451   srand(static_cast<unsigned int>(time(
NULL)));
 
  452   char buffer[kBufferSize];
 
  453   for (
int length = 1; length < 15; length++) {
 
  454     for (
int i = 0; i < kShortStrtodRandomCount; ++i) {
 
  456       for (
int j = 0; j < length; ++j) {
 
  457         buffer[pos++] = rand() % 10 + 
'0';
 
  459       int exponent = DeterministicRandom() % (25*2 + 1) - 25 - length;
 
  462       double strtod_result = 
Strtod(vector, exponent);
 
  463       CHECK(CheckDouble(vector, exponent, strtod_result));
 
  466   for (
int length = 15; length < 800; length += 2) {
 
  467     for (
int i = 0; i < kLargeStrtodRandomCount; ++i) {
 
  469       for (
int j = 0; j < length; ++j) {
 
  470         buffer[pos++] = rand() % 10 + 
'0';
 
  472       int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length;
 
  475       double strtod_result = 
Strtod(vector, exponent);
 
  476       CHECK(CheckDouble(vector, exponent, strtod_result));
 
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
 
void AssignBignum(const Bignum &other)
 
#define CHECK_EQ(expected, value)
 
void AssignUInt64(uint64_t value)
 
static int Compare(const Bignum &a, const Bignum &b)
 
double Strtod(Vector< const char > buffer, int exponent)
 
void ShiftLeft(int shift_amount)
 
int StrLength(const char *string)
 
void AssignDecimalString(Vector< const char > value)
 
void MultiplyByPowerOfTen(int exponent)