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

Unified Diff: src/trusted/validator_ragel/unreviewed/validator-x86_64.rl

Issue 9968039: Add ragel machine generators to SCONS (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator_ragel/unreviewed/validator-x86_64.rl
===================================================================
--- src/trusted/validator_ragel/unreviewed/validator-x86_64.rl (revision 8170)
+++ src/trusted/validator_ragel/unreviewed/validator-x86_64.rl (working copy)
@@ -5,26 +5,24 @@
*/
#include <assert.h>
-#include <elf.h>
-#include <inttypes.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "validator.h"
-#undef TRUE
-#define TRUE 1
+#include "native_client/src/shared/utils/types.h"
+#include "native_client/src/trusted/validator_ragel/unreviewed/validator.h"
-#undef FALSE
-#define FALSE 0
+#if defined(_MSC_VER)
+#define inline __inline
+#endif
-#include "validator-x86_64-instruction-consts.c"
+#include "native_client/src/trusted/validator_ragel/generated/validator-x86_64-instruction-consts.c"
#define check_jump_dest \
if ((jump_dest & bundle_mask) != bundle_mask) { \
if (jump_dest >= size) { \
- printf("direct jump out of range: %zx\n", jump_dest); \
+ printf("direct jump out of range: %"NACL_PRIxS"\n", jump_dest); \
result = 1; \
goto error_detected; \
} else { \
@@ -33,10 +31,10 @@
} \
operand0 = JMP_TO; \
base = REG_RIP; \
- index = REG_NONE;
+ index = NO_REG;
static void PrintError(const char* msg, uintptr_t ptr) {
- printf("offset 0x%zx: %s", ptr, msg);
+ printf("offset 0x%"NACL_PRIxS": %s", ptr, msg);
}
%%{
@@ -51,7 +49,7 @@
((index == REG_RDI) &&
(restricted_register == kSandboxedRsiRestrictedRdi))) {
BitmapClearBit(valid_targets, begin - data);
- } else if ((index != REG_NONE) && (index != REG_RIZ)) {
+ } else if ((index != NO_REG) && (index != REG_RIZ)) {
PrintError("Improper sandboxing in instruction\n", begin - data);
result = 1;
goto error_detected;
@@ -63,7 +61,7 @@
((base == REG_RDI) &&
(restricted_register == kSandboxedRsiRestrictedRdi))) {
BitmapClearBit(valid_targets, begin - data);
- } else if ((base != REG_NONE) && (base != REG_RIZ)) {
+ } else if ((base != NO_REG) && (base != REG_RIZ)) {
PrintError("Improper sandboxing in instruction\n", begin - data);
result = 1;
goto error_detected;
@@ -414,8 +412,8 @@
static const int kBitsPerByte = 8;
-static inline uint8_t *BitmapAllocate(uint32_t indexes) {
- uint32_t byte_count = (indexes + kBitsPerByte - 1) / kBitsPerByte;
+static inline uint8_t *BitmapAllocate(size_t indexes) {
+ size_t byte_count = (indexes + kBitsPerByte - 1) / kBitsPerByte;
uint8_t *bitmap = malloc(byte_count);
if (bitmap != NULL) {
memset(bitmap, 0, byte_count);
@@ -423,15 +421,15 @@
return bitmap;
}
-static inline int BitmapIsBitSet(uint8_t *bitmap, uint32_t index) {
+static inline int BitmapIsBitSet(uint8_t *bitmap, size_t index) {
return (bitmap[index / kBitsPerByte] & (1 << (index % kBitsPerByte))) != 0;
}
-static inline void BitmapSetBit(uint8_t *bitmap, uint32_t index) {
+static inline void BitmapSetBit(uint8_t *bitmap, size_t index) {
bitmap[index / kBitsPerByte] |= 1 << (index % kBitsPerByte);
}
-static inline void BitmapClearBit(uint8_t *bitmap, uint32_t index) {
+static inline void BitmapClearBit(uint8_t *bitmap, size_t index) {
bitmap[index / kBitsPerByte] &= ~(1 << (index % kBitsPerByte));
}
@@ -460,14 +458,22 @@
const uint8_t *p = data;
const uint8_t *begin = p; /* Start of the instruction being processed. */
- uint8_t rex_prefix, vex_prefix2, vex_prefix3;
+ uint8_t rex_prefix = FALSE;
pasko-google - do not use 2012/04/06 15:23:58 uint8_t rex_prefix = 0;
khim 2012/04/06 15:30:04 Done.
+ uint8_t vex_prefix2 = 0xe0;
+ uint8_t vex_prefix3 = 0x00;
struct Operand {
unsigned int name :5;
unsigned int type :2;
- bool write :1;
+#ifdef _MSC_VER
+ Bool write :1;
+#else
+ _Bool write :1;
+#endif
} operands[5];
- enum register_name base, index;
- uint8_t operands_count, i;
+ enum register_name base = NO_REG;
+ enum register_name index = NO_REG;
+ uint8_t operands_count = 0;
+ uint8_t i;
int result = 0;
/*
* These are borders of the appropriate instructions. Initialize them to make

Powered by Google App Engine
This is Rietveld 408576698