2012-02-02 20:18:19 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright 2012 the V8 project authors. All rights reserved.
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Emits a C++ file to be compiled and linked into libv8 to support postmortem
|
|
|
|
# debugging tools. Most importantly, this tool emits constants describing V8
|
|
|
|
# internals:
|
|
|
|
#
|
|
|
|
# v8dbg_type_CLASS__TYPE = VALUE Describes class type values
|
|
|
|
# v8dbg_class_CLASS__FIELD__TYPE = OFFSET Describes class fields
|
|
|
|
# v8dbg_parent_CLASS__PARENT Describes class hierarchy
|
|
|
|
# v8dbg_frametype_NAME = VALUE Describes stack frame values
|
|
|
|
# v8dbg_off_fp_NAME = OFFSET Frame pointer offsets
|
|
|
|
# v8dbg_prop_NAME = OFFSET Object property offsets
|
|
|
|
# v8dbg_NAME = VALUE Miscellaneous values
|
|
|
|
#
|
|
|
|
# These constants are declared as global integers so that they'll be present in
|
|
|
|
# the generated libv8 binary.
|
|
|
|
#
|
|
|
|
|
2019-02-19 08:28:26 +00:00
|
|
|
# for py2/py3 compatibility
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2019-11-02 14:30:05 +00:00
|
|
|
import io
|
2012-02-02 20:18:19 +00:00
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
#
|
2016-06-10 04:06:16 +00:00
|
|
|
# Miscellaneous constants such as tags and masks used for object identification,
|
|
|
|
# enumeration values used as indexes in internal tables, etc..
|
2012-02-02 20:18:19 +00:00
|
|
|
#
|
|
|
|
consts_misc = [
|
|
|
|
{ 'name': 'FirstNonstringType', 'value': 'FIRST_NONSTRING_TYPE' },
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'APIObjectType', 'value': 'JS_API_OBJECT_TYPE' },
|
2016-11-21 19:33:33 +00:00
|
|
|
{ 'name': 'SpecialAPIObjectType', 'value': 'JS_SPECIAL_API_OBJECT_TYPE' },
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2018-07-28 03:09:39 +00:00
|
|
|
{ 'name': 'FirstContextType', 'value': 'FIRST_CONTEXT_TYPE' },
|
|
|
|
{ 'name': 'LastContextType', 'value': 'LAST_CONTEXT_TYPE' },
|
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'IsNotStringMask', 'value': 'kIsNotStringMask' },
|
|
|
|
{ 'name': 'StringTag', 'value': 'kStringTag' },
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
{ 'name': 'StringEncodingMask', 'value': 'kStringEncodingMask' },
|
|
|
|
{ 'name': 'TwoByteStringTag', 'value': 'kTwoByteStringTag' },
|
2014-09-10 12:56:19 +00:00
|
|
|
{ 'name': 'OneByteStringTag', 'value': 'kOneByteStringTag' },
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
{ 'name': 'StringRepresentationMask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'kStringRepresentationMask' },
|
|
|
|
{ 'name': 'SeqStringTag', 'value': 'kSeqStringTag' },
|
|
|
|
{ 'name': 'ConsStringTag', 'value': 'kConsStringTag' },
|
2012-02-02 20:18:19 +00:00
|
|
|
{ 'name': 'ExternalStringTag', 'value': 'kExternalStringTag' },
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'SlicedStringTag', 'value': 'kSlicedStringTag' },
|
|
|
|
{ 'name': 'ThinStringTag', 'value': 'kThinStringTag' },
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'HeapObjectTag', 'value': 'kHeapObjectTag' },
|
2012-02-02 20:18:19 +00:00
|
|
|
{ 'name': 'HeapObjectTagMask', 'value': 'kHeapObjectTagMask' },
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'SmiTag', 'value': 'kSmiTag' },
|
|
|
|
{ 'name': 'SmiTagMask', 'value': 'kSmiTagMask' },
|
|
|
|
{ 'name': 'SmiValueShift', 'value': 'kSmiTagSize' },
|
|
|
|
{ 'name': 'SmiShiftSize', 'value': 'kSmiShiftSize' },
|
2019-08-09 17:24:23 +00:00
|
|
|
{ 'name': 'SystemPointerSize', 'value': 'kSystemPointerSize' },
|
|
|
|
{ 'name': 'SystemPointerSizeLog2', 'value': 'kSystemPointerSizeLog2' },
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'TaggedSize', 'value': 'kTaggedSize' },
|
|
|
|
{ 'name': 'TaggedSizeLog2', 'value': 'kTaggedSizeLog2' },
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-08-13 15:00:32 +00:00
|
|
|
{ 'name': 'CodeKindFieldMask', 'value': 'Code::KindField::kMask' },
|
|
|
|
{ 'name': 'CodeKindFieldShift', 'value': 'Code::KindField::kShift' },
|
|
|
|
|
|
|
|
{ 'name': 'CodeKindBytecodeHandler',
|
|
|
|
'value': 'static_cast<int>(CodeKind::BYTECODE_HANDLER)' },
|
|
|
|
{ 'name': 'CodeKindInterpretedFunction',
|
|
|
|
'value': 'static_cast<int>(CodeKind::INTERPRETED_FUNCTION)' },
|
|
|
|
{ 'name': 'CodeKindBaseline',
|
|
|
|
'value': 'static_cast<int>(CodeKind::BASELINE)' },
|
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'OddballFalse', 'value': 'Oddball::kFalse' },
|
|
|
|
{ 'name': 'OddballTrue', 'value': 'Oddball::kTrue' },
|
|
|
|
{ 'name': 'OddballTheHole', 'value': 'Oddball::kTheHole' },
|
|
|
|
{ 'name': 'OddballNull', 'value': 'Oddball::kNull' },
|
2016-02-22 08:15:33 +00:00
|
|
|
{ 'name': 'OddballArgumentsMarker', 'value': 'Oddball::kArgumentsMarker' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'OddballUndefined', 'value': 'Oddball::kUndefined' },
|
|
|
|
{ 'name': 'OddballUninitialized', 'value': 'Oddball::kUninitialized' },
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'OddballOther', 'value': 'Oddball::kOther' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'OddballException', 'value': 'Oddball::kException' },
|
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
{ 'name': 'ContextRegister', 'value': 'kContextRegister.code()' },
|
|
|
|
{ 'name': 'ReturnRegister0', 'value': 'kReturnRegister0.code()' },
|
2020-11-07 11:17:30 +00:00
|
|
|
{ 'name': 'JSFunctionRegister', 'value': 'kJSFunctionRegister.code()' },
|
|
|
|
{ 'name': 'InterpreterBytecodeOffsetRegister',
|
|
|
|
'value': 'kInterpreterBytecodeOffsetRegister.code()' },
|
|
|
|
{ 'name': 'InterpreterBytecodeArrayRegister',
|
|
|
|
'value': 'kInterpreterBytecodeArrayRegister.code()' },
|
|
|
|
{ 'name': 'RuntimeCallFunctionRegister',
|
|
|
|
'value': 'kRuntimeCallFunctionRegister.code()' },
|
|
|
|
|
2017-01-16 14:24:50 +00:00
|
|
|
{ 'name': 'prop_kind_Data',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'kData' },
|
2017-01-16 14:24:50 +00:00
|
|
|
{ 'name': 'prop_kind_Accessor',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'kAccessor' },
|
2017-01-16 14:24:50 +00:00
|
|
|
{ 'name': 'prop_kind_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::KindField::kMask' },
|
2017-04-26 12:24:52 +00:00
|
|
|
{ 'name': 'prop_location_Descriptor',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'static_cast<int>(PropertyLocation::kDescriptor)' },
|
2017-04-26 12:24:52 +00:00
|
|
|
{ 'name': 'prop_location_Field',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'static_cast<int>(PropertyLocation::kField)' },
|
2017-04-26 12:24:52 +00:00
|
|
|
{ 'name': 'prop_location_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::LocationField::kMask' },
|
2017-04-26 12:24:52 +00:00
|
|
|
{ 'name': 'prop_location_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::LocationField::kShift' },
|
2017-04-26 12:24:52 +00:00
|
|
|
{ 'name': 'prop_attributes_NONE', 'value': 'NONE' },
|
|
|
|
{ 'name': 'prop_attributes_READ_ONLY', 'value': 'READ_ONLY' },
|
|
|
|
{ 'name': 'prop_attributes_DONT_ENUM', 'value': 'DONT_ENUM' },
|
|
|
|
{ 'name': 'prop_attributes_DONT_DELETE', 'value': 'DONT_DELETE' },
|
|
|
|
{ 'name': 'prop_attributes_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::AttributesField::kMask' },
|
2017-04-26 12:24:52 +00:00
|
|
|
{ 'name': 'prop_attributes_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::AttributesField::kShift' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'prop_index_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::FieldIndexField::kMask' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'prop_index_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::FieldIndexField::kShift' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'prop_representation_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::RepresentationField::kMask' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'prop_representation_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PropertyDetails::RepresentationField::kShift' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'prop_representation_smi',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Representation::Kind::kSmi' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'prop_representation_double',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Representation::Kind::kDouble' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'prop_representation_heapobject',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Representation::Kind::kHeapObject' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'prop_representation_tagged',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Representation::Kind::kTagged' },
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2013-10-14 13:08:52 +00:00
|
|
|
{ 'name': 'prop_desc_key',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'DescriptorArray::kEntryKeyIndex' },
|
2013-10-14 13:08:52 +00:00
|
|
|
{ 'name': 'prop_desc_details',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'DescriptorArray::kEntryDetailsIndex' },
|
2013-10-14 13:08:52 +00:00
|
|
|
{ 'name': 'prop_desc_value',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'DescriptorArray::kEntryValueIndex' },
|
2013-10-14 13:08:52 +00:00
|
|
|
{ 'name': 'prop_desc_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'DescriptorArray::kEntrySize' },
|
2013-10-14 13:08:52 +00:00
|
|
|
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'elements_fast_holey_elements',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'HOLEY_ELEMENTS' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'elements_fast_elements',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'PACKED_ELEMENTS' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'elements_dictionary_elements',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'DICTIONARY_ELEMENTS' },
|
2014-07-23 10:48:16 +00:00
|
|
|
|
|
|
|
{ 'name': 'bit_field2_elements_kind_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Map::Bits2::ElementsKindBits::kMask' },
|
2014-07-23 10:48:16 +00:00
|
|
|
{ 'name': 'bit_field2_elements_kind_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Map::Bits2::ElementsKindBits::kShift' },
|
2017-12-07 11:03:41 +00:00
|
|
|
{ 'name': 'bit_field3_is_dictionary_map_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Map::Bits3::IsDictionaryMapBit::kShift' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'bit_field3_number_of_own_descriptors_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Map::Bits3::NumberOfOwnDescriptorsBits::kMask' },
|
2015-11-11 19:13:45 +00:00
|
|
|
{ 'name': 'bit_field3_number_of_own_descriptors_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Map::Bits3::NumberOfOwnDescriptorsBits::kShift' },
|
2019-08-09 17:24:23 +00:00
|
|
|
{ 'name': 'class_Map__instance_descriptors_offset',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Map::kInstanceDescriptorsOffset' },
|
2014-07-23 10:48:16 +00:00
|
|
|
|
2017-01-27 18:19:08 +00:00
|
|
|
{ 'name': 'off_fp_context_or_frame_type',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'CommonFrameConstants::kContextOrFrameTypeOffset'},
|
2012-02-02 20:18:19 +00:00
|
|
|
{ 'name': 'off_fp_context',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'StandardFrameConstants::kContextOffset' },
|
2013-12-30 11:23:59 +00:00
|
|
|
{ 'name': 'off_fp_constant_pool',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'StandardFrameConstants::kConstantPoolOffset' },
|
2012-02-02 20:18:19 +00:00
|
|
|
{ 'name': 'off_fp_function',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'StandardFrameConstants::kFunctionOffset' },
|
2012-02-02 20:18:19 +00:00
|
|
|
{ 'name': 'off_fp_args',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'StandardFrameConstants::kFixedFrameSizeAboveFp' },
|
2021-08-13 15:00:32 +00:00
|
|
|
{ 'name': 'off_fp_bytecode_array',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'UnoptimizedFrameConstants::kBytecodeArrayFromFp' },
|
2021-08-13 15:00:32 +00:00
|
|
|
{ 'name': 'off_fp_bytecode_offset',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'UnoptimizedFrameConstants::kBytecodeOffsetOrFeedbackVectorFromFp' },
|
2015-09-21 05:45:20 +00:00
|
|
|
|
|
|
|
{ 'name': 'scopeinfo_idx_nparams',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'ScopeInfo::kParameterCount' },
|
2015-09-21 05:45:20 +00:00
|
|
|
{ 'name': 'scopeinfo_idx_ncontextlocals',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'ScopeInfo::kContextLocalCount' },
|
2015-09-21 05:45:20 +00:00
|
|
|
{ 'name': 'scopeinfo_idx_first_vars',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'ScopeInfo::kVariablePartIndex' },
|
2015-11-11 19:13:45 +00:00
|
|
|
|
2018-12-11 10:22:02 +00:00
|
|
|
{ 'name': 'jsarray_buffer_was_detached_mask',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'JSArrayBuffer::WasDetachedBit::kMask' },
|
2018-12-11 10:22:02 +00:00
|
|
|
{ 'name': 'jsarray_buffer_was_detached_shift',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'JSArrayBuffer::WasDetachedBit::kShift' },
|
2016-06-10 04:06:16 +00:00
|
|
|
|
2018-05-02 13:57:26 +00:00
|
|
|
{ 'name': 'context_idx_scope_info',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Context::SCOPE_INFO_INDEX' },
|
2016-06-10 04:06:16 +00:00
|
|
|
{ 'name': 'context_idx_prev',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Context::PREVIOUS_INDEX' },
|
2016-06-10 04:06:16 +00:00
|
|
|
{ 'name': 'context_min_slots',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Context::MIN_CONTEXT_SLOTS' },
|
2018-11-22 14:41:39 +00:00
|
|
|
{ 'name': 'native_context_embedder_data_offset',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'Internals::kNativeContextEmbedderDataOffset' },
|
2018-07-16 15:16:06 +00:00
|
|
|
|
2016-06-10 04:06:16 +00:00
|
|
|
|
|
|
|
{ 'name': 'namedictionaryshape_prefix_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'NameDictionaryShape::kPrefixSize' },
|
2016-06-10 04:06:16 +00:00
|
|
|
{ 'name': 'namedictionaryshape_entry_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'NameDictionaryShape::kEntrySize' },
|
2016-06-29 14:25:36 +00:00
|
|
|
{ 'name': 'globaldictionaryshape_entry_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'GlobalDictionaryShape::kEntrySize' },
|
2016-06-10 04:06:16 +00:00
|
|
|
|
|
|
|
{ 'name': 'namedictionary_prefix_start_index',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'NameDictionary::kPrefixStartIndex' },
|
2016-06-10 04:06:16 +00:00
|
|
|
|
2017-11-07 09:35:59 +00:00
|
|
|
{ 'name': 'numberdictionaryshape_prefix_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'NumberDictionaryShape::kPrefixSize' },
|
2017-11-07 09:35:59 +00:00
|
|
|
{ 'name': 'numberdictionaryshape_entry_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'NumberDictionaryShape::kEntrySize' },
|
2018-01-25 08:42:56 +00:00
|
|
|
|
|
|
|
{ 'name': 'simplenumberdictionaryshape_prefix_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'SimpleNumberDictionaryShape::kPrefixSize' },
|
2018-01-25 08:42:56 +00:00
|
|
|
{ 'name': 'simplenumberdictionaryshape_entry_size',
|
2021-10-08 14:00:59 +00:00
|
|
|
'value': 'SimpleNumberDictionaryShape::kEntrySize' },
|
2018-07-16 15:16:06 +00:00
|
|
|
|
|
|
|
{ 'name': 'type_JSError__JS_ERROR_TYPE', 'value': 'JS_ERROR_TYPE' },
|
2012-02-02 20:18:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
#
|
|
|
|
# The following useful fields are missing accessors, so we define fake ones.
|
2016-06-10 04:06:16 +00:00
|
|
|
# Please note that extra accessors should _only_ be added to expose offsets that
|
|
|
|
# can be used to access actual V8 objects' properties. They should not be added
|
|
|
|
# for exposing other values. For instance, enumeration values or class'
|
|
|
|
# constants should be exposed by adding an entry in the "consts_misc" table, not
|
|
|
|
# in this "extras_accessors" table.
|
2012-02-02 20:18:19 +00:00
|
|
|
#
|
|
|
|
extras_accessors = [
|
2015-11-11 19:13:45 +00:00
|
|
|
'JSFunction, context, Context, kContextOffset',
|
2019-02-03 23:40:56 +00:00
|
|
|
'JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset',
|
2012-02-02 20:18:19 +00:00
|
|
|
'HeapObject, map, Map, kMapOffset',
|
|
|
|
'JSObject, elements, Object, kElementsOffset',
|
2016-11-21 19:33:33 +00:00
|
|
|
'JSObject, internal_fields, uintptr_t, kHeaderSize',
|
2012-02-02 20:18:19 +00:00
|
|
|
'FixedArray, data, uintptr_t, kHeaderSize',
|
2021-08-13 15:00:32 +00:00
|
|
|
'BytecodeArray, data, uintptr_t, kHeaderSize',
|
2019-02-27 14:45:43 +00:00
|
|
|
'JSArrayBuffer, backing_store, uintptr_t, kBackingStoreOffset',
|
2018-10-14 18:44:37 +00:00
|
|
|
'JSArrayBuffer, byte_length, size_t, kByteLengthOffset',
|
|
|
|
'JSArrayBufferView, byte_length, size_t, kByteLengthOffset',
|
|
|
|
'JSArrayBufferView, byte_offset, size_t, kByteOffsetOffset',
|
2019-10-09 14:40:48 +00:00
|
|
|
'JSDate, value, Object, kValueOffset',
|
|
|
|
'JSRegExp, source, Object, kSourceOffset',
|
2019-08-09 17:24:23 +00:00
|
|
|
'JSTypedArray, external_pointer, uintptr_t, kExternalPointerOffset',
|
2015-09-23 05:37:21 +00:00
|
|
|
'JSTypedArray, length, Object, kLengthOffset',
|
2017-11-17 21:24:02 +00:00
|
|
|
'Map, instance_size_in_words, char, kInstanceSizeInWordsOffset',
|
2021-07-19 19:18:05 +00:00
|
|
|
'Map, inobject_properties_start_or_constructor_function_index, char, kInobjectPropertiesStartOrConstructorFunctionIndexOffset',
|
2017-11-22 18:04:36 +00:00
|
|
|
'Map, instance_type, uint16_t, kInstanceTypeOffset',
|
2014-07-23 10:48:16 +00:00
|
|
|
'Map, bit_field, char, kBitFieldOffset',
|
|
|
|
'Map, bit_field2, char, kBitField2Offset',
|
2015-09-18 22:41:04 +00:00
|
|
|
'Map, bit_field3, int, kBitField3Offset',
|
2014-07-23 10:48:16 +00:00
|
|
|
'Map, prototype, Object, kPrototypeOffset',
|
|
|
|
'Oddball, kind_offset, int, kKindOffset',
|
2012-02-02 20:18:19 +00:00
|
|
|
'HeapNumber, value, double, kValueOffset',
|
|
|
|
'ExternalString, resource, Object, kResourceOffset',
|
2012-11-15 13:31:27 +00:00
|
|
|
'SeqOneByteString, chars, char, kHeaderSize',
|
2013-10-14 13:08:52 +00:00
|
|
|
'SeqTwoByteString, chars, char, kHeaderSize',
|
2020-05-08 18:48:33 +00:00
|
|
|
'UncompiledData, inferred_name, String, kInferredNameOffset',
|
2018-07-09 09:34:34 +00:00
|
|
|
'UncompiledData, start_position, int32_t, kStartPositionOffset',
|
|
|
|
'UncompiledData, end_position, int32_t, kEndPositionOffset',
|
2021-08-13 15:00:32 +00:00
|
|
|
'Script, source, Object, kSourceOffset',
|
2020-12-09 18:58:11 +00:00
|
|
|
'Script, name, Object, kNameOffset',
|
|
|
|
'Script, line_ends, Object, kLineEndsOffset',
|
2018-07-09 09:34:34 +00:00
|
|
|
'SharedFunctionInfo, raw_function_token_offset, int16_t, kFunctionTokenOffsetOffset',
|
2018-05-30 11:12:26 +00:00
|
|
|
'SharedFunctionInfo, internal_formal_parameter_count, uint16_t, kFormalParameterCountOffset',
|
2018-03-27 10:55:27 +00:00
|
|
|
'SharedFunctionInfo, flags, int, kFlagsOffset',
|
2018-05-30 11:12:26 +00:00
|
|
|
'SharedFunctionInfo, length, uint16_t, kLengthOffset',
|
2013-10-14 13:08:52 +00:00
|
|
|
'SlicedString, parent, String, kParentOffset',
|
2021-08-13 15:00:32 +00:00
|
|
|
'Code, flags, uint32_t, kFlagsOffset',
|
2012-03-09 12:34:42 +00:00
|
|
|
'Code, instruction_start, uintptr_t, kHeaderSize',
|
|
|
|
'Code, instruction_size, int, kInstructionSizeOffset',
|
2018-10-14 18:44:37 +00:00
|
|
|
'String, length, int32_t, kLengthOffset',
|
2019-09-30 23:40:47 +00:00
|
|
|
'DescriptorArray, header_size, uintptr_t, kHeaderSize',
|
2019-10-09 00:08:49 +00:00
|
|
|
'ConsString, first, String, kFirstOffset',
|
|
|
|
'ConsString, second, String, kSecondOffset',
|
|
|
|
'SlicedString, offset, SMI, kOffsetOffset',
|
|
|
|
'ThinString, actual, String, kActualOffset',
|
2019-10-28 18:16:45 +00:00
|
|
|
'Symbol, name, Object, kDescriptionOffset',
|
2020-11-30 15:51:42 +00:00
|
|
|
'FixedArrayBase, length, SMI, kLengthOffset',
|
2012-02-02 20:18:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
#
|
|
|
|
# The following is a whitelist of classes we expect to find when scanning the
|
|
|
|
# source code. This list is not exhaustive, but it's still useful to identify
|
|
|
|
# when this script gets out of sync with the source. See load_objects().
|
|
|
|
#
|
|
|
|
expected_classes = [
|
|
|
|
'ConsString', 'FixedArray', 'HeapNumber', 'JSArray', 'JSFunction',
|
2019-06-24 13:13:34 +00:00
|
|
|
'JSObject', 'JSRegExp', 'JSPrimitiveWrapper', 'Map', 'Oddball', 'Script',
|
2019-09-30 23:40:47 +00:00
|
|
|
'SeqOneByteString', 'SharedFunctionInfo', 'ScopeInfo', 'JSPromise',
|
|
|
|
'DescriptorArray'
|
2012-02-02 20:18:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# The following structures store high-level representations of the structures
|
|
|
|
# for which we're going to emit descriptive constants.
|
|
|
|
#
|
2021-10-08 14:00:59 +00:00
|
|
|
types = {}; # set of all type names
|
2012-02-02 20:18:19 +00:00
|
|
|
typeclasses = {}; # maps type names to corresponding class names
|
2021-10-08 14:00:59 +00:00
|
|
|
klasses = {}; # known classes, including parents
|
|
|
|
fields = []; # field declarations
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
header = '''
|
|
|
|
/*
|
|
|
|
* This file is generated by %s. Do not edit directly.
|
|
|
|
*/
|
|
|
|
|
2019-05-24 13:51:59 +00:00
|
|
|
#include "src/init/v8.h"
|
2020-11-07 11:17:30 +00:00
|
|
|
#include "src/codegen/register-arch.h"
|
2019-05-22 07:55:37 +00:00
|
|
|
#include "src/execution/frames.h"
|
|
|
|
#include "src/execution/frames-inl.h" /* for architecture-specific frame constants */
|
2019-05-23 08:51:46 +00:00
|
|
|
#include "src/objects/contexts.h"
|
|
|
|
#include "src/objects/objects.h"
|
2019-02-07 20:27:25 +00:00
|
|
|
#include "src/objects/data-handler.h"
|
2018-10-04 09:47:11 +00:00
|
|
|
#include "src/objects/js-promise.h"
|
2018-05-23 13:29:02 +00:00
|
|
|
#include "src/objects/js-regexp-string-iterator.h"
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2019-02-13 10:23:31 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
/* stack frame constants */
|
|
|
|
#define FRAME_CONST(value, klass) \
|
2020-11-07 11:17:30 +00:00
|
|
|
V8_EXPORT int v8dbg_frametype_##klass = StackFrame::value;
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
STACK_FRAME_TYPE_LIST(FRAME_CONST)
|
|
|
|
|
|
|
|
#undef FRAME_CONST
|
|
|
|
|
|
|
|
''' % sys.argv[0];
|
|
|
|
|
|
|
|
footer = '''
|
|
|
|
}
|
2019-02-13 10:23:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-02-02 20:18:19 +00:00
|
|
|
'''
|
|
|
|
|
2015-11-12 14:47:38 +00:00
|
|
|
#
|
|
|
|
# Get the base class
|
|
|
|
#
|
|
|
|
def get_base_class(klass):
|
2021-10-08 14:00:59 +00:00
|
|
|
if (klass == 'Object'):
|
|
|
|
return klass;
|
2015-11-12 14:47:38 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
if (not (klass in klasses)):
|
|
|
|
return None;
|
2015-11-12 14:47:38 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
k = klasses[klass];
|
2015-11-12 14:47:38 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
return get_base_class(k['parent']);
|
2015-11-12 14:47:38 +00:00
|
|
|
|
2012-02-02 20:18:19 +00:00
|
|
|
#
|
2017-05-17 11:31:18 +00:00
|
|
|
# Loads class hierarchy and type information from "objects.h" etc.
|
2012-02-02 20:18:19 +00:00
|
|
|
#
|
|
|
|
def load_objects():
|
2021-10-08 14:00:59 +00:00
|
|
|
#
|
|
|
|
# Construct a dictionary for the classes we're sure should be present.
|
|
|
|
#
|
|
|
|
checktypes = {};
|
|
|
|
for klass in expected_classes:
|
|
|
|
checktypes[klass] = True;
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2017-05-17 11:31:18 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
for filename in sys.argv[2:]:
|
|
|
|
if not filename.endswith("-inl.h"):
|
|
|
|
load_objects_from_file(filename, checktypes)
|
2017-05-17 11:31:18 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
if (len(checktypes) > 0):
|
|
|
|
for klass in checktypes:
|
|
|
|
print('error: expected class \"%s\" not found' % klass);
|
2017-05-17 11:31:18 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
sys.exit(1);
|
2017-05-17 11:31:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
def load_objects_from_file(objfilename, checktypes):
|
2021-10-08 14:00:59 +00:00
|
|
|
objfile = io.open(objfilename, 'r', encoding='utf-8');
|
|
|
|
in_insttype = False;
|
|
|
|
in_torque_insttype = False
|
|
|
|
in_torque_fulldef = False
|
|
|
|
|
|
|
|
typestr = '';
|
|
|
|
torque_typestr = ''
|
|
|
|
torque_fulldefstr = ''
|
|
|
|
uncommented_file = ''
|
|
|
|
|
|
|
|
#
|
|
|
|
# Iterate the header file line-by-line to collect type and class
|
|
|
|
# information. For types, we accumulate a string representing the entire
|
|
|
|
# InstanceType enum definition and parse it later because it's easier to
|
|
|
|
# do so without the embedded newlines.
|
|
|
|
#
|
|
|
|
for line in objfile:
|
|
|
|
if (line.startswith('enum InstanceType : uint16_t {')):
|
|
|
|
in_insttype = True;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (line.startswith('#define TORQUE_ASSIGNED_INSTANCE_TYPE_LIST')):
|
|
|
|
in_torque_insttype = True
|
|
|
|
continue
|
|
|
|
|
|
|
|
if (line.startswith('#define TORQUE_INSTANCE_CHECKERS_SINGLE_FULLY_DEFINED')):
|
|
|
|
in_torque_fulldef = True
|
|
|
|
continue
|
|
|
|
|
|
|
|
if (in_insttype and line.startswith('};')):
|
|
|
|
in_insttype = False;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (in_torque_insttype and (not line or line.isspace())):
|
2019-10-11 21:52:06 +00:00
|
|
|
in_torque_insttype = False
|
2021-10-08 14:00:59 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
if (in_torque_fulldef and (not line or line.isspace())):
|
2020-02-14 01:36:24 +00:00
|
|
|
in_torque_fulldef = False
|
2021-10-08 14:00:59 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
line = re.sub('//.*', '', line.strip());
|
|
|
|
|
|
|
|
if (in_insttype):
|
|
|
|
typestr += line;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (in_torque_insttype):
|
|
|
|
torque_typestr += line
|
|
|
|
continue
|
|
|
|
|
|
|
|
if (in_torque_fulldef):
|
|
|
|
torque_fulldefstr += line
|
|
|
|
continue
|
|
|
|
|
|
|
|
uncommented_file += '\n' + line
|
|
|
|
|
|
|
|
for match in re.finditer(r'\nclass(?:\s+V8_EXPORT(?:_PRIVATE)?)?'
|
|
|
|
r'\s+(\w[^:;]*)'
|
|
|
|
r'(?:: public (\w[^{]*))?\s*{\s*',
|
|
|
|
uncommented_file):
|
|
|
|
klass = match.group(1).strip();
|
|
|
|
pklass = match.group(2);
|
|
|
|
if (pklass):
|
|
|
|
# Check for generated Torque class.
|
|
|
|
gen_match = re.match(
|
|
|
|
r'TorqueGenerated\w+\s*<\s*\w+,\s*(\w+)\s*>',
|
|
|
|
pklass)
|
|
|
|
if (gen_match):
|
|
|
|
pklass = gen_match.group(1)
|
|
|
|
# Strip potential template arguments from parent
|
|
|
|
# class.
|
|
|
|
match = re.match(r'(\w+)(<.*>)?', pklass.strip());
|
|
|
|
pklass = match.group(1).strip();
|
|
|
|
klasses[klass] = { 'parent': pklass };
|
|
|
|
|
|
|
|
#
|
|
|
|
# Process the instance type declaration.
|
|
|
|
#
|
|
|
|
entries = typestr.split(',');
|
|
|
|
for entry in entries:
|
|
|
|
types[re.sub('\s*=.*', '', entry).lstrip()] = True;
|
|
|
|
entries = torque_typestr.split('\\')
|
|
|
|
for entry in entries:
|
|
|
|
name = re.sub(r' *V\(|\).*', '', entry)
|
|
|
|
types[name] = True
|
|
|
|
entries = torque_fulldefstr.split('\\')
|
|
|
|
for entry in entries:
|
|
|
|
entry = entry.strip()
|
|
|
|
if not entry:
|
|
|
|
continue
|
|
|
|
start = entry.find('(');
|
|
|
|
end = entry.find(')', start);
|
|
|
|
rest = entry[start + 1: end];
|
|
|
|
args = re.split('\s*,\s*', rest);
|
|
|
|
typename = args[0]
|
|
|
|
typeconst = args[1]
|
|
|
|
types[typeconst] = True
|
|
|
|
typeclasses[typeconst] = typename
|
|
|
|
#
|
|
|
|
# Infer class names for each type based on a systematic transformation.
|
|
|
|
# For example, "JS_FUNCTION_TYPE" becomes "JSFunction". We find the
|
|
|
|
# class for each type rather than the other way around because there are
|
|
|
|
# fewer cases where one type maps to more than one class than the other
|
|
|
|
# way around.
|
|
|
|
#
|
|
|
|
for type in types:
|
|
|
|
usetype = type
|
|
|
|
|
|
|
|
#
|
|
|
|
# Remove the "_TYPE" suffix and then convert to camel case,
|
|
|
|
# except that a "JS" prefix remains uppercase (as in
|
|
|
|
# "JS_FUNCTION_TYPE" => "JSFunction").
|
|
|
|
#
|
|
|
|
if (not usetype.endswith('_TYPE')):
|
|
|
|
continue;
|
|
|
|
|
|
|
|
usetype = usetype[0:len(usetype) - len('_TYPE')];
|
|
|
|
parts = usetype.split('_');
|
|
|
|
cctype = '';
|
|
|
|
|
|
|
|
if (parts[0] == 'JS'):
|
|
|
|
cctype = 'JS';
|
|
|
|
start = 1;
|
|
|
|
else:
|
|
|
|
cctype = '';
|
|
|
|
start = 0;
|
|
|
|
|
|
|
|
for ii in range(start, len(parts)):
|
|
|
|
part = parts[ii];
|
|
|
|
cctype += part[0].upper() + part[1:].lower();
|
|
|
|
|
|
|
|
#
|
|
|
|
# Mapping string types is more complicated. Both types and
|
|
|
|
# class names for Strings specify a representation (e.g., Seq,
|
|
|
|
# Cons, External, or Sliced) and an encoding (TwoByte/OneByte),
|
|
|
|
# In the simplest case, both of these are explicit in both
|
|
|
|
# names, as in:
|
|
|
|
#
|
|
|
|
# EXTERNAL_ONE_BYTE_STRING_TYPE => ExternalOneByteString
|
|
|
|
#
|
|
|
|
# However, either the representation or encoding can be omitted
|
|
|
|
# from the type name, in which case "Seq" and "TwoByte" are
|
|
|
|
# assumed, as in:
|
|
|
|
#
|
|
|
|
# STRING_TYPE => SeqTwoByteString
|
|
|
|
#
|
|
|
|
# Additionally, sometimes the type name has more information
|
|
|
|
# than the class, as in:
|
|
|
|
#
|
|
|
|
# CONS_ONE_BYTE_STRING_TYPE => ConsString
|
|
|
|
#
|
|
|
|
# To figure this out dynamically, we first check for a
|
|
|
|
# representation and encoding and add them if they're not
|
|
|
|
# present. If that doesn't yield a valid class name, then we
|
|
|
|
# strip out the representation.
|
|
|
|
#
|
|
|
|
if (cctype.endswith('String')):
|
|
|
|
if (cctype.find('Cons') == -1 and
|
|
|
|
cctype.find('External') == -1 and
|
|
|
|
cctype.find('Sliced') == -1):
|
|
|
|
if (cctype.find('OneByte') != -1):
|
|
|
|
cctype = re.sub('OneByteString$',
|
|
|
|
'SeqOneByteString', cctype);
|
|
|
|
else:
|
|
|
|
cctype = re.sub('String$',
|
|
|
|
'SeqString', cctype);
|
|
|
|
|
|
|
|
if (cctype.find('OneByte') == -1):
|
|
|
|
cctype = re.sub('String$', 'TwoByteString',
|
|
|
|
cctype);
|
2017-05-17 11:31:18 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
if (not (cctype in klasses)):
|
|
|
|
cctype = re.sub('OneByte', '', cctype);
|
|
|
|
cctype = re.sub('TwoByte', '', cctype);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Despite all that, some types have no corresponding class.
|
|
|
|
#
|
|
|
|
if (cctype in klasses):
|
|
|
|
typeclasses[type] = cctype;
|
|
|
|
if (cctype in checktypes):
|
|
|
|
del checktypes[cctype];
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# For a given macro call, pick apart the arguments and return an object
|
|
|
|
# describing the corresponding output constant. See load_fields().
|
|
|
|
#
|
|
|
|
def parse_field(call):
|
2021-10-08 14:00:59 +00:00
|
|
|
# Replace newlines with spaces.
|
|
|
|
for ii in range(0, len(call)):
|
|
|
|
if (call[ii] == '\n'):
|
|
|
|
call[ii] == ' ';
|
|
|
|
|
|
|
|
idx = call.find('(');
|
|
|
|
kind = call[0:idx];
|
|
|
|
rest = call[idx + 1: len(call) - 1];
|
|
|
|
args = re.split('\s*,\s*', rest);
|
|
|
|
|
|
|
|
consts = [];
|
|
|
|
|
|
|
|
klass = args[0];
|
|
|
|
field = args[1];
|
|
|
|
dtype = None
|
|
|
|
offset = None
|
|
|
|
if kind.startswith('WEAK_ACCESSORS'):
|
|
|
|
dtype = 'weak'
|
|
|
|
offset = args[2];
|
|
|
|
elif not (kind.startswith('SMI_ACCESSORS') or kind.startswith('ACCESSORS_TO_SMI')):
|
|
|
|
dtype = args[2].replace('<', '_').replace('>', '_')
|
|
|
|
offset = args[3];
|
|
|
|
else:
|
|
|
|
offset = args[2];
|
|
|
|
dtype = 'SMI'
|
|
|
|
|
|
|
|
|
|
|
|
assert(offset is not None and dtype is not None);
|
|
|
|
return ({
|
|
|
|
'name': 'class_%s__%s__%s' % (klass, field, dtype),
|
|
|
|
'value': '%s::%s' % (klass, offset)
|
|
|
|
});
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
#
|
2017-05-17 11:31:18 +00:00
|
|
|
# Load field offset information from objects-inl.h etc.
|
2012-02-02 20:18:19 +00:00
|
|
|
#
|
|
|
|
def load_fields():
|
2021-10-08 14:00:59 +00:00
|
|
|
for filename in sys.argv[2:]:
|
|
|
|
if filename.endswith("-inl.h"):
|
|
|
|
load_fields_from_file(filename)
|
2017-05-17 11:31:18 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
for body in extras_accessors:
|
|
|
|
fields.append(parse_field('ACCESSORS(%s)' % body));
|
2017-05-17 11:31:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
def load_fields_from_file(filename):
|
2021-10-08 14:00:59 +00:00
|
|
|
inlfile = io.open(filename, 'r', encoding='utf-8');
|
|
|
|
|
|
|
|
#
|
|
|
|
# Each class's fields and the corresponding offsets are described in the
|
|
|
|
# source by calls to macros like "ACCESSORS" (and friends). All we do
|
|
|
|
# here is extract these macro invocations, taking into account that they
|
|
|
|
# may span multiple lines and may contain nested parentheses. We also
|
|
|
|
# call parse_field() to pick apart the invocation.
|
|
|
|
#
|
|
|
|
prefixes = [ 'ACCESSORS', 'ACCESSORS2', 'ACCESSORS_GCSAFE',
|
|
|
|
'SMI_ACCESSORS', 'ACCESSORS_TO_SMI',
|
|
|
|
'RELEASE_ACQUIRE_ACCESSORS', 'WEAK_ACCESSORS' ];
|
|
|
|
prefixes += ([ prefix + "_CHECKED" for prefix in prefixes ] +
|
|
|
|
[ prefix + "_CHECKED2" for prefix in prefixes ])
|
|
|
|
current = '';
|
|
|
|
opens = 0;
|
|
|
|
|
|
|
|
for line in inlfile:
|
|
|
|
if (opens > 0):
|
|
|
|
# Continuation line
|
|
|
|
for ii in range(0, len(line)):
|
|
|
|
if (line[ii] == '('):
|
|
|
|
opens += 1;
|
|
|
|
elif (line[ii] == ')'):
|
|
|
|
opens -= 1;
|
|
|
|
|
|
|
|
if (opens == 0):
|
|
|
|
break;
|
|
|
|
|
|
|
|
current += line[0:ii + 1];
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for prefix in prefixes:
|
|
|
|
if (not line.startswith(prefix + '(')):
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (len(current) > 0):
|
|
|
|
fields.append(parse_field(current));
|
2012-02-02 20:18:19 +00:00
|
|
|
current = '';
|
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
for ii in range(len(prefix), len(line)):
|
|
|
|
if (line[ii] == '('):
|
|
|
|
opens += 1;
|
|
|
|
elif (line[ii] == ')'):
|
|
|
|
opens -= 1;
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
if (opens == 0):
|
|
|
|
break;
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
current += line[0:ii + 1];
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
if (len(current) > 0):
|
|
|
|
fields.append(parse_field(current));
|
|
|
|
current = '';
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Emit a block of constants.
|
|
|
|
#
|
|
|
|
def emit_set(out, consts):
|
2021-10-08 14:00:59 +00:00
|
|
|
lines = set() # To remove duplicates.
|
2020-10-07 09:43:11 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
# Fix up overzealous parses. This could be done inside the
|
|
|
|
# parsers but as there are several, it's easiest to do it here.
|
|
|
|
ws = re.compile('\s+')
|
|
|
|
for const in consts:
|
|
|
|
name = ws.sub('', const['name'])
|
|
|
|
value = ws.sub('', str(const['value'])) # Can be a number.
|
|
|
|
lines.add('V8_EXPORT int v8dbg_%s = %s;\n' % (name, value))
|
2020-10-07 09:43:11 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
for line in lines:
|
|
|
|
out.write(line);
|
|
|
|
out.write('\n');
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Emit the whole output file.
|
|
|
|
#
|
|
|
|
def emit_config():
|
2021-10-08 14:00:59 +00:00
|
|
|
out = open(sys.argv[1], 'w');
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
out.write(header);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
out.write('/* miscellaneous constants */\n');
|
|
|
|
emit_set(out, consts_misc);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
out.write('/* class type information */\n');
|
|
|
|
consts = [];
|
|
|
|
for typename in sorted(typeclasses):
|
|
|
|
klass = typeclasses[typename];
|
|
|
|
consts.append({
|
|
|
|
'name': 'type_%s__%s' % (klass, typename),
|
|
|
|
'value': typename
|
|
|
|
});
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
emit_set(out, consts);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
out.write('/* class hierarchy information */\n');
|
|
|
|
consts = [];
|
|
|
|
for klassname in sorted(klasses):
|
|
|
|
pklass = klasses[klassname]['parent'];
|
|
|
|
bklass = get_base_class(klassname);
|
|
|
|
if (bklass != 'Object'):
|
|
|
|
continue;
|
|
|
|
if (pklass == None):
|
|
|
|
continue;
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
consts.append({
|
|
|
|
'name': 'parent_%s__%s' % (klassname, pklass),
|
|
|
|
'value': 0
|
|
|
|
});
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
emit_set(out, consts);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
out.write('/* field information */\n');
|
|
|
|
emit_set(out, fields);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
2021-10-08 14:00:59 +00:00
|
|
|
out.write(footer);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
if (len(sys.argv) < 4):
|
2021-10-08 14:00:59 +00:00
|
|
|
print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]);
|
|
|
|
sys.exit(2);
|
2012-02-02 20:18:19 +00:00
|
|
|
|
|
|
|
load_objects();
|
|
|
|
load_fields();
|
|
|
|
emit_config();
|