forked from parrot/parrot
/
runops_cores.c
97 lines (82 loc) · 2.15 KB
/
runops_cores.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* runops_cores.c
* Copyright: (When this is determined...it will go here)
* CVS Info
* $Id$
* Overview:
* The switchable runops cores.
* Data Structure and Algorithms:
* History:
* Notes:
* References:
*/
#include "parrot/runops_cores.h"
#include "parrot/trace.h"
#include "parrot/interp_guts.h"
#ifdef HAVE_COMPUTED_GOTO
# include "parrot/oplib/core_ops_cg.h"
#endif
/*=for api interpreter runops_fast_core
* run parrot operations until the program is complete
*
* No bounds checking.
* No profiling.
* No tracing.
*/
opcode_t *
runops_fast_core(struct Parrot_Interp *interpreter, opcode_t *pc)
{
#ifdef HAVE_COMPUTED_GOTO
pc = cg_core(pc, interpreter);
#else
while (pc) {
DO_OP(pc, interpreter);
}
#endif
return pc;
}
/*=for api interpreter runops_slow_core
*
* With tracing.
* With profiling.
* With bounds checking.
*/
opcode_t *
runops_slow_core(struct Parrot_Interp *interpreter, opcode_t *pc)
{
opcode_t *code_start;
INTVAL code_size; /* in opcodes */
opcode_t *code_end;
opcode_t *lastpc = NULL;
FLOATVAL starttime = 0;
code_start = interpreter->code->byte_code;
code_size = interpreter->code->byte_code_size / sizeof(opcode_t);
code_end = interpreter->code->byte_code + code_size;
if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) {
trace_op(interpreter, code_start, code_end, pc);
}
while (pc && pc >= code_start && pc < code_end) {
if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
interpreter->profile[*pc].numcalls++;
lastpc = pc;
starttime = Parrot_floatval_time();
}
DO_OP(pc, interpreter);
if (Interp_flags_TEST(interpreter, PARROT_TRACE_FLAG)) {
trace_op(interpreter, code_start, code_end, pc);
}
if (Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
interpreter->profile[*lastpc].time +=
Parrot_floatval_time() - starttime;
}
}
return pc;
}
/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/