summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-04-21 19:09:38 +0100
committerKeith Whitwell <[email protected]>2008-04-21 19:12:08 +0100
commitb17e123a8f20239e8e1fc6816ccf115d9ec57471 (patch)
tree6d5735c6bf9546d9e95a765203e6572cd354324c /src
parent65efe807b9067aa07b382e3c4d9cea6222c5fc6b (diff)
rtasm: propogate errors in x86 emit
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.c34
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.h1
2 files changed, 30 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
index f2c08c96a6f..c2fe0e40f57 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
@@ -146,7 +146,10 @@ _fill(
static void do_realloc( struct x86_function *p )
{
- if (p->size == 0) {
+ if (p->store == p->error_overflow) {
+ p->csr = p->store;
+ }
+ else if (p->size == 0) {
p->size = 1024;
p->store = rtasm_exec_malloc(p->size);
p->csr = p->store;
@@ -156,10 +159,22 @@ static void do_realloc( struct x86_function *p )
unsigned char *tmp = p->store;
p->size *= 2;
p->store = rtasm_exec_malloc(p->size);
- memcpy(p->store, tmp, used);
- p->csr = p->store + used;
+
+ if (p->store) {
+ memcpy(p->store, tmp, used);
+ p->csr = p->store + used;
+ }
+ else {
+ p->csr = p->store;
+ }
+
rtasm_exec_free(tmp);
}
+
+ if (p->store == NULL) {
+ p->store = p->csr = p->error_overflow;
+ p->size = 4;
+ }
}
/* Emit bytes to the instruction stream:
@@ -1440,12 +1455,17 @@ void x86_init_func_size( struct x86_function *p, unsigned code_size )
{
p->size = code_size;
p->store = rtasm_exec_malloc(code_size);
+ if (p->store == NULL) {
+ p->store = p->error_overflow;
+ }
p->csr = p->store;
}
void x86_release_func( struct x86_function *p )
{
- rtasm_exec_free(p->store);
+ if (p->store && p->store != p->error_overflow)
+ rtasm_exec_free(p->store);
+
p->store = NULL;
p->csr = NULL;
p->size = 0;
@@ -1456,7 +1476,11 @@ void (*x86_get_func( struct x86_function *p ))(void)
{
if (DISASSEM && p->store)
debug_printf("disassemble %p %p\n", p->store, p->csr);
- return (void (*)(void)) p->store;
+
+ if (p->store == p->error_overflow)
+ return (void (*)(void)) NULL;
+ else
+ return (void (*)(void)) p->store;
}
#else
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
index 5e99ceea706..695a1cef4e3 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
@@ -43,6 +43,7 @@ struct x86_function {
unsigned char *csr;
unsigned stack_offset;
int need_emms;
+ unsigned char error_overflow[4];
const char *fn;
};