35 #ifdef COMPRESS_STARTUP_DATA_BZ2
36 #error Using compressed startup data is not supported for this sample
55 bool report_exceptions);
65 static bool run_shell;
68 int main(
int argc,
char* argv[]) {
72 run_shell = (argc == 1);
78 fprintf(stderr,
"Error creating context\n");
82 result =
RunMain(isolate, argc, argv);
93 return *value ? *value :
"<string conversion failed>";
127 for (
int i = 0; i < args.
Length(); i++) {
172 for (
int i = 0; i < args.
Length(); i++) {
204 int exit_code = args[0]->Int32Value();
219 FILE* file = fopen(name,
"rb");
222 fseek(file, 0, SEEK_END);
223 int size = ftell(file);
226 char* chars =
new char[size + 1];
228 for (
int i = 0; i <
size;) {
229 int read =
static_cast<int>(fread(&chars[i], 1, size - i, file));
242 for (
int i = 1; i < argc; i++) {
243 const char* str = argv[i];
244 if (strcmp(str,
"--shell") == 0) {
246 }
else if (strcmp(str,
"-f") == 0) {
250 }
else if (strncmp(str,
"--", 2) == 0) {
252 "Warning: unknown flag %s.\nTry --help for options\n", str);
253 }
else if (strcmp(str,
"-e") == 0 && i + 1 < argc) {
259 if (!
ExecuteString(isolate, source, file_name,
false,
true))
return 1;
265 fprintf(stderr,
"Error reading '%s'\n", str);
268 if (!
ExecuteString(isolate, source, file_name,
false,
true))
return 1;
278 static const int kBufferSize = 256;
284 char buffer[kBufferSize];
285 fprintf(stderr,
"> ");
286 char* str = fgets(buffer, kBufferSize, stdin);
287 if (str ==
NULL)
break;
295 fprintf(stderr,
"\n");
304 bool report_exceptions) {
311 if (report_exceptions)
319 if (report_exceptions)
329 printf(
"%s\n", cstr);
340 const char* exception_string =
ToCString(exception);
345 fprintf(stderr,
"%s\n", exception_string);
349 const char* filename_string =
ToCString(filename);
351 fprintf(stderr,
"%s:%i: %s\n", filename_string, linenum, exception_string);
354 const char* sourceline_string =
ToCString(sourceline);
355 fprintf(stderr,
"%s\n", sourceline_string);
358 for (
int i = 0; i < start; i++) {
359 fprintf(stderr,
" ");
362 for (
int i = start; i < end; i++) {
363 fprintf(stderr,
"^");
365 fprintf(stderr,
"\n");
367 if (stack_trace.length() > 0) {
368 const char* stack_trace_string =
ToCString(stack_trace);
369 fprintf(stderr,
"%s\n", stack_trace_string);
int main(int argc, char *argv[])
static Isolate * GetCurrent()
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
Local< Value > Exception() const
V8_INLINE Isolate * GetIsolate() const
V8_INLINE ReturnValue< T > GetReturnValue() const
V8_INLINE int Length() const
void Quit(const v8::FunctionCallbackInfo< v8::Value > &args)
void Read(const v8::FunctionCallbackInfo< v8::Value > &args)
const char * ToCString(const v8::String::Utf8Value &value)
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
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
Handle< Value > GetScriptResourceName() const
v8::Isolate * GetIsolate()
static const char * GetVersion()
v8::Handle< v8::Context > CreateShellContext(v8::Isolate *isolate)
static Local< ObjectTemplate > New()
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >(), int length=0)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
void Version(const v8::FunctionCallbackInfo< v8::Value > &args)
v8::Handle< v8::String > ReadFile(v8::Isolate *isolate, const char *name)
V8_INLINE bool IsUndefined() const
int GetLineNumber() const
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
Local< Value > StackTrace() const
void Load(const v8::FunctionCallbackInfo< v8::Value > &args)
V8_INLINE bool IsEmpty() const
void ReportException(v8::Isolate *isolate, v8::TryCatch *handler)
static bool InitializeICU(const char *icu_data_file=NULL)
bool ExecuteString(v8::Isolate *isolate, v8::Handle< v8::String > source, v8::Handle< v8::Value > name, bool print_result, bool report_exceptions)
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
int GetStartColumn() const
void RunShell(v8::Handle< v8::Context > context)
Local< v8::Message > Message() const
int RunMain(v8::Isolate *isolate, int argc, char *argv[])
Local< String > GetSourceLine() const
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)