Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_utils.c

Issue 7980021: Speed up x86-64 validator by inlining heavily called routines. Speeds up (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* Some useful utilities for validator patterns. */ 7 /* Some useful utilities for validator patterns. */
8 8
9 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_utils .h" 9 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_utils .h"
10 10
11 #include "native_client/src/shared/platform/nacl_log.h" 11 #include "native_client/src/shared/platform/nacl_log.h"
12 #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h" 12 #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h"
13 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal .h" 13 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal .h"
14 #include "native_client/src/trusted/validator/x86/decoder/ncop_exps.h" 14 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc_inl.h"
15 #include "native_client/src/trusted/validator/x86/decoder/ncop_exps_inl.h"
15 16
16 /* To turn on debugging of instruction decoding, change value of 17 /* To turn on debugging of instruction decoding, change value of
17 * DEBUGGING to 1. 18 * DEBUGGING to 1.
18 */ 19 */
19 #define DEBUGGING 0 20 #define DEBUGGING 0
20 21
21 #include "native_client/src/shared/utils/debugging.h" 22 #include "native_client/src/shared/utils/debugging.h"
22 23
23 const NaClOpFlags NaClOpSetOrUse = NACL_OPFLAG(OpSet) | NACL_OPFLAG(OpUse); 24 const NaClOpFlags NaClOpSetOrUse = NACL_OPFLAG(OpSet) | NACL_OPFLAG(OpUse);
24 25
25 Bool NaClIsBinaryUsingRegisters(const NaClInst* inst, 26 Bool NaClIsBinaryUsingRegisters(const NaClInst* inst,
26 NaClMnemonic name, 27 NaClMnemonic name,
27 NaClExpVector* vector, 28 NaClExpVector* vector,
28 NaClOpKind reg_1, 29 NaClOpKind reg_1,
29 NaClOpKind reg_2) { 30 NaClOpKind reg_2) {
30 return name == inst->name && 31 return name == inst->name &&
31 2 == NaClGetInstNumberOperands(inst) && 32 2 == NaClGetInstNumberOperandsInline(inst) &&
32 /* Note: Since the vector contains a list of operand expressions, the 33 /* Note: Since the vector contains a list of operand expressions, the
33 * first operand reference is always at index zero, and its first child 34 * first operand reference is always at index zero, and its first child
34 * (where the register would be defined) is at index 1. 35 * (where the register would be defined) is at index 1.
35 */ 36 */
36 ExprRegister == vector->node[1].kind && 37 ExprRegister == vector->node[1].kind &&
37 reg_1 == NaClGetExpRegister(&vector->node[1]) && 38 reg_1 == NaClGetExpRegisterInline(&vector->node[1]) &&
38 /* Note: Since the first subtree is a register operand, it uses 39 /* Note: Since the first subtree is a register operand, it uses
39 * nodes 0 and 1 in the vector (node 0 is the operand reference, and 40 * nodes 0 and 1 in the vector (node 0 is the operand reference, and
40 * node 1 is its child defining a register value). The second operand 41 * node 1 is its child defining a register value). The second operand
41 * reference therefore lies at node 2, and if the operand is defined by 42 * reference therefore lies at node 2, and if the operand is defined by
42 * a register, it is the first kid of node 2, which is node 3. 43 * a register, it is the first kid of node 2, which is node 3.
43 */ 44 */
44 ExprRegister == vector->node[3].kind && 45 ExprRegister == vector->node[3].kind &&
45 reg_2 == NaClGetExpRegister(&vector->node[3]); 46 reg_2 == NaClGetExpRegisterInline(&vector->node[3]);
46 } 47 }
47 48
48 Bool NaClIsMovUsingRegisters(const NaClDecodeTables* tables, 49 Bool NaClIsMovUsingRegisters(const NaClDecodeTables* tables,
49 const NaClInst* inst, 50 const NaClInst* inst,
50 NaClExpVector* vector, 51 NaClExpVector* vector,
51 NaClOpKind reg_set, 52 NaClOpKind reg_set,
52 NaClOpKind reg_use) { 53 NaClOpKind reg_use) {
53 return NaClIsBinaryUsingRegisters(inst, InstMov, vector, reg_set, reg_use) && 54 return NaClIsBinaryUsingRegisters(inst, InstMov, vector, reg_set, reg_use) &&
54 NACL_OPFLAG(OpSet) == 55 NACL_OPFLAG(OpSet) ==
55 (NaClGetInstOperand(tables, inst, 0)->flags & NaClOpSetOrUse) && 56 (NaClGetInstOperandInline(tables, inst, 0)->flags & NaClOpSetOrUse) &&
56 NACL_OPFLAG(OpUse) == 57 NACL_OPFLAG(OpUse) ==
57 (NaClGetInstOperand(tables, inst, 1)->flags & NaClOpSetOrUse); 58 (NaClGetInstOperandInline(tables, inst, 1)->flags & NaClOpSetOrUse);
58 } 59 }
59 60
60 Bool NaClIsBinarySetUsingRegisters(const NaClDecodeTables* tables, 61 Bool NaClIsBinarySetUsingRegisters(const NaClDecodeTables* tables,
61 const NaClInst* inst, 62 const NaClInst* inst,
62 NaClMnemonic name, 63 NaClMnemonic name,
63 NaClExpVector* vector, 64 NaClExpVector* vector,
64 NaClOpKind reg_1, 65 NaClOpKind reg_1,
65 NaClOpKind reg_2) { 66 NaClOpKind reg_2) {
66 return NaClIsBinaryUsingRegisters(inst, name, vector, reg_1, reg_2) && 67 return NaClIsBinaryUsingRegisters(inst, name, vector, reg_1, reg_2) &&
67 NaClOpSetOrUse == 68 NaClOpSetOrUse ==
68 (NaClGetInstOperand(tables, inst, 0)->flags & NaClOpSetOrUse) && 69 (NaClGetInstOperandInline(tables, inst, 0)->flags & NaClOpSetOrUse) &&
69 NACL_OPFLAG(OpUse) == 70 NACL_OPFLAG(OpUse) ==
70 (NaClGetInstOperand(tables, inst, 1)->flags & NaClOpSetOrUse); 71 (NaClGetInstOperandInline(tables, inst, 1)->flags & NaClOpSetOrUse);
71 } 72 }
72 73
73 Bool NaClOperandOneIsRegisterSet(NaClInstState* inst, 74 Bool NaClOperandOneIsRegisterSet(NaClInstState* inst,
74 NaClOpKind reg_name) { 75 NaClOpKind reg_name) {
75 /* Note: Since the vector contains a list of operand expressions, the 76 /* Note: Since the vector contains a list of operand expressions, the
76 * first operand reference is always at index zero, and its first child 77 * first operand reference is always at index zero, and its first child
77 * (where the register would be defined) is at index 1. 78 * (where the register would be defined) is at index 1.
78 */ 79 */
79 Bool result = FALSE; 80 Bool result = FALSE;
80 NaClExpVector* vector = NaClInstStateExpVector(inst); 81 NaClExpVector* vector = NaClInstStateExpVector(inst);
81 DEBUG(NaClLog(LOG_INFO, 82 DEBUG(NaClLog(LOG_INFO,
82 "->NaClOperandOneIsRegisterSet %s\n", 83 "->NaClOperandOneIsRegisterSet %s\n",
83 NaClOpKindName(reg_name))); 84 NaClOpKindName(reg_name)));
84 DEBUG(NaClExpVectorPrint(NaClLogGetGio(), vector)); 85 DEBUG(NaClExpVectorPrint(NaClLogGetGio(), vector));
85 if (vector->number_expr_nodes >= 2) { 86 if (vector->number_expr_nodes >= 2) {
86 NaClExp* op_reg = &vector->node[1]; 87 NaClExp* op_reg = &vector->node[1];
87 result = (ExprRegister == op_reg->kind && 88 result = (ExprRegister == op_reg->kind &&
88 reg_name == NaClGetExpRegister(op_reg) && 89 reg_name == NaClGetExpRegisterInline(op_reg) &&
89 (op_reg->flags & NACL_EFLAG(ExprSet))); 90 (op_reg->flags & NACL_EFLAG(ExprSet)));
90 } 91 }
91 DEBUG(NaClLog(LOG_INFO, 92 DEBUG(NaClLog(LOG_INFO,
92 "<-NaClOperandOneIsRegisterSet = %"NACL_PRIdBool"\n", result)); 93 "<-NaClOperandOneIsRegisterSet = %"NACL_PRIdBool"\n", result));
93 return result; 94 return result;
94 } 95 }
95 96
96 Bool NaClOperandOneZeroExtends(NaClInstState* state) { 97 Bool NaClOperandOneZeroExtends(NaClInstState* state) {
97 Bool result = FALSE; 98 Bool result = FALSE;
98 const NaClInst* inst = NaClInstStateInst(state); 99 const NaClInst* inst = NaClInstStateInst(state);
99 DEBUG(NaClLog(LOG_INFO, "->NaClOperandOneZeroExtends\n")); 100 DEBUG(NaClLog(LOG_INFO, "->NaClOperandOneZeroExtends\n"));
100 DEBUG_OR_ERASE(NaClInstPrint(NaClLogGetGio(), state->decoder_tables, inst)); 101 DEBUG_OR_ERASE(NaClInstPrint(NaClLogGetGio(), state->decoder_tables, inst));
101 result = (1 <= NaClGetInstNumberOperands(inst) && 102 result = (1 <= NaClGetInstNumberOperandsInline(inst) &&
102 (NaClGetInstOperand(state->decoder_tables, inst, 0)->flags & 103 (NaClGetInstOperandInline(state->decoder_tables, inst, 0)->flags &
103 NACL_OPFLAG(OperandZeroExtends_v)) && 104 NACL_OPFLAG(OperandZeroExtends_v)) &&
104 4 == NaClInstStateOperandSize(state)); 105 4 == NaClInstStateOperandSize(state));
105 DEBUG(NaClLog(LOG_INFO, 106 DEBUG(NaClLog(LOG_INFO,
106 "<-NcOPerandOneZeroExtends = %"NACL_PRIdBool"\n", result)); 107 "<-NcOPerandOneZeroExtends = %"NACL_PRIdBool"\n", result));
107 return result; 108 return result;
108 } 109 }
109 110
110 Bool NaClAssignsRegisterWithZeroExtends(NaClInstState* state, 111 Bool NaClAssignsRegisterWithZeroExtends(NaClInstState* state,
111 NaClOpKind reg_name) { 112 NaClOpKind reg_name) {
112 return NaClOperandOneIsRegisterSet(state, reg_name) && 113 return NaClOperandOneIsRegisterSet(state, reg_name) &&
113 NaClOperandOneZeroExtends(state); 114 NaClOperandOneZeroExtends(state);
114 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698