35 #ifdef COMPRESS_STARTUP_DATA_BZ2
36 #error Using compressed startup data is not supported for this sample
50 int RunMain(
int argc,
char* argv[]);
54 bool report_exceptions);
64 static bool run_shell;
67 int main(
int argc,
char* argv[]) {
69 run_shell = (argc == 1);
75 printf(
"Error creating context\n");
91 return *value ? *value :
"<string conversion failed>";
120 for (
int i = 0; i < args.
Length(); i++) {
160 for (
int i = 0; i < args.
Length(); i++) {
183 int exit_code = args[0]->Int32Value();
198 FILE* file = fopen(name,
"rb");
201 fseek(file, 0, SEEK_END);
202 int size = ftell(file);
205 char* chars =
new char[size + 1];
207 for (
int i = 0; i < size;) {
208 int read =
static_cast<int>(fread(&chars[i], 1, size - i, file));
220 for (
int i = 1; i < argc; i++) {
221 const char* str = argv[i];
222 if (strcmp(str,
"--shell") == 0) {
224 }
else if (strcmp(str,
"-f") == 0) {
228 }
else if (strncmp(str,
"--", 2) == 0) {
229 printf(
"Warning: unknown flag %s.\nTry --help for options\n", str);
230 }
else if (strcmp(str,
"-e") == 0 && i + 1 < argc) {
234 if (!
ExecuteString(source, file_name,
false,
true))
return 1;
240 printf(
"Error reading '%s'\n", str);
243 if (!
ExecuteString(source, file_name,
false,
true))
return 1;
253 static const int kBufferSize = 256;
258 char buffer[kBufferSize];
260 char* str = fgets(buffer, kBufferSize, stdin);
261 if (str ==
NULL)
break;
273 bool report_exceptions) {
279 if (report_exceptions)
287 if (report_exceptions)
297 printf(
"%s\n", cstr);
308 const char* exception_string =
ToCString(exception);
313 printf(
"%s\n", exception_string);
317 const char* filename_string =
ToCString(filename);
319 printf(
"%s:%i: %s\n", filename_string, linenum, exception_string);
322 const char* sourceline_string =
ToCString(sourceline);
323 printf(
"%s\n", sourceline_string);
326 for (
int i = 0; i < start; i++) {
330 for (
int i = start; i < end; i++) {
335 if (stack_trace.length() > 0) {
336 const char* stack_trace_string =
ToCString(stack_trace);
337 printf(
"%s\n", stack_trace_string);
int main(int argc, char *argv[])
v8::Handle< v8::Value > Print(const v8::Arguments &args)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
static Local< FunctionTemplate > New(InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >())
Local< Value > Exception() const
static V8EXPORT Local< String > New(const char *data, int length=-1)
v8::Persistent< v8::Context > CreateShellContext()
int RunMain(int argc, char *argv[])
const char * ToCString(const v8::String::Utf8Value &value)
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
Handle< Value > GetScriptResourceName() const
v8::Handle< v8::Value > Read(const v8::Arguments &args)
v8::Handle< v8::String > ReadFile(const char *name)
static const char * GetVersion()
static Local< ObjectTemplate > New()
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
Local< Value > StackTrace() const
v8::Handle< v8::Value > Quit(const v8::Arguments &args)
void ReportException(v8::TryCatch *handler)
v8::Handle< v8::Value > Version(const v8::Arguments &args)
bool ExecuteString(v8::Handle< v8::String > source, v8::Handle< v8::Value > name, bool print_result, bool report_exceptions)
v8::Handle< v8::Value > Load(const v8::Arguments &args)
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
Handle< Primitive > V8EXPORT Undefined()
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
int GetStartColumn() const
Handle< Value > V8EXPORT ThrowException(Handle< Value > exception)
void RunShell(v8::Handle< v8::Context > context)
Local< v8::Message > Message() const
Local< String > GetSourceLine() const