| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # | 3 # |
| 4 # Copyright 2012 the V8 project authors. All rights reserved. | 4 # Copyright 2012 the V8 project authors. All rights reserved. |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
| 7 # met: | 7 # met: |
| 8 # | 8 # |
| 9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 { 'name': 'sharedfunctioninfo_start_position_mask', | 175 { 'name': 'sharedfunctioninfo_start_position_mask', |
| 176 'value': 'SharedFunctionInfo::kStartPositionMask' }, | 176 'value': 'SharedFunctionInfo::kStartPositionMask' }, |
| 177 { 'name': 'sharedfunctioninfo_start_position_shift', | 177 { 'name': 'sharedfunctioninfo_start_position_shift', |
| 178 'value': 'SharedFunctionInfo::kStartPositionShift' }, | 178 'value': 'SharedFunctionInfo::kStartPositionShift' }, |
| 179 | 179 |
| 180 { 'name': 'jsarray_buffer_was_neutered_mask', | 180 { 'name': 'jsarray_buffer_was_neutered_mask', |
| 181 'value': 'JSArrayBuffer::WasNeutered::kMask' }, | 181 'value': 'JSArrayBuffer::WasNeutered::kMask' }, |
| 182 { 'name': 'jsarray_buffer_was_neutered_shift', | 182 { 'name': 'jsarray_buffer_was_neutered_shift', |
| 183 'value': 'JSArrayBuffer::WasNeutered::kShift' }, | 183 'value': 'JSArrayBuffer::WasNeutered::kShift' }, |
| 184 |
| 185 { 'name': 'new_space', |
| 186 'value': 'AllocationSpace::NEW_SPACE' }, |
| 187 { 'name': 'old_space', |
| 188 'value': 'AllocationSpace::OLD_SPACE' }, |
| 189 { 'name': 'code_space', |
| 190 'value': 'AllocationSpace::CODE_SPACE' }, |
| 191 { 'name': 'map_space', |
| 192 'value': 'AllocationSpace::MAP_SPACE' }, |
| 193 { 'name': 'lo_space', |
| 194 'value': 'AllocationSpace::LO_SPACE' }, |
| 195 { 'name': 'first_space', |
| 196 'value': 'AllocationSpace::FIRST_SPACE' }, |
| 197 { 'name': 'last_space', |
| 198 'value': 'AllocationSpace::LAST_SPACE' }, |
| 199 { 'name': 'first_paged_space', |
| 200 'value': 'AllocationSpace::FIRST_PAGED_SPACE' }, |
| 201 { 'name': 'last_paged_space', |
| 202 'value': 'AllocationSpace::LAST_PAGED_SPACE' }, |
| 184 ]; | 203 ]; |
| 185 | 204 |
| 186 # | 205 # |
| 187 # The following useful fields are missing accessors, so we define fake ones. | 206 # The following useful fields are missing accessors, so we define fake ones. |
| 188 # | 207 # |
| 189 extras_accessors = [ | 208 extras_accessors = [ |
| 190 'JSFunction, context, Context, kContextOffset', | 209 'JSFunction, context, Context, kContextOffset', |
| 191 'Context, closure_index, int, CLOSURE_INDEX', | 210 'Context, closure_index, int, CLOSURE_INDEX', |
| 192 'Context, global_object_index, int, GLOBAL_OBJECT_INDEX', | 211 'Context, global_object_index, int, GLOBAL_OBJECT_INDEX', |
| 193 'Context, previous_index, int, PREVIOUS_INDEX', | 212 'Context, previous_index, int, PREVIOUS_INDEX', |
| (...skipping 22 matching lines...) Expand all Loading... |
| 216 'ConsString, first, String, kFirstOffset', | 235 'ConsString, first, String, kFirstOffset', |
| 217 'ConsString, second, String, kSecondOffset', | 236 'ConsString, second, String, kSecondOffset', |
| 218 'ExternalString, resource, Object, kResourceOffset', | 237 'ExternalString, resource, Object, kResourceOffset', |
| 219 'SeqOneByteString, chars, char, kHeaderSize', | 238 'SeqOneByteString, chars, char, kHeaderSize', |
| 220 'SeqTwoByteString, chars, char, kHeaderSize', | 239 'SeqTwoByteString, chars, char, kHeaderSize', |
| 221 'SharedFunctionInfo, code, Code, kCodeOffset', | 240 'SharedFunctionInfo, code, Code, kCodeOffset', |
| 222 'SharedFunctionInfo, scope_info, ScopeInfo, kScopeInfoOffset', | 241 'SharedFunctionInfo, scope_info, ScopeInfo, kScopeInfoOffset', |
| 223 'SlicedString, parent, String, kParentOffset', | 242 'SlicedString, parent, String, kParentOffset', |
| 224 'Code, instruction_start, uintptr_t, kHeaderSize', | 243 'Code, instruction_start, uintptr_t, kHeaderSize', |
| 225 'Code, instruction_size, int, kInstructionSizeOffset', | 244 'Code, instruction_size, int, kInstructionSizeOffset', |
| 245 'Heap, root_count, int, kRootListLength', |
| 226 ]; | 246 ]; |
| 227 | 247 |
| 228 # | 248 # |
| 229 # The following is a whitelist of classes we expect to find when scanning the | 249 # The following is a whitelist of classes we expect to find when scanning the |
| 230 # source code. This list is not exhaustive, but it's still useful to identify | 250 # source code. This list is not exhaustive, but it's still useful to identify |
| 231 # when this script gets out of sync with the source. See load_objects(). | 251 # when this script gets out of sync with the source. See load_objects(). |
| 232 # | 252 # |
| 233 expected_classes = [ | 253 expected_classes = [ |
| 234 'ConsString', 'FixedArray', 'HeapNumber', 'JSArray', 'JSFunction', | 254 'ConsString', 'FixedArray', 'HeapNumber', 'JSArray', 'JSFunction', |
| 235 'JSObject', 'JSRegExp', 'JSValue', 'Map', 'Oddball', 'Script', | 255 'JSObject', 'JSRegExp', 'JSValue', 'Map', 'Oddball', 'Script', |
| 236 'SeqOneByteString', 'SharedFunctionInfo' | 256 'SeqOneByteString', 'SharedFunctionInfo' |
| 237 ]; | 257 ]; |
| 238 | 258 |
| 239 | 259 |
| 260 private_fields = [ |
| 261 { 'class': 'Isolate', 'field': 'heap_' }, |
| 262 |
| 263 { 'class': 'Heap', 'field': 'amount_of_external_allocated_memory_' }, |
| 264 { 'class': 'Heap', 'field': 'roots_' }, |
| 265 { 'class': 'Heap', 'field': 'new_space_' }, |
| 266 { 'class': 'Heap', 'field': 'old_space_' }, |
| 267 { 'class': 'Heap', 'field': 'code_space_' }, |
| 268 { 'class': 'Heap', 'field': 'map_space_' }, |
| 269 { 'class': 'Heap', 'field': 'lo_space_' }, |
| 270 |
| 271 { 'class': 'NewSpace', 'field': 'heap_' }, |
| 272 { 'class': 'NewSpace', 'field': 'id_' }, |
| 273 { 'class': 'NewSpace', 'field': 'executable_' }, |
| 274 { 'class': 'NewSpace', 'field': 'to_space_' }, |
| 275 { 'class': 'NewSpace', 'field': 'from_space_' }, |
| 276 { 'class': 'NewSpace', 'field': 'pages_used_' }, |
| 277 |
| 278 { 'class': 'SemiSpace', 'field': 'heap_' }, |
| 279 { 'class': 'SemiSpace', 'field': 'id_' }, |
| 280 { 'class': 'SemiSpace', 'field': 'executable_' }, |
| 281 { 'class': 'SemiSpace', 'field': 'anchor_' }, |
| 282 { 'class': 'SemiSpace', 'field': 'current_page_' }, |
| 283 { 'class': 'SemiSpace', 'field': 'committed_' }, |
| 284 |
| 285 { 'class': 'OldSpace', 'field': 'heap_' }, |
| 286 { 'class': 'OldSpace', 'field': 'id_' }, |
| 287 { 'class': 'OldSpace', 'field': 'executable_' }, |
| 288 { 'class': 'OldSpace', 'field': 'anchor_' }, |
| 289 |
| 290 { 'class': 'MapSpace', 'field': 'heap_' }, |
| 291 { 'class': 'MapSpace', 'field': 'id_' }, |
| 292 { 'class': 'MapSpace', 'field': 'executable_' }, |
| 293 { 'class': 'MapSpace', 'field': 'anchor_' }, |
| 294 |
| 295 { 'class': 'LargeObjectSpace', 'field': 'heap_' }, |
| 296 { 'class': 'LargeObjectSpace', 'field': 'id_' }, |
| 297 { 'class': 'LargeObjectSpace', 'field': 'executable_' }, |
| 298 { 'class': 'LargeObjectSpace', 'field': 'size_' }, |
| 299 { 'class': 'LargeObjectSpace', 'field': 'objects_size_' }, |
| 300 { 'class': 'LargeObjectSpace', 'field': 'first_page_' }, |
| 301 |
| 302 { 'class': 'Page', 'field': 'size_' }, |
| 303 { 'class': 'Page', 'field': 'area_start_' }, |
| 304 { 'class': 'Page', 'field': 'area_end_' }, |
| 305 { 'class': 'Page', 'field': 'prev_chunk_' }, |
| 306 { 'class': 'Page', 'field': 'next_chunk_' }, |
| 307 |
| 308 { 'class': 'NewSpacePage', 'field': 'size_' }, |
| 309 { 'class': 'NewSpacePage', 'field': 'area_start_' }, |
| 310 { 'class': 'NewSpacePage', 'field': 'area_end_' }, |
| 311 { 'class': 'NewSpacePage', 'field': 'prev_chunk_' }, |
| 312 { 'class': 'NewSpacePage', 'field': 'next_chunk_' }, |
| 313 |
| 314 { 'class': 'LargePage', 'field': 'size_' }, |
| 315 { 'class': 'LargePage', 'field': 'area_start_' }, |
| 316 { 'class': 'LargePage', 'field': 'area_end_' }, |
| 317 { 'class': 'LargePage', 'field': 'prev_chunk_' }, |
| 318 { 'class': 'LargePage', 'field': 'next_chunk_' }, |
| 319 ]; |
| 320 |
| 240 # | 321 # |
| 241 # The following structures store high-level representations of the structures | 322 # The following structures store high-level representations of the structures |
| 242 # for which we're going to emit descriptive constants. | 323 # for which we're going to emit descriptive constants. |
| 243 # | 324 # |
| 244 types = {}; # set of all type names | 325 types = {}; # set of all type names |
| 245 typeclasses = {}; # maps type names to corresponding class names | 326 typeclasses = {}; # maps type names to corresponding class names |
| 246 klasses = {}; # known classes, including parents | 327 klasses = {}; # known classes, including parents |
| 247 fields = []; # field declarations | 328 fields = []; # field declarations |
| 248 | 329 |
| 249 header = ''' | 330 header = ''' |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 # Fix up overzealous parses. This could be done inside the | 612 # Fix up overzealous parses. This could be done inside the |
| 532 # parsers but as there are several, it's easiest to do it here. | 613 # parsers but as there are several, it's easiest to do it here. |
| 533 ws = re.compile('\s+') | 614 ws = re.compile('\s+') |
| 534 for const in consts: | 615 for const in consts: |
| 535 name = ws.sub('', const['name']) | 616 name = ws.sub('', const['name']) |
| 536 value = ws.sub('', str(const['value'])) # Can be a number. | 617 value = ws.sub('', str(const['value'])) # Can be a number. |
| 537 out.write('int v8dbg_%s = %s;\n' % (name, value)) | 618 out.write('int v8dbg_%s = %s;\n' % (name, value)) |
| 538 out.write('\n'); | 619 out.write('\n'); |
| 539 | 620 |
| 540 # | 621 # |
| 622 # Emit private fields class and values |
| 623 # |
| 624 def emit_private_fields(out, fields, consts): |
| 625 # Fix up overzealous parses. This could be done inside the |
| 626 # parsers but as there are several, it's easiest to do it here. |
| 627 ws = re.compile('\s+') |
| 628 out.write('namespace v8 {\n'); |
| 629 out.write('namespace internal {\n\n'); |
| 630 out.write('class PostMortem {\n'); |
| 631 out.write(' public:\n'); |
| 632 for field in fields: |
| 633 klass = ws.sub('', field['class']) |
| 634 field = ws.sub('', field['field']) |
| 635 out.write(' static const int k%s__%s = offsetof(%s, %s);\n' % |
| 636 (klass, field, klass, field)); |
| 637 consts.append({ |
| 638 'name': 'field_%s__%s' % (klass, field), |
| 639 'value': 'v8::internal::PostMortem::k%s__%s' % |
| 640 (klass, field) |
| 641 }); |
| 642 out.write('};\n'); |
| 643 out.write('} // namespace internal\n'); |
| 644 out.write('} // namespace v8\n\n'); |
| 645 |
| 646 # |
| 541 # Emit the whole output file. | 647 # Emit the whole output file. |
| 542 # | 648 # |
| 543 def emit_config(): | 649 def emit_config(): |
| 544 out = file(sys.argv[1], 'w'); | 650 out = file(sys.argv[1], 'w'); |
| 545 | 651 |
| 546 out.write(header); | 652 out.write(header); |
| 547 | 653 |
| 548 out.write('/* miscellaneous constants */\n'); | 654 out.write('/* miscellaneous constants */\n'); |
| 549 emit_set(out, consts_misc); | 655 emit_set(out, consts_misc); |
| 550 | 656 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 573 consts.append({ | 679 consts.append({ |
| 574 'name': 'parent_%s__%s' % (klassname, pklass), | 680 'name': 'parent_%s__%s' % (klassname, pklass), |
| 575 'value': 0 | 681 'value': 0 |
| 576 }); | 682 }); |
| 577 | 683 |
| 578 emit_set(out, consts); | 684 emit_set(out, consts); |
| 579 | 685 |
| 580 out.write('/* field information */\n'); | 686 out.write('/* field information */\n'); |
| 581 emit_set(out, fields); | 687 emit_set(out, fields); |
| 582 | 688 |
| 689 out.write('/* private fields */\n'); |
| 690 consts = [] |
| 691 emit_private_fields(out, private_fields, consts); |
| 692 |
| 693 emit_set(out, consts); |
| 694 |
| 583 out.write(footer); | 695 out.write(footer); |
| 584 | 696 |
| 585 if (len(sys.argv) < 4): | 697 if (len(sys.argv) < 4): |
| 586 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); | 698 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); |
| 587 sys.exit(2); | 699 sys.exit(2); |
| 588 | 700 |
| 589 load_objects(); | 701 load_objects(); |
| 590 load_fields(); | 702 load_fields(); |
| 591 emit_config(); | 703 emit_config(); |
| OLD | NEW |