Changeset 126505 in webkit


Ignore:
Timestamp:
Aug 23, 2012, 4:49:48 PM (13 years ago)
Author:
[email protected]
Message:

Autogenerate Opcode definitions
https://bugs.webkit.org/show_bug.cgi?id=94840

Reviewed by Gavin Barraclough.

Start the process of autogenerating the code emission for the bytecode.
We'll just start with automatic generation of the list of Opcodes as that
requires the actual definition of the opcodes, and the logic for parsing
them.

Due to some rather annoying dependency cycles, this initial version has
the OpcodeDefinitions.h file checked into the tree, although with some
work I hope to be able to fix that.

  • DerivedSources.make:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/Opcode.h: Include OpcodeDefinitions.h as our definitive source of info about the opcodes.
  • bytecode/OpcodeDefinitions.h: Added. Autogenerated file
  • bytecode/opcodes: Added. The new opcode definition file
  • opcode_definition_generator.py: Added.

(generateOpcodeDefinition):
(generate):

Module that generates the content for OpcodeDefinitions.h

  • opcode_generator.py: Added.

(printUsage):
(main):

Driver script

  • opcode_parser.py: Added. Simple parser for the opcode definitions.
Location:
trunk/Source/JavaScriptCore
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r126494 r126505  
     12012-08-23  Oliver Hunt  <[email protected]>
     2
     3        Autogenerate Opcode definitions
     4        https://bugs.webkit.org/show_bug.cgi?id=94840
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Start the process of autogenerating the code emission for the bytecode.
     9        We'll just start with automatic generation of the list of Opcodes as that
     10        requires the actual definition of the opcodes, and the logic for parsing
     11        them.
     12
     13        Due to some rather annoying dependency cycles, this initial version has
     14        the OpcodeDefinitions.h file checked into the tree, although with some
     15        work I hope to be able to fix that.
     16
     17        * DerivedSources.make:
     18        * JavaScriptCore.xcodeproj/project.pbxproj:
     19        * bytecode/Opcode.h:
     20          Include OpcodeDefinitions.h as our definitive source of info
     21          about the opcodes.
     22        * bytecode/OpcodeDefinitions.h: Added.
     23          Autogenerated file
     24        * bytecode/opcodes: Added.
     25          The new opcode definition file
     26        * opcode_definition_generator.py: Added.
     27        (generateOpcodeDefinition):
     28        (generate):
     29          Module that generates the content for OpcodeDefinitions.h
     30        * opcode_generator.py: Added.
     31        (printUsage):
     32        (main):
     33          Driver script
     34        * opcode_parser.py: Added.
     35          Simple parser for the opcode definitions.
     36
    1372012-08-23  Mark Hahnenberg  <[email protected]>
    238
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r120745 r126505  
    8181        python $^ > $@
    8282
     83# Don't autogenerate these yet, as there are some dependency problems
     84# interacting with the LLIntOffsetsExtractor
     85# opcode_generator.py: opcode_definition_generator.py opcode_parser.py
     86#
     87# OpcodeDefinitions.h: opcode_generator.py | bytecode/opcodes
     88#       python $< -i $| -m definition -o $@
     89
    8390# udis86 instruction tables
    8491
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r126387 r126505  
    143143                0F63945415D07055006A597C /* ArrayProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63945115D07051006A597C /* ArrayProfile.cpp */; };
    144144                0F63945515D07057006A597C /* ArrayProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63945215D07051006A597C /* ArrayProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
     145                0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    145146                0F63948415E48118006A597C /* DFGArrayMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63948115E48114006A597C /* DFGArrayMode.cpp */; };
    146147                0F63948515E4811B006A597C /* DFGArrayMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63948215E48114006A597C /* DFGArrayMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    147                 0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    148148                0F66E16B14DF3F1600B7B2E4 /* DFGAdjacencyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */; settings = {ATTRIBUTES = (Private, ); }; };
    149149                0F66E16C14DF3F1600B7B2E4 /* DFGEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    576576                A7E2EA6B0FB460CF00601F06 /* LiteralParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A7E2EA690FB460CF00601F06 /* LiteralParser.h */; };
    577577                A7E2EA6C0FB460CF00601F06 /* LiteralParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E2EA6A0FB460CF00601F06 /* LiteralParser.cpp */; };
     578                A7EC8C7A15E6E9500051E9A9 /* OpcodeDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = A758FB5C15E6C91B00AC9895 /* OpcodeDefinitions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    578579                A7F9935F0FD7325100A0B2D0 /* JSONObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A7F9935D0FD7325100A0B2D0 /* JSONObject.h */; };
    579580                A7F993600FD7325100A0B2D0 /* JSONObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7F9935E0FD7325100A0B2D0 /* JSONObject.cpp */; };
     
    902903                0F63945115D07051006A597C /* ArrayProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayProfile.cpp; sourceTree = "<group>"; };
    903904                0F63945215D07051006A597C /* ArrayProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayProfile.h; sourceTree = "<group>"; };
     905                0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
    904906                0F63948115E48114006A597C /* DFGArrayMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGArrayMode.cpp; path = dfg/DFGArrayMode.cpp; sourceTree = "<group>"; };
    905907                0F63948215E48114006A597C /* DFGArrayMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGArrayMode.h; path = dfg/DFGArrayMode.h; sourceTree = "<group>"; };
    906                 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
    907908                0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAdjacencyList.h; path = dfg/DFGAdjacencyList.h; sourceTree = "<group>"; };
    908909                0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGEdge.h; path = dfg/DFGEdge.h; sourceTree = "<group>"; };
     
    13371338                A7521E121429169A003C8D0C /* CardSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CardSet.h; sourceTree = "<group>"; };
    13381339                A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITArithmetic32_64.cpp; sourceTree = "<group>"; };
     1340                A758FB5815E6C89400AC9895 /* opcode_definition_generator.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = opcode_definition_generator.py; sourceTree = "<group>"; };
     1341                A758FB5915E6C89400AC9895 /* opcode_generator.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = opcode_generator.py; sourceTree = "<group>"; };
     1342                A758FB5A15E6C89400AC9895 /* opcode_parser.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = opcode_parser.py; sourceTree = "<group>"; };
     1343                A758FB5C15E6C91B00AC9895 /* OpcodeDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpcodeDefinitions.h; sourceTree = "<group>"; };
     1344                A758FB5D15E6C91B00AC9895 /* opcodes */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = opcodes; sourceTree = "<group>"; };
    13391345                A767FF9F14F4502900789059 /* JSCTypedArrayStubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCTypedArrayStubs.h; sourceTree = "<group>"; };
    13401346                A76C51741182748D00715B05 /* JSInterfaceJIT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInterfaceJIT.h; sourceTree = "<group>"; };
     
    15981604                        isa = PBXGroup;
    15991605                        children = (
     1606                                A758FB5815E6C89400AC9895 /* opcode_definition_generator.py */,
     1607                                A758FB5915E6C89400AC9895 /* opcode_generator.py */,
     1608                                A758FB5A15E6C89400AC9895 /* opcode_parser.py */,
    16001609                                8604F4F2143A6C4400B295F5 /* ChangeLog */,
    16011610                                A718F8211178EB4B002465A7 /* create_regex_tables */,
     
    24472456                                0F0FC45814BD15F100B81154 /* LLIntCallLinkInfo.h */,
    24482457                                0F2BDC2B151FDE8B00CD8910 /* Operands.h */,
     2458                                A758FB5C15E6C91B00AC9895 /* OpcodeDefinitions.h */,
     2459                                A758FB5D15E6C91B00AC9895 /* opcodes */,
    24492460                                0F9FC8BF14E1B5FB00D52AE0 /* PolymorphicPutByIdList.cpp */,
    24502461                                0F9FC8C014E1B5FB00D52AE0 /* PolymorphicPutByIdList.h */,
     
    29042915                                0F63948515E4811B006A597C /* DFGArrayMode.h in Headers */,
    29052916                                0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */,
     2917                                A7EC8C7A15E6E9500051E9A9 /* OpcodeDefinitions.h in Headers */,
    29062918                        );
    29072919                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/bytecode/Opcode.h

    r125637 r126505  
    3131#define Opcode_h
    3232
     33#include "OpcodeDefinitions.h"
     34
    3335#include <algorithm>
    3436#include <string.h>
     
    3840namespace JSC {
    3941
    40     #define FOR_EACH_OPCODE_ID(macro) \
    41         macro(op_enter, 1) \
    42         macro(op_create_activation, 2) \
    43         macro(op_init_lazy_reg, 2) \
    44         macro(op_create_arguments, 2) \
    45         macro(op_create_this, 2) \
    46         macro(op_convert_this, 3) \
    47         \
    48         macro(op_new_object, 2) \
    49         macro(op_new_array, 4) \
    50         macro(op_new_array_buffer, 4) \
    51         macro(op_new_regexp, 3) \
    52         macro(op_mov, 3) \
    53         \
    54         macro(op_not, 3) \
    55         macro(op_eq, 4) \
    56         macro(op_eq_null, 3) \
    57         macro(op_neq, 4) \
    58         macro(op_neq_null, 3) \
    59         macro(op_stricteq, 4) \
    60         macro(op_nstricteq, 4) \
    61         macro(op_less, 4) \
    62         macro(op_lesseq, 4) \
    63         macro(op_greater, 4) \
    64         macro(op_greatereq, 4) \
    65         \
    66         macro(op_pre_inc, 2) \
    67         macro(op_pre_dec, 2) \
    68         macro(op_post_inc, 3) \
    69         macro(op_post_dec, 3) \
    70         macro(op_to_jsnumber, 3) \
    71         macro(op_negate, 3) \
    72         macro(op_add, 5) \
    73         macro(op_mul, 5) \
    74         macro(op_div, 5) \
    75         macro(op_mod, 4) \
    76         macro(op_sub, 5) \
    77         \
    78         macro(op_lshift, 4) \
    79         macro(op_rshift, 4) \
    80         macro(op_urshift, 4) \
    81         macro(op_bitand, 5) \
    82         macro(op_bitxor, 5) \
    83         macro(op_bitor, 5) \
    84         \
    85         macro(op_check_has_instance, 2) \
    86         macro(op_instanceof, 5) \
    87         macro(op_typeof, 3) \
    88         macro(op_is_undefined, 3) \
    89         macro(op_is_boolean, 3) \
    90         macro(op_is_number, 3) \
    91         macro(op_is_string, 3) \
    92         macro(op_is_object, 3) \
    93         macro(op_is_function, 3) \
    94         macro(op_in, 4) \
    95         \
    96         macro(op_resolve, 4) /* has value profiling */  \
    97         macro(op_resolve_skip, 5) /* has value profiling */ \
    98         macro(op_resolve_global, 6) /* has value profiling */ \
    99         macro(op_resolve_global_dynamic, 7) /* has value profiling */ \
    100         macro(op_get_scoped_var, 5) /* has value profiling */ \
    101         macro(op_put_scoped_var, 4) \
    102         macro(op_get_global_var, 4) /* has value profiling */ \
    103         macro(op_get_global_var_watchable, 5) /* has value profiling */ \
    104         macro(op_put_global_var, 3) \
    105         macro(op_put_global_var_check, 5) \
    106         macro(op_resolve_base, 5) /* has value profiling */ \
    107         macro(op_ensure_property_exists, 3) \
    108         macro(op_resolve_with_base, 5) /* has value profiling */ \
    109         macro(op_resolve_with_this, 5) /* has value profiling */ \
    110         macro(op_get_by_id, 9) /* has value profiling */ \
    111         macro(op_get_by_id_out_of_line, 9) /* has value profiling */ \
    112         macro(op_get_by_id_self, 9) /* has value profiling */ \
    113         macro(op_get_by_id_proto, 9) /* has value profiling */ \
    114         macro(op_get_by_id_chain, 9) /* has value profiling */ \
    115         macro(op_get_by_id_getter_self, 9) /* has value profiling */ \
    116         macro(op_get_by_id_getter_proto, 9) /* has value profiling */ \
    117         macro(op_get_by_id_getter_chain, 9) /* has value profiling */ \
    118         macro(op_get_by_id_custom_self, 9) /* has value profiling */ \
    119         macro(op_get_by_id_custom_proto, 9) /* has value profiling */ \
    120         macro(op_get_by_id_custom_chain, 9) /* has value profiling */ \
    121         macro(op_get_by_id_generic, 9) /* has value profiling */ \
    122         macro(op_get_array_length, 9) /* has value profiling */ \
    123         macro(op_get_string_length, 9) /* has value profiling */ \
    124         macro(op_get_arguments_length, 4) \
    125         macro(op_put_by_id, 9) \
    126         macro(op_put_by_id_out_of_line, 9) \
    127         macro(op_put_by_id_transition, 9) \
    128         macro(op_put_by_id_transition_direct, 9) \
    129         macro(op_put_by_id_transition_direct_out_of_line, 9) \
    130         macro(op_put_by_id_transition_normal, 9) \
    131         macro(op_put_by_id_transition_normal_out_of_line, 9) \
    132         macro(op_put_by_id_replace, 9) \
    133         macro(op_put_by_id_generic, 9) \
    134         macro(op_del_by_id, 4) \
    135         macro(op_get_by_val, 6) /* has value profiling */ \
    136         macro(op_get_argument_by_val, 6) /* must be the same size as op_get_by_val */ \
    137         macro(op_get_by_pname, 7) \
    138         macro(op_put_by_val, 5) \
    139         macro(op_del_by_val, 4) \
    140         macro(op_put_by_index, 4) \
    141         macro(op_put_getter_setter, 5) \
    142         \
    143         macro(op_jmp, 2) \
    144         macro(op_jtrue, 3) \
    145         macro(op_jfalse, 3) \
    146         macro(op_jeq_null, 3) \
    147         macro(op_jneq_null, 3) \
    148         macro(op_jneq_ptr, 4) \
    149         macro(op_jless, 4) \
    150         macro(op_jlesseq, 4) \
    151         macro(op_jgreater, 4) \
    152         macro(op_jgreatereq, 4) \
    153         macro(op_jnless, 4) \
    154         macro(op_jnlesseq, 4) \
    155         macro(op_jngreater, 4) \
    156         macro(op_jngreatereq, 4) \
    157         macro(op_jmp_scopes, 3) \
    158         macro(op_loop, 2) \
    159         macro(op_loop_if_true, 3) \
    160         macro(op_loop_if_false, 3) \
    161         macro(op_loop_if_less, 4) \
    162         macro(op_loop_if_lesseq, 4) \
    163         macro(op_loop_if_greater, 4) \
    164         macro(op_loop_if_greatereq, 4) \
    165         macro(op_loop_hint, 1) \
    166         macro(op_switch_imm, 4) \
    167         macro(op_switch_char, 4) \
    168         macro(op_switch_string, 4) \
    169         \
    170         macro(op_new_func, 4) \
    171         macro(op_new_func_exp, 3) \
    172         macro(op_call, 6) \
    173         macro(op_call_eval, 6) \
    174         macro(op_call_varargs, 5) \
    175         macro(op_tear_off_activation, 3) \
    176         macro(op_tear_off_arguments, 2) \
    177         macro(op_ret, 2) \
    178         macro(op_call_put_result, 3) /* has value profiling */ \
    179         macro(op_ret_object_or_this, 3) \
    180         macro(op_method_check, 1) \
    181         \
    182         macro(op_construct, 6) \
    183         macro(op_strcat, 4) \
    184         macro(op_to_primitive, 3) \
    185         \
    186         macro(op_get_pnames, 6) \
    187         macro(op_next_pname, 7) \
    188         \
    189         macro(op_push_scope, 2) \
    190         macro(op_pop_scope, 1) \
    191         macro(op_push_new_scope, 4) \
    192         \
    193         macro(op_catch, 2) \
    194         macro(op_throw, 2) \
    195         macro(op_throw_reference_error, 2) \
    196         \
    197         macro(op_debug, 5) \
    198         macro(op_profile_will_call, 2) \
    199         macro(op_profile_did_call, 2) \
    200         \
    201         macro(op_end, 2) // end must be the last opcode in the list
    202 
    20342    #define OPCODE_ID_ENUM(opcode, length) opcode,
    20443        typedef enum { FOR_EACH_OPCODE_ID(OPCODE_ID_ENUM) } OpcodeID;
    20544    #undef OPCODE_ID_ENUM
    20645
    207     const int maxOpcodeLength = 9;
    20846    const int numOpcodeIDs = op_end + 1;
    20947
Note: See TracChangeset for help on using the changeset viewer.