Opcode.h revision 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5
1635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/* 2635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 4635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 5635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Redistribution and use in source and binary forms, with or without 6635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * modification, are permitted provided that the following conditions 7635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * are met: 8635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 9635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 10635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * notice, this list of conditions and the following disclaimer. 11635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 12635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 13635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * documentation and/or other materials provided with the distribution. 14635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * its contributors may be used to endorse or promote products derived 16635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * from this software without specific prior written permission. 17635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * 18635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */ 29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 30635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#ifndef Opcode_h 31635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define Opcode_h 32635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 33635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include <algorithm> 34635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include <string.h> 35635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 36635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include <wtf/Assertions.h> 37635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 38635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Projectnamespace JSC { 39635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 40635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #define FOR_EACH_OPCODE_ID(macro) \ 41635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_enter, 1) \ 42635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_enter_with_activation, 2) \ 435f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_init_arguments, 1) \ 44635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_create_arguments, 1) \ 45635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_convert_this, 2) \ 46635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 47635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_new_object, 2) \ 48635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_new_array, 4) \ 49635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_new_regexp, 3) \ 50635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_mov, 3) \ 51635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 52635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_not, 3) \ 53635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_eq, 4) \ 54635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_eq_null, 3) \ 55635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_neq, 4) \ 56635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_neq_null, 3) \ 57635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_stricteq, 4) \ 58635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_nstricteq, 4) \ 59635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_less, 4) \ 60635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_lesseq, 4) \ 61635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 62635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_pre_inc, 2) \ 63635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_pre_dec, 2) \ 64635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_post_inc, 3) \ 65635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_post_dec, 3) \ 66635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_to_jsnumber, 3) \ 67635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_negate, 3) \ 68635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_add, 5) \ 69635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_mul, 5) \ 700bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch macro(op_div, 5) \ 71635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_mod, 4) \ 72635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_sub, 5) \ 73635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 74635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_lshift, 4) \ 75635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_rshift, 4) \ 76635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_urshift, 4) \ 77635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_bitand, 5) \ 78635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_bitxor, 5) \ 79635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_bitor, 5) \ 80635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_bitnot, 3) \ 81635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 82635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_instanceof, 5) \ 83635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_typeof, 3) \ 84635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_is_undefined, 3) \ 85635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_is_boolean, 3) \ 86635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_is_number, 3) \ 87635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_is_string, 3) \ 88635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_is_object, 3) \ 89635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_is_function, 3) \ 90635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_in, 4) \ 91635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 92635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_resolve, 3) \ 93635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_resolve_skip, 4) \ 94635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_resolve_global, 6) \ 95635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_scoped_var, 4) \ 96635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_scoped_var, 4) \ 97635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_global_var, 4) \ 98635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_global_var, 4) \ 99635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_resolve_base, 3) \ 100635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_resolve_with_base, 4) \ 101635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id, 8) \ 102635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id_self, 8) \ 103635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id_self_list, 8) \ 104635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id_proto, 8) \ 105635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id_proto_list, 8) \ 106635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id_chain, 8) \ 107635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_id_generic, 8) \ 108635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_array_length, 8) \ 109635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_string_length, 8) \ 110635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_by_id, 8) \ 111635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_by_id_transition, 8) \ 112635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_by_id_replace, 8) \ 113635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_by_id_generic, 8) \ 114635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_del_by_id, 4) \ 115635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_by_val, 4) \ 116635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_by_val, 4) \ 117635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_del_by_val, 4) \ 118635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_by_index, 4) \ 119635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_getter, 4) \ 120635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_put_setter, 4) \ 121635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 122635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jmp, 2) \ 123635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jtrue, 3) \ 124635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jfalse, 3) \ 125635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jeq_null, 3) \ 126635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jneq_null, 3) \ 1275f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_jneq_ptr, 4) \ 128635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jnless, 4) \ 1295f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_jnlesseq, 4) \ 130635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jmp_scopes, 3) \ 131635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_loop, 2) \ 132635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_loop_if_true, 3) \ 133635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_loop_if_less, 4) \ 134635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_loop_if_lesseq, 4) \ 135635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_switch_imm, 4) \ 136635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_switch_char, 4) \ 137635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_switch_string, 4) \ 138635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 139635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_new_func, 3) \ 140635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_new_func_exp, 3) \ 141635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_call, 5) \ 142635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_call_eval, 5) \ 1435f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_call_varargs, 5) \ 1445f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_load_varargs, 3) \ 145635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_tear_off_activation, 2) \ 146635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_tear_off_arguments, 1) \ 147635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_ret, 2) \ 1485f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_method_check, 1) \ 149635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 150635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_construct, 7) \ 151635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_construct_verify, 3) \ 1525f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_strcat, 4) \ 1535f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian macro(op_to_primitive, 3) \ 154635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 155635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_get_pnames, 3) \ 156635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_next_pname, 4) \ 157635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 158635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_push_scope, 2) \ 159635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_pop_scope, 1) \ 160635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_push_new_scope, 4) \ 161635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 162635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_catch, 2) \ 163635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_throw, 2) \ 164635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_new_error, 4) \ 165635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 166635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_jsr, 3) \ 167635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_sret, 2) \ 168635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 169635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_debug, 4) \ 170635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_profile_will_call, 2) \ 171635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_profile_did_call, 2) \ 172635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project \ 173635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project macro(op_end, 2) // end must be the last opcode in the list 174635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 175635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #define OPCODE_ID_ENUM(opcode, length) opcode, 176635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project typedef enum { FOR_EACH_OPCODE_ID(OPCODE_ID_ENUM) } OpcodeID; 177635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #undef OPCODE_ID_ENUM 178635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 179635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project const int numOpcodeIDs = op_end + 1; 180635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 181635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #define OPCODE_ID_LENGTHS(id, length) const int id##_length = length; 182635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project FOR_EACH_OPCODE_ID(OPCODE_ID_LENGTHS); 1830bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch #undef OPCODE_ID_LENGTHS 184635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 185635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #define OPCODE_LENGTH(opcode) opcode##_length 186635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 187635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #define OPCODE_ID_LENGTH_MAP(opcode, length) length, 188635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project const int opcodeLengths[numOpcodeIDs] = { FOR_EACH_OPCODE_ID(OPCODE_ID_LENGTH_MAP) }; 189635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #undef OPCODE_ID_LENGTH_MAP 190635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 191635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #define VERIFY_OPCODE_ID(id, size) COMPILE_ASSERT(id <= op_end, ASSERT_THAT_JS_OPCODE_IDS_ARE_VALID); 192635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project FOR_EACH_OPCODE_ID(VERIFY_OPCODE_ID); 193635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project #undef VERIFY_OPCODE_ID 194635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 195635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#if HAVE(COMPUTED_GOTO) 196635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project typedef void* Opcode; 197635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#else 198635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project typedef OpcodeID Opcode; 199635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif 200635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 201635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#if ENABLE(OPCODE_SAMPLING) || ENABLE(CODEBLOCK_SAMPLING) || ENABLE(OPCODE_STATS) 202635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 203635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define PADDING_STRING " " 204635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define PADDING_STRING_LENGTH static_cast<unsigned>(strlen(PADDING_STRING)) 205635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 206635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project extern const char* const opcodeNames[]; 207635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 208635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project inline const char* padOpcodeName(OpcodeID op, unsigned width) 209635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project { 210635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project unsigned pad = width - strlen(opcodeNames[op]); 211635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project pad = std::min(pad, PADDING_STRING_LENGTH); 212635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project return PADDING_STRING + PADDING_STRING_LENGTH - pad; 213635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project } 214635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 215635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#undef PADDING_STRING_LENGTH 216635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#undef PADDING_STRING 217635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 218635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif 219635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 220635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#if ENABLE(OPCODE_STATS) 221635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 222635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project struct OpcodeStats { 223635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project OpcodeStats(); 224635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project ~OpcodeStats(); 225635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static long long opcodeCounts[numOpcodeIDs]; 226635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static long long opcodePairCounts[numOpcodeIDs][numOpcodeIDs]; 227635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static int lastOpcode; 228635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 229635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static void recordInstruction(int opcode); 230635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static void resetLastInstruction(); 231635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project }; 232635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 233635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif 234635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 235635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project} // namespace JSC 236635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 237635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif // Opcode_h 238