~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to vm.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  vm.h -
4
4
 
5
5
  $Author: ko1 $
6
 
  $Date: 2007-05-21 13:46:51 +0900 (月, 21  5月 2007) $
 
6
  $Date: 2007-08-13 04:09:15 +0900 (月, 13  8月 2007) $
7
7
  created at: 04/01/01 16:56:59 JST
8
8
 
9
9
  Copyright (C) 2004-2006 Koichi Sasada
10
10
 
11
11
**********************************************************************/
12
12
 
13
 
#ifndef _VM_H_INCLUDED_
14
 
#define _VM_H_INCLUDED_
15
 
 
16
 
 
17
 
#if YARVDEBUG > VMDEBUG
18
 
#undef  VMDEBUG
19
 
#define VMDEBUG YARVDEBUG
20
 
#endif
 
13
#ifndef RUBY_VM_H
 
14
#define RUBY_VM_H
21
15
 
22
16
typedef long OFFSET;
 
17
typedef unsigned long rb_num_t;
 
18
typedef unsigned long lindex_t;
 
19
typedef unsigned long dindex_t;
 
20
typedef rb_num_t GENTRY;
 
21
typedef rb_iseq_t *ISEQ;
 
22
 
 
23
extern VALUE rb_cEnv;
 
24
extern VALUE ruby_vm_global_state_version;
 
25
extern VALUE ruby_vm_redefined_flag;
 
26
 
23
27
 
24
28
/**
25
29
 * VM Debug Level
27
31
 * debug level:
28
32
 *  0: no debug output
29
33
 *  1: show instruction name
30
 
 *  2:
 
34
 *  2: show stack frame when control stack frame is changed
31
35
 *  3: show stack status
32
36
 *  4: show register
33
37
 *  5:
34
38
 * 10: gc check
35
39
 */
36
40
 
 
41
 
 
42
#ifndef VMDEBUG
 
43
#define VMDEBUG 0
 
44
#endif
 
45
 
37
46
#if 0
38
47
#undef  VMDEBUG
39
48
#define VMDEBUG 3
44
53
#define USAGE_ANALYSIS_OPERAND(insn, n, op) vm_analysis_operand(insn, n, (VALUE)op)
45
54
#define USAGE_ANALYSIS_REGISTER(reg, s)     vm_analysis_register(reg, s)
46
55
#else
47
 
#define USAGE_ANALYSIS_INSN(insn)       /* none */
 
56
#define USAGE_ANALYSIS_INSN(insn)               /* none */
48
57
#define USAGE_ANALYSIS_OPERAND(insn, n, op)     /* none */
49
 
#define USAGE_ANALYSIS_REGISTER(reg, s) /* none */
 
58
#define USAGE_ANALYSIS_REGISTER(reg, s)         /* none */
50
59
#endif
51
60
 
52
61
#ifdef __GCC__
89
98
/************************************************/
90
99
#elif OPT_CALL_THREADED_CODE
91
100
 
92
 
#if __GCC__
93
 
#define FASTCALL __attribute__ ((fastcall))
94
 
#else
95
 
#define FASTCALL
96
 
#endif
97
 
 
98
 
 
99
101
#define LABEL(x)  insn_func_##x
100
102
#define ELABEL(x)
101
103
#define LABEL_PTR(x) &LABEL(x)
102
104
 
103
 
typedef rb_control_frame_t *
104
 
    (*insn_func_type) (rb_thread_t *, rb_control_frame_t *)FASTCALL;
105
 
 
106
105
#define INSN_ENTRY(insn) \
107
 
  rb_control_frame_t * \
108
 
    LABEL(insn)(rb_thread_t *th, rb_control_frame_t *reg_cfp) FASTCALL {
 
106
  static rb_control_frame_t * \
 
107
    FUNC_FASTCALL(LABEL(insn))(rb_thread_t *th, rb_control_frame_t *reg_cfp) {
109
108
 
110
109
#define END_INSN(insn) return reg_cfp;}
111
110
 
167
166
#endif /* DISPATCH_DIRECT_THREADED_CODE */
168
167
 
169
168
#define END_INSN(insn)      \
170
 
  GC_CHECK();               \
171
169
  DEBUG_END_INSN();         \
172
170
  TC_DISPATCH(insn);        \
173
171
 
189
187
case BIN(insn):
190
188
 
191
189
#define END_INSN(insn)                        \
192
 
  GC_CHECK();                                 \
193
190
  DEBUG_END_INSN();                           \
194
191
  break;
195
192
 
213
210
/************************************************/
214
211
/************************************************/
215
212
 
 
213
#define VM_CFP_CNT(th, cfp) \
 
214
  ((rb_control_frame_t *)(th->stack + th->stack_size) - (rb_control_frame_t *)(cfp))
 
215
#define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
 
216
 
 
217
#define CHECK_STACK_OVERFLOW(cfp, margin) do \
 
218
  if (((VALUE *)(cfp)->sp) + (margin) >= ((VALUE *)cfp)) { \
 
219
      rb_exc_raise(sysstack_error); \
 
220
  } \
 
221
while (0)
 
222
 
216
223
/*
217
224
  env{
218
225
    env[0] // special (block or prev env)
219
 
    env[1] // orphan
220
 
    env[2] // in heap
221
 
    env[3] // env object
222
 
    env[4] // prev env val
 
226
    env[1] // env object
 
227
    env[2] // prev env val
223
228
  };
224
229
 */
225
230
 
226
 
#define ORPHAN_ENV_P(env)   ((env)[1] == Qundef)
227
 
#define ENV_IN_HEAP_P(env)  ((env)[2] == Qundef)
228
 
#define ENV_VAL(env)        ((env)[3])
229
 
 
230
 
#define FRAME_MAGIC_METHOD 0xfaffff11
231
 
#define FRAME_MAGIC_BLOCK  0xfaffff21
232
 
#define FRAME_MAGIC_CLASS  0xfaffff31
233
 
#define FRAME_MAGIC_TOP    0xfaffff41
234
 
#define FRAME_MAGIC_FINISH 0xfaffff51
235
 
#define FRAME_MAGIC_CFUNC  0xfaffff61
236
 
#define FRAME_MAGIC_PROC   0xfaffff71
237
 
#define FRAME_MAGIC_IFUNC  0xfaffff81
238
 
#define FRAME_MAGIC_EVAL   0xfaffff91
239
 
#define FRAME_MAGIC_LAMBDA 0xfaffffa1
240
 
 
241
 
#define CHECK_FRAME_MAGIC(magic)                   \
242
 
{                                                  \
243
 
  if((magic & 0xffffff00) != 0xfaffff00){          \
244
 
    rb_bug("YARV Stack frame error: %08x", magic); \
245
 
  }                                                \
246
 
}
 
231
#define ENV_IN_HEAP_P(th, env)  \
 
232
  (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
 
233
#define ENV_VAL(env)        ((env)[1])
 
234
 
 
235
#define FRAME_MAGIC_METHOD 0x11
 
236
#define FRAME_MAGIC_BLOCK  0x21
 
237
#define FRAME_MAGIC_CLASS  0x31
 
238
#define FRAME_MAGIC_TOP    0x41
 
239
#define FRAME_MAGIC_FINISH 0x51
 
240
#define FRAME_MAGIC_CFUNC  0x61
 
241
#define FRAME_MAGIC_PROC   0x71
 
242
#define FRAME_MAGIC_IFUNC  0x81
 
243
#define FRAME_MAGIC_EVAL   0x91
 
244
#define FRAME_MAGIC_LAMBDA 0xa1
 
245
#define FRAME_MAGIC_MASK   0xff
 
246
 
 
247
#define VM_FRAME_FLAG(type) ((VALUE)((type) & FRAME_MAGIC_MASK))
 
248
 
 
249
#define VM_FRAME_TYPE(cfp) \
 
250
  ((cfp)->flag & FRAME_MAGIC_MASK)
247
251
 
248
252
#define RUBYVM_CFUNC_FRAME_P(cfp) \
249
 
  ((cfp)->magic == FRAME_MAGIC_CFUNC)
 
253
  (VM_FRAME_TYPE(cfp) == FRAME_MAGIC_CFUNC)
250
254
 
251
255
/*
252
256
 * Excception
262
266
#define SET_THROWOBJ_STATE(obj, val) \
263
267
  (RNODE((obj))->u3.value = (val))
264
268
 
 
269
#if OPT_CALL_THREADED_CODE
 
270
#define THROW_EXCEPTION(exc) do { \
 
271
    th->errinfo = (VALUE)(exc); \
 
272
    return 0; \
 
273
} while (0)
 
274
#else
 
275
#define THROW_EXCEPTION(exc) return (VALUE)(exc)
 
276
#endif
 
277
 
265
278
#define SCREG(r) (reg_##r)
266
279
 
267
280
/* VM state version */
268
281
 
269
 
#define GET_VM_STATE_VERSION() (vm_global_state_version)
 
282
#define GET_VM_STATE_VERSION() (ruby_vm_global_state_version)
270
283
#define INC_VM_STATE_VERSION() \
271
 
  (vm_global_state_version = (vm_global_state_version+1) & 0x8fffffff)
 
284
  (ruby_vm_global_state_version = (ruby_vm_global_state_version+1) & 0x8fffffff)
272
285
 
273
286
#define BOP_PLUS     0x01
274
287
#define BOP_MINUS    0x02
286
299
#define BOP_GT     0x2000
287
300
#define BOP_GE     0x4000
288
301
 
289
 
#endif /* _VM_H_INCLUDED_ */
 
302
#endif /* RUBY_VM_H */