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

Side by Side Diff: src/trusted/validator/x86/decoder/ncop_exps.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 #include "native_client/src/trusted/validator/x86/decoder/ncop_exps.h" 7 #include "native_client/src/trusted/validator/x86/decoder/ncop_exps.h"
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <ctype.h> 10 #include <ctype.h>
(...skipping 13 matching lines...) Expand all
24 * DEBUGGING to 1. 24 * DEBUGGING to 1.
25 * 25 *
26 * WARNING: Debugging messages inside of print messages must be sent to the 26 * WARNING: Debugging messages inside of print messages must be sent to the
27 * same gio stream as being printed, since they may be used by another 27 * same gio stream as being printed, since they may be used by another
28 * nacl log message that has locked the access to NaClLogGetGio(). 28 * nacl log message that has locked the access to NaClLogGetGio().
29 */ 29 */
30 #define DEBUGGING 0 30 #define DEBUGGING 0
31 31
32 #include "native_client/src/shared/utils/debugging.h" 32 #include "native_client/src/shared/utils/debugging.h"
33 33
34 #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc_inl.c"
35 #include "native_client/src/trusted/validator/x86/decoder/ncop_exps_inl.c"
36
34 void NaClPrintExpFlags(struct Gio* file, NaClExpFlags flags) { 37 void NaClPrintExpFlags(struct Gio* file, NaClExpFlags flags) {
35 if (flags == 0) { 38 if (flags == 0) {
36 gprintf(file, "0"); 39 gprintf(file, "0");
37 } else { 40 } else {
38 NaClExpFlag f; 41 NaClExpFlag f;
39 Bool is_first = TRUE; 42 Bool is_first = TRUE;
40 for (f = 0; f < NaClExpFlagEnumSize; f++) { 43 for (f = 0; f < NaClExpFlagEnumSize; f++) {
41 if (flags & NACL_EFLAG(f)) { 44 if (flags & NACL_EFLAG(f)) {
42 if (is_first) { 45 if (is_first) {
43 is_first = FALSE; 46 is_first = FALSE;
(...skipping 25 matching lines...) Expand all
69 {ExprMemOffset, 4}, 72 {ExprMemOffset, 4},
70 }; 73 };
71 74
72 int NaClExpKindRank(NaClExpKind kind) { 75 int NaClExpKindRank(NaClExpKind kind) {
73 assert(kind == g_NaClExpKindDesc[kind].name); 76 assert(kind == g_NaClExpKindDesc[kind].name);
74 return g_NaClExpKindDesc[kind].rank; 77 return g_NaClExpKindDesc[kind].rank;
75 } 78 }
76 79
77 /* Returns the register defined by the given node. */ 80 /* Returns the register defined by the given node. */
78 NaClOpKind NaClGetExpRegister(NaClExp* node) { 81 NaClOpKind NaClGetExpRegister(NaClExp* node) {
79 assert(node->kind == ExprRegister); 82 return NaClGetExpRegisterInline(node);
80 return (NaClOpKind) node->value;
81 } 83 }
82 84
83 /* Returns the name of the register defined by the indexed node in the 85 /* Returns the name of the register defined by the indexed node in the
84 * vector of nodes. 86 * vector of nodes.
85 */ 87 */
86 NaClOpKind NaClGetExpVectorRegister(NaClExpVector* vector, 88 NaClOpKind NaClGetExpVectorRegister(NaClExpVector* vector,
87 int node) { 89 int node) {
88 return NaClGetExpRegister(&vector->node[node]); 90 return NaClGetExpRegisterInline(&vector->node[node]);
89 } 91 }
90 92
91 static int NaClPrintDisassembledExp(struct Gio* file, 93 static int NaClPrintDisassembledExp(struct Gio* file,
92 NaClExpVector* vector, 94 NaClExpVector* vector,
93 uint32_t index); 95 uint32_t index);
94 96
95 /* Print the characters in the given string using lower case. */ 97 /* Print the characters in the given string using lower case. */
96 static void NaClPrintLower(struct Gio* file, char* str) { 98 static void NaClPrintLower(struct Gio* file, char* str) {
97 while (*str) { 99 while (*str) {
98 gprintf(file, "%c", tolower(*str)); 100 gprintf(file, "%c", tolower(*str));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 * to the given file. 163 * to the given file.
162 */ 164 */
163 static void NaClPrintDisassembledRegKind(struct Gio* file, NaClOpKind reg) { 165 static void NaClPrintDisassembledRegKind(struct Gio* file, NaClOpKind reg) {
164 const char* name = NaClOpKindName(reg); 166 const char* name = NaClOpKindName(reg);
165 char* str = strstr(name, "Reg"); 167 char* str = strstr(name, "Reg");
166 gprintf(file, "%c", '%'); 168 gprintf(file, "%c", '%');
167 NaClPrintLower(file, str == NULL ? (char*) name : str + strlen("Reg")); 169 NaClPrintLower(file, str == NULL ? (char*) name : str + strlen("Reg"));
168 } 170 }
169 171
170 static INLINE void NaClPrintDisassembledReg(struct Gio* file, NaClExp* node) { 172 static INLINE void NaClPrintDisassembledReg(struct Gio* file, NaClExp* node) {
171 NaClPrintDisassembledRegKind(file, NaClGetExpRegister(node)); 173 NaClPrintDisassembledRegKind(file, NaClGetExpRegisterInline(node));
172 } 174 }
173 175
174 void NaClExpVectorPrint(struct Gio* file, NaClExpVector* vector) { 176 void NaClExpVectorPrint(struct Gio* file, NaClExpVector* vector) {
175 uint32_t i; 177 uint32_t i;
176 gprintf(file, "NaClExpVector[%d] = {\n", vector->number_expr_nodes); 178 gprintf(file, "NaClExpVector[%d] = {\n", vector->number_expr_nodes);
177 for (i = 0; i < vector->number_expr_nodes; i++) { 179 for (i = 0; i < vector->number_expr_nodes; i++) {
178 NaClExp* node = &vector->node[i]; 180 NaClExp* node = &vector->node[i];
179 gprintf(file, " { %s[%d] , ", 181 gprintf(file, " { %s[%d] , ",
180 NaClExpKindName(node->kind), 182 NaClExpKindName(node->kind),
181 NaClExpKindRank(node->kind)); 183 NaClExpKindRank(node->kind));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 */ 301 */
300 static Bool NaClHasSegmentOverride(NaClExpVector* vector, 302 static Bool NaClHasSegmentOverride(NaClExpVector* vector,
301 int seg_addr_index, 303 int seg_addr_index,
302 NaClExpFlag seg_eflag, 304 NaClExpFlag seg_eflag,
303 NaClOpKind seg_reg) { 305 NaClOpKind seg_reg) {
304 NaClExp* seg_node = &vector->node[seg_addr_index]; 306 NaClExp* seg_node = &vector->node[seg_addr_index];
305 if (seg_node->flags & NACL_EFLAG(seg_eflag)) { 307 if (seg_node->flags & NACL_EFLAG(seg_eflag)) {
306 int seg_index = seg_addr_index + 1; 308 int seg_index = seg_addr_index + 1;
307 NaClExp* node = &vector->node[seg_index]; 309 NaClExp* node = &vector->node[seg_index];
308 if ((ExprRegister == node->kind) && 310 if ((ExprRegister == node->kind) &&
309 (seg_reg != NaClGetExpRegister(node))) { 311 (seg_reg != NaClGetExpRegisterInline(node))) {
310 return TRUE; 312 return TRUE;
311 } 313 }
312 } 314 }
313 return FALSE; 315 return FALSE;
314 } 316 }
315 317
316 /* Prints out the segment register associated with the segment 318 /* Prints out the segment register associated with the segment
317 * address node defined by vector[seg_addr_index]. 319 * address node defined by vector[seg_addr_index].
318 * 320 *
319 * Parameters: 321 * Parameters:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } else { 390 } else {
389 gprintf(file, ", "); 391 gprintf(file, ", ");
390 } 392 }
391 NaClPrintDisassembledExp(file, vector, tree_index); 393 NaClPrintDisassembledExp(file, vector, tree_index);
392 394
393 /* If this is a partial instruction, add set/use information 395 /* If this is a partial instruction, add set/use information
394 * so that that it is more clear what was matched. 396 * so that that it is more clear what was matched.
395 */ 397 */
396 if (NaClHasBit(inst->flags, NACL_IFLAG(PartialInstruction)) && 398 if (NaClHasBit(inst->flags, NACL_IFLAG(PartialInstruction)) &&
397 node->kind == OperandReference) { 399 node->kind == OperandReference) {
398 const NaClOp* op = NaClGetInstOperand(state->decoder_tables, 400 const NaClOp* op =
399 inst, (uint8_t) node->value); 401 NaClGetInstOperandInline(state->decoder_tables,
402 inst, (uint8_t) node->value);
400 if (NaClHasBit(op->flags, (NACL_OPFLAG(OpSet) | 403 if (NaClHasBit(op->flags, (NACL_OPFLAG(OpSet) |
401 NACL_OPFLAG(OpUse) | 404 NACL_OPFLAG(OpUse) |
402 NACL_OPFLAG(OperandZeroExtends_v)))) { 405 NACL_OPFLAG(OperandZeroExtends_v)))) {
403 gprintf(file, " ("); 406 gprintf(file, " (");
404 NaClPrintAddOperandFlag(file, op, OpSet, "s"); 407 NaClPrintAddOperandFlag(file, op, OpSet, "s");
405 NaClPrintAddOperandFlag(file, op, OpUse, "u"); 408 NaClPrintAddOperandFlag(file, op, OpUse, "u");
406 NaClPrintAddOperandFlag(file, op, OperandZeroExtends_v, "z"); 409 NaClPrintAddOperandFlag(file, op, OperandZeroExtends_v, "z");
407 gprintf(file, ")"); 410 gprintf(file, ")");
408 } 411 }
409 } 412 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 /* Assume signed value. */ 603 /* Assume signed value. */
601 int64_t value = (int64_t) NaClGetExpConstant(vector, index); 604 int64_t value = (int64_t) NaClGetExpConstant(vector, index);
602 return value < 0; 605 return value < 0;
603 } 606 }
604 break; 607 break;
605 default: 608 default:
606 break; 609 break;
607 } 610 }
608 return FALSE; 611 return FALSE;
609 } 612 }
613
614 /* Dummy routine to allow unreferenced NaClGetInstNumberOperandsInline
615 * inline.
616 */
617 uint8_t NaClNcopExpsDummyNaClGetInstNumberOperands(const NaClInst* inst) {
618 return NaClGetInstNumberOperandsInline(inst);
619 }
OLDNEW
« no previous file with comments | « src/trusted/validator/x86/decoder/nc_inst_trans.c ('k') | src/trusted/validator/x86/decoder/ncop_exps_inl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698