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 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 argv[i] = NULL; | 2533 argv[i] = NULL; |
2534 } else if (strcmp(argv[i], "--omit-quit") == 0) { | 2534 } else if (strcmp(argv[i], "--omit-quit") == 0) { |
2535 options.omit_quit = true; | 2535 options.omit_quit = true; |
2536 argv[i] = NULL; | 2536 argv[i] = NULL; |
2537 } else if (strcmp(argv[i], "-f") == 0) { | 2537 } else if (strcmp(argv[i], "-f") == 0) { |
2538 // Ignore any -f flags for compatibility with other stand-alone | 2538 // Ignore any -f flags for compatibility with other stand-alone |
2539 // JavaScript engines. | 2539 // JavaScript engines. |
2540 continue; | 2540 continue; |
2541 } else if (strcmp(argv[i], "--isolate") == 0) { | 2541 } else if (strcmp(argv[i], "--isolate") == 0) { |
2542 options.num_isolates++; | 2542 options.num_isolates++; |
2543 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) { | |
2544 options.dump_heap_constants = true; | |
2545 argv[i] = NULL; | |
2546 } else if (strcmp(argv[i], "--throws") == 0) { | 2543 } else if (strcmp(argv[i], "--throws") == 0) { |
2547 options.expected_to_throw = true; | 2544 options.expected_to_throw = true; |
2548 argv[i] = NULL; | 2545 argv[i] = NULL; |
2549 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { | 2546 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { |
2550 options.icu_data_file = argv[i] + 16; | 2547 options.icu_data_file = argv[i] + 16; |
2551 argv[i] = NULL; | 2548 argv[i] = NULL; |
2552 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 2549 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
2553 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { | 2550 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { |
2554 options.natives_blob = argv[i] + 15; | 2551 options.natives_blob = argv[i] + 15; |
2555 argv[i] = NULL; | 2552 argv[i] = NULL; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 worker->WaitForThread(); | 2913 worker->WaitForThread(); |
2917 delete worker; | 2914 delete worker; |
2918 } | 2915 } |
2919 | 2916 |
2920 // Now that all workers are terminated, we can re-enable Worker creation. | 2917 // Now that all workers are terminated, we can re-enable Worker creation. |
2921 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); | 2918 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); |
2922 allow_new_workers_ = true; | 2919 allow_new_workers_ = true; |
2923 externalized_contents_.clear(); | 2920 externalized_contents_.clear(); |
2924 } | 2921 } |
2925 | 2922 |
2926 | |
2927 static void DumpHeapConstants(i::Isolate* isolate) { | |
2928 i::Heap* heap = isolate->heap(); | |
2929 printf( | |
2930 "# Copyright 2017 the V8 project authors. All rights reserved.\n" | |
2931 "# Use of this source code is governed by a BSD-style license that can\n" | |
2932 "# be found in the LICENSE file.\n\n"); | |
2933 // Dump the INSTANCE_TYPES table to the console. | |
2934 printf("# List of known V8 instance types.\n"); | |
2935 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); | |
2936 printf("INSTANCE_TYPES = {\n"); | |
2937 INSTANCE_TYPE_LIST(DUMP_TYPE) | |
2938 printf("}\n"); | |
2939 #undef DUMP_TYPE | |
2940 | |
2941 // Dump the KNOWN_MAP table to the console. | |
2942 printf("\n# List of known V8 maps.\n"); | |
2943 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
2944 if (n == NULL && o == heap->name()) n = #camel_name; | |
2945 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \ | |
2946 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map"; | |
2947 i::HeapObjectIterator it(heap->map_space()); | |
2948 printf("KNOWN_MAPS = {\n"); | |
2949 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
2950 i::Map* m = i::Map::cast(o); | |
2951 const char* n = NULL; | |
2952 intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7ffff; | |
2953 int t = m->instance_type(); | |
2954 ROOT_LIST(ROOT_LIST_CASE) | |
2955 STRUCT_LIST(STRUCT_LIST_CASE) | |
2956 if (n == NULL) continue; | |
2957 printf(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n); | |
2958 } | |
2959 printf("}\n"); | |
2960 #undef STRUCT_LIST_CASE | |
2961 #undef ROOT_LIST_CASE | |
2962 | |
2963 // Dump the KNOWN_OBJECTS table to the console. | |
2964 printf("\n# List of known V8 objects.\n"); | |
2965 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
2966 if (n == NULL && o == heap->name()) n = #camel_name; | |
2967 i::OldSpaces spit(heap); | |
2968 printf("KNOWN_OBJECTS = {\n"); | |
2969 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) { | |
2970 i::HeapObjectIterator it(s); | |
2971 const char* sname = AllocationSpaceName(s->identity()); | |
2972 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
2973 const char* n = NULL; | |
2974 intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7ffff; | |
2975 ROOT_LIST(ROOT_LIST_CASE) | |
2976 if (n == NULL) continue; | |
2977 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); | |
2978 } | |
2979 } | |
2980 printf("}\n"); | |
2981 #undef ROOT_LIST_CASE | |
2982 | |
2983 // Dump frame markers | |
2984 printf("\n# List of known V8 Frame Markers.\n"); | |
2985 #define DUMP_MARKER(T, class) printf(" \"%s\",\n", #T); | |
2986 printf("FRAME_MARKERS = (\n"); | |
2987 STACK_FRAME_TYPE_LIST(DUMP_MARKER) | |
2988 printf(")\n"); | |
2989 #undef DUMP_TYPE | |
2990 } | |
2991 | |
2992 | |
2993 int Shell::Main(int argc, char* argv[]) { | 2923 int Shell::Main(int argc, char* argv[]) { |
2994 std::ofstream trace_file; | 2924 std::ofstream trace_file; |
2995 #if (defined(_WIN32) || defined(_WIN64)) | 2925 #if (defined(_WIN32) || defined(_WIN64)) |
2996 UINT new_flags = | 2926 UINT new_flags = |
2997 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; | 2927 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; |
2998 UINT existing_flags = SetErrorMode(new_flags); | 2928 UINT existing_flags = SetErrorMode(new_flags); |
2999 SetErrorMode(existing_flags | new_flags); | 2929 SetErrorMode(existing_flags | new_flags); |
3000 #if defined(_MSC_VER) | 2930 #if defined(_MSC_VER) |
3001 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 2931 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
3002 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 2932 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3087 trace_config = | 3017 trace_config = |
3088 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); | 3018 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); |
3089 delete[] trace_config_json_str; | 3019 delete[] trace_config_json_str; |
3090 } else { | 3020 } else { |
3091 trace_config = | 3021 trace_config = |
3092 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); | 3022 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); |
3093 } | 3023 } |
3094 tracing_controller->StartTracing(trace_config); | 3024 tracing_controller->StartTracing(trace_config); |
3095 } | 3025 } |
3096 | 3026 |
3097 if (options.dump_heap_constants) { | |
3098 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); | |
3099 return 0; | |
3100 } | |
3101 | |
3102 if (options.stress_opt || options.stress_deopt) { | 3027 if (options.stress_opt || options.stress_deopt) { |
3103 Testing::SetStressRunType(options.stress_opt | 3028 Testing::SetStressRunType(options.stress_opt |
3104 ? Testing::kStressTypeOpt | 3029 ? Testing::kStressTypeOpt |
3105 : Testing::kStressTypeDeopt); | 3030 : Testing::kStressTypeDeopt); |
3106 options.stress_runs = Testing::GetStressRuns(); | 3031 options.stress_runs = Testing::GetStressRuns(); |
3107 for (int i = 0; i < options.stress_runs && result == 0; i++) { | 3032 for (int i = 0; i < options.stress_runs && result == 0; i++) { |
3108 printf("============ Stress %d/%d ============\n", i + 1, | 3033 printf("============ Stress %d/%d ============\n", i + 1, |
3109 options.stress_runs); | 3034 options.stress_runs); |
3110 Testing::PrepareStressRun(i); | 3035 Testing::PrepareStressRun(i); |
3111 bool last_run = i == options.stress_runs - 1; | 3036 bool last_run = i == options.stress_runs - 1; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3154 } | 3079 } |
3155 | 3080 |
3156 } // namespace v8 | 3081 } // namespace v8 |
3157 | 3082 |
3158 | 3083 |
3159 #ifndef GOOGLE3 | 3084 #ifndef GOOGLE3 |
3160 int main(int argc, char* argv[]) { | 3085 int main(int argc, char* argv[]) { |
3161 return v8::Shell::Main(argc, argv); | 3086 return v8::Shell::Main(argc, argv); |
3162 } | 3087 } |
3163 #endif | 3088 #endif |
OLD | NEW |