| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
| 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
| 8 #define V8_SHARED | 8 #define V8_SHARED |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #ifdef COMPRESS_STARTUP_DATA_BZ2 | |
| 12 #include <bzlib.h> | |
| 13 #endif | |
| 14 | |
| 15 #include <errno.h> | 11 #include <errno.h> |
| 16 #include <stdlib.h> | 12 #include <stdlib.h> |
| 17 #include <string.h> | 13 #include <string.h> |
| 18 #include <sys/stat.h> | 14 #include <sys/stat.h> |
| 19 | 15 |
| 20 #ifdef V8_SHARED | 16 #ifdef V8_SHARED |
| 21 #include <assert.h> | 17 #include <assert.h> |
| 22 #endif // V8_SHARED | 18 #endif // V8_SHARED |
| 23 | 19 |
| 24 #ifndef V8_SHARED | 20 #ifndef V8_SHARED |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 : i::Handle<i::Script>(i::Script::cast( | 872 : i::Handle<i::Script>(i::Script::cast( |
| 877 i::SharedFunctionInfo::cast(*compiled_script)->script())); | 873 i::SharedFunctionInfo::cast(*compiled_script)->script())); |
| 878 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); | 874 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); |
| 879 | 875 |
| 880 // Start the in-process debugger if requested. | 876 // Start the in-process debugger if requested. |
| 881 if (i::FLAG_debugger) v8::Debug::SetDebugEventListener(HandleDebugEvent); | 877 if (i::FLAG_debugger) v8::Debug::SetDebugEventListener(HandleDebugEvent); |
| 882 } | 878 } |
| 883 #endif // !V8_SHARED | 879 #endif // !V8_SHARED |
| 884 | 880 |
| 885 | 881 |
| 886 #ifdef COMPRESS_STARTUP_DATA_BZ2 | |
| 887 class BZip2Decompressor : public v8::StartupDataDecompressor { | |
| 888 public: | |
| 889 virtual ~BZip2Decompressor() { } | |
| 890 | |
| 891 protected: | |
| 892 virtual int DecompressData(char* raw_data, | |
| 893 int* raw_data_size, | |
| 894 const char* compressed_data, | |
| 895 int compressed_data_size) { | |
| 896 DCHECK_EQ(v8::StartupData::kBZip2, | |
| 897 v8::V8::GetCompressedStartupDataAlgorithm()); | |
| 898 unsigned int decompressed_size = *raw_data_size; | |
| 899 int result = | |
| 900 BZ2_bzBuffToBuffDecompress(raw_data, | |
| 901 &decompressed_size, | |
| 902 const_cast<char*>(compressed_data), | |
| 903 compressed_data_size, | |
| 904 0, 1); | |
| 905 if (result == BZ_OK) { | |
| 906 *raw_data_size = decompressed_size; | |
| 907 } | |
| 908 return result; | |
| 909 } | |
| 910 }; | |
| 911 #endif | |
| 912 | |
| 913 | |
| 914 Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { | 882 Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { |
| 915 Handle<ObjectTemplate> global_template = ObjectTemplate::New(isolate); | 883 Handle<ObjectTemplate> global_template = ObjectTemplate::New(isolate); |
| 916 global_template->Set(String::NewFromUtf8(isolate, "print"), | 884 global_template->Set(String::NewFromUtf8(isolate, "print"), |
| 917 FunctionTemplate::New(isolate, Print)); | 885 FunctionTemplate::New(isolate, Print)); |
| 918 global_template->Set(String::NewFromUtf8(isolate, "write"), | 886 global_template->Set(String::NewFromUtf8(isolate, "write"), |
| 919 FunctionTemplate::New(isolate, Write)); | 887 FunctionTemplate::New(isolate, Write)); |
| 920 global_template->Set(String::NewFromUtf8(isolate, "read"), | 888 global_template->Set(String::NewFromUtf8(isolate, "read"), |
| 921 FunctionTemplate::New(isolate, Read)); | 889 FunctionTemplate::New(isolate, Read)); |
| 922 global_template->Set(String::NewFromUtf8(isolate, "readbuffer"), | 890 global_template->Set(String::NewFromUtf8(isolate, "readbuffer"), |
| 923 FunctionTemplate::New(isolate, ReadBuffer)); | 891 FunctionTemplate::New(isolate, ReadBuffer)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 928 |
| 961 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); | 929 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); |
| 962 AddOSMethods(isolate, os_templ); | 930 AddOSMethods(isolate, os_templ); |
| 963 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); | 931 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); |
| 964 | 932 |
| 965 return global_template; | 933 return global_template; |
| 966 } | 934 } |
| 967 | 935 |
| 968 | 936 |
| 969 void Shell::Initialize(Isolate* isolate) { | 937 void Shell::Initialize(Isolate* isolate) { |
| 970 #ifdef COMPRESS_STARTUP_DATA_BZ2 | |
| 971 BZip2Decompressor startup_data_decompressor; | |
| 972 int bz2_result = startup_data_decompressor.Decompress(); | |
| 973 if (bz2_result != BZ_OK) { | |
| 974 fprintf(stderr, "bzip error code: %d\n", bz2_result); | |
| 975 Exit(1); | |
| 976 } | |
| 977 #endif | |
| 978 | |
| 979 #ifndef V8_SHARED | 938 #ifndef V8_SHARED |
| 980 Shell::counter_map_ = new CounterMap(); | 939 Shell::counter_map_ = new CounterMap(); |
| 981 // Set up counters | 940 // Set up counters |
| 982 if (i::StrLength(i::FLAG_map_counters) != 0) | 941 if (i::StrLength(i::FLAG_map_counters) != 0) |
| 983 MapCounters(isolate, i::FLAG_map_counters); | 942 MapCounters(isolate, i::FLAG_map_counters); |
| 984 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) { | 943 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) { |
| 985 isolate->SetCounterFunction(LookupCounter); | 944 isolate->SetCounterFunction(LookupCounter); |
| 986 isolate->SetCreateHistogramFunction(CreateHistogram); | 945 isolate->SetCreateHistogramFunction(CreateHistogram); |
| 987 isolate->SetAddHistogramSampleFunction(AddHistogramSample); | 946 isolate->SetAddHistogramSampleFunction(AddHistogramSample); |
| 988 } | 947 } |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 } | 1724 } |
| 1766 | 1725 |
| 1767 } // namespace v8 | 1726 } // namespace v8 |
| 1768 | 1727 |
| 1769 | 1728 |
| 1770 #ifndef GOOGLE3 | 1729 #ifndef GOOGLE3 |
| 1771 int main(int argc, char* argv[]) { | 1730 int main(int argc, char* argv[]) { |
| 1772 return v8::Shell::Main(argc, argv); | 1731 return v8::Shell::Main(argc, argv); |
| 1773 } | 1732 } |
| 1774 #endif | 1733 #endif |
| OLD | NEW |