| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 v8::String::Utf8Value str(str_obj); | 450 v8::String::Utf8Value str(str_obj); |
| 451 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); | 451 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
| 452 if (n != str.length()) { | 452 if (n != str.length()) { |
| 453 printf("Error in fwrite\n"); | 453 printf("Error in fwrite\n"); |
| 454 Exit(1); | 454 Exit(1); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 | 458 |
| 459 | 459 |
| 460 void Shell::EnableProfiler(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 461 V8::ResumeProfiler(); | |
| 462 } | |
| 463 | |
| 464 | |
| 465 void Shell::DisableProfiler(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 466 V8::PauseProfiler(); | |
| 467 } | |
| 468 | |
| 469 | |
| 470 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { | 460 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 471 String::Utf8Value file(args[0]); | 461 String::Utf8Value file(args[0]); |
| 472 if (*file == NULL) { | 462 if (*file == NULL) { |
| 473 Throw("Error loading file"); | 463 Throw("Error loading file"); |
| 474 return; | 464 return; |
| 475 } | 465 } |
| 476 Handle<String> source = ReadFile(args.GetIsolate(), *file); | 466 Handle<String> source = ReadFile(args.GetIsolate(), *file); |
| 477 if (source.IsEmpty()) { | 467 if (source.IsEmpty()) { |
| 478 Throw("Error loading file"); | 468 Throw("Error loading file"); |
| 479 return; | 469 return; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); | 840 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); |
| 851 global_template->Set(String::New("write"), FunctionTemplate::New(Write)); | 841 global_template->Set(String::New("write"), FunctionTemplate::New(Write)); |
| 852 global_template->Set(String::New("read"), FunctionTemplate::New(Read)); | 842 global_template->Set(String::New("read"), FunctionTemplate::New(Read)); |
| 853 global_template->Set(String::New("readbuffer"), | 843 global_template->Set(String::New("readbuffer"), |
| 854 FunctionTemplate::New(ReadBuffer)); | 844 FunctionTemplate::New(ReadBuffer)); |
| 855 global_template->Set(String::New("readline"), | 845 global_template->Set(String::New("readline"), |
| 856 FunctionTemplate::New(ReadLine)); | 846 FunctionTemplate::New(ReadLine)); |
| 857 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); | 847 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); |
| 858 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); | 848 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); |
| 859 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); | 849 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); |
| 860 global_template->Set(String::New("enableProfiler"), | |
| 861 FunctionTemplate::New(EnableProfiler)); | |
| 862 global_template->Set(String::New("disableProfiler"), | |
| 863 FunctionTemplate::New(DisableProfiler)); | |
| 864 | 850 |
| 865 // Bind the Realm object. | 851 // Bind the Realm object. |
| 866 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(); | 852 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(); |
| 867 realm_template->Set(String::New("current"), | 853 realm_template->Set(String::New("current"), |
| 868 FunctionTemplate::New(RealmCurrent)); | 854 FunctionTemplate::New(RealmCurrent)); |
| 869 realm_template->Set(String::New("owner"), | 855 realm_template->Set(String::New("owner"), |
| 870 FunctionTemplate::New(RealmOwner)); | 856 FunctionTemplate::New(RealmOwner)); |
| 871 realm_template->Set(String::New("global"), | 857 realm_template->Set(String::New("global"), |
| 872 FunctionTemplate::New(RealmGlobal)); | 858 FunctionTemplate::New(RealmGlobal)); |
| 873 realm_template->Set(String::New("create"), | 859 realm_template->Set(String::New("create"), |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 if (threads.length() > 0 && options.use_preemption) { | 1540 if (threads.length() > 0 && options.use_preemption) { |
| 1555 Locker lock(isolate); | 1541 Locker lock(isolate); |
| 1556 Locker::StopPreemption(); | 1542 Locker::StopPreemption(); |
| 1557 } | 1543 } |
| 1558 #endif // V8_SHARED | 1544 #endif // V8_SHARED |
| 1559 return 0; | 1545 return 0; |
| 1560 } | 1546 } |
| 1561 | 1547 |
| 1562 | 1548 |
| 1563 #ifdef V8_SHARED | 1549 #ifdef V8_SHARED |
| 1564 static void EnableHarmonyTypedArraysViaCommandLine() { | 1550 static void SetStandaloneFlagsViaCommandLine() { |
| 1565 int fake_argc = 2; | 1551 int fake_argc = 3; |
| 1566 char **fake_argv = new char*[2]; | 1552 char **fake_argv = new char*[3]; |
| 1567 fake_argv[0] = NULL; | 1553 fake_argv[0] = NULL; |
| 1568 fake_argv[1] = strdup("--harmony-typed-arrays"); | 1554 fake_argv[1] = strdup("--harmony-typed-arrays"); |
| 1555 fake_argv[2] = strdup("--trace-hydrogen-file=hydrogen.cfg"); |
| 1569 v8::V8::SetFlagsFromCommandLine(&fake_argc, fake_argv, false); | 1556 v8::V8::SetFlagsFromCommandLine(&fake_argc, fake_argv, false); |
| 1570 free(fake_argv[1]); | 1557 free(fake_argv[1]); |
| 1571 delete[] fake_argv; | 1558 delete[] fake_argv; |
| 1572 } | 1559 } |
| 1573 #endif | 1560 #endif |
| 1574 | 1561 |
| 1575 | 1562 |
| 1576 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 1563 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 1577 public: | 1564 public: |
| 1578 virtual void* Allocate(size_t length) { return malloc(length); } | 1565 virtual void* Allocate(size_t length) { return malloc(length); } |
| 1579 virtual void Free(void* data) { free(data); } | 1566 virtual void Free(void* data) { free(data); } |
| 1580 }; | 1567 }; |
| 1581 | 1568 |
| 1582 | 1569 |
| 1583 int Shell::Main(int argc, char* argv[]) { | 1570 int Shell::Main(int argc, char* argv[]) { |
| 1584 if (!SetOptions(argc, argv)) return 1; | 1571 if (!SetOptions(argc, argv)) return 1; |
| 1585 v8::V8::InitializeICU(); | 1572 v8::V8::InitializeICU(); |
| 1586 #ifndef V8_SHARED | 1573 #ifndef V8_SHARED |
| 1587 i::FLAG_harmony_array_buffer = true; | 1574 i::FLAG_harmony_array_buffer = true; |
| 1588 i::FLAG_harmony_typed_arrays = true; | 1575 i::FLAG_harmony_typed_arrays = true; |
| 1576 i::FLAG_trace_hydrogen_file = "hydrogen.cfg"; |
| 1589 #else | 1577 #else |
| 1590 EnableHarmonyTypedArraysViaCommandLine(); | 1578 SetStandaloneFlagsViaCommandLine(); |
| 1591 #endif | 1579 #endif |
| 1592 ShellArrayBufferAllocator array_buffer_allocator; | 1580 ShellArrayBufferAllocator array_buffer_allocator; |
| 1593 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); | 1581 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); |
| 1594 int result = 0; | 1582 int result = 0; |
| 1595 Isolate* isolate = Isolate::GetCurrent(); | 1583 Isolate* isolate = Isolate::GetCurrent(); |
| 1596 DumbLineEditor dumb_line_editor(isolate); | 1584 DumbLineEditor dumb_line_editor(isolate); |
| 1597 { | 1585 { |
| 1598 Initialize(isolate); | 1586 Initialize(isolate); |
| 1599 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 1587 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 1600 vTune::InitializeVtuneForV8(); | 1588 vTune::InitializeVtuneForV8(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 } | 1647 } |
| 1660 | 1648 |
| 1661 } // namespace v8 | 1649 } // namespace v8 |
| 1662 | 1650 |
| 1663 | 1651 |
| 1664 #ifndef GOOGLE3 | 1652 #ifndef GOOGLE3 |
| 1665 int main(int argc, char* argv[]) { | 1653 int main(int argc, char* argv[]) { |
| 1666 return v8::Shell::Main(argc, argv); | 1654 return v8::Shell::Main(argc, argv); |
| 1667 } | 1655 } |
| 1668 #endif | 1656 #endif |
| OLD | NEW |