5 #ifndef V8_UTILS_INL_H_ 6 #define V8_UTILS_INL_H_ 10 #include "include/v8-platform.h" 11 #include "src/base/platform/time.h" 12 #include "src/char-predicates-inl.h" 21 : start_(TimestampMs()), result_(result) {}
23 ~
TimedScope() { *result_ = TimestampMs() - start_; }
26 static inline double TimestampMs() {
27 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() *
28 static_cast<double>(base::Time::kMillisecondsPerSecond);
35 template <
typename Char>
36 bool TryAddIndexChar(
uint32_t* index, Char c) {
37 if (!IsDecimalDigit(c))
return false;
39 if (*index > 429496729U - ((d + 3) >> 3))
return false;
40 *index = (*index) * 10 + d;
44 template <
typename Stream>
45 bool StringToArrayIndex(Stream* stream,
uint32_t* index) {
46 uint16_t ch = stream->GetNext();
52 return !stream->HasMore();
56 if (!IsDecimalDigit(ch))
return false;
59 while (stream->HasMore()) {
60 if (!TryAddIndexChar(&result, stream->GetNext()))
return false;
70 #endif // V8_UTILS_INL_H_