30 #ifdef COMPRESS_STARTUP_DATA_BZ2
59 virtual void Put(
int byte,
const char* description) {
62 virtual int Position() {
return data_.length(); }
64 int length = Position();
65 for (
int j = 0; j < length; j++) {
66 if ((j & 0x1f) == 0x1f) {
72 fprintf(fp,
"%u", static_cast<unsigned char>(at(j)));
75 char at(
int i) {
return data_[i]; }
78 raw_size_ = data_.length();
79 if (!compressor->
Compress(data_.ToVector()))
return false;
81 data_.AddAll(*compressor->
output());
97 i::PrintF(
"Unable to write to snapshot file \"%s\"\n", snapshot_file);
100 fprintf(fp_,
"// Autogenerated snapshot file. Do not edit.\n\n");
101 fprintf(fp_,
"#include \"v8.h\"\n");
102 fprintf(fp_,
"#include \"platform.h\"\n\n");
103 fprintf(fp_,
"#include \"snapshot.h\"\n\n");
104 fprintf(fp_,
"namespace v8 {\nnamespace internal {\n\n");
105 fprintf(fp_,
"const byte Snapshot::data_[] = {");
109 fprintf(fp_,
"const int Snapshot::size_ = %d;\n", Position());
110 #ifdef COMPRESS_STARTUP_DATA_BZ2
111 fprintf(fp_,
"const byte* Snapshot::raw_data_ = NULL;\n");
113 "const int Snapshot::raw_size_ = %d;\n\n",
117 "const byte* Snapshot::raw_data_ = Snapshot::data_;\n");
119 "const int Snapshot::raw_size_ = Snapshot::size_;\n\n");
121 fprintf(fp_,
"} } // namespace v8::internal\n");
128 int pointer_space_used,
133 int property_cell_space_used) {
135 "const int Snapshot::%snew_space_used_ = %d;\n",
139 "const int Snapshot::%spointer_space_used_ = %d;\n",
143 "const int Snapshot::%sdata_space_used_ = %d;\n",
147 "const int Snapshot::%scode_space_used_ = %d;\n",
151 "const int Snapshot::%smap_space_used_ = %d;\n",
155 "const int Snapshot::%scell_space_used_ = %d;\n",
159 "const int Snapshot::%sproperty_cell_space_used_ = %d;\n",
161 property_cell_space_used);
165 int length = partial_sink_.Position();
166 fprintf(fp_,
"};\n\n");
167 fprintf(fp_,
"const int Snapshot::context_size_ = %d;\n", length);
168 #ifdef COMPRESS_STARTUP_DATA_BZ2
170 "const int Snapshot::context_raw_size_ = %d;\n",
171 partial_sink_.raw_size());
174 "const int Snapshot::context_raw_size_ = "
175 "Snapshot::context_size_;\n");
177 fprintf(fp_,
"const byte Snapshot::context_data_[] = {\n");
178 partial_sink_.Print(fp_);
179 fprintf(fp_,
"};\n\n");
180 #ifdef COMPRESS_STARTUP_DATA_BZ2
181 fprintf(fp_,
"const byte* Snapshot::context_raw_data_ = NULL;\n");
183 fprintf(fp_,
"const byte* Snapshot::context_raw_data_ ="
184 " Snapshot::context_data_;\n");
200 #ifdef COMPRESS_STARTUP_DATA_BZ2
203 BZip2Compressor() : output_(
NULL) {}
204 virtual ~BZip2Compressor() {
210 unsigned int output_length_ = output_->length();
211 int result = BZ2_bzBuffToBuffCompress(output_->start(), &output_length_,
214 if (result == BZ_OK) {
215 output_->Truncate(output_length_);
218 fprintf(stderr,
"bzlib error code: %d\n", result);
231 virtual ~BZip2Decompressor() { }
234 virtual int DecompressData(
char* raw_data,
236 const char* compressed_data,
237 int compressed_data_size) {
240 unsigned int decompressed_size = *raw_data_size;
242 BZ2_bzBuffToBuffDecompress(raw_data,
244 const_cast<char*>(compressed_data),
245 compressed_data_size,
247 if (result == BZ_OK) {
248 *raw_data_size = decompressed_size;
259 fprintf(stderr,
"%s at line %d\n", *message_string, message->
GetLineNumber());
260 fprintf(stderr,
"%s\n", *message_line);
262 fprintf(stderr,
"%c", i < message->GetStartColumn() ?
' ' :
'^');
264 fprintf(stderr,
"\n");
268 int main(
int argc,
char** argv) {
273 i::FLAG_log_code =
true;
277 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv,
true);
278 if (result > 0 || argc != 2 || i::FLAG_help) {
279 ::printf(
"Usage: %s [flag] ... outfile\n", argv[0]);
280 i::FlagList::PrintHelp();
281 return !i::FLAG_help;
283 #ifdef COMPRESS_STARTUP_DATA_BZ2
284 BZip2Decompressor natives_decompressor;
285 int bz2_result = natives_decompressor.Decompress();
286 if (bz2_result != BZ_OK) {
287 fprintf(stderr,
"bzip error code: %d\n", bz2_result);
291 i::FLAG_logfile_per_isolate =
false;
305 "\nException thrown while compiling natives - see above.\n\n");
308 if (i::FLAG_extra_code !=
NULL) {
313 const char*
name = i::FLAG_extra_code;
316 fprintf(stderr,
"Failed to open '%s': errno %d\n", name, errno);
320 fseek(file, 0, SEEK_END);
321 int size = ftell(file);
324 char* chars =
new char[size + 1];
326 for (
int i = 0; i <
size;) {
327 int read =
static_cast<int>(fread(&chars[i], 1, size - i, file));
329 fprintf(stderr,
"Failed to read '%s': errno %d\n", name, errno);
339 fprintf(stderr,
"Failure compiling '%s'\n", name);
345 fprintf(stderr,
"Failure running '%s'\n", name);
374 #ifdef COMPRESS_STARTUP_DATA_BZ2
375 BZip2Compressor compressor;
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
int CurrentAllocationAddress(int space)
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)
virtual bool Compress(i::Vector< char > input)=0
Local< String > Get() const
static void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
static v8::internal::Handle< v8::internal::Object > OpenPersistent(const v8::Persistent< T > &persistent)
virtual void SerializeStrongReferences()
void SerializeWeakReferences()
void WritePartialSnapshot()
Bootstrapper * bootstrapper()
void DumpException(Handle< Message > message)
bool Compress(Compressor *compressor)
static void SetCrashIfDefaultIsolateInitialized()
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 message
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
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 size
static int GetBuiltinsCount()
PartialSnapshotSink * partial_sink()
static const int kNoGCFlags
static FILE * FOpen(const char *path, const char *mode)
int main(int argc, char **argv)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
Handle< String > NativesSourceLookup(int index)
int GetLineNumber() const
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 >())
void WriteSpaceUsed(const char *prefix, 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)
virtual ~PartialSnapshotSink()
V8_INLINE bool IsEmpty() const
static bool InitializeICU(const char *icu_data_file=NULL)
#define ASSERT_EQ(v1, v2)
virtual void Put(int byte, const char *description)
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
CppByteSink(const char *snapshot_file)
virtual i::Vector< char > * output()=0
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
Local< v8::Message > Message() const
Local< String > GetSourceLine() const
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)