diff --git a/src/encode.c b/src/encode.c index a4531c443dcd4e310e69d4966e55a987636e2428..104d651ba2dfafb8c87ba82211652402f1d8efa8 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: encode.c,v 1.199 2003/11/15 17:25:05 mast Exp $ +|| $Id: encode.c,v 1.200 2003/11/17 14:39:47 grubba Exp $ */ #include "global.h" @@ -29,8 +29,9 @@ #include "bignum.h" #include "pikecode.h" #include "pike_types.h" +#include "opcodes.h" -RCSID("$Id: encode.c,v 1.199 2003/11/15 17:25:05 mast Exp $"); +RCSID("$Id: encode.c,v 1.200 2003/11/17 14:39:47 grubba Exp $"); /* #define ENCODE_DEBUG */ @@ -1193,6 +1194,11 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc */ code_number(PIKE_BYTECODE_METHOD, data); +#ifdef PIKE_USE_MACHINE_CODE + /* Add the checksum of the instrs array. */ + code_number(instrs_checksum, data); +#endif /* PIKE_USE_MACHINE_CODE */ + /* program */ #ifdef ENCODE_PROGRAM #ifdef PIKE_DEBUG @@ -3359,6 +3365,18 @@ static void decode_value2(struct decode_data *data) Pike_error("Unsupported byte-code method: %d\n", bytecode_method); } +#ifdef PIKE_USE_MACHINE_CODE + { + size_t csum; + /* Check the checksum of the instrs array. */ + decode_number(csum, data); + if (csum != instrs_checksum) { + Pike_error("Bad instruction checksum: %d (expected %d)\n", + csum, instrs_checksum); + } + } +#endif /* PIKE_USE_MACHINE_CODE */ + /* Decode program */ if (data->ptr + (int)local_num_program >= data->len) { Pike_error("Failed to decode program. (string too short)\n"); diff --git a/src/opcodes.c b/src/opcodes.c index c7dc882b38505f531e9cdeb0f2266a192fe5ea77..749ccb96c98e1226c00e1140f69e151b9b4ab15f 100644 --- a/src/opcodes.c +++ b/src/opcodes.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: opcodes.c,v 1.158 2003/11/15 16:40:04 grubba Exp $ +|| $Id: opcodes.c,v 1.159 2003/11/17 14:39:47 grubba Exp $ */ #include "global.h" -RCSID("$Id: opcodes.c,v 1.158 2003/11/15 16:40:04 grubba Exp $"); +RCSID("$Id: opcodes.c,v 1.159 2003/11/17 14:39:47 grubba Exp $"); #include "constants.h" #include "interpret.h" #include "opcodes.h" @@ -292,6 +292,9 @@ struct keyword instr_names[]= }; struct instr instrs[F_MAX_INSTR - F_OFFSET]; +#ifdef PIKE_USE_MACHINE_CODE +size_t instrs_checksum; +#endif /* PIKE_USE_MACHINE_CODE */ char *low_get_f_name(int n, struct program *p) { @@ -397,6 +400,10 @@ void init_opcodes(void) #endif } +#ifdef PIKE_USE_MACHINE_CODE + instrs_checksum = hash_mem(instrs, sizeof(instrs), sizeof(instrs)); +#endif /* PIKE_USE_MACHINE_CODE */ + #ifdef PIKE_DEBUG for(i=1; i<F_MAX_OPCODE-F_OFFSET;i++) { diff --git a/src/opcodes.h b/src/opcodes.h index e5bea8a2d0fb84227d7adcc7367bf12e51ce56ae..c4cf51d5c0e75e92052ec134f93f360b8987a5b8 100644 --- a/src/opcodes.h +++ b/src/opcodes.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: opcodes.h,v 1.36 2003/11/14 10:12:29 mast Exp $ +|| $Id: opcodes.h,v 1.37 2003/11/17 14:39:48 grubba Exp $ */ #ifndef OPCODES_H @@ -124,6 +124,9 @@ struct hash_table; #endif extern struct instr instrs[]; +#ifdef PIKE_USE_MACHINE_CODE +extern size_t instrs_checksum; +#endif /* PIKE_USE_MACHINE_CODE */ /* Opcode enum */ diff --git a/src/version.h b/src/version.h index f25fb7507c220ed1af7aeb64d5281b5120ce2e14..d5c20d75b4b498fae51e77fedef050d66bf4b6bd 100644 --- a/src/version.h +++ b/src/version.h @@ -2,12 +2,12 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: version.h,v 1.344 2003/09/05 15:19:49 mast Exp $ +|| $Id: version.h,v 1.345 2003/11/17 14:39:47 grubba Exp $ */ #define PIKE_MAJOR_VERSION 7 #define PIKE_MINOR_VERSION 5 -#define PIKE_BUILD_VERSION 12 +#define PIKE_BUILD_VERSION 13 /* Prototypes begin here */ void f_version(INT32 args);