38 #ifndef _STLP_VENDOR_CSTD
48 const char* str,
int flags,
double empty_string_val) {
51 const uint8_t* start =
reinterpret_cast<const uint8_t*
>(str);
52 const uint8_t* end = start +
StrLength(str);
61 double empty_string_val) {
64 const uint8_t* start =
reinterpret_cast<const uint8_t*
>(str.
start());
65 const uint8_t* end = start + str.
length();
74 double empty_string_val) {
84 case FP_INFINITE:
return (v < 0.0 ?
"-Infinity" :
"Infinity");
91 char decimal_rep[kV8DtoaBufferCapacity];
96 &sign, &length, &decimal_point);
98 if (sign) builder.AddCharacter(
'-');
100 if (length <= decimal_point && decimal_point <= 21) {
102 builder.AddString(decimal_rep);
103 builder.AddPadding(
'0', decimal_point - length);
105 }
else if (0 < decimal_point && decimal_point <= 21) {
107 builder.AddSubstring(decimal_rep, decimal_point);
108 builder.AddCharacter(
'.');
109 builder.AddString(decimal_rep + decimal_point);
111 }
else if (decimal_point <= 0 && decimal_point > -6) {
113 builder.AddString(
"0.");
114 builder.AddPadding(
'0', -decimal_point);
115 builder.AddString(decimal_rep);
119 builder.AddCharacter(decimal_rep[0]);
121 builder.AddCharacter(
'.');
122 builder.AddString(decimal_rep + 1);
124 builder.AddCharacter(
'e');
125 builder.AddCharacter((decimal_point >= 0) ?
'+' :
'-');
126 int exponent = decimal_point - 1;
127 if (exponent < 0) exponent = -exponent;
128 builder.AddDecimalInteger(exponent);
130 return builder.Finalize();
148 buffer[--i] =
'0' + (n % 10);
151 if (negative) buffer[--i] =
'-';
152 return buffer.
start() + i;
157 const int kMaxDigitsBeforePoint = 21;
158 const double kFirstNonFixed = 1e21;
159 const int kMaxDigitsAfterPoint = 20;
161 ASSERT(f <= kMaxDigitsAfterPoint);
164 double abs_value = value;
172 if (abs_value >= kFirstNonFixed) {
182 const int kDecimalRepCapacity =
183 kMaxDigitsBeforePoint + kMaxDigitsAfterPoint + 1;
184 char decimal_rep[kDecimalRepCapacity];
185 int decimal_rep_length;
188 &sign, &decimal_rep_length, &decimal_point);
191 int zero_prefix_length = 0;
192 int zero_postfix_length = 0;
194 if (decimal_point <= 0) {
195 zero_prefix_length = -decimal_point + 1;
199 if (zero_prefix_length + decimal_rep_length < decimal_point + f) {
200 zero_postfix_length = decimal_point + f - decimal_rep_length -
204 unsigned rep_length =
205 zero_prefix_length + decimal_rep_length + zero_postfix_length;
207 rep_builder.
AddPadding(
'0', zero_prefix_length);
209 rep_builder.
AddPadding(
'0', zero_postfix_length);
214 unsigned result_size = decimal_point + f + 2;
227 static char* CreateExponentialRepresentation(
char* decimal_rep,
230 int significant_digits) {
231 bool negative_exponent =
false;
233 negative_exponent =
true;
234 exponent = -exponent;
240 unsigned result_size = significant_digits + 7;
241 SimpleStringBuilder builder(result_size + 1);
243 if (negative) builder.AddCharacter(
'-');
244 builder.AddCharacter(decimal_rep[0]);
245 if (significant_digits != 1) {
246 builder.AddCharacter(
'.');
247 builder.AddString(decimal_rep + 1);
249 builder.AddPadding(
'0', significant_digits - rep_length);
252 builder.AddCharacter(
'e');
253 builder.AddCharacter(negative_exponent ?
'-' :
'+');
254 builder.AddDecimalInteger(exponent);
255 return builder.Finalize();
261 const int kMaxDigitsAfterPoint = 20;
263 ASSERT(f >= -1 && f <= kMaxDigitsAfterPoint);
265 bool negative =
false;
277 const int kV8DtoaBufferCapacity = kMaxDigitsAfterPoint + 1 + 1;
281 char decimal_rep[kV8DtoaBufferCapacity];
282 int decimal_rep_length;
287 &sign, &decimal_rep_length, &decimal_point);
288 f = decimal_rep_length - 1;
292 &sign, &decimal_rep_length, &decimal_point);
294 ASSERT(decimal_rep_length > 0);
295 ASSERT(decimal_rep_length <= f + 1);
297 int exponent = decimal_point - 1;
299 CreateExponentialRepresentation(decimal_rep, exponent, negative, f+1);
306 const int kMinimalDigits = 1;
307 const int kMaximalDigits = 21;
308 ASSERT(p >= kMinimalDigits && p <= kMaximalDigits);
311 bool negative =
false;
321 const int kV8DtoaBufferCapacity = kMaximalDigits + 1;
322 char decimal_rep[kV8DtoaBufferCapacity];
323 int decimal_rep_length;
327 &sign, &decimal_rep_length, &decimal_point);
328 ASSERT(decimal_rep_length <= p);
330 int exponent = decimal_point - 1;
334 if (exponent < -6 || exponent >= p) {
336 CreateExponentialRepresentation(decimal_rep, exponent, negative, p);
343 unsigned result_size = (decimal_point <= 0)
344 ? -decimal_point + p + 3
348 if (decimal_point <= 0) {
352 builder.
AddPadding(
'0', p - decimal_rep_length);
354 const int m =
Min(decimal_rep_length, decimal_point);
356 builder.
AddPadding(
'0', decimal_point - decimal_rep_length);
357 if (decimal_point < p) {
359 const int extra = negative ? 2 : 1;
360 if (decimal_rep_length > decimal_point) {
361 const int len =
StrLength(decimal_rep + decimal_point);
362 const int n =
Min(len, p - (builder.
position() - extra));
376 ASSERT(radix >= 2 && radix <= 36);
379 static const char chars[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
383 static const int kBufferSize = 1100;
384 char integer_buffer[kBufferSize];
385 integer_buffer[kBufferSize - 1] =
'\0';
389 char decimal_buffer[kBufferSize];
390 decimal_buffer[kBufferSize - 1] =
'\0';
393 bool is_negative = value < 0.0;
394 if (is_negative) value = -value;
397 double integer_part = std::floor(value);
398 double decimal_part = value - integer_part;
402 int integer_pos = kBufferSize - 2;
404 double remainder = std::fmod(integer_part, radix);
405 integer_buffer[integer_pos--] = chars[
static_cast<int>(remainder)];
406 integer_part -= remainder;
407 integer_part /= radix;
408 }
while (integer_part >= 1.0);
412 if (is_negative) integer_buffer[integer_pos--] =
'-';
424 while ((decimal_part > 0.0) && (decimal_pos < kBufferSize - 1)) {
425 decimal_part *= radix;
426 decimal_buffer[decimal_pos++] =
427 chars[
static_cast<int>(std::floor(decimal_part))];
428 decimal_part -= std::floor(decimal_part);
430 decimal_buffer[decimal_pos] =
'\0';
433 int integer_part_size = kBufferSize - 2 - integer_pos;
435 unsigned result_size = integer_part_size + decimal_pos;
437 if (decimal_pos > 0) result_size++;
440 builder.
AddSubstring(integer_buffer + integer_pos + 1, integer_part_size);
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 AddString(const char *s)
double InternalStringToDouble(UnicodeCache *unicode_cache, Iterator current, EndMark end, int flags, double empty_string_val)
#define ASSERT(condition)
double StringToDouble(UnicodeCache *unicode_cache, const char *str, int flags, double empty_string_val)
const char * IntToCString(int n, Vector< char > buffer)
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 trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
const char * DoubleToCString(double v, Vector< char > buffer)
int StrLength(const char *string)
char * DoubleToPrecisionCString(double value, int p)
void AddSubstring(const char *s, int n)
void AddCharacter(char c)
void AddPadding(char c, int count)
char * StrDup(const char *str)
char * DoubleToExponentialCString(double value, int f)
void DoubleToAscii(double v, DtoaMode mode, int requested_digits, Vector< char > buffer, int *sign, int *length, int *point)
char * DoubleToRadixCString(double value, int radix)
void DeleteArray(T *array)
const int kBase10MaximalLength
char * DoubleToFixedCString(double value, int f)