69 static const int msb4[] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4};
83 return nibble + msb4[x];
106 template <
typename T>
108 return Compare<T>(*a, *b);
115 template<
typename T>
class Handle;
116 template <
typename T>
118 return Compare<T*>(*(*a), *(*b));
122 template <
typename T,
typename U>
124 return (value & (alignment - 1)) == 0;
138 template <
typename T>
140 return a < b ? b : a;
145 template <
typename T>
147 return a < b ? a : b;
152 template <
typename T>
154 return a < 0 ? -a : a;
161 if (x == 0)
return x;
163 return std::floor(x);
196 template<
class T,
int shift,
int size,
class U>
202 static const U kOne =
static_cast<U>(1U);
213 return (
static_cast<U>(value) & ~
static_cast<U>(
kMax)) == 0;
219 return static_cast<U>(value) <<
shift;
234 template<
class T,
int shift,
int size>
238 template<
class T,
int shift,
int size>
252 hash = ~hash + (hash << 15);
253 hash = hash ^ (hash >> 12);
254 hash = hash + (hash << 2);
255 hash = hash ^ (hash >> 4);
257 hash = hash ^ (hash >> 16);
264 hash = ~hash + (hash << 18);
265 hash = hash ^ (hash >> 31);
267 hash = hash ^ (hash >> 11);
268 hash = hash + (hash << 6);
269 hash = hash ^ (hash >> 22);
276 static_cast<uint32_t>(
reinterpret_cast<intptr_t
>(ptr)),
288 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87)
294 void MemMove(
void* dest,
const void* src,
size_t size);
295 typedef void (*MemMoveFunction)(
void* dest,
const void* src,
size_t size);
302 #elif defined(V8_HOST_ARCH_ARM)
303 typedef void (*MemCopyUint8Function)(uint8_t* dest,
const uint8_t* src,
305 extern MemCopyUint8Function memcopy_uint8_function;
306 V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest,
const uint8_t* src,
308 memcpy(dest, src, chars);
313 (*memcopy_uint8_function)(
reinterpret_cast<uint8_t*
>(dest),
314 reinterpret_cast<const uint8_t*
>(src),
size);
317 memmove(dest, src,
size);
320 typedef void (*MemCopyUint16Uint8Function)(
uint16_t* dest,
const uint8_t* src,
322 extern MemCopyUint16Uint8Function memcopy_uint16_uint8_function;
323 void MemCopyUint16Uint8Wrapper(
uint16_t* dest,
const uint8_t* src,
326 const int kMinComplexConvertMemCopy = 12;
329 (*memcopy_uint16_uint8_function)(dest, src,
size);
331 #elif defined(V8_HOST_ARCH_MIPS)
332 typedef void (*MemCopyUint8Function)(uint8_t* dest,
const uint8_t* src,
334 extern MemCopyUint8Function memcopy_uint8_function;
335 V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest,
const uint8_t* src,
337 memcpy(dest, src, chars);
342 (*memcopy_uint8_function)(
reinterpret_cast<uint8_t*
>(dest),
343 reinterpret_cast<const uint8_t*
>(src),
size);
346 memmove(dest, src,
size);
351 memcpy(dest, src,
size);
354 memmove(dest, src,
size);
366 template <
typename T>
372 template <
typename S>
friend class Access;
379 template <
typename T>
427 template <
typename T,
int kSize>
433 for (
int i = 0;
i < kSize; ++
i) {
446 if (
this == &rhs)
return *
this;
467 template <
typename T,
int growth_factor = 2,
int max_growth = 1 * MB>
478 for (
int i =
chunks_.length() - 1;
i >= 0;
i--) {
505 for (
int i = 0;
i <
size;
i++) {
506 position[
i] = initial_value;
523 for (
int i = 0;
i < source.
length();
i++) {
524 position[
i] = source[
i];
536 for (
int j = 0; j < chunk.
length(); j++) {
537 destination[position] = chunk[j];
558 virtual void Reset();
572 DCHECK(growth_factor > 1);
577 new_capacity = min_capacity * growth_factor;
580 int growth = current_length * (growth_factor - 1);
581 if (growth > max_growth) {
584 new_capacity = current_length + growth;
585 if (new_capacity < min_capacity) {
586 new_capacity = min_capacity + growth;
619 template <
typename T,
int growth_factor = 2,
int max_growth = 1 * MB>
623 :
Collector<
T, growth_factor, max_growth>(initial_capacity),
646 this->
size_ -= sequence_length;
669 for (
int i = 0;
i < sequence_length;
i++) {
678 this->
index_ = sequence_length;
685 template <
typename l
char,
typename r
char>
689 const lchar* limit = lhs + chars;
690 if (
sizeof(*lhs) ==
sizeof(
char) &&
sizeof(*rhs) ==
sizeof(
char)) {
693 return memcmp(lhs, rhs, chars);
695 while (lhs < limit) {
696 int r =
static_cast<int>(*lhs) -
static_cast<int>(*rhs);
697 if (r != 0)
return r;
704 template<
typename l
char,
typename r
char>
705 inline int CompareChars(
const lchar* lhs,
const rchar* rhs,
int chars) {
706 DCHECK(
sizeof(lchar) <= 2);
707 DCHECK(
sizeof(rchar) <= 2);
708 if (
sizeof(lchar) == 1) {
709 if (
sizeof(rchar) == 1) {
711 reinterpret_cast<const uint8_t*
>(rhs),
715 reinterpret_cast<const uint16_t*
>(rhs),
719 if (
sizeof(rchar) == 1) {
721 reinterpret_cast<const uint8_t*
>(rhs),
725 reinterpret_cast<const uint16_t*
>(rhs),
737 for (
int i = 1;
i < exponent;
i++) answer *= 10;
742 template<
typename ElementType,
int NumElements>
747 int length()
const {
return NumElements; }
762 template<
typename ElementType>
768 static ElementType t = 0;
773 static ElementType t = 0;
846 template <
class E,
class T =
int>
872 DCHECK(
static_cast<int>(element) <
static_cast<int>(
sizeof(
T) * CHAR_BIT));
873 return static_cast<T>(1) << element;
881 return (x >> lsb) & ((1 << (1 + msb - lsb)) - 1);
885 return (x >> lsb) & ((
static_cast<uint64_t
>(1) << (1 + msb - lsb)) - 1);
889 return (x << (31 - msb)) >> (lsb + 31 - msb);
894 return (x << (63 - msb)) >> (lsb + 63 - msb);
899 DCHECK((0 < n) && (n < 64));
900 int64_t limit =
static_cast<int64_t
>(1) << (n - 1);
901 return (-limit <= x) && (x < limit);
912 return (x & ((
static_cast<T>(1) << n) - 1));
915 #define INT_1_TO_63_LIST(V) \
916 V(1) V(2) V(3) V(4) V(5) V(6) V(7) V(8) \
917 V(9) V(10) V(11) V(12) V(13) V(14) V(15) V(16) \
918 V(17) V(18) V(19) V(20) V(21) V(22) V(23) V(24) \
919 V(25) V(26) V(27) V(28) V(29) V(30) V(31) V(32) \
920 V(33) V(34) V(35) V(36) V(37) V(38) V(39) V(40) \
921 V(41) V(42) V(43) V(44) V(45) V(46) V(47) V(48) \
922 V(49) V(50) V(51) V(52) V(53) V(54) V(55) V(56) \
923 V(57) V(58) V(59) V(60) V(61) V(62) V(63)
925 #define DECLARE_IS_INT_N(N) \
926 inline bool is_int##N(int64_t x) { return is_intn(x, N); }
927 #define DECLARE_IS_UINT_N(N) \
929 inline bool is_uint##N(T x) { return is_uintn(x, N); }
930 #define DECLARE_TRUNCATE_TO_INT_N(N) \
932 inline T truncate_to_int##N(T x) { return truncate_to_intn(x, N); }
936 #undef DECLARE_IS_INT_N
937 #undef DECLARE_IS_UINT_N
938 #undef DECLARE_TRUNCATE_TO_INT_N
1013 #if defined(__MACH__) && defined(__APPLE__)
1014 #define PRINTF_CHECKING
1015 #define FPRINTF_CHECKING
1016 #define PRINTF_METHOD_CHECKING
1017 #define FPRINTF_METHOD_CHECKING
1019 #define PRINTF_CHECKING __attribute__ ((format (printf, 1, 2)))
1020 #define FPRINTF_CHECKING __attribute__ ((format (printf, 2, 3)))
1021 #define PRINTF_METHOD_CHECKING __attribute__ ((format (printf, 2, 3)))
1022 #define FPRINTF_METHOD_CHECKING __attribute__ ((format (printf, 3, 4)))
1025 #define PRINTF_CHECKING
1026 #define FPRINTF_CHECKING
1027 #define PRINTF_METHOD_CHECKING
1028 #define FPRINTF_METHOD_CHECKING
1041 int VSNPrintF(Vector<char> str,
const char* format, va_list args);
1043 void StrNCpy(Vector<char> dest,
const char* src,
size_t n);
1046 void Flush(FILE* out);
1055 char*
ReadLine(
const char* prompt);
1061 byte*
ReadBytes(
const char* filename,
int*
size,
bool verbose =
true);
1069 bool verbose =
true);
1077 bool verbose =
true);
1085 bool verbose =
true);
1093 const char* str,
int size,
bool verbose =
true);
1099 template <
typename T>
1111 template <
typename T>
1123 static const size_t kBlockCopyLimit = 16;
1125 if (num_words < kBlockCopyLimit) {
1129 }
while (num_words > 0);
1137 template <
typename T>
1144 static const size_t kBlockCopyLimit = 16;
1146 if (num_words < kBlockCopyLimit &&
1147 ((dst < src) || (dst >= (src + num_words *
kPointerSize)))) {
1148 T* end = dst + num_words;
1152 }
while (num_words > 0);
1160 template <
typename T>
1163 DCHECK(
Min(dst,
const_cast<T*
>(src)) + num_bytes <=
1164 Max(dst,
const_cast<T*
>(src)));
1165 if (num_bytes == 0)
return;
1171 if (num_bytes <
static_cast<size_t>(kBlockCopyLimit)) {
1175 }
while (num_bytes > 0);
1182 template <
typename T,
typename U>
1190 #if V8_HOST_ARCH_IA32
1191 #define STOS "stosl"
1192 #elif V8_HOST_ARCH_X64
1193 #if V8_HOST_ARCH_32_BIT
1194 #define STOS "addr32 stosl"
1196 #define STOS "stosq"
1199 #if defined(__native_client__)
1207 #if defined(MEMORY_SANITIZER)
1212 #if defined(__GNUC__) && defined(STOS)
1216 :
"+&c" (counter),
"+&D" (dest)
1220 for (
int i = 0;
i < counter;
i++) {
1232 Vector<const char>
ReadFile(
const char* filename,
1234 bool verbose =
true);
1237 bool verbose =
true);
1240 template <
typename source
char,
typename sink
char>
1242 const sourcechar* src,
1244 #if defined(V8_HOST_ARCH_ARM)
1248 #elif defined(V8_HOST_ARCH_MIPS)
1254 template <
typename source
char,
typename sink
char>
1257 template<
typename source
char,
typename sink
char>
1258 void CopyChars(sinkchar* dest,
const sourcechar* src,
int chars) {
1259 DCHECK(
sizeof(sourcechar) <= 2);
1260 DCHECK(
sizeof(sinkchar) <= 2);
1261 if (
sizeof(sinkchar) == 1) {
1262 if (
sizeof(sourcechar) == 1) {
1264 reinterpret_cast<const uint8_t*
>(src),
1268 reinterpret_cast<const uint16_t*
>(src),
1272 if (
sizeof(sourcechar) == 1) {
1274 reinterpret_cast<const uint8_t*
>(src),
1278 reinterpret_cast<const uint16_t*
>(src),
1284 template <
typename source
char,
typename sink
char>
1286 sinkchar* limit = dest + chars;
1287 if ((
sizeof(*dest) ==
sizeof(*src)) &&
1289 MemCopy(dest, src, chars *
sizeof(*dest));
1291 while (dest < limit) *dest++ =
static_cast<sinkchar
>(*src++);
1296 #if defined(V8_HOST_ARCH_ARM)
1298 switch (
static_cast<unsigned>(chars)) {
1305 memcpy(dest, src, 2);
1308 memcpy(dest, src, 3);
1311 memcpy(dest, src, 4);
1314 memcpy(dest, src, 5);
1317 memcpy(dest, src, 6);
1320 memcpy(dest, src, 7);
1323 memcpy(dest, src, 8);
1326 memcpy(dest, src, 9);
1329 memcpy(dest, src, 10);
1332 memcpy(dest, src, 11);
1335 memcpy(dest, src, 12);
1338 memcpy(dest, src, 13);
1341 memcpy(dest, src, 14);
1344 memcpy(dest, src, 15);
1354 if (chars >= kMinComplexConvertMemCopy) {
1355 MemCopyUint16Uint8(dest, src, chars);
1357 MemCopyUint16Uint8Wrapper(dest, src, chars);
1363 switch (
static_cast<unsigned>(chars)) {
1370 memcpy(dest, src, 4);
1373 memcpy(dest, src, 6);
1376 memcpy(dest, src, 8);
1379 memcpy(dest, src, 10);
1382 memcpy(dest, src, 12);
1385 memcpy(dest, src, 14);
1388 MemCopy(dest, src, chars *
sizeof(*dest));
1394 #elif defined(V8_HOST_ARCH_MIPS)
1397 memcpy(dest, src, chars);
1405 memcpy(dest, src, chars *
sizeof(*dest));
1407 MemCopy(dest, src, chars *
sizeof(*dest));
1430 template <
typename Stream>
1438 return !stream->HasMore();
1443 if (d < 0 || d > 9)
return false;
1445 while (stream->HasMore()) {
1446 d = stream->GetNext() -
'0';
1447 if (d < 0 || d > 9)
return false;
1449 if (result > 429496729U - ((d > 5) ? 1 : 0))
return false;
1450 result = (result * 10) + d;
An object reference managed by the v8 garbage collector.
Access(StaticResource< T > *resource)
StaticResource< T > * resource_
static const int kFirstUsableId
static const int kDeclarationsId
static BailoutId Declarations()
static BailoutId StubEntry()
static BailoutId FirstUsable()
static BailoutId FunctionEntry()
static const int kStubEntryId
bool operator!=(const BailoutId &other) const
static const int kFunctionEntryId
bool operator==(const BailoutId &other) const
static U update(U previous, T value)
static bool is_valid(T value)
void WriteTo(Vector< T > destination)
Vector< T > AddBlock(int size, T initial_value)
Collector(int initial_capacity=kMinCapacity)
static const int kMinCapacity
void Grow(int min_capacity)
Vector< T > AddBlock(Vector< const T > source)
List< Vector< T > > chunks_
Vector< T > current_chunk_
virtual void NewChunk(int new_capacity)
reverse_iterator rbegin()
ContainerPointerWrapper(C *container)
C::reverse_iterator reverse_iterator
ElementType & operator[](int i)
const ElementType & operator[](int i) const
ElementType & operator[](int i)
ElementType elems_[NumElements]
const ElementType & operator[](int i) const
EmbeddedVector(T initial_value)
EmbeddedVector(const EmbeddedVector &rhs)
EmbeddedVector & operator=(const EmbeddedVector &rhs)
void Remove(const EnumSet &set)
bool Contains(E element) const
EnumSet< E, T > operator|(const EnumSet &set) const
void Add(const EnumSet &set)
bool operator==(const EnumSet &set)
bool operator!=(const EnumSet &set)
bool ContainsAnyOf(const EnumSet &set) const
void Intersect(const EnumSet &set)
static const int kNoSequence
virtual ~SequenceCollector()
Vector< T > EndSequence()
SequenceCollector(int initial_capacity)
virtual void NewChunk(int new_capacity)
void AddDecimalInteger(int value)
SimpleStringBuilder(char *buffer, int size)
DISALLOW_IMPLICIT_CONSTRUCTORS(SimpleStringBuilder)
void AddPadding(char c, int count)
bool is_finalized() const
void AddCharacter(char c)
void AddSubstring(const char *s, int n)
SimpleStringBuilder(int size)
void AddString(const char *s)
DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder)
void AddFormattedList(const char *format, va_list list)
void AddFormatted(const char *format,...)
StringBuilder(char *buffer, int size)
static TypeFeedbackId None()
static Vector< T > New(int length)
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes A file to write the raw context snapshot bytes Write V8 startup blob file(mksnapshot only)") DEFINE_BOOL(profile_hydrogen_code_stub_compilation
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be NULL
enable harmony numeric enable harmony object literal extensions Optimize object Array shift
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
bool IsPowerOfTwo32(uint32_t value)
int WhichPowerOf2(uint32_t x)
void CopyChars(sinkchar *dest, const sourcechar *src, int chars)
int signed_bitextract_64(int msb, int lsb, int x)
char * ReadLine(const char *prompt)
void StrNCpy(Vector< char > dest, const char *src, size_t n)
bool IsAddressAligned(Address addr, intptr_t alignment, int offset=0)
void PrintPID(const char *format,...)
int PointerValueCompare(const T *a, const T *b)
int Compare(const T &a, const T &b)
uint32_t ComputeLongHash(uint64_t key)
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
int MostSignificantBit(uint32_t x)
bool is_uintn(int64_t x, unsigned n)
int CompareChars(const lchar *lhs, const rchar *rhs, int chars)
bool DoubleToBoolean(double d)
void MemsetPointer(T **dest, U *value, int counter)
static const uint32_t kZeroHashSeed
bool CStringEquals(const char *s1, const char *s2)
int SNPrintF(Vector< char > str, const char *format,...)
void MemMove(void *dest, const void *src, size_t size)
int AppendChars(const char *filename, const char *str, int size, bool verbose)
int32_t WhichPowerOf2Abs(int32_t x)
uint32_t ComputePointerHash(void *ptr)
DISABLE_ASAN uintptr_t GetCurrentStackPosition()
int WriteChars(const char *filename, const char *str, int size, bool verbose)
int ArithmeticShiftRight(int x, int s)
static LifetimePosition Max(LifetimePosition a, LifetimePosition b)
INLINE(static HeapObject *EnsureDoubleAligned(Heap *heap, HeapObject *object, int size))
void PrintF(const char *format,...)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
const int kMinComplexMemCopy
int WriteAsCFile(const char *filename, const char *varname, const char *str, int size, bool verbose=true)
int HandleObjectPointerCompare(const Handle< T > *a, const Handle< T > *b)
int CompareCharsUnsigned(const lchar *lhs, const rchar *rhs, int chars)
void CopyCharsUnsigned(sinkchar *dest, const sourcechar *src, int chars)
void CopyWords(T *dst, const T *src, size_t num_words)
int VSNPrintF(Vector< char > str, const char *format, va_list args)
uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed)
int TenToThe(int exponent)
int32_t signed_bitextract_32(int msb, int lsb, int32_t x)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
void MoveWords(T *dst, const T *src, size_t num_words)
uint64_t unsigned_bitextract_64(int msb, int lsb, uint64_t x)
T truncate_to_intn(T x, unsigned n)
bool is_intn(int64_t x, unsigned n)
byte * ReadBytes(const char *filename, int *size, bool verbose)
bool StringToArrayIndex(Stream *stream, uint32_t *index)
Vector< const char > ReadFile(const char *filename, bool *exists, bool verbose)
int WriteBytes(const char *filename, const byte *bytes, int size, bool verbose)
bool IsAligned(T value, U alignment)
void MemCopy(void *dest, const void *src, size_t size)
void init_memcopy_functions()
void CopyBytes(uint8_t *target, uint8_t *source)
uint32_t unsigned_bitextract_32(int msb, int lsb, uint32_t x)
Debugger support for the V8 JavaScript engine.
#define T(name, string, precedence)
#define DECLARE_IS_UINT_N(N)
#define INT_1_TO_63_LIST(V)
#define DECLARE_TRUNCATE_TO_INT_N(N)
#define DECLARE_IS_INT_N(N)