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 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2546 argv[i] = NULL; | 2546 argv[i] = NULL; |
2547 } else if (strcmp(argv[i], "--omit-quit") == 0) { | 2547 } else if (strcmp(argv[i], "--omit-quit") == 0) { |
2548 options.omit_quit = true; | 2548 options.omit_quit = true; |
2549 argv[i] = NULL; | 2549 argv[i] = NULL; |
2550 } else if (strcmp(argv[i], "-f") == 0) { | 2550 } else if (strcmp(argv[i], "-f") == 0) { |
2551 // Ignore any -f flags for compatibility with other stand-alone | 2551 // Ignore any -f flags for compatibility with other stand-alone |
2552 // JavaScript engines. | 2552 // JavaScript engines. |
2553 continue; | 2553 continue; |
2554 } else if (strcmp(argv[i], "--isolate") == 0) { | 2554 } else if (strcmp(argv[i], "--isolate") == 0) { |
2555 options.num_isolates++; | 2555 options.num_isolates++; |
2556 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) { | |
2557 options.dump_heap_constants = true; | |
2558 argv[i] = NULL; | |
2559 } else if (strcmp(argv[i], "--throws") == 0) { | 2556 } else if (strcmp(argv[i], "--throws") == 0) { |
2560 options.expected_to_throw = true; | 2557 options.expected_to_throw = true; |
2561 argv[i] = NULL; | 2558 argv[i] = NULL; |
2562 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { | 2559 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { |
2563 options.icu_data_file = argv[i] + 16; | 2560 options.icu_data_file = argv[i] + 16; |
2564 argv[i] = NULL; | 2561 argv[i] = NULL; |
2565 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 2562 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
2566 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { | 2563 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { |
2567 options.natives_blob = argv[i] + 15; | 2564 options.natives_blob = argv[i] + 15; |
2568 argv[i] = NULL; | 2565 argv[i] = NULL; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 worker->WaitForThread(); | 2926 worker->WaitForThread(); |
2930 delete worker; | 2927 delete worker; |
2931 } | 2928 } |
2932 | 2929 |
2933 // Now that all workers are terminated, we can re-enable Worker creation. | 2930 // Now that all workers are terminated, we can re-enable Worker creation. |
2934 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); | 2931 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); |
2935 allow_new_workers_ = true; | 2932 allow_new_workers_ = true; |
2936 externalized_contents_.clear(); | 2933 externalized_contents_.clear(); |
2937 } | 2934 } |
2938 | 2935 |
2939 | |
2940 static void DumpHeapConstants(i::Isolate* isolate) { | |
2941 i::Heap* heap = isolate->heap(); | |
2942 printf( | |
2943 "# Copyright 2017 the V8 project authors. All rights reserved.\n" | |
2944 "# Use of this source code is governed by a BSD-style license that can\n" | |
2945 "# be found in the LICENSE file.\n\n"); | |
2946 // Dump the INSTANCE_TYPES table to the console. | |
2947 printf("# List of known V8 instance types.\n"); | |
2948 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); | |
2949 printf("INSTANCE_TYPES = {\n"); | |
2950 INSTANCE_TYPE_LIST(DUMP_TYPE) | |
2951 printf("}\n"); | |
2952 #undef DUMP_TYPE | |
2953 | |
2954 // Dump the KNOWN_MAP table to the console. | |
2955 printf("\n# List of known V8 maps.\n"); | |
2956 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
2957 if (n == NULL && o == heap->name()) n = #camel_name; | |
2958 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \ | |
2959 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map"; | |
2960 i::HeapObjectIterator it(heap->map_space()); | |
2961 printf("KNOWN_MAPS = {\n"); | |
2962 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
2963 i::Map* m = i::Map::cast(o); | |
2964 const char* n = NULL; | |
2965 intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7ffff; | |
2966 int t = m->instance_type(); | |
2967 ROOT_LIST(ROOT_LIST_CASE) | |
2968 STRUCT_LIST(STRUCT_LIST_CASE) | |
2969 if (n == NULL) continue; | |
2970 printf(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n); | |
2971 } | |
2972 printf("}\n"); | |
2973 #undef STRUCT_LIST_CASE | |
2974 #undef ROOT_LIST_CASE | |
2975 | |
2976 // Dump the KNOWN_OBJECTS table to the console. | |
2977 printf("\n# List of known V8 objects.\n"); | |
2978 #define ROOT_LIST_CASE(type, name, camel_name) \ | |
2979 if (n == NULL && o == heap->name()) n = #camel_name; | |
2980 i::OldSpaces spit(heap); | |
2981 printf("KNOWN_OBJECTS = {\n"); | |
2982 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) { | |
2983 i::HeapObjectIterator it(s); | |
2984 const char* sname = AllocationSpaceName(s->identity()); | |
2985 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) { | |
2986 const char* n = NULL; | |
2987 intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7ffff; | |
2988 ROOT_LIST(ROOT_LIST_CASE) | |
2989 if (n == NULL) continue; | |
2990 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); | |
2991 } | |
2992 } | |
2993 printf("}\n"); | |
2994 #undef ROOT_LIST_CASE | |
2995 | |
2996 // Dump frame markers | |
2997 printf("\n# List of known V8 Frame Markers.\n"); | |
2998 #define DUMP_MARKER(T, class) printf(" \"%s\",\n", #T); | |
2999 printf("FRAME_MARKERS = (\n"); | |
3000 STACK_FRAME_TYPE_LIST(DUMP_MARKER) | |
3001 printf(")\n"); | |
3002 #undef DUMP_TYPE | |
3003 } | |
3004 | |
3005 | |
3006 int Shell::Main(int argc, char* argv[]) { | 2936 int Shell::Main(int argc, char* argv[]) { |
3007 std::ofstream trace_file; | 2937 std::ofstream trace_file; |
3008 #if (defined(_WIN32) || defined(_WIN64)) | 2938 #if (defined(_WIN32) || defined(_WIN64)) |
3009 UINT new_flags = | 2939 UINT new_flags = |
3010 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; | 2940 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; |
3011 UINT existing_flags = SetErrorMode(new_flags); | 2941 UINT existing_flags = SetErrorMode(new_flags); |
3012 SetErrorMode(existing_flags | new_flags); | 2942 SetErrorMode(existing_flags | new_flags); |
3013 #if defined(_MSC_VER) | 2943 #if defined(_MSC_VER) |
3014 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 2944 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
3015 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 2945 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3100 trace_config = | 3030 trace_config = |
3101 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); | 3031 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); |
3102 delete[] trace_config_json_str; | 3032 delete[] trace_config_json_str; |
3103 } else { | 3033 } else { |
3104 trace_config = | 3034 trace_config = |
3105 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); | 3035 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); |
3106 } | 3036 } |
3107 tracing_controller->StartTracing(trace_config); | 3037 tracing_controller->StartTracing(trace_config); |
3108 } | 3038 } |
3109 | 3039 |
3110 if (options.dump_heap_constants) { | |
3111 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); | |
3112 return 0; | |
3113 } | |
3114 | |
3115 if (options.stress_opt || options.stress_deopt) { | 3040 if (options.stress_opt || options.stress_deopt) { |
3116 Testing::SetStressRunType(options.stress_opt | 3041 Testing::SetStressRunType(options.stress_opt |
3117 ? Testing::kStressTypeOpt | 3042 ? Testing::kStressTypeOpt |
3118 : Testing::kStressTypeDeopt); | 3043 : Testing::kStressTypeDeopt); |
3119 options.stress_runs = Testing::GetStressRuns(); | 3044 options.stress_runs = Testing::GetStressRuns(); |
3120 for (int i = 0; i < options.stress_runs && result == 0; i++) { | 3045 for (int i = 0; i < options.stress_runs && result == 0; i++) { |
3121 printf("============ Stress %d/%d ============\n", i + 1, | 3046 printf("============ Stress %d/%d ============\n", i + 1, |
3122 options.stress_runs); | 3047 options.stress_runs); |
3123 Testing::PrepareStressRun(i); | 3048 Testing::PrepareStressRun(i); |
3124 bool last_run = i == options.stress_runs - 1; | 3049 bool last_run = i == options.stress_runs - 1; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3167 } | 3092 } |
3168 | 3093 |
3169 } // namespace v8 | 3094 } // namespace v8 |
3170 | 3095 |
3171 | 3096 |
3172 #ifndef GOOGLE3 | 3097 #ifndef GOOGLE3 |
3173 int main(int argc, char* argv[]) { | 3098 int main(int argc, char* argv[]) { |
3174 return v8::Shell::Main(argc, argv); | 3099 return v8::Shell::Main(argc, argv); |
3175 } | 3100 } |
3176 #endif | 3101 #endif |
OLD | NEW |