source: webkit/trunk/JavaScriptCore/VM/Opcode.h@ 34842

Last change on this file since 34842 was 34842, checked in by [email protected], 17 years ago

Bug 18626: SQUIRRELFISH: support the "slow script" dialog <https://bugs.webkit.org/show_bug.cgi?id=18626>
<rdar://problem/5973931> Slow script dialog needs to be reimplemented for squirrelfish

Reviewed by Sam

Adds support for the slow script dialog in squirrelfish. This requires the addition
of three new op codes, op_loop, op_loop_if_true, and op_loop_if_less which have the
same behaviour as their simple jump equivalents but have an additional time out check.

Additional assertions were added to other jump instructions to prevent accidentally
creating loops with jump types that do not support time out checks.

Sunspider does not report a regression, however this appears very sensitive to code
layout and hardware, so i would expect up to a 1% regression on other systems.

Part of this required moving the old timeout logic from JSGlobalObject and into Machine
which is the cause of a number of the larger diff blocks.

File size: 4.8 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Cameron Zwarich <[email protected]>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef Opcodes_h
31#define Opcodes_h
32
33#include <wtf/Assertions.h>
34
35namespace KJS {
36
37#define DUMP_OPCODE_STATS 0
38
39 #define FOR_EACH_OPCODE_ID(macro) \
40 macro(op_load) \
41 macro(op_new_object) \
42 macro(op_new_array) \
43 macro(op_new_regexp) \
44 macro(op_mov) \
45 \
46 macro(op_not) \
47 macro(op_eq) \
48 macro(op_neq) \
49 macro(op_stricteq) \
50 macro(op_nstricteq) \
51 macro(op_less) \
52 macro(op_lesseq) \
53 \
54 macro(op_pre_inc) \
55 macro(op_pre_dec) \
56 macro(op_post_inc) \
57 macro(op_post_dec) \
58 macro(op_to_jsnumber) \
59 macro(op_negate) \
60 macro(op_add) \
61 macro(op_mul) \
62 macro(op_div) \
63 macro(op_mod) \
64 macro(op_sub) \
65 \
66 macro(op_lshift) \
67 macro(op_rshift) \
68 macro(op_urshift) \
69 macro(op_bitand) \
70 macro(op_bitxor) \
71 macro(op_bitor) \
72 macro(op_bitnot) \
73 \
74 macro(op_instanceof) \
75 macro(op_typeof) \
76 macro(op_in) \
77 \
78 macro(op_resolve) \
79 macro(op_resolve_skip) \
80 macro(op_get_scoped_var) \
81 macro(op_put_scoped_var) \
82 macro(op_resolve_base) \
83 macro(op_resolve_with_base) \
84 macro(op_resolve_func) \
85 macro(op_get_by_id) \
86 macro(op_put_by_id) \
87 macro(op_del_by_id) \
88 macro(op_get_by_val) \
89 macro(op_put_by_val) \
90 macro(op_del_by_val) \
91 macro(op_put_by_index) \
92 macro(op_put_getter) \
93 macro(op_put_setter) \
94 \
95 macro(op_jmp) \
96 macro(op_jtrue) \
97 macro(op_jfalse) \
98 macro(op_jless) \
99 macro(op_jmp_scopes) \
100 macro(op_loop) \
101 macro(op_loop_if_true) \
102 macro(op_loop_if_less) \
103 \
104 macro(op_new_func) \
105 macro(op_new_func_exp) \
106 macro(op_call) \
107 macro(op_call_eval) \
108 macro(op_ret) \
109 \
110 macro(op_construct) \
111 \
112 macro(op_get_pnames) \
113 macro(op_next_pname) \
114 \
115 macro(op_push_scope) \
116 macro(op_pop_scope) \
117 \
118 macro(op_catch) \
119 macro(op_throw) \
120 macro(op_new_error) \
121 \
122 macro(op_jsr) \
123 macro(op_sret) \
124 \
125 macro(op_debug) \
126 \
127 macro(op_end) // end must be the last opcode in the list
128
129 #define OPCODE_ID_ENUM(opcode) opcode,
130 typedef enum { FOR_EACH_OPCODE_ID(OPCODE_ID_ENUM) } OpcodeID;
131 #undef OPCODE_ID_ENUM
132
133 const int numOpcodeIDs = op_end + 1;
134
135 #define VERIFY_OPCODE_ID(id) COMPILE_ASSERT(id <= op_end, ASSERT_THAT_JS_OPCODE_IDS_ARE_VALID);
136 FOR_EACH_OPCODE_ID(VERIFY_OPCODE_ID);
137 #undef VERIFY_OPCODE_ID
138
139#if HAVE(COMPUTED_GOTO)
140 typedef void* Opcode;
141#else
142 typedef OpcodeID Opcode;
143#endif
144
145#if DUMP_OPCODE_STATS
146
147 struct OpcodeStats {
148 OpcodeStats();
149 ~OpcodeStats();
150 static long long opcodeCounts[numOpcodeIDs];
151 static long long opcodePairCounts[numOpcodeIDs][numOpcodeIDs];
152 static int lastOpcode;
153
154 static void recordInstruction(int opcode);
155 static void resetLastInstruction();
156 };
157
158#endif
159
160} // namespace KJS
161
162#endif // Opcodes_h
Note: See TracBrowser for help on using the repository browser.