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

Side by Side Diff: src/trusted/validator_ragel/decoder_x86_32.rl

Issue 11000033: Move validator_x86_XX.rl out of unreviewed. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 7 years, 9 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) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 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 /* 7 /*
8 * Full-blown decoder for ia32 case. Can be used to decode instruction sequence 8 * Full-blown decoder for ia32 case. Can be used to decode instruction sequence
9 * and process it, but right now is only used in tests. 9 * and process it, but right now is only used in tests.
10 * 10 *
11 * The code is in [hand-written] "parse_instruction.rl" and in [auto-generated] 11 * The code is in [hand-written] "parse_instruction.rl" and in [auto-generated]
12 * "decoder_x86_32_instruction.rl" file. This file only includes tiny amount 12 * "decoder_x86_32_instruction.rl" file. This file only includes tiny amount
13 * of the glue code. 13 * of the glue code.
14 */ 14 */
15 15
16 #include <assert.h> 16 #include <assert.h>
17 #include <stddef.h> 17 #include <stddef.h>
18 #include <stdio.h> 18 #include <stdio.h>
19 #include <stdlib.h> 19 #include <stdlib.h>
20 #include <string.h> 20 #include <string.h>
21 21
22 #include "native_client/src/shared/utils/types.h" 22 #include "native_client/src/shared/utils/types.h"
23 #include "native_client/src/trusted/validator_ragel/unreviewed/decoder_internal. h" 23 #include "native_client/src/trusted/validator_ragel/decoder_internal.h"
24 24
25 /* 25 /*
26 * These prefixes are not useful in IA32 mode, but they will "cleaned up" by 26 * These prefixes are not useful in IA32 mode, but they will "cleaned up" by
27 * decoder's cleanup procedure anyway. Do nothing when that happens. 27 * decoder's cleanup procedure anyway. Do nothing when that happens.
28 */ 28 */
halyavin 2013/03/13 15:25:33 Remove this defines by duplicating end_of_instruct
khim 2013/03/19 14:54:46 Done: https://codereview.chromium.org/12716018
29 #define SET_REX_PREFIX(P) 29 #define SET_REX_PREFIX(P)
30 #define SET_VEX_PREFIX2(P) 30 #define SET_VEX_PREFIX2(P)
31 #define CLEAR_SPURIOUS_REX_B() 31 #define CLEAR_SPURIOUS_REX_B()
32 #define SET_SPURIOUS_REX_B() 32 #define SET_SPURIOUS_REX_B()
33 #define CLEAR_SPURIOUS_REX_X() 33 #define CLEAR_SPURIOUS_REX_X()
34 #define SET_SPURIOUS_REX_X() 34 #define SET_SPURIOUS_REX_X()
35 #define CLEAR_SPURIOUS_REX_R() 35 #define CLEAR_SPURIOUS_REX_R()
36 #define SET_SPURIOUS_REX_R() 36 #define SET_SPURIOUS_REX_R()
37 #define CLEAR_SPURIOUS_REX_W() 37 #define CLEAR_SPURIOUS_REX_W()
38 #define SET_SPURIOUS_REX_W() 38 #define SET_SPURIOUS_REX_W()
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl"; 81 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl";
82 82
83 include decode_x86_32 "decoder_x86_32_instruction.rl"; 83 include decode_x86_32 "decoder_x86_32_instruction.rl";
84 84
85 include decoder 85 include decoder
86 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl"; 86 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl";
87 87
88 main := decoder; 88 main := decoder;
89 }%% 89 }%%
90 90
91 /*
92 * The "write data" statement causes Ragel to emit the constant static data
93 * needed by the ragel machine.
94 */
91 %% write data; 95 %% write data;
92 96
93 int DecodeChunkIA32(const uint8_t *data, size_t size, 97 int DecodeChunkIA32(const uint8_t *data, size_t size,
94 ProcessInstructionFunc process_instruction, 98 ProcessInstructionFunc process_instruction,
95 ProcessDecodingErrorFunc process_error, void *userdata) { 99 ProcessDecodingErrorFunc process_error, void *userdata) {
96 const uint8_t *current_position = data; 100 const uint8_t *current_position = data;
97 const uint8_t *end_of_data = data + size; 101 const uint8_t *end_of_data = data + size;
98 const uint8_t *instruction_begin = current_position; 102 const uint8_t *instruction_begin = current_position;
99 uint8_t vex_prefix3 = 0x00; 103 uint8_t vex_prefix3 = 0x00;
100 enum ImmediateMode imm_operand = IMMNONE; 104 enum ImmediateMode imm_operand = IMMNONE;
101 enum ImmediateMode imm2_operand = IMMNONE; 105 enum ImmediateMode imm2_operand = IMMNONE;
102 struct Instruction instruction; 106 struct Instruction instruction;
103 int result = TRUE; 107 int result = TRUE;
104 108
105 int current_state; 109 int current_state;
106 110
107 /* Not used in ia32_mode. */ 111 /* Not used in ia32_mode. */
108 instruction.prefix.rex = 0; 112 instruction.prefix.rex = 0;
halyavin 2013/03/13 15:41:36 use memset to clear instruction.
khim 2013/03/19 14:54:46 Done: https://codereview.chromium.org/12716018
109 113
110 SET_DISP_TYPE(DISPNONE); 114 SET_DISP_TYPE(DISPNONE);
111 SET_IMM_TYPE(IMMNONE); 115 SET_IMM_TYPE(IMMNONE);
112 SET_IMM2_TYPE(IMMNONE); 116 SET_IMM2_TYPE(IMMNONE);
113 SET_DATA16_PREFIX(FALSE); 117 SET_DATA16_PREFIX(FALSE);
114 SET_LOCK_PREFIX(FALSE); 118 SET_LOCK_PREFIX(FALSE);
115 SET_REPNZ_PREFIX(FALSE); 119 SET_REPNZ_PREFIX(FALSE);
116 SET_REPZ_PREFIX(FALSE); 120 SET_REPZ_PREFIX(FALSE);
117 SET_BRANCH_NOT_TAKEN(FALSE); 121 SET_BRANCH_NOT_TAKEN(FALSE);
118 SET_BRANCH_TAKEN(FALSE); 122 SET_BRANCH_TAKEN(FALSE);
119 SET_ATT_INSTRUCTION_SUFFIX(NULL); 123 SET_ATT_INSTRUCTION_SUFFIX(NULL);
120 instruction.prefix.rex_b_spurious = FALSE; 124 instruction.prefix.rex_b_spurious = FALSE;
121 instruction.prefix.rex_x_spurious = FALSE; 125 instruction.prefix.rex_x_spurious = FALSE;
122 instruction.prefix.rex_r_spurious = FALSE; 126 instruction.prefix.rex_r_spurious = FALSE;
123 instruction.prefix.rex_w_spurious = FALSE; 127 instruction.prefix.rex_w_spurious = FALSE;
124 128
129 /*
130 * The "write init" statement causes Ragel to emit initialization code.
131 * This should be executed once before the ragel machine is started.
132 */
125 %% write init; 133 %% write init;
134 /*
135 * The "write exec" statement causes Ragel to emit the ragel machine's
136 * execution code.
137 */
126 %% write exec; 138 %% write exec;
127 139
128 error_detected: 140 error_detected:
129 return result; 141 return result;
130 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698