| 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 #include <errno.h> | 5 #include <errno.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2436 argv[i] = NULL; | 2436 argv[i] = NULL; |
| 2437 } else if (strcmp(argv[i], "--omit-quit") == 0) { | 2437 } else if (strcmp(argv[i], "--omit-quit") == 0) { |
| 2438 options.omit_quit = true; | 2438 options.omit_quit = true; |
| 2439 argv[i] = NULL; | 2439 argv[i] = NULL; |
| 2440 } else if (strcmp(argv[i], "-f") == 0) { | 2440 } else if (strcmp(argv[i], "-f") == 0) { |
| 2441 // Ignore any -f flags for compatibility with other stand-alone | 2441 // Ignore any -f flags for compatibility with other stand-alone |
| 2442 // JavaScript engines. | 2442 // JavaScript engines. |
| 2443 continue; | 2443 continue; |
| 2444 } else if (strcmp(argv[i], "--isolate") == 0) { | 2444 } else if (strcmp(argv[i], "--isolate") == 0) { |
| 2445 options.num_isolates++; | 2445 options.num_isolates++; |
| 2446 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) { | |
| 2447 options.dump_heap_constants = true; | |
| 2448 argv[i] = NULL; | |
| 2449 } else if (strcmp(argv[i], "--throws") == 0) { | 2446 } else if (strcmp(argv[i], "--throws") == 0) { |
| 2450 options.expected_to_throw = true; | 2447 options.expected_to_throw = true; |
| 2451 argv[i] = NULL; | 2448 argv[i] = NULL; |
| 2452 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { | 2449 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { |
| 2453 options.icu_data_file = argv[i] + 16; | 2450 options.icu_data_file = argv[i] + 16; |
| 2454 argv[i] = NULL; | 2451 argv[i] = NULL; |
| 2455 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 2452 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 2456 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { | 2453 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { |
| 2457 options.natives_blob = argv[i] + 15; | 2454 options.natives_blob = argv[i] + 15; |
| 2458 argv[i] = NULL; | 2455 argv[i] = NULL; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2816 worker->WaitForThread(); | 2813 worker->WaitForThread(); |
| 2817 delete worker; | 2814 delete worker; |
| 2818 } | 2815 } |
| 2819 | 2816 |
| 2820 // Now that all workers are terminated, we can re-enable Worker creation. | 2817 // Now that all workers are terminated, we can re-enable Worker creation. |
| 2821 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); | 2818 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); |
| 2822 allow_new_workers_ = true; | 2819 allow_new_workers_ = true; |
| 2823 externalized_contents_.clear(); | 2820 externalized_contents_.clear(); |
| 2824 } | 2821 } |
| 2825 | 2822 |
| 2826 | |
| 2827 static void DumpHeapConstants(i::Isolate* isolate) { | |
| 2828 i::Heap* heap = isolate->heap(); | |
| 2829 printf( | |
| 2830 "# Copyright 2017 the V8 project authors. All rights reserved.\n" | |
| 2831 "# Use of this source code is governed by a BSD-style license that can\n" | |
| 2832 "# be found in the LICENSE file.\n\n"); | |
| 2833 // Dump the INSTANCE_TYPES table to the console. | |
| 2834 printf("# List of known V8 instance types.\n"); | |
| 2835 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); | |
| 2836 printf("INSTANCE_TYPES = {\n"); | |
| 2837 INSTANCE_TYPE_LIST(DUMP_TYPE) | |
| 2838 printf("}\n"); | |
| 2839 #undef DUMP_TYPE | |
| 2840 | |
| 2841 // Dump the KNOWN_MAP table to the console. | |
| 2842 printf("\n# List of known V8 maps.\n"); | |
| 2843 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
| 2844 if (n == NULL && o == heap->name()) n = #camel_name; | |
| 2845 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \ | |
| 2846 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map"; | |
| 2847 i::HeapObjectIterator it(heap->map_space()); | |
| 2848 printf("KNOWN_MAPS = {\n"); | |
| 2849 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
| 2850 i::Map* m = i::Map::cast(o); | |
| 2851 const char* n = NULL; | |
| 2852 intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7ffff; | |
| 2853 int t = m->instance_type(); | |
| 2854 ROOT_LIST(ROOT_LIST_CASE) | |
| 2855 STRUCT_LIST(STRUCT_LIST_CASE) | |
| 2856 if (n == NULL) continue; | |
| 2857 printf(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n); | |
| 2858 } | |
| 2859 printf("}\n"); | |
| 2860 #undef STRUCT_LIST_CASE | |
| 2861 #undef ROOT_LIST_CASE | |
| 2862 | |
| 2863 // Dump the KNOWN_OBJECTS table to the console. | |
| 2864 printf("\n# List of known V8 objects.\n"); | |
| 2865 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
| 2866 if (n == NULL && o == heap->name()) n = #camel_name; | |
| 2867 i::OldSpaces spit(heap); | |
| 2868 printf("KNOWN_OBJECTS = {\n"); | |
| 2869 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) { | |
| 2870 i::HeapObjectIterator it(s); | |
| 2871 const char* sname = AllocationSpaceName(s->identity()); | |
| 2872 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
| 2873 const char* n = NULL; | |
| 2874 intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7ffff; | |
| 2875 ROOT_LIST(ROOT_LIST_CASE) | |
| 2876 if (n == NULL) continue; | |
| 2877 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); | |
| 2878 } | |
| 2879 } | |
| 2880 printf("}\n"); | |
| 2881 #undef ROOT_LIST_CASE | |
| 2882 | |
| 2883 // Dump frame markers | |
| 2884 printf("\n# List of known V8 Frame Markers.\n"); | |
| 2885 #define DUMP_MARKER(T, class) printf(" \"%s\",\n", #T); | |
| 2886 printf("FRAME_MARKERS = (\n"); | |
| 2887 STACK_FRAME_TYPE_LIST(DUMP_MARKER) | |
| 2888 printf(")\n"); | |
| 2889 #undef DUMP_TYPE | |
| 2890 } | |
| 2891 | |
| 2892 | |
| 2893 int Shell::Main(int argc, char* argv[]) { | 2823 int Shell::Main(int argc, char* argv[]) { |
| 2894 std::ofstream trace_file; | 2824 std::ofstream trace_file; |
| 2895 #if (defined(_WIN32) || defined(_WIN64)) | 2825 #if (defined(_WIN32) || defined(_WIN64)) |
| 2896 UINT new_flags = | 2826 UINT new_flags = |
| 2897 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; | 2827 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; |
| 2898 UINT existing_flags = SetErrorMode(new_flags); | 2828 UINT existing_flags = SetErrorMode(new_flags); |
| 2899 SetErrorMode(existing_flags | new_flags); | 2829 SetErrorMode(existing_flags | new_flags); |
| 2900 #if defined(_MSC_VER) | 2830 #if defined(_MSC_VER) |
| 2901 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 2831 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
| 2902 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 2832 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2984 trace_config = | 2914 trace_config = |
| 2985 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); | 2915 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); |
| 2986 delete[] trace_config_json_str; | 2916 delete[] trace_config_json_str; |
| 2987 } else { | 2917 } else { |
| 2988 trace_config = | 2918 trace_config = |
| 2989 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); | 2919 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); |
| 2990 } | 2920 } |
| 2991 tracing_controller->StartTracing(trace_config); | 2921 tracing_controller->StartTracing(trace_config); |
| 2992 } | 2922 } |
| 2993 | 2923 |
| 2994 if (options.dump_heap_constants) { | |
| 2995 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); | |
| 2996 return 0; | |
| 2997 } | |
| 2998 | |
| 2999 if (options.stress_opt || options.stress_deopt) { | 2924 if (options.stress_opt || options.stress_deopt) { |
| 3000 Testing::SetStressRunType(options.stress_opt | 2925 Testing::SetStressRunType(options.stress_opt |
| 3001 ? Testing::kStressTypeOpt | 2926 ? Testing::kStressTypeOpt |
| 3002 : Testing::kStressTypeDeopt); | 2927 : Testing::kStressTypeDeopt); |
| 3003 options.stress_runs = Testing::GetStressRuns(); | 2928 options.stress_runs = Testing::GetStressRuns(); |
| 3004 for (int i = 0; i < options.stress_runs && result == 0; i++) { | 2929 for (int i = 0; i < options.stress_runs && result == 0; i++) { |
| 3005 printf("============ Stress %d/%d ============\n", i + 1, | 2930 printf("============ Stress %d/%d ============\n", i + 1, |
| 3006 options.stress_runs); | 2931 options.stress_runs); |
| 3007 Testing::PrepareStressRun(i); | 2932 Testing::PrepareStressRun(i); |
| 3008 bool last_run = i == options.stress_runs - 1; | 2933 bool last_run = i == options.stress_runs - 1; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3051 } | 2976 } |
| 3052 | 2977 |
| 3053 } // namespace v8 | 2978 } // namespace v8 |
| 3054 | 2979 |
| 3055 | 2980 |
| 3056 #ifndef GOOGLE3 | 2981 #ifndef GOOGLE3 |
| 3057 int main(int argc, char* argv[]) { | 2982 int main(int argc, char* argv[]) { |
| 3058 return v8::Shell::Main(argc, argv); | 2983 return v8::Shell::Main(argc, argv); |
| 3059 } | 2984 } |
| 3060 #endif | 2985 #endif |
| OLD | NEW |