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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 { 'name': 'FailureTag', 'value': 'kFailureTag' }, | 73 { 'name': 'FailureTag', 'value': 'kFailureTag' }, |
74 { 'name': 'FailureTagMask', 'value': 'kFailureTagMask' }, | 74 { 'name': 'FailureTagMask', 'value': 'kFailureTagMask' }, |
75 { 'name': 'HeapObjectTag', 'value': 'kHeapObjectTag' }, | 75 { 'name': 'HeapObjectTag', 'value': 'kHeapObjectTag' }, |
76 { 'name': 'HeapObjectTagMask', 'value': 'kHeapObjectTagMask' }, | 76 { 'name': 'HeapObjectTagMask', 'value': 'kHeapObjectTagMask' }, |
77 { 'name': 'SmiTag', 'value': 'kSmiTag' }, | 77 { 'name': 'SmiTag', 'value': 'kSmiTag' }, |
78 { 'name': 'SmiTagMask', 'value': 'kSmiTagMask' }, | 78 { 'name': 'SmiTagMask', 'value': 'kSmiTagMask' }, |
79 { 'name': 'SmiValueShift', 'value': 'kSmiTagSize' }, | 79 { 'name': 'SmiValueShift', 'value': 'kSmiTagSize' }, |
80 { 'name': 'SmiShiftSize', 'value': 'kSmiShiftSize' }, | 80 { 'name': 'SmiShiftSize', 'value': 'kSmiShiftSize' }, |
81 { 'name': 'PointerSizeLog2', 'value': 'kPointerSizeLog2' }, | 81 { 'name': 'PointerSizeLog2', 'value': 'kPointerSizeLog2' }, |
82 | 82 |
| 83 { 'name': 'OddballFalse', 'value': 'Oddball::kFalse' }, |
| 84 { 'name': 'OddballTrue', 'value': 'Oddball::kTrue' }, |
| 85 { 'name': 'OddballTheHole', 'value': 'Oddball::kTheHole' }, |
| 86 { 'name': 'OddballNull', 'value': 'Oddball::kNull' }, |
| 87 { 'name': 'OddballArgumentMarker', 'value': 'Oddball::kArgumentMarker' }, |
| 88 { 'name': 'OddballUndefined', 'value': 'Oddball::kUndefined' }, |
| 89 { 'name': 'OddballUninitialized', 'value': 'Oddball::kUninitialized' }, |
| 90 { 'name': 'OddballOther', 'value': 'Oddball::kOther' }, |
| 91 { 'name': 'OddballException', 'value': 'Oddball::kException' }, |
| 92 |
83 { 'name': 'prop_idx_first', | 93 { 'name': 'prop_idx_first', |
84 'value': 'DescriptorArray::kFirstIndex' }, | 94 'value': 'DescriptorArray::kFirstIndex' }, |
85 { 'name': 'prop_type_field', | 95 { 'name': 'prop_type_field', |
86 'value': 'FIELD' }, | 96 'value': 'FIELD' }, |
87 { 'name': 'prop_type_first_phantom', | 97 { 'name': 'prop_type_first_phantom', |
88 'value': 'TRANSITION' }, | 98 'value': 'TRANSITION' }, |
89 { 'name': 'prop_type_mask', | 99 { 'name': 'prop_type_mask', |
90 'value': 'PropertyDetails::TypeField::kMask' }, | 100 'value': 'PropertyDetails::TypeField::kMask' }, |
| 101 { 'name': 'prop_index_mask', |
| 102 'value': 'PropertyDetails::FieldIndexField::kMask' }, |
| 103 { 'name': 'prop_index_shift', |
| 104 'value': 'PropertyDetails::FieldIndexField::kShift' }, |
91 | 105 |
92 { 'name': 'prop_desc_key', | 106 { 'name': 'prop_desc_key', |
93 'value': 'DescriptorArray::kDescriptorKey' }, | 107 'value': 'DescriptorArray::kDescriptorKey' }, |
94 { 'name': 'prop_desc_details', | 108 { 'name': 'prop_desc_details', |
95 'value': 'DescriptorArray::kDescriptorDetails' }, | 109 'value': 'DescriptorArray::kDescriptorDetails' }, |
96 { 'name': 'prop_desc_value', | 110 { 'name': 'prop_desc_value', |
97 'value': 'DescriptorArray::kDescriptorValue' }, | 111 'value': 'DescriptorArray::kDescriptorValue' }, |
98 { 'name': 'prop_desc_size', | 112 { 'name': 'prop_desc_size', |
99 'value': 'DescriptorArray::kDescriptorSize' }, | 113 'value': 'DescriptorArray::kDescriptorSize' }, |
100 | 114 |
| 115 { 'name': 'elements_fast_holey_elements', |
| 116 'value': 'FAST_HOLEY_ELEMENTS' }, |
| 117 { 'name': 'elements_fast_elements', |
| 118 'value': 'FAST_ELEMENTS' }, |
| 119 { 'name': 'elements_dictionary_elements', |
| 120 'value': 'DICTIONARY_ELEMENTS' }, |
| 121 |
| 122 { 'name': 'bit_field2_elements_kind_mask', |
| 123 'value': 'Map::kElementsKindMask' }, |
| 124 { 'name': 'bit_field2_elements_kind_shift', |
| 125 'value': 'Map::kElementsKindShift' }, |
| 126 { 'name': 'bit_field3_dictionary_map_shift', |
| 127 'value': 'Map::DictionaryMap::kShift' }, |
| 128 |
101 { 'name': 'off_fp_context', | 129 { 'name': 'off_fp_context', |
102 'value': 'StandardFrameConstants::kContextOffset' }, | 130 'value': 'StandardFrameConstants::kContextOffset' }, |
103 { 'name': 'off_fp_constant_pool', | 131 { 'name': 'off_fp_constant_pool', |
104 'value': 'StandardFrameConstants::kConstantPoolOffset' }, | 132 'value': 'StandardFrameConstants::kConstantPoolOffset' }, |
105 { 'name': 'off_fp_marker', | 133 { 'name': 'off_fp_marker', |
106 'value': 'StandardFrameConstants::kMarkerOffset' }, | 134 'value': 'StandardFrameConstants::kMarkerOffset' }, |
107 { 'name': 'off_fp_function', | 135 { 'name': 'off_fp_function', |
108 'value': 'JavaScriptFrameConstants::kFunctionOffset' }, | 136 'value': 'JavaScriptFrameConstants::kFunctionOffset' }, |
109 { 'name': 'off_fp_args', | 137 { 'name': 'off_fp_args', |
110 'value': 'JavaScriptFrameConstants::kLastParameterOffset' }, | 138 'value': 'JavaScriptFrameConstants::kLastParameterOffset' }, |
111 ]; | 139 ]; |
112 | 140 |
113 # | 141 # |
114 # The following useful fields are missing accessors, so we define fake ones. | 142 # The following useful fields are missing accessors, so we define fake ones. |
115 # | 143 # |
116 extras_accessors = [ | 144 extras_accessors = [ |
117 'HeapObject, map, Map, kMapOffset', | 145 'HeapObject, map, Map, kMapOffset', |
118 'JSObject, elements, Object, kElementsOffset', | 146 'JSObject, elements, Object, kElementsOffset', |
119 'FixedArray, data, uintptr_t, kHeaderSize', | 147 'FixedArray, data, uintptr_t, kHeaderSize', |
120 'Map, instance_attributes, int, kInstanceAttributesOffset', | 148 'Map, instance_attributes, int, kInstanceAttributesOffset', |
121 'Map, inobject_properties, int, kInObjectPropertiesOffset', | 149 'Map, inobject_properties, int, kInObjectPropertiesOffset', |
122 'Map, instance_size, int, kInstanceSizeOffset', | 150 'Map, instance_size, int, kInstanceSizeOffset', |
| 151 'Map, bit_field, char, kBitFieldOffset', |
| 152 'Map, bit_field2, char, kBitField2Offset', |
| 153 'Map, bit_field3, SMI, kBitField3Offset', |
| 154 'Map, prototype, Object, kPrototypeOffset', |
| 155 'NameDictionaryShape, prefix_size, int, kPrefixSize', |
| 156 'NameDictionaryShape, entry_size, int, kEntrySize', |
| 157 'SeededNumberDictionaryShape, prefix_size, int, kPrefixSize', |
| 158 'UnseededNumberDictionaryShape, prefix_size, int, kPrefixSize', |
| 159 'NumberDictionaryShape, entry_size, int, kEntrySize', |
| 160 'Oddball, kind_offset, int, kKindOffset', |
123 'HeapNumber, value, double, kValueOffset', | 161 'HeapNumber, value, double, kValueOffset', |
124 'ConsString, first, String, kFirstOffset', | 162 'ConsString, first, String, kFirstOffset', |
125 'ConsString, second, String, kSecondOffset', | 163 'ConsString, second, String, kSecondOffset', |
126 'ExternalString, resource, Object, kResourceOffset', | 164 'ExternalString, resource, Object, kResourceOffset', |
127 'SeqOneByteString, chars, char, kHeaderSize', | 165 'SeqOneByteString, chars, char, kHeaderSize', |
128 'SeqTwoByteString, chars, char, kHeaderSize', | 166 'SeqTwoByteString, chars, char, kHeaderSize', |
129 'SharedFunctionInfo, code, Code, kCodeOffset', | 167 'SharedFunctionInfo, code, Code, kCodeOffset', |
130 'SlicedString, parent, String, kParentOffset', | 168 'SlicedString, parent, String, kParentOffset', |
131 'Code, instruction_start, uintptr_t, kHeaderSize', | 169 'Code, instruction_start, uintptr_t, kHeaderSize', |
132 'Code, instruction_size, int, kInstructionSizeOffset', | 170 'Code, instruction_size, int, kInstructionSizeOffset', |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 klass = args[0]; | 392 klass = args[0]; |
355 field = args[1]; | 393 field = args[1]; |
356 dtype = args[2]; | 394 dtype = args[2]; |
357 offset = args[3]; | 395 offset = args[3]; |
358 | 396 |
359 return ({ | 397 return ({ |
360 'name': 'class_%s__%s__%s' % (klass, field, dtype), | 398 'name': 'class_%s__%s__%s' % (klass, field, dtype), |
361 'value': '%s::%s' % (klass, offset) | 399 'value': '%s::%s' % (klass, offset) |
362 }); | 400 }); |
363 | 401 |
364 assert(kind == 'SMI_ACCESSORS'); | 402 assert(kind == 'SMI_ACCESSORS' or kind == 'ACCESSORS_TO_SMI'); |
365 klass = args[0]; | 403 klass = args[0]; |
366 field = args[1]; | 404 field = args[1]; |
367 offset = args[2]; | 405 offset = args[2]; |
368 | 406 |
369 return ({ | 407 return ({ |
370 'name': 'class_%s__%s__%s' % (klass, field, 'SMI'), | 408 'name': 'class_%s__%s__%s' % (klass, field, 'SMI'), |
371 'value': '%s::%s' % (klass, offset) | 409 'value': '%s::%s' % (klass, offset) |
372 }); | 410 }); |
373 | 411 |
374 # | 412 # |
375 # Load field offset information from objects-inl.h. | 413 # Load field offset information from objects-inl.h. |
376 # | 414 # |
377 def load_fields(): | 415 def load_fields(): |
378 inlfilename = sys.argv[3]; | 416 inlfilename = sys.argv[3]; |
379 inlfile = open(inlfilename, 'r'); | 417 inlfile = open(inlfilename, 'r'); |
380 | 418 |
381 # | 419 # |
382 # Each class's fields and the corresponding offsets are described in the | 420 # Each class's fields and the corresponding offsets are described in the |
383 # source by calls to macros like "ACCESSORS" (and friends). All we do | 421 # source by calls to macros like "ACCESSORS" (and friends). All we do |
384 # here is extract these macro invocations, taking into account that they | 422 # here is extract these macro invocations, taking into account that they |
385 # may span multiple lines and may contain nested parentheses. We also | 423 # may span multiple lines and may contain nested parentheses. We also |
386 # call parse_field() to pick apart the invocation. | 424 # call parse_field() to pick apart the invocation. |
387 # | 425 # |
388 prefixes = [ 'ACCESSORS', 'ACCESSORS_GCSAFE', 'SMI_ACCESSORS' ]; | 426 prefixes = [ 'ACCESSORS', 'ACCESSORS_GCSAFE', |
| 427 'SMI_ACCESSORS', 'ACCESSORS_TO_SMI' ]; |
389 current = ''; | 428 current = ''; |
390 opens = 0; | 429 opens = 0; |
391 | 430 |
392 for line in inlfile: | 431 for line in inlfile: |
393 if (opens > 0): | 432 if (opens > 0): |
394 # Continuation line | 433 # Continuation line |
395 for ii in range(0, len(line)): | 434 for ii in range(0, len(line)): |
396 if (line[ii] == '('): | 435 if (line[ii] == '('): |
397 opens += 1; | 436 opens += 1; |
398 elif (line[ii] == ')'): | 437 elif (line[ii] == ')'): |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 527 |
489 out.write(footer); | 528 out.write(footer); |
490 | 529 |
491 if (len(sys.argv) < 4): | 530 if (len(sys.argv) < 4): |
492 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); | 531 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); |
493 sys.exit(2); | 532 sys.exit(2); |
494 | 533 |
495 load_objects(); | 534 load_objects(); |
496 load_fields(); | 535 load_fields(); |
497 emit_config(); | 536 emit_config(); |
OLD | NEW |