7 #ifdef COMPRESS_STARTUP_DATA_BZ2
38 : fp_(GetFileDescriptorOrDie(snapshot_file))
40 , raw_context_file_(
NULL)
41 , startup_blob_file_(
NULL)
47 if (raw_file_) fclose(raw_file_);
48 if (raw_context_file_) fclose(raw_context_file_);
49 if (startup_blob_file_) fclose(startup_blob_file_);
53 compressor_ = compressor;
56 void SetRawFiles(
const char* raw_file,
const char* raw_context_file) {
57 raw_file_ = GetFileDescriptorOrDie(raw_file);
58 raw_context_file_ = GetFileDescriptorOrDie(raw_context_file);
62 if (startup_blob_file !=
NULL)
63 startup_blob_file_ = GetFileDescriptorOrDie(startup_blob_file);
70 WriteSnapshotFile(snapshot_data, serializer,
71 context_snapshot_data, context_serializer);
72 MaybeWriteStartupBlob(snapshot_data, serializer,
73 context_snapshot_data, context_serializer);
81 if (!startup_blob_file_)
93 sink.
PutBlob(snapshot_bytes, snapshot_data.length(),
"snapshot");
98 sink.
PutBlob(context_bytes, context_snapshot_data.length(),
"context");
103 size_t written = fwrite(startup_blob.
begin(), 1, startup_blob.length(),
105 if (written != (
size_t)startup_blob.length()) {
106 i::PrintF(
"Writing snapshot file failed.. Aborting.\n");
116 WriteData(
"", snapshot_data, raw_file_);
117 WriteData(
"context_", context_snapshot_data, raw_context_file_);
118 WriteMeta(
"context_", context_serializer);
119 WriteMeta(
"", serializer);
124 fprintf(fp_,
"// Autogenerated snapshot file. Do not edit.\n\n");
125 fprintf(fp_,
"#include \"src/v8.h\"\n");
126 fprintf(fp_,
"#include \"src/base/platform/platform.h\"\n\n");
127 fprintf(fp_,
"#include \"src/snapshot.h\"\n\n");
128 fprintf(fp_,
"namespace v8 {\n");
129 fprintf(fp_,
"namespace internal {\n\n");
133 fprintf(fp_,
"} // namespace internal\n");
134 fprintf(fp_,
"} // namespace v8\n");
138 FILE* raw_file)
const {
142 data_to_be_written = &source_data;
143 }
else if (compressor_->Compress(source_data.
ToVector())) {
144 compressed_data.
AddAll(*compressor_->output());
145 data_to_be_written = &compressed_data;
147 i::PrintF(
"Compression failed. Aborting.\n");
151 DCHECK(data_to_be_written);
152 MaybeWriteRawFile(data_to_be_written, raw_file);
153 WriteData(prefix, source_data, data_to_be_written);
157 if (!data || !raw_file)
164 size_t written = fwrite(data->
begin(), 1, data->length(), raw_file);
165 if (written != (
size_t)data->length()) {
166 i::PrintF(
"Writing raw file failed.. Aborting.\n");
173 fprintf(fp_,
"const byte Snapshot::%sdata_[] = {\n", prefix);
174 WriteSnapshotData(data_to_be_written);
175 fprintf(fp_,
"};\n");
176 fprintf(fp_,
"const int Snapshot::%ssize_ = %d;\n", prefix,
177 data_to_be_written->length());
179 if (data_to_be_written == &source_data) {
180 fprintf(fp_,
"const byte* Snapshot::%sraw_data_ = Snapshot::%sdata_;\n",
182 fprintf(fp_,
"const int Snapshot::%sraw_size_ = Snapshot::%ssize_;\n",
185 fprintf(fp_,
"const byte* Snapshot::%sraw_data_ = NULL;\n", prefix);
186 fprintf(fp_,
"const int Snapshot::%sraw_size_ = %d;\n",
187 prefix, source_data.length());
206 fprintf(fp_,
"const int Snapshot::%s%s_space_used_ = %d;\n",
211 for (
int i = 0;
i < data->length();
i++) {
212 if ((
i & 0x1f) == 0x1f)
216 fprintf(fp_,
"%u",
static_cast<unsigned char>(data->
at(
i)));
224 i::PrintF(
"Unable to open file \"%s\" for writing.\n", filename);
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;
297 fprintf(stderr,
"%s at line %d\n", *message_string, message->GetLineNumber());
298 fprintf(stderr,
"%s\n", *message_line);
299 for (
int i = 0;
i <= message->GetEndColumn(); ++
i) {
300 fprintf(stderr,
"%c", i < message->GetStartColumn() ?
' ' :
'^');
302 fprintf(stderr,
"\n");
306 int main(
int argc,
char** argv) {
308 i::FLAG_log_code =
true;
313 if (result > 0 || argc != 2 || i::FLAG_help) {
314 ::printf(
"Usage: %s [flag] ... outfile\n", argv[0]);
316 return !i::FLAG_help;
325 #ifdef COMPRESS_STARTUP_DATA_BZ2
326 BZip2Decompressor natives_decompressor;
327 int bz2_result = natives_decompressor.Decompress();
328 if (bz2_result != BZ_OK) {
329 fprintf(stderr,
"bzip error code: %d\n", bz2_result);
333 i::FLAG_logfile_per_isolate =
false;
349 "\nException thrown while compiling natives - see above.\n\n");
352 if (i::FLAG_extra_code !=
NULL) {
357 const char*
name = i::FLAG_extra_code;
360 fprintf(stderr,
"Failed to open '%s': errno %d\n",
name, errno);
364 fseek(
file, 0, SEEK_END);
368 char* chars =
new char[
size + 1];
370 for (
int i = 0;
i <
size;) {
371 int read =
static_cast<int>(fread(&chars[
i], 1,
size -
i,
file));
373 fprintf(stderr,
"Failed to read '%s': errno %d\n",
name, errno);
383 fprintf(stderr,
"Failure compiling '%s'\n",
name);
389 fprintf(stderr,
"Failure running '%s'\n",
name);
422 if (i::FLAG_raw_file && i::FLAG_raw_context_file)
423 writer.
SetRawFiles(i::FLAG_raw_file, i::FLAG_raw_context_file);
424 if (i::FLAG_startup_blob)
426 #ifdef COMPRESS_STARTUP_DATA_BZ2
427 BZip2Compressor bzip2;
430 writer.
WriteSnapshot(snapshot_data, ser, context_data, context_ser);
virtual i::Vector< i::byte > * output()=0
virtual bool Compress(i::Vector< i::byte > input)=0
void WriteSnapshot(const i::List< i::byte > &snapshot_data, const i::Serializer &serializer, const i::List< i::byte > &context_snapshot_data, const i::Serializer &context_serializer) const
void WriteData(const char *prefix, const i::List< i::byte > &source_data, const i::List< i::byte > *data_to_be_written) const
void WriteSnapshotFile(const i::List< i::byte > &snapshot_data, const i::Serializer &serializer, const i::List< i::byte > &context_snapshot_data, const i::Serializer &context_serializer) const
FILE * GetFileDescriptorOrDie(const char *filename)
void MaybeWriteStartupBlob(const i::List< i::byte > &snapshot_data, const i::Serializer &serializer, const i::List< i::byte > &context_snapshot_data, const i::Serializer &context_serializer) const
void WriteSnapshotData(const i::List< i::byte > *data) const
void WriteSizeVar(const i::Serializer &ser, const char *prefix, const char *name, int space) const
FILE * startup_blob_file_
SnapshotWriter(const char *snapshot_file)
void WriteFilePrefix() const
void WriteFileSuffix() const
void WriteData(const char *prefix, const i::List< i::byte > &source_data, FILE *raw_file) const
void SetStartupBlobFile(const char *startup_blob_file)
void SetRawFiles(const char *raw_file, const char *raw_context_file)
void SetCompressor(Compressor *compressor)
void MaybeWriteRawFile(const i::List< i::byte > *data, FILE *raw_file) const
void WriteMeta(const char *prefix, const i::Serializer &ser) const
Stack-allocated class which sets the execution context for all operations executed within a local sco...
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
Creates a new context and returns a handle to the newly allocated context.
A stack-allocated class that governs a number of local handles.
An object reference managed by the v8 garbage collector.
Stack-allocated class which sets the isolate for all operations executed within a local scope.
Isolate represents an isolated instance of the V8 engine.
void Dispose()
Disposes the isolate.
static Isolate * New(const CreateParams ¶ms=CreateParams())
Creates a new isolate.
A light-weight stack-allocated object handle.
void Reset()
If non-empty, destroy the underlying storage cell IsEmpty() will return true after this call.
A PersistentBase which allows copy and assignment.
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL)
A shorthand for ScriptCompiler::Compile().
A helper class for driving V8 startup data decompression.
Converts an object to a UTF-8-encoded character array.
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
Allocates a new string from UTF-8 data.
An external exception handler.
Local< v8::Message > Message() const
Returns the message associated with this exception.
bool HasCaught() const
Returns true if an exception has been caught by this try/catch block.
static v8::internal::Handle< v8::internal::Object > OpenPersistent(const v8::Persistent< T > &persistent)
static bool InitializeICU(const char *icu_data_file=NULL)
Initialize the ICU library bundled with V8.
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
The following 4 functions are to be used when V8 is built with the 'compress_startup_data' flag enabl...
static void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
Tells V8 to capture current stack trace when uncaught exception occurs and report it to the message l...
static void InitializePlatform(Platform *platform)
Sets the v8::Platform to use.
static void ShutdownPlatform()
Clears all references to the v8::Platform.
static bool Dispose()
Releases any resources used by v8 and stops any utility threads that may be running.
static bool Initialize()
Initializes V8.
static FILE * FOpen(const char *path, const char *mode)
static void Probe(bool cross_compile)
static int SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
static const int kNoGCFlags
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Bootstrapper * bootstrapper()
void AddAll(const List< T, AllocationPolicy > &other, AllocationPolicy allocator=AllocationPolicy())
Vector< T > ToVector() const
static int GetBuiltinsCount()
void Serialize(Object **o)
int CurrentAllocationAddress(int space) const
void PutInt(uintptr_t integer, const char *description)
void PutBlob(byte *data, int number_of_bytes, const char *description)
virtual void SerializeStrongReferences()
void SerializeWeakReferences()
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 name
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 space(in MBytes)
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
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
void DumpException(Handle< Message > message)
int main(int argc, char **argv)
void PrintF(const char *format,...)
Debugger support for the V8 JavaScript engine.
Initial configuration parameters for a new Isolate.
bool enable_serializer
This flag currently renders the Isolate unusable.