7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
11 #ifdef COMPRESS_STARTUP_DATA_BZ2
32 #if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE)
36 #ifdef ENABLE_VTUNE_JIT_INTERFACE
56 #if !defined(_WIN32) && !defined(_WIN64)
66 #define DCHECK(condition) assert(condition)
121 : type_(type), name_(
name) {
137 printf(
"%s", prompt);
138 #if defined(__native_client__)
154 base::TimeTicks::HighResolutionNow();
164 const int MB = 1024 * 1024;
167 const char* name1 =
reinterpret_cast<const char*
>(key1);
168 const char* name2 =
reinterpret_cast<const char*
>(key2);
169 return strcmp(name1, name2) == 0;
176 return *value ? *value :
"<string conversion failed>";
215 bool report_exceptions) {
217 bool FLAG_debugger = i::FLAG_debugger;
219 bool FLAG_debugger =
false;
233 if (report_exceptions && !FLAG_debugger)
241 Handle<Value> result = script->BindToCurrentContext()->Run();
247 if (report_exceptions && !FLAG_debugger)
253 #if !defined(V8_SHARED)
256 if (!result->IsUndefined()) {
260 fwrite(*str,
sizeof(**str), str.
length(), stdout);
263 #if !defined(V8_SHARED)
276 fwrite(*str,
sizeof(**str), str.
length(), stdout);
299 for (
int i = 0;
i < data_->realm_count_; ++
i)
300 data_->realms_[
i].Reset();
301 delete[] data_->realms_;
302 if (!data_->realm_shared_.IsEmpty())
303 data_->realm_shared_.Reset();
318 if (args.
Length() < arg_offset || !args[arg_offset]->IsNumber()) {
322 int index = args[arg_offset]->Int32Value();
338 if (i::FLAG_verify_predictable) {
343 base::TimeDelta delta =
344 base::TimeTicks::HighResolutionNow() - kInitialTicks;
356 if (index == -1)
return;
365 if (args.
Length() < 1 || !args[0]->IsObject()) {
369 int index = data->
RealmFind(args[0]->ToObject()->CreationContext());
370 if (index == -1)
return;
380 if (index == -1)
return;
393 for (
int i = 0;
i < index; ++
i) {
394 data->
realms_[
i].Reset(isolate, old_realms[
i]);
409 if (index == -1)
return;
424 if (index == -1)
return;
434 if (index == -1)
return;
435 if (args.
Length() < 2 || !args[1]->IsString()) {
441 isolate, &script_source);
445 Handle<Value> result = script->BindToCurrentContext()->Run();
477 for (
int i = 0;
i < args.
Length();
i++) {
492 int n =
static_cast<int>(fwrite(*str,
sizeof(**str), str.
length(), stdout));
494 printf(
"Error in fwrite\n");
528 length =
static_cast<int>(strlen(buffer));
531 }
else if (buffer[length-1] !=
'\n') {
535 }
else if (length > 1 && buffer[length-2] ==
'\\') {
536 buffer[length-2] =
'\n';
550 for (
int i = 0;
i < args.
Length();
i++) {
575 int exit_code = args[0]->Int32Value();
591 bool enter_context = !isolate->
InContext();
594 utility_context->Enter();
598 const char* exception_string = ToCString(exception);
603 printf(
"%s\n", exception_string);
607 const char* filename_string = ToCString(filename);
608 int linenum = message->GetLineNumber();
609 printf(
"%s:%i: %s\n", filename_string, linenum, exception_string);
612 const char* sourceline_string = ToCString(sourceline);
613 printf(
"%s\n", sourceline_string);
615 int start = message->GetStartColumn();
616 for (
int i = 0;
i < start;
i++) {
619 int end = message->GetEndColumn();
620 for (
int i = start;
i < end;
i++) {
625 if (stack_trace.
length() > 0) {
626 const char* stack_trace_string = ToCString(stack_trace);
627 printf(
"%s\n", stack_trace_string);
632 if (enter_context) utility_context->Exit();
648 static const int kArgc = 3;
651 Handle<Value> argv[kArgc] = { evaluation_context->Global(), text, full };
666 static const int kArgc = 1;
682 static const int kArgc = 1;
691 for (
i = 0;
i < kMaxNameSize - 1 &&
name[
i];
i++)
692 name_[
i] =
static_cast<char>(
name[
i]);
694 is_histogram_ = is_histogram;
701 sample_total_ += sample;
706 magic_number_ = 0xDEADFACE;
707 max_counters_ = kMaxCounters;
709 counters_in_use_ = 0;
714 if (counters_in_use_ == kMaxCounters)
return NULL;
715 return &counters_[counters_in_use_++];
722 void* memory = (counters_file_ ==
NULL) ?
723 NULL : counters_file_->memory();
724 if (memory ==
NULL) {
725 printf(
"Could not map counters file %s\n",
name);
738 while ((c = *
name++) != 0) {
749 if (counter ==
NULL) {
750 counter = counters_->GetNextCounter();
751 if (counter !=
NULL) {
752 counter_map_->Set(
name, counter);
765 if (counter !=
NULL) {
766 return counter->
ptr();
777 return GetCounter(
name,
true);
795 utility_context->SetSecurityToken(
Undefined(isolate));
796 evaluation_context->SetSecurityToken(
Undefined(isolate));
799 if (i::FLAG_debugger) printf(
"JavaScript debugger enabled\n");
808 debug_context->set_security_token(
809 reinterpret_cast<i::Isolate*
>(isolate)->heap()->undefined_value());
831 i::JSFunction::cast(*compiled_script)->shared()->script()))
833 i::SharedFunctionInfo::cast(*compiled_script)->script()));
842 #ifdef COMPRESS_STARTUP_DATA_BZ2
845 virtual ~BZip2Decompressor() { }
848 virtual int DecompressData(
char* raw_data,
850 const char* compressed_data,
851 int compressed_data_size) {
854 unsigned int decompressed_size = *raw_data_size;
856 BZ2_bzBuffToBuffDecompress(raw_data,
858 const_cast<char*
>(compressed_data),
859 compressed_data_size,
861 if (result == BZ_OK) {
862 *raw_data_size = decompressed_size;
906 RealmSharedGet, RealmSharedSet);
914 performance_template);
918 AddOSMethods(isolate, os_templ);
921 return global_template;
926 #ifdef COMPRESS_STARTUP_DATA_BZ2
927 BZip2Decompressor startup_data_decompressor;
928 int bz2_result = startup_data_decompressor.Decompress();
929 if (bz2_result != BZ_OK) {
930 fprintf(stderr,
"bzip error code: %d\n", bz2_result);
939 MapCounters(isolate, i::FLAG_map_counters);
940 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) {
950 if (options.test_shell)
return;
954 utility_context_.Reset(isolate,
963 base::LockGuard<base::Mutex> lock_guard(&context_mutex_);
973 i::Factory* factory =
reinterpret_cast<i::Isolate*
>(isolate)->factory();
974 i::JSArguments js_args = i::FLAG_js_arguments;
976 factory->NewFixedArray(js_args.argc);
977 for (
int j = 0; j < js_args.argc; j++) {
979 factory->NewStringFromUtf8(
i::CStrVector(js_args[j])).ToHandleChecked();
980 arguments_array->set(j, *arg);
983 factory->NewJSArrayWithElements(arguments_array);
987 return handle_scope.
Escape(context);
1008 return strcmp(lhs.
key, rhs.
key) < 0;
1015 if (line_editor) line_editor->
Close();
1017 if (i::FLAG_dump_counters) {
1018 int number_of_counters = 0;
1020 number_of_counters++;
1025 counters[j].
counter =
i.CurrentValue();
1026 counters[j].
key =
i.CurrentKey();
1028 std::sort(counters, counters + number_of_counters);
1029 printf(
"+----------------------------------------------------------------+"
1030 "-------------+\n");
1033 printf(
"+----------------------------------------------------------------+"
1034 "-------------+\n");
1035 for (j = 0; j < number_of_counters; j++) {
1037 const char* key = counters[j].
key;
1039 printf(
"| c:%-60s | %11i |\n", key, counter->
count());
1040 printf(
"| t:%-60s | %11i |\n", key, counter->
sample_total());
1042 printf(
"| %-62s | %11i |\n", key, counter->
count());
1045 printf(
"+----------------------------------------------------------------+"
1046 "-------------+\n");
1049 delete counters_file_;
1050 delete counter_map_;
1057 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1059 if (fopen_s(&result, path,
mode) == 0) {
1067 struct stat file_stat;
1068 if (fstat(fileno(
file), &file_stat) != 0)
return NULL;
1069 bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
1070 if (is_regular_file)
return file;
1081 fseek(
file, 0, SEEK_END);
1085 char* chars =
new char[
size + 1];
1087 for (
int i = 0;
i <
size;) {
1088 int read =
static_cast<int>(fread(&chars[
i], 1,
size -
i,
file));
1105 size_t byte_length = data.
GetValue()->ByteLength();
1107 -
static_cast<intptr_t
>(byte_length));
1116 DCHECK(
sizeof(
char) ==
sizeof(uint8_t));
1119 if (*filename ==
NULL) {
1126 data->
data =
reinterpret_cast<uint8_t*
>(
1135 data->
handle.Reset(isolate, buffer);
1137 data->
handle.MarkIndependent();
1165 console->
Open(isolate);
1170 ExecuteString(isolate, input,
name,
true,
true);
1185 bool exception_was_thrown =
false;
1186 for (
int i = begin_offset_;
i < end_offset_; ++
i) {
1187 const char* arg = argv_[
i];
1188 if (strcmp(arg,
"-e") == 0 &&
i + 1 < end_offset_) {
1194 exception_was_thrown =
true;
1198 }
else if (arg[0] ==
'-') {
1206 printf(
"Error reading '%s'\n", arg);
1210 exception_was_thrown =
true;
1245 next_semaphore_.Wait();
1259 const int kLongIdlePauseInMs = 1000;
1270 done_semaphore_.Signal();
1278 if (thread_ ==
NULL) {
1282 next_semaphore_.Signal();
1287 if (thread_ ==
NULL)
return;
1291 done_semaphore_.Wait();
1303 bool logfile_per_isolate =
false;
1304 for (
int i = 0;
i < argc;
i++) {
1305 if (strcmp(argv[
i],
"--stress-opt") == 0) {
1306 options.stress_opt =
true;
1308 }
else if (strcmp(argv[
i],
"--nostress-opt") == 0) {
1309 options.stress_opt =
false;
1311 }
else if (strcmp(argv[
i],
"--stress-deopt") == 0) {
1312 options.stress_deopt =
true;
1314 }
else if (strcmp(argv[
i],
"--mock-arraybuffer-allocator") == 0) {
1315 options.mock_arraybuffer_allocator =
true;
1317 }
else if (strcmp(argv[
i],
"--noalways-opt") == 0) {
1319 options.stress_opt =
false;
1320 options.stress_deopt =
false;
1321 }
else if (strcmp(argv[
i],
"--logfile-per-isolate") == 0) {
1322 logfile_per_isolate =
true;
1324 }
else if (strcmp(argv[
i],
"--shell") == 0) {
1325 options.interactive_shell =
true;
1327 }
else if (strcmp(argv[
i],
"--test") == 0) {
1328 options.test_shell =
true;
1330 }
else if (strcmp(argv[
i],
"--send-idle-notification") == 0) {
1331 options.send_idle_notification =
true;
1333 }
else if (strcmp(argv[
i],
"--invoke-weak-callbacks") == 0) {
1334 options.invoke_weak_callbacks =
true;
1336 options.send_idle_notification =
true;
1338 }
else if (strcmp(argv[
i],
"-f") == 0) {
1342 }
else if (strcmp(argv[
i],
"--isolate") == 0) {
1344 printf(
"D8 with shared library does not support multi-threading\n");
1347 options.num_isolates++;
1348 }
else if (strcmp(argv[
i],
"--dump-heap-constants") == 0) {
1350 printf(
"D8 with shared library does not support constant dumping\n");
1353 options.dump_heap_constants =
true;
1356 }
else if (strcmp(argv[
i],
"--throws") == 0) {
1357 options.expected_to_throw =
true;
1359 }
else if (strncmp(argv[
i],
"--icu-data-file=", 16) == 0) {
1360 options.icu_data_file = argv[
i] + 16;
1363 }
else if (strcmp(argv[
i],
"--dump-counters") == 0) {
1364 printf(
"D8 with shared library does not include counters\n");
1366 }
else if (strcmp(argv[
i],
"--debugger") == 0) {
1367 printf(
"Javascript debugger not included\n");
1370 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
1371 }
else if (strncmp(argv[
i],
"--natives_blob=", 15) == 0) {
1372 options.natives_blob = argv[
i] + 15;
1374 }
else if (strncmp(argv[
i],
"--snapshot_blob=", 16) == 0) {
1375 options.snapshot_blob = argv[
i] + 16;
1378 }
else if (strcmp(argv[
i],
"--cache") == 0 ||
1379 strncmp(argv[
i],
"--cache=", 8) == 0) {
1380 const char* value = argv[
i] + 7;
1381 if (!*value || strncmp(value,
"=code", 6) == 0) {
1383 }
else if (strncmp(value,
"=parse", 7) == 0) {
1385 }
else if (strncmp(value,
"=none", 6) == 0) {
1388 printf(
"Unknown option to --cache.\n");
1398 options.isolate_sources =
new SourceGroup[options.num_isolates];
1400 current->
Begin(argv, 1);
1401 for (
int i = 1;
i < argc;
i++) {
1402 const char* str = argv[
i];
1403 if (strcmp(str,
"--isolate") == 0) {
1406 current->
Begin(argv,
i + 1);
1407 }
else if (strncmp(argv[
i],
"--", 2) == 0) {
1408 printf(
"Warning: unknown flag %s.\nTry --help for options\n", argv[
i]);
1413 if (!logfile_per_isolate && options.num_isolates) {
1423 for (
int i = 1;
i < options.num_isolates; ++
i) {
1424 options.isolate_sources[
i].StartExecuteInThread();
1430 if (options.last_run && options.use_interactive_shell()) {
1432 evaluation_context_.Reset(isolate, context);
1436 if (i::FLAG_debugger) {
1437 InstallUtilityScript(isolate);
1444 options.isolate_sources[0].Execute(isolate);
1447 if (options.send_idle_notification) {
1448 const int kLongIdlePauseInMs = 1000;
1452 if (options.invoke_weak_callbacks) {
1460 for (
int i = 1;
i < options.num_isolates; ++
i) {
1461 options.isolate_sources[
i].WaitForThread();
1473 printf(
"# List of known V8 instance types.\n");
1474 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T);
1475 printf(
"INSTANCE_TYPES = {\n");
1481 printf(
"\n# List of known V8 maps.\n");
1482 #define ROOT_LIST_CASE(type, name, camel_name) \
1483 if (n == NULL && o == heap->name()) n = #camel_name;
1484 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \
1485 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map";
1487 printf(
"KNOWN_MAPS = {\n");
1489 i::Map* m = i::Map::cast(o);
1490 const char* n =
NULL;
1491 intptr_t p =
reinterpret_cast<intptr_t
>(m) & 0xfffff;
1495 if (n ==
NULL)
continue;
1496 printf(
" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n);
1499 #undef STRUCT_LIST_CASE
1500 #undef ROOT_LIST_CASE
1503 printf(
"\n# List of known V8 objects.\n");
1504 #define ROOT_LIST_CASE(type, name, camel_name) \
1505 if (n == NULL && o == heap->name()) n = #camel_name;
1506 i::OldSpaces spit(heap);
1507 printf(
"KNOWN_OBJECTS = {\n");
1512 const char* n =
NULL;
1513 intptr_t p =
reinterpret_cast<intptr_t
>(o) & 0xfffff;
1515 if (n ==
NULL)
continue;
1516 printf(
" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
1520 #undef ROOT_LIST_CASE
1528 void* data = AllocateUninitialized(length);
1529 return data ==
NULL ? data : memset(data, 0, length);
1532 virtual void Free(
void* data,
size_t) { free(data); }
1550 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
1551 class StartupDataHandler {
1553 StartupDataHandler(
const char* natives_blob,
1554 const char* snapshot_blob) {
1559 ~StartupDataHandler() {
1560 delete[] natives_.data;
1561 delete[] snapshot_.data;
1565 void Load(
const char* blob_file,
1575 FILE*
file = fopen(blob_file,
"rb");
1579 fseek(
file, 0, SEEK_END);
1585 const_cast<char*
>(startup_data->
data), 1, startup_data->
raw_size,
1590 (*setter_fn)(startup_data);
1597 StartupDataHandler(
const StartupDataHandler& other);
1598 void operator=(
const StartupDataHandler& other);
1604 #if (defined(_WIN32) || defined(_WIN64))
1606 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
1607 UINT existing_flags = SetErrorMode(new_flags);
1608 SetErrorMode(existing_flags | new_flags);
1609 #if defined(_MSC_VER)
1610 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
1611 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
1612 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
1613 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
1614 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
1615 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
1616 _set_error_mode(_OUT_TO_STDERR);
1619 if (!SetOptions(argc, argv))
return 1;
1624 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
1625 StartupDataHandler startup_data(options.natives_blob, options.snapshot_blob);
1631 if (options.mock_arraybuffer_allocator) {
1638 #if !defined(V8_SHARED) && defined(ENABLE_GDB_JIT_INTERFACE)
1639 if (i::FLAG_gdbjit) {
1643 #ifdef ENABLE_VTUNE_JIT_INTERFACE
1648 base::SysInfo::AmountOfPhysicalMemory(),
1649 base::SysInfo::AmountOfVirtualMemory(),
1650 base::SysInfo::NumberOfProcessors());
1656 Initialize(isolate);
1658 InitializeDebugger(isolate);
1661 if (options.dump_heap_constants) {
1667 if (options.stress_opt || options.stress_deopt) {
1672 for (
int i = 0;
i < stress_runs && result == 0;
i++) {
1673 printf(
"============ Stress %d/%d ============\n",
i + 1, stress_runs);
1675 options.last_run = (
i == stress_runs - 1);
1676 result = RunMain(isolate, argc, argv);
1678 printf(
"======== Full Deoptimization =======\n");
1680 #if !defined(V8_SHARED)
1681 }
else if (i::FLAG_stress_runs > 0) {
1682 int stress_runs = i::FLAG_stress_runs;
1683 for (
int i = 0;
i < stress_runs && result == 0;
i++) {
1684 printf(
"============ Run %d/%d ============\n",
i + 1, stress_runs);
1685 options.last_run = (
i == stress_runs - 1);
1686 result = RunMain(isolate, argc, argv);
1690 result = RunMain(isolate, argc, argv);
1695 if (options.use_interactive_shell()) {
1697 if (!i::FLAG_debugger) {
1698 InstallUtilityScript(isolate);
1707 reinterpret_cast<i::Isolate*
>(isolate)->basic_block_profiler()) {
Allocator that V8 uses to allocate |ArrayBuffer|'s memory.
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
Create a new ArrayBuffer.
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.
Counter * GetNextCounter()
static int Hash(const char *name)
static bool Match(void *key1, void *key2)
int32_t * Bind(const char *name, bool histogram)
static const int kMaxNameSize
void AddSample(int32_t sample)
static bool SetDebugEventListener(EventCallback that, Handle< Value > data=Handle< Value >())
virtual Handle< String > Prompt(const char *prompt)
DumbLineEditor(Isolate *isolate)
A HandleScope which first allocates a handle in the current scope which will be later filled with the...
Local< T > Escape(Local< T > value)
Pushes the value into the previous scope and returns a handle to it.
The argument information given to function call callbacks.
ReturnValue< T > GetReturnValue() const
Isolate * GetIsolate() const
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >(), int length=0)
Creates a function template.
A stack-allocated class that governs a number of local handles.
An object reference managed by the v8 garbage collector.
bool IsEmpty() const
Returns true if the handle is empty.
static Handle< T > Cast(Handle< S > that)
Stack-allocated class which sets the isolate for all operations executed within a local scope.
Isolate represents an isolated instance of the V8 engine.
Local< Context > GetEnteredContext()
Returns the last entered context.
int ContextDisposedNotification()
Optional notification that a context has been disposed.
void Dispose()
Disposes the isolate.
void SetData(uint32_t slot, void *data)
Associate embedder-specific data with the isolate.
static Isolate * New(const CreateParams ¶ms=CreateParams())
Creates a new isolate.
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Adjusts the amount of registered external memory.
void LowMemoryNotification()
Optional notification that the system is running low on memory.
void SetCounterFunction(CounterLookupCallback)
Enables the host application to provide a mechanism for recording statistics counters.
Local< Value > ThrowException(Local< Value > exception)
Schedules an exception to be thrown when returning to JavaScript.
void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
bool IdleNotification(int idle_time_in_ms)
Optional notification that the embedder is idle.
void * GetData(uint32_t slot)
Retrieve embedder-specific data from the isolate.
bool InContext()
Returns true if this isolate has a current context.
void SetCreateHistogramFunction(CreateHistogramCallback)
Enables the host application to provide a mechanism for recording histograms.
virtual Handle< String > Prompt(const char *prompt)=0
static LineEditor * Get()
virtual bool Open(Isolate *isolate)
static LineEditor * current_
LineEditor(Type type, const char *name)
A light-weight stack-allocated object handle.
static Local< T > Cast(Local< S > that)
static Local< T > New(Isolate *isolate, Handle< T > that)
Create a local handle for the content of another handle.
virtual void Free(void *p, size_t) OVERRIDE
Free the memory block of size |length|, pointed to by |data|.
virtual void * AllocateUninitialized(size_t length) OVERRIDE
Allocate |length| bytes.
virtual void * Allocate(size_t) OVERRIDE
Allocate |length| bytes.
static Local< ObjectTemplate > New()
RealmScope(PerIsolateData *data)
int RealmFind(Handle< Context > context)
int RealmIndexOrThrow(const v8::FunctionCallbackInfo< v8::Value > &args, int arg_offset)
PerIsolateData(Isolate *isolate)
Persistent< Context > * realms_
Persistent< Value > realm_shared_
static PerIsolateData * Get(Isolate *isolate)
A PersistentBase which allows copy and assignment.
The information passed to a property callback about the context of the property access.
ReturnValue< T > GetReturnValue() const
Isolate * GetIsolate() const
void ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit, uint32_t number_of_processors)
Configures the constraints with reasonable default values based on the capabilities of the current de...
Source code which can be then compiled to a UnboundScript or Script.
const CachedData * GetCachedData() const
static Local< UnboundScript > CompileUnbound(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions)
Compiles the specified script (context-independent).
The origin, within a file, of a script.
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL)
A shorthand for ScriptCompiler::Compile().
virtual void * AllocateUninitialized(size_t length)
Allocate |length| bytes.
virtual void Free(void *data, size_t)
Free the memory block of size |length|, pointed to by |data|.
virtual void * Allocate(size_t length)
Allocate |length| bytes.
v8::ScriptCompiler::CompileOptions compile_options
static int Main(int argc, char *argv[])
static void Read(const v8::FunctionCallbackInfo< v8::Value > &args)
static Local< UnboundScript > CompileString(Isolate *isolate, Local< String > source, Local< Value > name, v8::ScriptCompiler::CompileOptions compile_options)
static CounterCollection * counters_
static void AddHistogramSample(void *histogram, int sample)
static base::OS::MemoryMappedFile * counters_file_
static void Quit(const v8::FunctionCallbackInfo< v8::Value > &args)
static void RealmSharedGet(Local< String > property, const PropertyCallbackInfo< Value > &info)
static void PerformanceNow(const v8::FunctionCallbackInfo< v8::Value > &args)
static void RealmEval(const v8::FunctionCallbackInfo< v8::Value > &args)
static Persistent< Context > utility_context_
static void RealmCreate(const v8::FunctionCallbackInfo< v8::Value > &args)
static void ReadBuffer(const v8::FunctionCallbackInfo< v8::Value > &args)
static Handle< Array > GetCompletions(Isolate *isolate, Handle< String > text, Handle< String > full)
static void ReportException(Isolate *isolate, TryCatch *try_catch)
static const char * ToCString(const v8::String::Utf8Value &value)
static Local< Object > DebugMessageDetails(Isolate *isolate, Handle< String > message)
static void * CreateHistogram(const char *name, int min, int max, size_t buckets)
static void Version(const v8::FunctionCallbackInfo< v8::Value > &args)
static void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
static void InstallUtilityScript(Isolate *isolate)
static Local< Context > CreateEvaluationContext(Isolate *isolate)
static const char * kPrompt
static void RealmSharedSet(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
static void RealmDispose(const v8::FunctionCallbackInfo< v8::Value > &args)
static void Initialize(Isolate *isolate)
static void RunShell(Isolate *isolate)
static int RunMain(Isolate *isolate, int argc, char *argv[])
static base::Mutex context_mutex_
static const base::TimeTicks kInitialTicks
static Counter * GetCounter(const char *name, bool is_histogram)
static void RealmCurrent(const v8::FunctionCallbackInfo< v8::Value > &args)
static void RealmOwner(const v8::FunctionCallbackInfo< v8::Value > &args)
static bool SetOptions(int argc, char *argv[])
static void Exit(int exit_code)
static Local< Value > DebugCommandToJSONRequest(Isolate *isolate, Handle< String > command)
static int * LookupCounter(const char *name)
static void RealmSwitch(const v8::FunctionCallbackInfo< v8::Value > &args)
static void Load(const v8::FunctionCallbackInfo< v8::Value > &args)
static CounterCollection local_counters_
static Handle< String > ReadFromStdin(Isolate *isolate)
static CounterMap * counter_map_
static void RealmGlobal(const v8::FunctionCallbackInfo< v8::Value > &args)
static Handle< String > ReadFile(Isolate *isolate, const char *name)
static void InitializeDebugger(Isolate *isolate)
static bool ExecuteString(Isolate *isolate, Handle< String > source, Handle< Value > name, bool print_result, bool report_exceptions)
static Handle< ObjectTemplate > CreateGlobalTemplate(Isolate *isolate)
static Persistent< Context > evaluation_context_
static ShellOptions options
static void MapCounters(v8::Isolate *isolate, const char *name)
static void Write(const v8::FunctionCallbackInfo< v8::Value > &args)
void Begin(char **argv, int offset)
static base::Thread::Options GetThreadOptions()
void Execute(Isolate *isolate)
void StartExecuteInThread()
Handle< String > ReadFile(Isolate *isolate, const char *name)
A helper class for driving V8 startup data decompression.
Converts an object to a UTF-8-encoded character array.
static Local< String > Concat(Handle< String > left, Handle< String > right)
Creates a new string by concatenating the left and the right strings passed in as parameters.
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
Allocates a new string from UTF-8 data.
static int GetStressRuns()
Get the number of runs of a given test that is required to get the full stress coverage.
static void DeoptimizeAll()
Force deoptimization of all functions.
static void PrepareStressRun(int run)
Indicate the number of the run which is about to start.
static void SetStressRunType(StressType type)
Set the type of stressing to do.
An external exception handler.
void SetVerbose(bool value)
Set verbosity of the external exception handler.
Local< v8::Message > Message() const
Returns the message associated with this exception.
Local< Value > Exception() const
Returns the exception caught by this try/catch block.
Handle< Value > ReThrow()
Throws the exception caught by this TryCatch in a way that avoids it being caught again by this same ...
Local< Value > StackTrace() const
Returns the .stack property of the thrown object.
bool HasCaught() const
Returns true if an exception has been caught by this try/catch block.
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
static bool InitializeICU(const char *icu_data_file=NULL)
Initialize the ICU library bundled with V8.
static const char * GetVersion()
Get the version string.
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 SetFlagsFromString(const char *str, int length)
Sets V8 flags from a string.
static void InitializePlatform(Platform *platform)
Sets the v8::Platform to use.
static void SetSnapshotDataBlob(StartupData *startup_blob)
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
Sets V8 flags from the command line.
static void SetArrayBufferAllocator(ArrayBuffer::Allocator *allocator)
Set allocator to use for ArrayBuffer memory.
static void SetNativesDataBlob(StartupData *startup_blob)
Hand startup data to V8, in case the embedder has chosen to build V8 with external startup data.
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.
Isolate * GetIsolate() const
Local< T > GetValue() const
static MemoryMappedFile * create(const char *name, int size, void *initial)
Handle< Context > debug_context()
InstanceType instance_type()
static Vector< const char > GetScriptName(int index)
static Vector< const char > GetRawScriptSource(int index)
static int GetIndex(const char *name)
static Smi * FromInt(int value)
int main(int argc, char *argv[])
#define ROOT_LIST_CASE(type, name, camel_name)
#define DCHECK(condition)
#define STRUCT_LIST_CASE(upper_name, camel_name, 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 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 Print the time it takes to lazily compile hydrogen code stubs dump only objects containing this substring stress the GC compactor to flush out pretty print source code for builtins print C code to recreate TurboFan graphs report heap spill statistics along with enable possessive quantifier syntax for testing Minimal Log code events to the log file without profiling log positions Log statistical profiling Used with turns on browser compatible mode for profiling Enable perf linux profiler(experimental annotate support).") DEFINE_STRING(gc_fake_mmap
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
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_EQ(v1, v2)
static const size_t kBufferSize
Vector< const char > CStrVector(const char *data)
char * ReadLine(const char *prompt)
static int min(int a, int b)
Vector< const char > ReadFile(const char *filename, bool *exists, bool verbose)
int StrLength(const char *string)
const char * AllocationSpaceName(AllocationSpace space)
Debugger support for the V8 JavaScript engine.
static void SetFlagsFromString(const char *flags)
bool operator<(const CounterAndKey &lhs, const CounterAndKey &rhs)
static void DumpHeapConstants(i::Isolate *isolate)
static void ReadBufferWeakCallback(const v8::WeakCallbackData< ArrayBuffer, DataAndPersistent > &data)
void HandleDebugEvent(const Debug::EventDetails &event_details)
static char * ReadChars(Isolate *isolate, const char *name, int *size_out)
static Handle< Value > Throw(Isolate *isolate, const char *message)
static FILE * FOpen(const char *path, const char *mode)
Handle< Primitive > Undefined(Isolate *isolate)
void InitializeVtuneForV8(v8::Isolate::CreateParams ¶ms)
#define INSTANCE_TYPE_LIST(V)
Persistent< ArrayBuffer > handle
Initial configuration parameters for a new Isolate.
ResourceConstraints constraints
ResourceConstraints to use for the new Isolate.
JitCodeEventHandler code_event_handler
Allows the host application to provide the address of a function that is notified each time code is a...
Compilation data that the embedder can cache and pass back to speed up future compilations.