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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.