From 8069c2a10dab777cd0abc331c9aa5f836969ac0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Sat, 2 Nov 2002 16:43:45 +0100 Subject: [PATCH] Added support for OPCODE{0,1,2}_{,TAIL}BRANCH(). Rev: src/interpret_functions.h:1.112 Rev: src/interpreter.h:1.79 Rev: src/opcodes.h:1.31 --- src/interpret_functions.h | 21 +++++++++++++++++++-- src/interpreter.h | 21 ++++++++++++++++++++- src/opcodes.h | 36 ++++++++++++++++++++++++------------ 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/src/interpret_functions.h b/src/interpret_functions.h index 2917206eb0..9a963175fc 100644 --- a/src/interpret_functions.h +++ b/src/interpret_functions.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: interpret_functions.h,v 1.111 2002/10/28 13:01:31 nilsson Exp $ +|| $Id: interpret_functions.h,v 1.112 2002/11/02 15:43:45 grubba Exp $ */ /* @@ -52,6 +52,12 @@ #define OPCODE0_TAILRETURN(A, B, F, C) OPCODE0_TAILRETURN(A, B, F) --- C #define OPCODE1_TAILRETURN(A, B, F, C) OPCODE1_TAILRETURN(A, B, F) --- C #define OPCODE2_TAILRETURN(A, B, F, C) OPCODE2_TAILRETURN(A, B, F) --- C +#define OPCODE0_BRANCH(A, B, F, C) OPCODE0_BRANCH(A, B, F) --- C +#define OPCODE1_BRANCH(A, B, F, C) OPCODE1_BRANCH(A, B, F) --- C +#define OPCODE2_BRANCH(A, B, F, C) OPCODE2_BRANCH(A, B, F) --- C +#define OPCODE0_TAILBRANCH(A, B, F, C) OPCODE0_TAILBRANCH(A, B, F) --- C +#define OPCODE1_TAILBRANCH(A, B, F, C) OPCODE1_TAILBRANCH(A, B, F) --- C +#define OPCODE2_TAILBRANCH(A, B, F, C) OPCODE2_TAILBRANCH(A, B, F) --- C #endif /* GEN_PROTOS */ @@ -69,6 +75,16 @@ #define INTER_RETURN return -1 #endif +/* BRANCH opcodes use these two to indicate whether the + * branch should be taken or not. + */ +#ifndef DO_BRANCH +#define DO_BRANCH DOJUMP +#endif +#ifndef DONT_BRANCH +#define DONT_BRANCH SKIPJUMP +#endif + #ifndef OVERRIDE_JUMPS #undef GET_JUMP @@ -1159,10 +1175,11 @@ OPCODE0_JUMP(F_CATCH, "catch", 0, { /* There was a return inside the evaluated code */ DO_DUMB_RETURN; case 2: + /* Escape catch, continue after the escape instruction. */ DO_JUMP_TO(Pike_fp->pc); break; default: - DO_JUMP_TO(PROG_COUNTER + GET_JUMP()); + DOJUMP(); } /* NOT_REACHED */ }); diff --git a/src/interpreter.h b/src/interpreter.h index a40ada534f..bfc5be41bb 100644 --- a/src/interpreter.h +++ b/src/interpreter.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: interpreter.h,v 1.78 2002/10/11 01:39:32 nilsson Exp $ +|| $Id: interpreter.h,v 1.79 2002/11/02 15:34:35 grubba Exp $ */ #undef LOW_GET_ARG @@ -315,6 +315,13 @@ static int eval_instruction(PIKE_OPCODE_T *pc) #define OPCODE1_TAILJUMP(OP, DESC, FLAGS, CODE) CASE(OP); CODE #define OPCODE2_TAILJUMP(OP, DESC, FLAGS, CODE) CASE(OP); CODE +#define OPCODE0_BRANCH OPCODE0_JUMP +#define OPCODE1_BRANCH OPCODE1_JUMP +#define OPCODE2_BRANCH OPCODE2_JUMP +#define OPCODE0_TAILBRANCH OPCODE0_TAILJUMP +#define OPCODE1_TAILBRANCH OPCODE1_TAILJUMP +#define OPCODE2_TAILBRANCH OPCODE2_TAILJUMP + #include "interpret_functions.h" #ifndef HAVE_COMPUTED_GOTO @@ -340,6 +347,18 @@ static int eval_instruction(PIKE_OPCODE_T *pc) #undef OPCODE0_TAILJUMP #undef OPCODE1_TAILJUMP #undef OPCODE2_TAILJUMP +#undef OPCODE0_RETURN +#undef OPCODE1_RETURN +#undef OPCODE2_RETURN +#undef OPCODE0_TAILRETURN +#undef OPCODE1_TAILRETURN +#undef OPCODE2_TAILRETURN +#undef OPCODE0_BRANCH +#undef OPCODE1_BRANCH +#undef OPCODE2_BRANCH +#undef OPCODE0_TAILBRANCH +#undef OPCODE1_TAILBRANCH +#undef OPCODE2_TAILBRANCH #undef LABEL #define LABEL(OP) &&PIKE_CONCAT(LABEL_,OP) #define NULL_LABEL(OP) NULL diff --git a/src/opcodes.h b/src/opcodes.h index da7573029a..ee3d1e837a 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.30 2002/10/11 01:39:34 nilsson Exp $ +|| $Id: opcodes.h,v 1.31 2002/11/02 15:29:34 grubba Exp $ */ #ifndef OPCODES_H @@ -10,10 +10,6 @@ /* Opcodes */ -/* - * These values are used by the stack machine, and can not be directly - * called from Pike. - */ #define OPCODE0(X,Y,F) X, #define OPCODE1(X,Y,F) X, #define OPCODE2(X,Y,F) X, @@ -32,9 +28,19 @@ #define OPCODE0_TAILRETURN(X,Y,F) X, #define OPCODE1_TAILRETURN(X,Y,F) X, #define OPCODE2_TAILRETURN(X,Y,F) X, +#define OPCODE0_BRANCH(X,Y,F) X, +#define OPCODE1_BRANCH(X,Y,F) X, +#define OPCODE2_BRANCH(X,Y,F) X, +#define OPCODE0_TAILBRANCH(X,Y,F) X, +#define OPCODE1_TAILBRANCH(X,Y,F) X, +#define OPCODE2_TAILBRANCH(X,Y,F) X, enum Pike_opcodes { + /* + * These values are used by the stack machine, and can not be directly + * called from Pike. + */ F_OFFSET = 257, F_PREFIX_256, F_PREFIX_512, @@ -51,19 +57,19 @@ enum Pike_opcodes F_PREFIX2_WORDX256, F_PREFIX2_24BITX256, -/* - * These are the predefined functions that can be accessed from Pike. - */ + /* + * These are the predefined functions that can be accessed from Pike. + */ #include "interpret_protos.h" /* Used to mark an entry point from eval_instruction(). */ F_ENTRY, -/* - * These are token values that needn't have an associated code for the - * compiled file - */ + /* + * These are token values that needn't have an associated code for the + * compiled file + */ F_MAX_OPCODE, F_ADD_EQ, @@ -127,6 +133,12 @@ enum Pike_opcodes #undef OPCODE0_TAILRETURN #undef OPCODE1_TAILRETURN #undef OPCODE2_TAILRETURN +#undef OPCODE0_BRANCH +#undef OPCODE1_BRANCH +#undef OPCODE2_BRANCH +#undef OPCODE0_TAILBRANCH +#undef OPCODE1_TAILBRANCH +#undef OPCODE2_TAILBRANCH /* Prototypes begin here */ -- GitLab