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

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 */
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()
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl"; 79 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl";
80 80
81 include decode_x86_32 "decoder_x86_32_instruction.rl"; 81 include decode_x86_32 "decoder_x86_32_instruction.rl";
82 82
83 include decoder 83 include decoder
84 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl"; 84 "native_client/src/trusted/validator_ragel/unreviewed/parse_instruction.rl";
85 85
86 main := decoder; 86 main := decoder;
87 }%% 87 }%%
88 88
89 /*
90 * The "write data" statement causes Ragel to emit the constant static data
91 * needed by the ragel machine.
92 */
89 %% write data; 93 %% write data;
90 94
91 int DecodeChunkIA32(const uint8_t *data, size_t size, 95 int DecodeChunkIA32(const uint8_t *data, size_t size,
92 ProcessInstructionFunc process_instruction, 96 ProcessInstructionFunc process_instruction,
93 ProcessDecodingErrorFunc process_error, void *userdata) { 97 ProcessDecodingErrorFunc process_error, void *userdata) {
94 const uint8_t *current_position = data; 98 const uint8_t *current_position = data;
95 const uint8_t *end_of_data = data + size; 99 const uint8_t *end_of_data = data + size;
96 const uint8_t *instruction_begin = current_position; 100 const uint8_t *instruction_begin = current_position;
97 uint8_t vex_prefix3 = 0x00; 101 uint8_t vex_prefix3 = 0x00;
98 enum ImmediateMode imm_operand = IMMNONE; 102 enum ImmediateMode imm_operand = IMMNONE;
(...skipping 14 matching lines...) Expand all
113 SET_REPNZ_PREFIX(FALSE); 117 SET_REPNZ_PREFIX(FALSE);
114 SET_REPZ_PREFIX(FALSE); 118 SET_REPZ_PREFIX(FALSE);
115 SET_BRANCH_NOT_TAKEN(FALSE); 119 SET_BRANCH_NOT_TAKEN(FALSE);
116 SET_BRANCH_TAKEN(FALSE); 120 SET_BRANCH_TAKEN(FALSE);
117 SET_ATT_INSTRUCTION_SUFFIX(NULL); 121 SET_ATT_INSTRUCTION_SUFFIX(NULL);
118 instruction.prefix.rex_b_spurious = FALSE; 122 instruction.prefix.rex_b_spurious = FALSE;
119 instruction.prefix.rex_x_spurious = FALSE; 123 instruction.prefix.rex_x_spurious = FALSE;
120 instruction.prefix.rex_r_spurious = FALSE; 124 instruction.prefix.rex_r_spurious = FALSE;
121 instruction.prefix.rex_w_spurious = FALSE; 125 instruction.prefix.rex_w_spurious = FALSE;
122 126
127 /*
128 * The "write init" statement causes Ragel to emit initialization code.
129 * This should be executed once before the ragel machine is started.
130 */
123 %% write init; 131 %% write init;
132 /*
133 * The "write exec" statement causes Ragel to emit the ragel machine's
134 * execution code.
135 */
124 %% write exec; 136 %% write exec;
125 137
126 error_detected: 138 error_detected:
127 return result; 139 return result;
128 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698