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 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 argv[i] = NULL; | 2525 argv[i] = NULL; |
2526 } else if (strcmp(argv[i], "--omit-quit") == 0) { | 2526 } else if (strcmp(argv[i], "--omit-quit") == 0) { |
2527 options.omit_quit = true; | 2527 options.omit_quit = true; |
2528 argv[i] = NULL; | 2528 argv[i] = NULL; |
2529 } else if (strcmp(argv[i], "-f") == 0) { | 2529 } else if (strcmp(argv[i], "-f") == 0) { |
2530 // Ignore any -f flags for compatibility with other stand-alone | 2530 // Ignore any -f flags for compatibility with other stand-alone |
2531 // JavaScript engines. | 2531 // JavaScript engines. |
2532 continue; | 2532 continue; |
2533 } else if (strcmp(argv[i], "--isolate") == 0) { | 2533 } else if (strcmp(argv[i], "--isolate") == 0) { |
2534 options.num_isolates++; | 2534 options.num_isolates++; |
2535 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) { | |
2536 options.dump_heap_constants = true; | |
2537 argv[i] = NULL; | |
2538 } else if (strcmp(argv[i], "--throws") == 0) { | 2535 } else if (strcmp(argv[i], "--throws") == 0) { |
2539 options.expected_to_throw = true; | 2536 options.expected_to_throw = true; |
2540 argv[i] = NULL; | 2537 argv[i] = NULL; |
2541 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { | 2538 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { |
2542 options.icu_data_file = argv[i] + 16; | 2539 options.icu_data_file = argv[i] + 16; |
2543 argv[i] = NULL; | 2540 argv[i] = NULL; |
2544 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 2541 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
2545 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { | 2542 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { |
2546 options.natives_blob = argv[i] + 15; | 2543 options.natives_blob = argv[i] + 15; |
2547 argv[i] = NULL; | 2544 argv[i] = NULL; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2905 worker->WaitForThread(); | 2902 worker->WaitForThread(); |
2906 delete worker; | 2903 delete worker; |
2907 } | 2904 } |
2908 | 2905 |
2909 // Now that all workers are terminated, we can re-enable Worker creation. | 2906 // Now that all workers are terminated, we can re-enable Worker creation. |
2910 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); | 2907 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); |
2911 allow_new_workers_ = true; | 2908 allow_new_workers_ = true; |
2912 externalized_contents_.clear(); | 2909 externalized_contents_.clear(); |
2913 } | 2910 } |
2914 | 2911 |
2915 | |
2916 static void DumpHeapConstants(i::Isolate* isolate) { | |
2917 i::Heap* heap = isolate->heap(); | |
2918 printf( | |
2919 "# Copyright 2017 the V8 project authors. All rights reserved.\n" | |
2920 "# Use of this source code is governed by a BSD-style license that can\n" | |
2921 "# be found in the LICENSE file.\n\n"); | |
2922 // Dump the INSTANCE_TYPES table to the console. | |
2923 printf("# List of known V8 instance types.\n"); | |
2924 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); | |
2925 printf("INSTANCE_TYPES = {\n"); | |
2926 INSTANCE_TYPE_LIST(DUMP_TYPE) | |
2927 printf("}\n"); | |
2928 #undef DUMP_TYPE | |
2929 | |
2930 // Dump the KNOWN_MAP table to the console. | |
2931 printf("\n# List of known V8 maps.\n"); | |
2932 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
2933 if (n == NULL && o == heap->name()) n = #camel_name; | |
2934 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \ | |
2935 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map"; | |
2936 i::HeapObjectIterator it(heap->map_space()); | |
2937 printf("KNOWN_MAPS = {\n"); | |
2938 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
2939 i::Map* m = i::Map::cast(o); | |
2940 const char* n = NULL; | |
2941 intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7ffff; | |
2942 int t = m->instance_type(); | |
2943 ROOT_LIST(ROOT_LIST_CASE) | |
2944 STRUCT_LIST(STRUCT_LIST_CASE) | |
2945 if (n == NULL) continue; | |
2946 printf(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n); | |
2947 } | |
2948 printf("}\n"); | |
2949 #undef STRUCT_LIST_CASE | |
2950 #undef ROOT_LIST_CASE | |
2951 | |
2952 // Dump the KNOWN_OBJECTS table to the console. | |
2953 printf("\n# List of known V8 objects.\n"); | |
2954 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
2955 if (n == NULL && o == heap->name()) n = #camel_name; | |
2956 i::OldSpaces spit(heap); | |
2957 printf("KNOWN_OBJECTS = {\n"); | |
2958 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) { | |
2959 i::HeapObjectIterator it(s); | |
2960 const char* sname = AllocationSpaceName(s->identity()); | |
2961 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
2962 const char* n = NULL; | |
2963 intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7ffff; | |
2964 ROOT_LIST(ROOT_LIST_CASE) | |
2965 if (n == NULL) continue; | |
2966 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); | |
2967 } | |
2968 } | |
2969 printf("}\n"); | |
2970 #undef ROOT_LIST_CASE | |
2971 | |
2972 // Dump frame markers | |
2973 printf("\n# List of known V8 Frame Markers.\n"); | |
2974 #define DUMP_MARKER(T, class) printf(" \"%s\",\n", #T); | |
2975 printf("FRAME_MARKERS = (\n"); | |
2976 STACK_FRAME_TYPE_LIST(DUMP_MARKER) | |
2977 printf(")\n"); | |
2978 #undef DUMP_TYPE | |
2979 } | |
2980 | |
2981 | |
2982 int Shell::Main(int argc, char* argv[]) { | 2912 int Shell::Main(int argc, char* argv[]) { |
2983 std::ofstream trace_file; | 2913 std::ofstream trace_file; |
2984 #if (defined(_WIN32) || defined(_WIN64)) | 2914 #if (defined(_WIN32) || defined(_WIN64)) |
2985 UINT new_flags = | 2915 UINT new_flags = |
2986 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; | 2916 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; |
2987 UINT existing_flags = SetErrorMode(new_flags); | 2917 UINT existing_flags = SetErrorMode(new_flags); |
2988 SetErrorMode(existing_flags | new_flags); | 2918 SetErrorMode(existing_flags | new_flags); |
2989 #if defined(_MSC_VER) | 2919 #if defined(_MSC_VER) |
2990 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 2920 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
2991 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 2921 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3076 trace_config = | 3006 trace_config = |
3077 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); | 3007 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); |
3078 delete[] trace_config_json_str; | 3008 delete[] trace_config_json_str; |
3079 } else { | 3009 } else { |
3080 trace_config = | 3010 trace_config = |
3081 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); | 3011 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); |
3082 } | 3012 } |
3083 tracing_controller->StartTracing(trace_config); | 3013 tracing_controller->StartTracing(trace_config); |
3084 } | 3014 } |
3085 | 3015 |
3086 if (options.dump_heap_constants) { | |
3087 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); | |
3088 return 0; | |
3089 } | |
3090 | |
3091 if (options.stress_opt || options.stress_deopt) { | 3016 if (options.stress_opt || options.stress_deopt) { |
3092 Testing::SetStressRunType(options.stress_opt | 3017 Testing::SetStressRunType(options.stress_opt |
3093 ? Testing::kStressTypeOpt | 3018 ? Testing::kStressTypeOpt |
3094 : Testing::kStressTypeDeopt); | 3019 : Testing::kStressTypeDeopt); |
3095 options.stress_runs = Testing::GetStressRuns(); | 3020 options.stress_runs = Testing::GetStressRuns(); |
3096 for (int i = 0; i < options.stress_runs && result == 0; i++) { | 3021 for (int i = 0; i < options.stress_runs && result == 0; i++) { |
3097 printf("============ Stress %d/%d ============\n", i + 1, | 3022 printf("============ Stress %d/%d ============\n", i + 1, |
3098 options.stress_runs); | 3023 options.stress_runs); |
3099 Testing::PrepareStressRun(i); | 3024 Testing::PrepareStressRun(i); |
3100 bool last_run = i == options.stress_runs - 1; | 3025 bool last_run = i == options.stress_runs - 1; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3143 } | 3068 } |
3144 | 3069 |
3145 } // namespace v8 | 3070 } // namespace v8 |
3146 | 3071 |
3147 | 3072 |
3148 #ifndef GOOGLE3 | 3073 #ifndef GOOGLE3 |
3149 int main(int argc, char* argv[]) { | 3074 int main(int argc, char* argv[]) { |
3150 return v8::Shell::Main(argc, argv); | 3075 return v8::Shell::Main(argc, argv); |
3151 } | 3076 } |
3152 #endif | 3077 #endif |
OLD | NEW |