Commit 35f94cbe authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[refactoring] Prepare conversions{.h,-inl.h,.cc} for BigInt.parseInt

- Move things to conversions.cc that don't need to be in headers
- Turn InternalStringToInt into a subclassable helper class
  so we can re-use it for BigInt.parseInt
- Bonus: play a round of IWYU with all the .cc files who thought that
  #including conversions-inl.h would give them nice Unicode things

Bug: v8:6791
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I64022543a9b83002e2b78416c7e87b40a1a016e6
Reviewed-on: https://chromium-review.googlesource.com/673725
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48174}
parent 3b57e96c
......@@ -71,6 +71,7 @@
#include "src/startup-data-util.h"
#include "src/tracing/trace-event.h"
#include "src/trap-handler/trap-handler.h"
#include "src/unicode-cache-inl.h"
#include "src/unicode-inl.h"
#include "src/v8.h"
#include "src/v8threads.h"
......
This diff is collapsed.
This diff is collapsed.
......@@ -17,31 +17,10 @@ template <typename T>
class Handle;
class UnicodeCache;
// Maximum number of significant digits in decimal representation.
// The longest possible double in decimal representation is
// (2^53 - 1) * 2 ^ -1074 that is (2 ^ 53 - 1) * 5 ^ 1074 / 10 ^ 1074
// (768 digits). If we parse a number whose first digits are equal to a
// mean of 2 adjacent doubles (that could have up to 769 digits) the result
// must be rounded to the bigger one unless the tail consists of zeros, so
// we don't need to preserve all the digits.
const int kMaxSignificantDigits = 772;
// The limit for the the fractionDigits/precision for toFixed, toPrecision
// and toExponential.
const int kMaxFractionDigits = 100;
inline bool isDigit(int x, int radix) {
return (x >= '0' && x <= '9' && x < '0' + radix)
|| (radix > 10 && x >= 'a' && x < 'a' + radix - 10)
|| (radix > 10 && x >= 'A' && x < 'A' + radix - 10);
}
inline bool isBinaryDigit(int x) {
return x == '0' || x == '1';
}
// The fast double-to-(unsigned-)int conversion routine does not guarantee
// rounding towards zero.
// If x is NaN, the result is INT_MIN. Otherwise the result is the argument x,
......@@ -123,15 +102,7 @@ double StringToDouble(UnicodeCache* unicode_cache,
int flags,
double empty_string_val = 0);
// Converts a string into an integer.
double StringToInt(UnicodeCache* unicode_cache,
Vector<const uint8_t> vector,
int radix);
double StringToInt(UnicodeCache* unicode_cache,
Vector<const uc16> vector,
int radix);
double StringToInt(Isolate* isolate, Handle<String> string, int radix);
const int kDoubleToCStringMinBufferSize = 100;
......
......@@ -19,6 +19,8 @@
#include "src/objects/frame-array-inl.h"
#include "src/objects/module.h"
#include "src/objects/scope-info.h"
#include "src/unicode-cache.h"
#include "src/unicode-decoder.h"
namespace v8 {
namespace internal {
......
......@@ -52,6 +52,7 @@
#include "src/snapshot/snapshot.h"
#include "src/tracing/trace-event.h"
#include "src/trap-handler/trap-handler.h"
#include "src/unicode-inl.h"
#include "src/utils-inl.h"
#include "src/utils.h"
#include "src/v8.h"
......
......@@ -48,6 +48,7 @@
#include "src/simulator.h"
#include "src/snapshot/startup-deserializer.h"
#include "src/tracing/tracing-category-observer.h"
#include "src/unicode-cache.h"
#include "src/v8.h"
#include "src/version.h"
#include "src/visitors.h"
......
......@@ -29,6 +29,7 @@
#include "src/source-position-table.h"
#include "src/string-stream.h"
#include "src/tracing/tracing-category-observer.h"
#include "src/unicode-inl.h"
#include "src/vm-state-inl.h"
namespace v8 {
......
......@@ -70,6 +70,7 @@
#include "src/string-builder.h"
#include "src/string-search.h"
#include "src/string-stream.h"
#include "src/unicode-cache-inl.h"
#include "src/utils-inl.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
......
......@@ -14,6 +14,7 @@
#include "src/char-predicates-inl.h"
#include "src/conversions-inl.h"
#include "src/parsing/duplicate-finder.h" // For Scanner::FindSymbol
#include "src/unicode-cache-inl.h"
namespace v8 {
namespace internal {
......
......@@ -26,6 +26,7 @@
#include "src/splay-tree-inl.h"
#include "src/string-search.h"
#include "src/unicode-decoder.h"
#include "src/unicode-inl.h"
#ifdef V8_INTL_SUPPORT
#include "unicode/uniset.h"
......
......@@ -8,6 +8,7 @@
#include "src/isolate-inl.h"
#include "src/regexp/regexp-stack.h"
#include "src/simulator.h"
#include "src/unicode-inl.h"
#ifdef V8_INTL_SUPPORT
#include "unicode/uchar.h"
......
......@@ -52,20 +52,7 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) {
return isolate->heap()->nan_value();
}
double result;
{
DisallowHeapAllocation no_gc;
String::FlatContent flat = subject->GetFlatContent();
if (flat.IsOneByte()) {
result = StringToInt(isolate->unicode_cache(), flat.ToOneByteVector(),
radix32);
} else {
result =
StringToInt(isolate->unicode_cache(), flat.ToUC16Vector(), radix32);
}
}
double result = StringToInt(isolate, subject, radix32);
return *isolate->factory()->NewNumber(result);
}
......
......@@ -10,6 +10,7 @@
#include "src/handles.h"
#include "src/isolate-inl.h"
#include "src/string-search.h"
#include "src/unicode-inl.h"
namespace v8 {
namespace internal {
......
......@@ -43,6 +43,8 @@
#include "src/regexp/regexp-parser.h"
#include "src/splay-tree-inl.h"
#include "src/string-stream.h"
#include "src/unicode-inl.h"
#ifdef V8_INTERPRETED_REGEXP
#include "src/regexp/interpreter-irregexp.h"
#else // V8_INTERPRETED_REGEXP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment