30 #ifdef COMPRESS_STARTUP_DATA_BZ2
46 static const unsigned int kMaxCounters = 256;
72 magic_number_ = 0xDEADFACE;
73 max_counters_ = kMaxCounters;
78 if (counters_in_use_ == kMaxCounters)
return NULL;
79 return &counters_[counters_in_use_++];
82 uint32_t magic_number_;
83 uint32_t max_counters_;
84 uint32_t max_name_size_;
85 uint32_t counters_in_use_;
86 Counter counters_[kMaxCounters];
102 virtual void Put(
int byte,
const char* description) {
107 int length = Position();
108 for (
int j = 0; j < length; j++) {
109 if ((j & 0x1f) == 0x1f) {
115 fprintf(fp,
"%u", static_cast<unsigned char>(at(j)));
118 char at(
int i) {
return data_[i]; }
121 raw_size_ = data_.length();
122 if (!compressor->
Compress(data_.ToVector()))
return false;
124 data_.AddAll(*compressor->
output());
140 i::PrintF(
"Unable to write to snapshot file \"%s\"\n", snapshot_file);
143 fprintf(fp_,
"// Autogenerated snapshot file. Do not edit.\n\n");
144 fprintf(fp_,
"#include \"v8.h\"\n");
145 fprintf(fp_,
"#include \"platform.h\"\n\n");
146 fprintf(fp_,
"#include \"snapshot.h\"\n\n");
147 fprintf(fp_,
"namespace v8 {\nnamespace internal {\n\n");
148 fprintf(fp_,
"const byte Snapshot::data_[] = {");
152 fprintf(fp_,
"const int Snapshot::size_ = %d;\n", Position());
153 #ifdef COMPRESS_STARTUP_DATA_BZ2
154 fprintf(fp_,
"const byte* Snapshot::raw_data_ = NULL;\n");
156 "const int Snapshot::raw_size_ = %d;\n\n",
160 "const byte* Snapshot::raw_data_ = Snapshot::data_;\n");
162 "const int Snapshot::raw_size_ = Snapshot::size_;\n\n");
164 fprintf(fp_,
"} } // namespace v8::internal\n");
171 int pointer_space_used,
175 int cell_space_used) {
177 "const int Snapshot::%snew_space_used_ = %d;\n",
181 "const int Snapshot::%spointer_space_used_ = %d;\n",
185 "const int Snapshot::%sdata_space_used_ = %d;\n",
189 "const int Snapshot::%scode_space_used_ = %d;\n",
193 "const int Snapshot::%smap_space_used_ = %d;\n",
197 "const int Snapshot::%scell_space_used_ = %d;\n",
203 int length = partial_sink_.Position();
204 fprintf(fp_,
"};\n\n");
205 fprintf(fp_,
"const int Snapshot::context_size_ = %d;\n", length);
206 #ifdef COMPRESS_STARTUP_DATA_BZ2
208 "const int Snapshot::context_raw_size_ = %d;\n",
209 partial_sink_.raw_size());
212 "const int Snapshot::context_raw_size_ = "
213 "Snapshot::context_size_;\n");
215 fprintf(fp_,
"const byte Snapshot::context_data_[] = {\n");
216 partial_sink_.Print(fp_);
217 fprintf(fp_,
"};\n\n");
218 #ifdef COMPRESS_STARTUP_DATA_BZ2
219 fprintf(fp_,
"const byte* Snapshot::context_raw_data_ = NULL;\n");
221 fprintf(fp_,
"const byte* Snapshot::context_raw_data_ ="
222 " Snapshot::context_data_;\n");
238 #ifdef COMPRESS_STARTUP_DATA_BZ2
241 BZip2Compressor() : output_(
NULL) {}
242 virtual ~BZip2Compressor() {
248 unsigned int output_length_ = output_->length();
249 int result = BZ2_bzBuffToBuffCompress(output_->start(), &output_length_,
252 if (result == BZ_OK) {
253 output_->Truncate(output_length_);
256 fprintf(stderr,
"bzlib error code: %d\n", result);
269 virtual ~BZip2Decompressor() { }
272 virtual int DecompressData(
char* raw_data,
274 const char* compressed_data,
275 int compressed_data_size) {
278 unsigned int decompressed_size = *raw_data_size;
280 BZ2_bzBuffToBuffDecompress(raw_data,
282 const_cast<char*>(compressed_data),
283 compressed_data_size,
285 if (result == BZ_OK) {
286 *raw_data_size = decompressed_size;
294 int main(
int argc,
char** argv) {
296 i::FLAG_log_code =
true;
301 if (result > 0 || argc != 2 || i::FLAG_help) {
302 ::printf(
"Usage: %s [flag] ... outfile\n", argv[0]);
304 return !i::FLAG_help;
306 #ifdef COMPRESS_STARTUP_DATA_BZ2
307 BZip2Decompressor natives_decompressor;
308 int bz2_result = natives_decompressor.Decompress();
309 if (bz2_result != BZ_OK) {
310 fprintf(stderr,
"bzip error code: %d\n", bz2_result);
318 "\nException thrown while compiling natives - see above.\n\n");
321 if (i::FLAG_extra_code !=
NULL) {
326 const char* name = i::FLAG_extra_code;
329 fprintf(stderr,
"Failed to open '%s': errno %d\n", name, errno);
333 fseek(file, 0, SEEK_END);
334 int size = ftell(file);
337 char* chars =
new char[size + 1];
339 for (
int i = 0; i < size;) {
340 int read =
static_cast<int>(fread(&chars[i], 1, size - i, file));
342 fprintf(stderr,
"Failed to read '%s': errno %d\n", name, errno);
352 fprintf(stderr,
"Failure compiling '%s' (see above)\n", name);
357 fprintf(stderr,
"Failure running '%s'\n", name);
362 char* buf =
new char(len);
364 fprintf(stderr,
"%s at line %d\n", buf, message->
GetLineNumber());
366 fprintf(stderr,
"%s\n", buf);
370 for (i = 0; i < from; i++) fprintf(stderr,
" ");
371 for ( ; i <= to; i++) fprintf(stderr,
"^");
372 fprintf(stderr,
"\n");
380 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
386 i::Object* raw_context = *(v8::Utils::OpenHandle(*context));
399 #ifdef COMPRESS_STARTUP_DATA_BZ2
400 BZip2Compressor compressor;
int CurrentAllocationAddress(int space)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
V8EXPORT int WriteUtf8(char *buffer, int length=-1, int *nchars_ref=NULL, int options=NO_OPTIONS) const
void PrintF(const char *format,...)
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 V8EXPORT Local< String > New(const char *data, int length=-1)
virtual void SerializeStrongReferences()
void SerializeWeakReferences()
void WritePartialSnapshot()
v8::Handle< v8::Value > Print(const v8::Arguments &args)
bool Compress(Compressor *compressor)
static const int kMaxNameSize
int32_t * Bind(const char *name)
static int GetBuiltinsCount()
PartialSnapshotSink * partial_sink()
static const int kNoGCFlags
V8EXPORT int Utf8Length() const
static FILE * FOpen(const char *path, const char *mode)
int main(int argc, char **argv)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting 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 more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
int GetLineNumber() const
Counter * GetNextCounter()
virtual ~PartialSnapshotSink()
#define ASSERT_EQ(v1, v2)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if NULL
virtual void Put(int byte, const char *description)
CppByteSink(const char *snapshot_file)
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
virtual i::Vector< char > * output()=0
int GetStartColumn() const
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
Local< v8::Message > Message() const
static int SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
Local< String > GetSourceLine() const
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)