46 using namespace v8::internal;
48 static const unsigned kCounters = 256;
49 static int local_counters[kCounters];
50 static const char* local_counter_names[kCounters];
53 static unsigned CounterHash(
const char* s) {
64 static int* counter_function(
const char*
name) {
65 unsigned hash = CounterHash(name) % kCounters;
66 unsigned original_hash = hash;
69 if (local_counter_names[hash] == name) {
70 return &local_counters[hash];
72 if (local_counter_names[hash] == 0) {
73 local_counter_names[hash] =
name;
74 return &local_counters[hash];
76 if (strcmp(local_counter_names[hash], name) == 0) {
77 return &local_counters[hash];
79 hash = (hash + 1) % kCounters;
80 ASSERT(hash != original_hash);
93 return encoder.
Encode(AddressOf(
id));
97 static int make_code(
TypeCode type,
int id) {
111 Encode(encoder, Runtime::kAbort));
112 ExternalReference total_compile_size =
113 ExternalReference(isolate->
counters()->total_compile_size());
115 encoder.
Encode(total_compile_size.address()));
116 ExternalReference stack_limit_address =
117 ExternalReference::address_of_stack_limit(isolate);
119 encoder.
Encode(stack_limit_address.address()));
120 ExternalReference real_stack_limit_address =
121 ExternalReference::address_of_real_stack_limit(isolate);
123 encoder.
Encode(real_stack_limit_address.address()));
124 #ifdef ENABLE_DEBUGGER_SUPPORT
126 encoder.
Encode(ExternalReference::debug_break(isolate).address()));
127 #endif // ENABLE_DEBUGGER_SUPPORT
130 ExternalReference::new_space_start(isolate).address()));
133 ExternalReference::roots_array_start(isolate).address()));
135 encoder.
Encode(ExternalReference::cpu_features().address()));
147 CHECK_EQ(AddressOf(Runtime::kAbort),
150 ExternalReference total_compile_size =
151 ExternalReference(isolate->
counters()->total_compile_size());
152 CHECK_EQ(total_compile_size.address(),
155 Counters::k_total_compile_size)));
156 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(),
158 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(),
160 #ifdef ENABLE_DEBUGGER_SUPPORT
161 CHECK_EQ(ExternalReference::debug_break(isolate).address(),
163 #endif // ENABLE_DEBUGGER_SUPPORT
164 CHECK_EQ(ExternalReference::new_space_start(isolate).address(),
173 file_name_ = snapshot_file;
175 PrintF(
"Unable to write to snapshot file \"%s\"\n", snapshot_file);
184 virtual void Put(
int byte,
const char* description) {
194 int pointer_space_used,
199 int property_cell_space_used);
203 const char* file_name_;
209 int pointer_space_used,
214 int property_cell_space_used) {
215 int file_name_length =
StrLength(file_name_) + 10;
220 fprintf(fp,
"new %d\n", new_space_used);
221 fprintf(fp,
"pointer %d\n", pointer_space_used);
222 fprintf(fp,
"data %d\n", data_space_used);
223 fprintf(fp,
"code %d\n", code_space_used);
224 fprintf(fp,
"map %d\n", map_space_used);
225 fprintf(fp,
"cell %d\n", cell_space_used);
226 fprintf(fp,
"property cell %d\n", property_cell_space_used);
231 static bool WriteToFile(
Isolate* isolate,
const char* snapshot_file) {
249 static void Serialize() {
262 WriteToFile(internal_isolate, FLAG_testing_serialization_file);
290 static void Deserialize() {
295 static void SanityCheck() {
349 const char* c_source =
"\"1234\".length";
367 const char* c_source =
"\"1234\".length";
410 int file_name_length =
StrLength(FLAG_testing_serialization_file) + 10;
412 OS::SNPrintF(startup_name,
"%s.startup", FLAG_testing_serialization_file);
422 startup_serializer.SerializeStrongReferences();
424 FileByteSink partial_sink(FLAG_testing_serialization_file);
427 startup_serializer.SerializeWeakReferences();
438 startup_sink.WriteSpaceUsed(
439 startup_serializer.CurrentAllocationAddress(
NEW_SPACE),
442 startup_serializer.CurrentAllocationAddress(
CODE_SPACE),
443 startup_serializer.CurrentAllocationAddress(
MAP_SPACE),
444 startup_serializer.CurrentAllocationAddress(
CELL_SPACE),
451 static void ReserveSpaceForSnapshot(
Deserializer* deserializer,
452 const char* file_name) {
453 int file_name_length =
StrLength(file_name) + 10;
458 int new_size, pointer_size, data_size, code_size, map_size, cell_size,
463 #define fscanf fscanf_s
465 CHECK_EQ(1, fscanf(fp,
"new %d\n", &new_size));
466 CHECK_EQ(1, fscanf(fp,
"pointer %d\n", &pointer_size));
467 CHECK_EQ(1, fscanf(fp,
"data %d\n", &data_size));
468 CHECK_EQ(1, fscanf(fp,
"code %d\n", &code_size));
469 CHECK_EQ(1, fscanf(fp,
"map %d\n", &map_size));
470 CHECK_EQ(1, fscanf(fp,
"cell %d\n", &cell_size));
471 CHECK_EQ(1, fscanf(fp,
"property cell %d\n", &property_cell_size));
488 int file_name_length =
StrLength(FLAG_testing_serialization_file) + 10;
490 OS::SNPrintF(startup_name,
"%s.startup", FLAG_testing_serialization_file);
495 const char* file_name = FLAG_testing_serialization_file;
497 int snapshot_size = 0;
505 ReserveSpaceForSnapshot(&deserializer, file_name);
507 CHECK(root->IsString());
517 ReserveSpaceForSnapshot(&deserializer, file_name);
519 CHECK(root2->IsString());
520 CHECK(*root_handle == root2);
554 int file_name_length =
StrLength(FLAG_testing_serialization_file) + 10;
556 OS::SNPrintF(startup_name,
"%s.startup", FLAG_testing_serialization_file);
569 startup_serializer.SerializeStrongReferences();
571 FileByteSink partial_sink(FLAG_testing_serialization_file);
574 startup_serializer.SerializeWeakReferences();
585 startup_sink.WriteSpaceUsed(
586 startup_serializer.CurrentAllocationAddress(
NEW_SPACE),
589 startup_serializer.CurrentAllocationAddress(
CODE_SPACE),
590 startup_serializer.CurrentAllocationAddress(
MAP_SPACE),
591 startup_serializer.CurrentAllocationAddress(
CELL_SPACE),
600 int file_name_length =
StrLength(FLAG_testing_serialization_file) + 10;
602 OS::SNPrintF(startup_name,
"%s.startup", FLAG_testing_serialization_file);
607 const char* file_name = FLAG_testing_serialization_file;
609 int snapshot_size = 0;
617 ReserveSpaceForSnapshot(&deserializer, file_name);
619 CHECK(root->IsContext());
629 ReserveSpaceForSnapshot(&deserializer, file_name);
631 CHECK(root2->IsContext());
632 CHECK(*root_handle != root2);
643 bool ArtificialFailure =
false;
644 CHECK(ArtificialFailure);
649 bool ArtificialFailure2 =
false;
650 CHECK(ArtificialFailure2);
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
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
int CurrentAllocationAddress(int space)
#define CHECK_EQ(expected, value)
const int kReferenceTypeShift
void PrintF(const char *format,...)
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
virtual void Serialize(Object **o)
StatsTable * stats_table()
static v8::internal::Handle< v8::internal::Object > OpenPersistent(const v8::Persistent< T > &persistent)
Bootstrapper * bootstrapper()
#define ASSERT(condition)
byte * ReadBytes(const char *filename, int *size, bool verbose)
Address Decode(uint32_t key) const
void SetCounterFunction(CounterLookupCallback f)
void set_reservation(int space_number, int reservation)
Handle< GlobalObject > global_object()
static int GetBuiltinsCount()
static const int kNoGCFlags
static FILE * FOpen(const char *path, const char *mode)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
Handle< String > NativesSourceLookup(int index)
void WriteSpaceUsed(int new_space_used, int pointer_space_used, int data_space_used, int code_space_used, int map_space_used, int cell_space_used, int property_cell_space_used)
static i::Isolate * i_isolate()
uint32_t Encode(Address key) const
void DeserializePartial(Isolate *isolate, Object **root)
#define STATIC_ASCII_VECTOR(x)
static Vector< T > New(int length)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
int StrLength(const char *string)
#define T(name, string, precedence)
static void Enable(Isolate *isolate)
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
static int SNPrintF(Vector< char > str, const char *format,...)
static bool HaveASnapshotToStartFrom()
Handle< String > InternalizeOneByteString(Vector< const uint8_t > str)
V8_INLINE bool IsEmpty() const
V8_INLINE bool IsEmpty() const
virtual void Put(int byte, const char *description)
DEPENDENT_TEST(Deserialize, Serialize)
Handle< Context > native_context()
FileByteSink(const char *snapshot_file)
static bool Initialize(const char *snapshot_file=NULL)
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 name
static v8::Isolate * isolate()
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)