Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/d8.cc

Issue 2809653003: Introduce mkgrokdump to update tools/v8heapconst.py. (Closed)
Patch Set: fix, another one Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/d8.h ('k') | test/BUILD.gn » ('j') | test/BUILD.gn » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 argv[i] = NULL; 2528 argv[i] = NULL;
2529 } else if (strcmp(argv[i], "--omit-quit") == 0) { 2529 } else if (strcmp(argv[i], "--omit-quit") == 0) {
2530 options.omit_quit = true; 2530 options.omit_quit = true;
2531 argv[i] = NULL; 2531 argv[i] = NULL;
2532 } else if (strcmp(argv[i], "-f") == 0) { 2532 } else if (strcmp(argv[i], "-f") == 0) {
2533 // Ignore any -f flags for compatibility with other stand-alone 2533 // Ignore any -f flags for compatibility with other stand-alone
2534 // JavaScript engines. 2534 // JavaScript engines.
2535 continue; 2535 continue;
2536 } else if (strcmp(argv[i], "--isolate") == 0) { 2536 } else if (strcmp(argv[i], "--isolate") == 0) {
2537 options.num_isolates++; 2537 options.num_isolates++;
2538 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) {
2539 options.dump_heap_constants = true;
2540 argv[i] = NULL;
2541 } else if (strcmp(argv[i], "--throws") == 0) { 2538 } else if (strcmp(argv[i], "--throws") == 0) {
2542 options.expected_to_throw = true; 2539 options.expected_to_throw = true;
2543 argv[i] = NULL; 2540 argv[i] = NULL;
2544 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { 2541 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
2545 options.icu_data_file = argv[i] + 16; 2542 options.icu_data_file = argv[i] + 16;
2546 argv[i] = NULL; 2543 argv[i] = NULL;
2547 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 2544 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
2548 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { 2545 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) {
2549 options.natives_blob = argv[i] + 15; 2546 options.natives_blob = argv[i] + 15;
2550 argv[i] = NULL; 2547 argv[i] = NULL;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 worker->WaitForThread(); 2908 worker->WaitForThread();
2912 delete worker; 2909 delete worker;
2913 } 2910 }
2914 2911
2915 // Now that all workers are terminated, we can re-enable Worker creation. 2912 // Now that all workers are terminated, we can re-enable Worker creation.
2916 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); 2913 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
2917 allow_new_workers_ = true; 2914 allow_new_workers_ = true;
2918 externalized_contents_.clear(); 2915 externalized_contents_.clear();
2919 } 2916 }
2920 2917
2921
2922 static void DumpHeapConstants(i::Isolate* isolate) {
2923 i::Heap* heap = isolate->heap();
2924 printf(
2925 "# Copyright 2017 the V8 project authors. All rights reserved.\n"
2926 "# Use of this source code is governed by a BSD-style license that can\n"
2927 "# be found in the LICENSE file.\n\n");
2928 // Dump the INSTANCE_TYPES table to the console.
2929 printf("# List of known V8 instance types.\n");
2930 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T);
2931 printf("INSTANCE_TYPES = {\n");
2932 INSTANCE_TYPE_LIST(DUMP_TYPE)
2933 printf("}\n");
2934 #undef DUMP_TYPE
2935
2936 // Dump the KNOWN_MAP table to the console.
2937 printf("\n# List of known V8 maps.\n");
2938 #define ROOT_LIST_CASE(type, name, camel_name) \
2939 if (n == NULL && o == heap->name()) n = #camel_name;
2940 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \
2941 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map";
2942 i::HeapObjectIterator it(heap->map_space());
2943 printf("KNOWN_MAPS = {\n");
2944 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
2945 i::Map* m = i::Map::cast(o);
2946 const char* n = NULL;
2947 intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7ffff;
2948 int t = m->instance_type();
2949 ROOT_LIST(ROOT_LIST_CASE)
2950 STRUCT_LIST(STRUCT_LIST_CASE)
2951 if (n == NULL) continue;
2952 printf(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n);
2953 }
2954 printf("}\n");
2955 #undef STRUCT_LIST_CASE
2956 #undef ROOT_LIST_CASE
2957
2958 // Dump the KNOWN_OBJECTS table to the console.
2959 printf("\n# List of known V8 objects.\n");
2960 #define ROOT_LIST_CASE(type, name, camel_name) \
2961 if (n == NULL && o == heap->name()) n = #camel_name;
2962 i::OldSpaces spit(heap);
2963 printf("KNOWN_OBJECTS = {\n");
2964 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) {
2965 i::HeapObjectIterator it(s);
2966 const char* sname = AllocationSpaceName(s->identity());
2967 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
2968 const char* n = NULL;
2969 intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7ffff;
2970 ROOT_LIST(ROOT_LIST_CASE)
2971 if (n == NULL) continue;
2972 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
2973 }
2974 }
2975 printf("}\n");
2976 #undef ROOT_LIST_CASE
2977
2978 // Dump frame markers
2979 printf("\n# List of known V8 Frame Markers.\n");
2980 #define DUMP_MARKER(T, class) printf(" \"%s\",\n", #T);
2981 printf("FRAME_MARKERS = (\n");
2982 STACK_FRAME_TYPE_LIST(DUMP_MARKER)
2983 printf(")\n");
2984 #undef DUMP_TYPE
2985 }
2986
2987
2988 int Shell::Main(int argc, char* argv[]) { 2918 int Shell::Main(int argc, char* argv[]) {
2989 std::ofstream trace_file; 2919 std::ofstream trace_file;
2990 #if (defined(_WIN32) || defined(_WIN64)) 2920 #if (defined(_WIN32) || defined(_WIN64))
2991 UINT new_flags = 2921 UINT new_flags =
2992 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 2922 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
2993 UINT existing_flags = SetErrorMode(new_flags); 2923 UINT existing_flags = SetErrorMode(new_flags);
2994 SetErrorMode(existing_flags | new_flags); 2924 SetErrorMode(existing_flags | new_flags);
2995 #if defined(_MSC_VER) 2925 #if defined(_MSC_VER)
2996 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2926 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2997 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 2927 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 trace_config = 3012 trace_config =
3083 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); 3013 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str);
3084 delete[] trace_config_json_str; 3014 delete[] trace_config_json_str;
3085 } else { 3015 } else {
3086 trace_config = 3016 trace_config =
3087 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); 3017 platform::tracing::TraceConfig::CreateDefaultTraceConfig();
3088 } 3018 }
3089 tracing_controller->StartTracing(trace_config); 3019 tracing_controller->StartTracing(trace_config);
3090 } 3020 }
3091 3021
3092 if (options.dump_heap_constants) {
3093 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
3094 return 0;
3095 }
3096
3097 if (options.stress_opt || options.stress_deopt) { 3022 if (options.stress_opt || options.stress_deopt) {
3098 Testing::SetStressRunType(options.stress_opt 3023 Testing::SetStressRunType(options.stress_opt
3099 ? Testing::kStressTypeOpt 3024 ? Testing::kStressTypeOpt
3100 : Testing::kStressTypeDeopt); 3025 : Testing::kStressTypeDeopt);
3101 options.stress_runs = Testing::GetStressRuns(); 3026 options.stress_runs = Testing::GetStressRuns();
3102 for (int i = 0; i < options.stress_runs && result == 0; i++) { 3027 for (int i = 0; i < options.stress_runs && result == 0; i++) {
3103 printf("============ Stress %d/%d ============\n", i + 1, 3028 printf("============ Stress %d/%d ============\n", i + 1,
3104 options.stress_runs); 3029 options.stress_runs);
3105 Testing::PrepareStressRun(i); 3030 Testing::PrepareStressRun(i);
3106 bool last_run = i == options.stress_runs - 1; 3031 bool last_run = i == options.stress_runs - 1;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 } 3074 }
3150 3075
3151 } // namespace v8 3076 } // namespace v8
3152 3077
3153 3078
3154 #ifndef GOOGLE3 3079 #ifndef GOOGLE3
3155 int main(int argc, char* argv[]) { 3080 int main(int argc, char* argv[]) {
3156 return v8::Shell::Main(argc, argv); 3081 return v8::Shell::Main(argc, argv);
3157 } 3082 }
3158 #endif 3083 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | test/BUILD.gn » ('j') | test/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698