mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 | * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> |
| 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 | #include "config.h" |
| 31 | #include "CodeBlock.h" |
| 32 | |
ggaren@apple.com | cc0f1f1 | 2008-11-17 23:16:00 +0000 | [diff] [blame] | 33 | #include "JIT.h" |
darin@apple.com | 9ce7902 | 2008-06-28 15:50:49 +0000 | [diff] [blame] | 34 | #include "JSValue.h" |
ggaren@apple.com | 901a8a2 | 2008-11-17 20:57:18 +0000 | [diff] [blame] | 35 | #include "Interpreter.h" |
cwzwarich@webkit.org | a691b5a | 2008-10-31 05:56:58 +0000 | [diff] [blame] | 36 | #include "Debugger.h" |
ap@webkit.org | 72d005d | 2008-05-24 12:43:02 +0000 | [diff] [blame] | 37 | #include <stdio.h> |
aroben@apple.com | a2fd570 | 2008-09-02 15:15:21 +0000 | [diff] [blame] | 38 | #include <wtf/StringExtras.h> |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 39 | |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 40 | #define DUMP_CODE_BLOCK_STATISTICS 0 |
| 41 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 42 | namespace JSC { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 43 | |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 44 | #if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) |
cwzwarich@webkit.org | 217b540 | 2008-08-09 11:00:38 +0000 | [diff] [blame] | 45 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 46 | static UString escapeQuotes(const UString& str) |
| 47 | { |
| 48 | UString result = str; |
| 49 | int pos = 0; |
| 50 | while ((pos = result.find('\"', pos)) >= 0) { |
| 51 | result = result.substr(0, pos) + "\"\\\"\"" + result.substr(pos + 1); |
| 52 | pos += 4; |
| 53 | } |
| 54 | return result; |
| 55 | } |
| 56 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 57 | static UString valueToSourceString(ExecState* exec, JSValue* val) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 58 | { |
ggaren@apple.com | c6b3b60 | 2008-07-23 05:10:05 +0000 | [diff] [blame] | 59 | if (val->isString()) { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 60 | UString result("\""); |
ggaren@apple.com | c6b3b60 | 2008-07-23 05:10:05 +0000 | [diff] [blame] | 61 | result += escapeQuotes(val->toString(exec)) + "\""; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 62 | return result; |
| 63 | } |
| 64 | |
ggaren@apple.com | c6b3b60 | 2008-07-23 05:10:05 +0000 | [diff] [blame] | 65 | return val->toString(exec); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | static CString registerName(int r) |
| 69 | { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 70 | if (r == missingThisObjectMarker()) |
| 71 | return "<null>"; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 72 | |
ggaren@apple.com | 107bd0e | 2008-09-24 00:27:18 +0000 | [diff] [blame] | 73 | return (UString("r") + UString::from(r)).UTF8String(); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 74 | } |
| 75 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 76 | static CString constantName(ExecState* exec, int k, JSValue* value) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 77 | { |
| 78 | return (valueToSourceString(exec, value) + "(@k" + UString::from(k) + ")").UTF8String(); |
| 79 | } |
| 80 | |
| 81 | static CString idName(int id0, const Identifier& ident) |
| 82 | { |
| 83 | return (ident.ustring() + "(@id" + UString::from(id0) +")").UTF8String(); |
| 84 | } |
| 85 | |
| 86 | static UString regexpToSourceString(RegExp* regExp) |
| 87 | { |
| 88 | UString pattern = UString("/") + regExp->pattern() + "/"; |
| 89 | if (regExp->global()) |
| 90 | pattern += "g"; |
| 91 | if (regExp->ignoreCase()) |
| 92 | pattern += "i"; |
| 93 | if (regExp->multiline()) |
| 94 | pattern += "m"; |
| 95 | |
| 96 | return pattern; |
| 97 | } |
| 98 | |
| 99 | static CString regexpName(int re, RegExp* regexp) |
| 100 | { |
| 101 | return (regexpToSourceString(regexp) + "(@re" + UString::from(re) + ")").UTF8String(); |
| 102 | } |
| 103 | |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 104 | static UString pointerToSourceString(void* p) |
| 105 | { |
| 106 | char buffer[2 + 2 * sizeof(void*) + 1]; // 0x [two characters per byte] \0 |
| 107 | snprintf(buffer, sizeof(buffer), "%p", p); |
| 108 | return buffer; |
| 109 | } |
| 110 | |
ggaren@apple.com | d0740c8 | 2008-05-28 20:47:13 +0000 | [diff] [blame] | 111 | NEVER_INLINE static const char* debugHookName(int debugHookID) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 112 | { |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 113 | switch (static_cast<DebugHookID>(debugHookID)) { |
| 114 | case DidEnterCallFrame: |
| 115 | return "didEnterCallFrame"; |
| 116 | case WillLeaveCallFrame: |
| 117 | return "willLeaveCallFrame"; |
| 118 | case WillExecuteStatement: |
| 119 | return "willExecuteStatement"; |
| 120 | case WillExecuteProgram: |
| 121 | return "willExecuteProgram"; |
| 122 | case DidExecuteProgram: |
| 123 | return "didExecuteProgram"; |
| 124 | case DidReachBreakpoint: |
| 125 | return "didReachBreakpoint"; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 126 | } |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 127 | |
ggaren@apple.com | d0740c8 | 2008-05-28 20:47:13 +0000 | [diff] [blame] | 128 | ASSERT_NOT_REACHED(); |
| 129 | return ""; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 130 | } |
| 131 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 132 | static int locationForOffset(const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator& it, int offset) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 133 | { |
| 134 | return it - begin + offset; |
| 135 | } |
| 136 | |
| 137 | static void printUnaryOp(int location, Vector<Instruction>::const_iterator& it, const char* op) |
| 138 | { |
| 139 | int r0 = (++it)->u.operand; |
| 140 | int r1 = (++it)->u.operand; |
| 141 | |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 142 | printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | static void printBinaryOp(int location, Vector<Instruction>::const_iterator& it, const char* op) |
| 146 | { |
| 147 | int r0 = (++it)->u.operand; |
| 148 | int r1 = (++it)->u.operand; |
| 149 | int r2 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 150 | printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | static void printConditionalJump(const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator& it, int location, const char* op) |
| 154 | { |
| 155 | int r0 = (++it)->u.operand; |
| 156 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 157 | printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, locationForOffset(begin, it, offset)); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 158 | } |
| 159 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 160 | static void printGetByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& m_identifiers, const char* op) |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 161 | { |
| 162 | int r0 = (++it)->u.operand; |
| 163 | int r1 = (++it)->u.operand; |
| 164 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 165 | printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 166 | it += 4; |
| 167 | } |
| 168 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 169 | static void printPutByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& m_identifiers, const char* op) |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 170 | { |
| 171 | int r0 = (++it)->u.operand; |
| 172 | int id0 = (++it)->u.operand; |
| 173 | int r1 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 174 | printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 175 | it += 4; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 176 | } |
| 177 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 178 | void CodeBlock::printStructure(const char* name, const Instruction* vPC, int operand) const |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 179 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 180 | unsigned instructionOffset = vPC - m_instructions.begin(); |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 181 | printf(" [%4d] %s: %s\n", instructionOffset, name, pointerToSourceString(vPC[operand].u.structure).UTF8String().c_str()); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 182 | } |
| 183 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 184 | void CodeBlock::printStructures(const Instruction* vPC) const |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 185 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 186 | Interpreter* interpreter = m_globalData->interpreter; |
| 187 | unsigned instructionOffset = vPC - m_instructions.begin(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 188 | |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 189 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 190 | printStructure("get_by_id", vPC, 4); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 191 | return; |
| 192 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 193 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 194 | printStructure("get_by_id_self", vPC, 4); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 195 | return; |
| 196 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 197 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 198 | printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structure).UTF8String().c_str()); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 199 | return; |
| 200 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 201 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 202 | printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_new", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[6].u.structureChain).UTF8String().c_str()); |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 203 | return; |
| 204 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 205 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 206 | printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structureChain).UTF8String().c_str()); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 207 | return; |
| 208 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 209 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 210 | printStructure("put_by_id", vPC, 4); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 211 | return; |
| 212 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 213 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 214 | printStructure("put_by_id_replace", vPC, 4); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 215 | return; |
| 216 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 217 | if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 218 | printStructure("resolve_global", vPC, 4); |
oliver@apple.com | 70579b5 | 2008-09-16 05:53:15 +0000 | [diff] [blame] | 219 | return; |
| 220 | } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 221 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 222 | // These m_instructions doesn't ref Structures. |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 223 | ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_call) || vPC[0].u.opcode == interpreter->getOpcode(op_call_eval) || vPC[0].u.opcode == interpreter->getOpcode(op_construct)); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 224 | } |
| 225 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 226 | void CodeBlock::dump(ExecState* exec) const |
| 227 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 228 | Vector<Instruction>::const_iterator begin = m_instructions.begin(); |
| 229 | Vector<Instruction>::const_iterator end = m_instructions.end(); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 230 | |
| 231 | size_t instructionCount = 0; |
| 232 | for (Vector<Instruction>::const_iterator it = begin; it != end; ++it) |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 233 | if (exec->interpreter()->isOpcode(it->u.opcode)) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 234 | ++instructionCount; |
| 235 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 236 | printf("%lu m_instructions; %lu bytes at %p; %d parameter(s); %d callee register(s)\n\n", |
darin@apple.com | 1ac13a6 | 2008-06-11 22:01:40 +0000 | [diff] [blame] | 237 | static_cast<unsigned long>(instructionCount), |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 238 | static_cast<unsigned long>(m_instructions.size() * sizeof(Instruction)), |
| 239 | this, m_numParameters, m_numCalleeRegisters); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 240 | |
| 241 | for (Vector<Instruction>::const_iterator it = begin; it != end; ++it) |
| 242 | dump(exec, begin, it); |
| 243 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 244 | if (!m_identifiers.isEmpty()) { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 245 | printf("\nIdentifiers:\n"); |
| 246 | size_t i = 0; |
| 247 | do { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 248 | printf(" id%u = %s\n", static_cast<unsigned>(i), m_identifiers[i].ascii()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 249 | ++i; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 250 | } while (i != m_identifiers.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 251 | } |
| 252 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 253 | if (!m_constantRegisters.isEmpty()) { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 254 | printf("\nConstants:\n"); |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 255 | unsigned registerIndex = m_numVars; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 256 | size_t i = 0; |
| 257 | do { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 258 | printf(" r%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue(exec)).ascii()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 259 | ++i; |
ggaren@apple.com | 6345f8b | 2008-10-29 00:11:21 +0000 | [diff] [blame] | 260 | ++registerIndex; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 261 | } while (i < m_constantRegisters.size()); |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 262 | } |
| 263 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 264 | if (m_rareData && !m_rareData->m_unexpectedConstants.isEmpty()) { |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 265 | printf("\nUnexpected Constants:\n"); |
| 266 | size_t i = 0; |
| 267 | do { |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 268 | printf(" k%u = %s\n", static_cast<unsigned>(i), valueToSourceString(exec, m_rareData->m_unexpectedConstants[i]).ascii()); |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 269 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 270 | } while (i < m_rareData->m_unexpectedConstants.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 271 | } |
| 272 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 273 | if (m_rareData && !m_rareData->m_regexps.isEmpty()) { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 274 | printf("\nm_regexps:\n"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 275 | size_t i = 0; |
| 276 | do { |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 277 | printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).ascii()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 278 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 279 | } while (i < m_rareData->m_regexps.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 280 | } |
| 281 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 282 | if (!m_globalResolveInstructions.isEmpty() || !m_propertyAccessInstructions.isEmpty()) |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 283 | printf("\nStructures:\n"); |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 284 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 285 | if (!m_globalResolveInstructions.isEmpty()) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 286 | size_t i = 0; |
| 287 | do { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 288 | printStructures(&m_instructions[m_globalResolveInstructions[i]]); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 289 | ++i; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 290 | } while (i < m_globalResolveInstructions.size()); |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 291 | } |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 292 | if (!m_propertyAccessInstructions.isEmpty()) { |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 293 | size_t i = 0; |
| 294 | do { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 295 | printStructures(&m_instructions[m_propertyAccessInstructions[i].bytecodeIndex]); |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 296 | ++i; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 297 | } while (i < m_propertyAccessInstructions.size()); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 298 | } |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 299 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 300 | if (m_rareData && !m_rareData->m_exceptionHandlers.isEmpty()) { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 301 | printf("\nException Handlers:\n"); |
| 302 | unsigned i = 0; |
| 303 | do { |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 304 | printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] }\n", i + 1, m_rareData->m_exceptionHandlers[i].start, m_rareData->m_exceptionHandlers[i].end, m_rareData->m_exceptionHandlers[i].target); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 305 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 306 | } while (i < m_rareData->m_exceptionHandlers.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 307 | } |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 308 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 309 | if (m_rareData && !m_rareData->m_immediateSwitchJumpTables.isEmpty()) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 310 | printf("Immediate Switch Jump Tables:\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 311 | unsigned i = 0; |
| 312 | do { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 313 | printf(" %1d = {\n", i); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 314 | int entry = 0; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 315 | Vector<int32_t>::const_iterator end = m_rareData->m_immediateSwitchJumpTables[i].branchOffsets.end(); |
| 316 | for (Vector<int32_t>::const_iterator iter = m_rareData->m_immediateSwitchJumpTables[i].branchOffsets.begin(); iter != end; ++iter, ++entry) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 317 | if (!*iter) |
| 318 | continue; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 319 | printf("\t\t%4d => %04d\n", entry + m_rareData->m_immediateSwitchJumpTables[i].min, *iter); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 320 | } |
| 321 | printf(" }\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 322 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 323 | } while (i < m_rareData->m_immediateSwitchJumpTables.size()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 324 | } |
| 325 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 326 | if (m_rareData && !m_rareData->m_characterSwitchJumpTables.isEmpty()) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 327 | printf("\nCharacter Switch Jump Tables:\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 328 | unsigned i = 0; |
| 329 | do { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 330 | printf(" %1d = {\n", i); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 331 | int entry = 0; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 332 | Vector<int32_t>::const_iterator end = m_rareData->m_characterSwitchJumpTables[i].branchOffsets.end(); |
| 333 | for (Vector<int32_t>::const_iterator iter = m_rareData->m_characterSwitchJumpTables[i].branchOffsets.begin(); iter != end; ++iter, ++entry) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 334 | if (!*iter) |
| 335 | continue; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 336 | ASSERT(!((i + m_rareData->m_characterSwitchJumpTables[i].min) & ~0xFFFF)); |
| 337 | UChar ch = static_cast<UChar>(entry + m_rareData->m_characterSwitchJumpTables[i].min); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 338 | printf("\t\t\"%s\" => %04d\n", UString(&ch, 1).ascii(), *iter); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 339 | } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 340 | printf(" }\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 341 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 342 | } while (i < m_rareData->m_characterSwitchJumpTables.size()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 343 | } |
| 344 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 345 | if (m_rareData && !m_rareData->m_stringSwitchJumpTables.isEmpty()) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 346 | printf("\nString Switch Jump Tables:\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 347 | unsigned i = 0; |
| 348 | do { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 349 | printf(" %1d = {\n", i); |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 350 | StringJumpTable::StringOffsetTable::const_iterator end = m_rareData->m_stringSwitchJumpTables[i].offsetTable.end(); |
| 351 | for (StringJumpTable::StringOffsetTable::const_iterator iter = m_rareData->m_stringSwitchJumpTables[i].offsetTable.begin(); iter != end; ++iter) |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 352 | printf("\t\t\"%s\" => %04d\n", UString(iter->first).ascii(), iter->second.branchOffset); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 353 | printf(" }\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 354 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 355 | } while (i < m_rareData->m_stringSwitchJumpTables.size()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 356 | } |
| 357 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 358 | printf("\n"); |
| 359 | } |
| 360 | |
| 361 | void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator& it) const |
| 362 | { |
| 363 | int location = it - begin; |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 364 | switch (exec->interpreter()->getOpcodeID(it->u.opcode)) { |
mjs@apple.com | 8b246d6 | 2008-10-04 07:15:33 +0000 | [diff] [blame] | 365 | case op_enter: { |
| 366 | printf("[%4d] enter\n", location); |
oliver@apple.com | ecfd224 | 2008-09-20 03:00:43 +0000 | [diff] [blame] | 367 | break; |
| 368 | } |
mjs@apple.com | 8b246d6 | 2008-10-04 07:15:33 +0000 | [diff] [blame] | 369 | case op_enter_with_activation: { |
cwzwarich@webkit.org | 5f5bc9e | 2008-10-07 03:53:47 +0000 | [diff] [blame] | 370 | int r0 = (++it)->u.operand; |
| 371 | printf("[%4d] enter_with_activation %s\n", location, registerName(r0).c_str()); |
ggaren@apple.com | a54a889 | 2008-09-26 22:40:26 +0000 | [diff] [blame] | 372 | break; |
| 373 | } |
cwzwarich@webkit.org | 2f316b4 | 2008-10-04 20:32:21 +0000 | [diff] [blame] | 374 | case op_create_arguments: { |
| 375 | printf("[%4d] create_arguments\n", location); |
cwzwarich@webkit.org | 9e464ca | 2008-09-29 03:04:08 +0000 | [diff] [blame] | 376 | break; |
| 377 | } |
mjs@apple.com | 8b246d6 | 2008-10-04 07:15:33 +0000 | [diff] [blame] | 378 | case op_convert_this: { |
| 379 | int r0 = (++it)->u.operand; |
| 380 | printf("[%4d] convert_this %s\n", location, registerName(r0).c_str()); |
| 381 | break; |
| 382 | } |
cwzwarich@webkit.org | ef62755 | 2008-08-09 03:56:46 +0000 | [diff] [blame] | 383 | case op_unexpected_load: { |
| 384 | int r0 = (++it)->u.operand; |
| 385 | int k0 = (++it)->u.operand; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 386 | printf("[%4d] unexpected_load\t %s, %s\n", location, registerName(r0).c_str(), constantName(exec, k0, unexpectedConstant(k0)).c_str()); |
cwzwarich@webkit.org | ef62755 | 2008-08-09 03:56:46 +0000 | [diff] [blame] | 387 | break; |
| 388 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 389 | case op_new_object: { |
| 390 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 391 | printf("[%4d] new_object\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 392 | break; |
| 393 | } |
| 394 | case op_new_array: { |
darin@apple.com | 9ce7902 | 2008-06-28 15:50:49 +0000 | [diff] [blame] | 395 | int dst = (++it)->u.operand; |
| 396 | int argv = (++it)->u.operand; |
| 397 | int argc = (++it)->u.operand; |
| 398 | printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(dst).c_str(), registerName(argv).c_str(), argc); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 399 | break; |
| 400 | } |
| 401 | case op_new_regexp: { |
| 402 | int r0 = (++it)->u.operand; |
| 403 | int re0 = (++it)->u.operand; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 404 | printf("[%4d] new_regexp\t %s, %s\n", location, registerName(r0).c_str(), regexpName(re0, regexp(re0)).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 405 | break; |
| 406 | } |
| 407 | case op_mov: { |
| 408 | int r0 = (++it)->u.operand; |
| 409 | int r1 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 410 | printf("[%4d] mov\t\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 411 | break; |
| 412 | } |
| 413 | case op_not: { |
| 414 | printUnaryOp(location, it, "not"); |
| 415 | break; |
| 416 | } |
| 417 | case op_eq: { |
| 418 | printBinaryOp(location, it, "eq"); |
| 419 | break; |
| 420 | } |
ggaren@apple.com | f15b1880 | 2008-09-03 02:58:14 +0000 | [diff] [blame] | 421 | case op_eq_null: { |
| 422 | printUnaryOp(location, it, "eq_null"); |
| 423 | break; |
| 424 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 425 | case op_neq: { |
| 426 | printBinaryOp(location, it, "neq"); |
| 427 | break; |
| 428 | } |
ggaren@apple.com | f15b1880 | 2008-09-03 02:58:14 +0000 | [diff] [blame] | 429 | case op_neq_null: { |
| 430 | printUnaryOp(location, it, "neq_null"); |
| 431 | break; |
| 432 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 433 | case op_stricteq: { |
| 434 | printBinaryOp(location, it, "stricteq"); |
| 435 | break; |
| 436 | } |
| 437 | case op_nstricteq: { |
| 438 | printBinaryOp(location, it, "nstricteq"); |
| 439 | break; |
| 440 | } |
| 441 | case op_less: { |
| 442 | printBinaryOp(location, it, "less"); |
| 443 | break; |
| 444 | } |
| 445 | case op_lesseq: { |
| 446 | printBinaryOp(location, it, "lesseq"); |
| 447 | break; |
| 448 | } |
| 449 | case op_pre_inc: { |
| 450 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 451 | printf("[%4d] pre_inc\t\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 452 | break; |
| 453 | } |
| 454 | case op_pre_dec: { |
| 455 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 456 | printf("[%4d] pre_dec\t\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 457 | break; |
| 458 | } |
| 459 | case op_post_inc: { |
| 460 | printUnaryOp(location, it, "post_inc"); |
| 461 | break; |
| 462 | } |
| 463 | case op_post_dec: { |
| 464 | printUnaryOp(location, it, "post_dec"); |
| 465 | break; |
| 466 | } |
| 467 | case op_to_jsnumber: { |
| 468 | printUnaryOp(location, it, "to_jsnumber"); |
| 469 | break; |
| 470 | } |
| 471 | case op_negate: { |
| 472 | printUnaryOp(location, it, "negate"); |
| 473 | break; |
| 474 | } |
| 475 | case op_add: { |
| 476 | printBinaryOp(location, it, "add"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 477 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 478 | break; |
| 479 | } |
| 480 | case op_mul: { |
| 481 | printBinaryOp(location, it, "mul"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 482 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 483 | break; |
| 484 | } |
| 485 | case op_div: { |
| 486 | printBinaryOp(location, it, "div"); |
| 487 | break; |
| 488 | } |
| 489 | case op_mod: { |
| 490 | printBinaryOp(location, it, "mod"); |
| 491 | break; |
| 492 | } |
| 493 | case op_sub: { |
| 494 | printBinaryOp(location, it, "sub"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 495 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 496 | break; |
| 497 | } |
| 498 | case op_lshift: { |
| 499 | printBinaryOp(location, it, "lshift"); |
| 500 | break; |
| 501 | } |
| 502 | case op_rshift: { |
| 503 | printBinaryOp(location, it, "rshift"); |
| 504 | break; |
| 505 | } |
| 506 | case op_urshift: { |
| 507 | printBinaryOp(location, it, "urshift"); |
| 508 | break; |
| 509 | } |
| 510 | case op_bitand: { |
| 511 | printBinaryOp(location, it, "bitand"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 512 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 513 | break; |
| 514 | } |
| 515 | case op_bitxor: { |
| 516 | printBinaryOp(location, it, "bitxor"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 517 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 518 | break; |
| 519 | } |
| 520 | case op_bitor: { |
| 521 | printBinaryOp(location, it, "bitor"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 522 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 523 | break; |
| 524 | } |
| 525 | case op_bitnot: { |
| 526 | printUnaryOp(location, it, "bitnot"); |
| 527 | break; |
| 528 | } |
| 529 | case op_instanceof: { |
mjs@apple.com | 988df6c | 2008-09-15 02:13:10 +0000 | [diff] [blame] | 530 | int r0 = (++it)->u.operand; |
| 531 | int r1 = (++it)->u.operand; |
| 532 | int r2 = (++it)->u.operand; |
| 533 | int r3 = (++it)->u.operand; |
| 534 | printf("[%4d] instanceof\t\t %s, %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 535 | break; |
| 536 | } |
| 537 | case op_typeof: { |
| 538 | printUnaryOp(location, it, "typeof"); |
| 539 | break; |
| 540 | } |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 541 | case op_is_undefined: { |
| 542 | printUnaryOp(location, it, "is_undefined"); |
| 543 | break; |
| 544 | } |
| 545 | case op_is_boolean: { |
| 546 | printUnaryOp(location, it, "is_boolean"); |
| 547 | break; |
| 548 | } |
| 549 | case op_is_number: { |
| 550 | printUnaryOp(location, it, "is_number"); |
| 551 | break; |
| 552 | } |
| 553 | case op_is_string: { |
| 554 | printUnaryOp(location, it, "is_string"); |
| 555 | break; |
| 556 | } |
| 557 | case op_is_object: { |
| 558 | printUnaryOp(location, it, "is_object"); |
| 559 | break; |
| 560 | } |
| 561 | case op_is_function: { |
| 562 | printUnaryOp(location, it, "is_function"); |
| 563 | break; |
| 564 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 565 | case op_in: { |
| 566 | printBinaryOp(location, it, "in"); |
| 567 | break; |
| 568 | } |
| 569 | case op_resolve: { |
| 570 | int r0 = (++it)->u.operand; |
| 571 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 572 | printf("[%4d] resolve\t\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 573 | break; |
| 574 | } |
| 575 | case op_resolve_skip: { |
| 576 | int r0 = (++it)->u.operand; |
| 577 | int id0 = (++it)->u.operand; |
| 578 | int skipLevels = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 579 | printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), skipLevels); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 580 | break; |
| 581 | } |
oliver@apple.com | 70579b5 | 2008-09-16 05:53:15 +0000 | [diff] [blame] | 582 | case op_resolve_global: { |
| 583 | int r0 = (++it)->u.operand; |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 584 | JSValue* scope = static_cast<JSValue*>((++it)->u.jsCell); |
oliver@apple.com | 70579b5 | 2008-09-16 05:53:15 +0000 | [diff] [blame] | 585 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 586 | printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).c_str()); |
oliver@apple.com | 70579b5 | 2008-09-16 05:53:15 +0000 | [diff] [blame] | 587 | it += 2; |
| 588 | break; |
| 589 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 590 | case op_get_scoped_var: { |
| 591 | int r0 = (++it)->u.operand; |
| 592 | int index = (++it)->u.operand; |
| 593 | int skipLevels = (++it)->u.operand; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 594 | printf("[%4d] get_scoped_var\t %s, %d, %d\n", location, registerName(r0).c_str(), index, skipLevels); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 595 | break; |
| 596 | } |
| 597 | case op_put_scoped_var: { |
| 598 | int index = (++it)->u.operand; |
| 599 | int skipLevels = (++it)->u.operand; |
| 600 | int r0 = (++it)->u.operand; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 601 | printf("[%4d] put_scoped_var\t %d, %d, %s\n", location, index, skipLevels, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 602 | break; |
| 603 | } |
oliver@apple.com | 957eefc | 2008-09-10 09:23:35 +0000 | [diff] [blame] | 604 | case op_get_global_var: { |
| 605 | int r0 = (++it)->u.operand; |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 606 | JSValue* scope = static_cast<JSValue*>((++it)->u.jsCell); |
oliver@apple.com | 957eefc | 2008-09-10 09:23:35 +0000 | [diff] [blame] | 607 | int index = (++it)->u.operand; |
| 608 | printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), index); |
| 609 | break; |
| 610 | } |
| 611 | case op_put_global_var: { |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 612 | JSValue* scope = static_cast<JSValue*>((++it)->u.jsCell); |
oliver@apple.com | 957eefc | 2008-09-10 09:23:35 +0000 | [diff] [blame] | 613 | int index = (++it)->u.operand; |
| 614 | int r0 = (++it)->u.operand; |
| 615 | printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope).ascii(), index, registerName(r0).c_str()); |
| 616 | break; |
| 617 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 618 | case op_resolve_base: { |
| 619 | int r0 = (++it)->u.operand; |
| 620 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 621 | printf("[%4d] resolve_base\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 622 | break; |
| 623 | } |
| 624 | case op_resolve_with_base: { |
| 625 | int r0 = (++it)->u.operand; |
| 626 | int r1 = (++it)->u.operand; |
| 627 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 628 | printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 629 | break; |
| 630 | } |
| 631 | case op_resolve_func: { |
| 632 | int r0 = (++it)->u.operand; |
| 633 | int r1 = (++it)->u.operand; |
| 634 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 635 | printf("[%4d] resolve_func\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 636 | break; |
| 637 | } |
| 638 | case op_get_by_id: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 639 | printGetByIdOp(location, it, m_identifiers, "get_by_id"); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 640 | break; |
| 641 | } |
| 642 | case op_get_by_id_self: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 643 | printGetByIdOp(location, it, m_identifiers, "get_by_id_self"); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 644 | break; |
| 645 | } |
barraclough@apple.com | bc0fea6 | 2008-11-22 03:34:43 +0000 | [diff] [blame] | 646 | case op_get_by_id_self_list: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 647 | printGetByIdOp(location, it, m_identifiers, "get_by_id_self_list"); |
barraclough@apple.com | bc0fea6 | 2008-11-22 03:34:43 +0000 | [diff] [blame] | 648 | break; |
| 649 | } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 650 | case op_get_by_id_proto: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 651 | printGetByIdOp(location, it, m_identifiers, "get_by_id_proto"); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 652 | break; |
| 653 | } |
barraclough@apple.com | f5f7482 | 2008-11-21 05:04:19 +0000 | [diff] [blame] | 654 | case op_get_by_id_proto_list: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 655 | printGetByIdOp(location, it, m_identifiers, "op_get_by_id_proto_list"); |
barraclough@apple.com | f5f7482 | 2008-11-21 05:04:19 +0000 | [diff] [blame] | 656 | break; |
| 657 | } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 658 | case op_get_by_id_chain: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 659 | printGetByIdOp(location, it, m_identifiers, "get_by_id_chain"); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 660 | break; |
| 661 | } |
| 662 | case op_get_by_id_generic: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 663 | printGetByIdOp(location, it, m_identifiers, "get_by_id_generic"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 664 | break; |
| 665 | } |
ggaren@apple.com | bc36309 | 2008-09-03 05:04:39 +0000 | [diff] [blame] | 666 | case op_get_array_length: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 667 | printGetByIdOp(location, it, m_identifiers, "get_array_length"); |
ggaren@apple.com | bc36309 | 2008-09-03 05:04:39 +0000 | [diff] [blame] | 668 | break; |
| 669 | } |
| 670 | case op_get_string_length: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 671 | printGetByIdOp(location, it, m_identifiers, "get_string_length"); |
ggaren@apple.com | bc36309 | 2008-09-03 05:04:39 +0000 | [diff] [blame] | 672 | break; |
| 673 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 674 | case op_put_by_id: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 675 | printPutByIdOp(location, it, m_identifiers, "put_by_id"); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 676 | break; |
| 677 | } |
| 678 | case op_put_by_id_replace: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 679 | printPutByIdOp(location, it, m_identifiers, "put_by_id_replace"); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 680 | break; |
| 681 | } |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 682 | case op_put_by_id_transition: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 683 | printPutByIdOp(location, it, m_identifiers, "put_by_id_transition"); |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 684 | break; |
| 685 | } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 686 | case op_put_by_id_generic: { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 687 | printPutByIdOp(location, it, m_identifiers, "put_by_id_generic"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 688 | break; |
| 689 | } |
| 690 | case op_put_getter: { |
| 691 | int r0 = (++it)->u.operand; |
| 692 | int id0 = (++it)->u.operand; |
| 693 | int r1 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 694 | printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 695 | break; |
| 696 | } |
| 697 | case op_put_setter: { |
| 698 | int r0 = (++it)->u.operand; |
| 699 | int id0 = (++it)->u.operand; |
| 700 | int r1 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 701 | printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 702 | break; |
| 703 | } |
| 704 | case op_del_by_id: { |
| 705 | int r0 = (++it)->u.operand; |
| 706 | int r1 = (++it)->u.operand; |
| 707 | int id0 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 708 | printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 709 | break; |
| 710 | } |
| 711 | case op_get_by_val: { |
| 712 | int r0 = (++it)->u.operand; |
| 713 | int r1 = (++it)->u.operand; |
| 714 | int r2 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 715 | printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 716 | break; |
| 717 | } |
| 718 | case op_put_by_val: { |
| 719 | int r0 = (++it)->u.operand; |
| 720 | int r1 = (++it)->u.operand; |
| 721 | int r2 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 722 | printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 723 | break; |
| 724 | } |
| 725 | case op_del_by_val: { |
| 726 | int r0 = (++it)->u.operand; |
| 727 | int r1 = (++it)->u.operand; |
| 728 | int r2 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 729 | printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 730 | break; |
| 731 | } |
| 732 | case op_put_by_index: { |
| 733 | int r0 = (++it)->u.operand; |
| 734 | unsigned n0 = (++it)->u.operand; |
| 735 | int r1 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 736 | printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(r0).c_str(), n0, registerName(r1).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 737 | break; |
| 738 | } |
| 739 | case op_jmp: { |
| 740 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 741 | printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset)); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 742 | break; |
| 743 | } |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 744 | case op_loop: { |
| 745 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 746 | printf("[%4d] loop\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset)); |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 747 | break; |
| 748 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 749 | case op_jtrue: { |
| 750 | printConditionalJump(begin, it, location, "jtrue"); |
| 751 | break; |
| 752 | } |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 753 | case op_loop_if_true: { |
| 754 | printConditionalJump(begin, it, location, "loop_if_true"); |
| 755 | break; |
| 756 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 757 | case op_jfalse: { |
| 758 | printConditionalJump(begin, it, location, "jfalse"); |
| 759 | break; |
| 760 | } |
cwzwarich@webkit.org | b8b3024 | 2008-10-22 21:06:30 +0000 | [diff] [blame] | 761 | case op_jeq_null: { |
| 762 | printConditionalJump(begin, it, location, "jeq_null"); |
| 763 | break; |
| 764 | } |
| 765 | case op_jneq_null: { |
| 766 | printConditionalJump(begin, it, location, "jneq_null"); |
| 767 | break; |
| 768 | } |
cwzwarich@webkit.org | 7b04fef | 2008-06-30 06:17:01 +0000 | [diff] [blame] | 769 | case op_jnless: { |
| 770 | int r0 = (++it)->u.operand; |
| 771 | int r1 = (++it)->u.operand; |
| 772 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 773 | printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); |
cwzwarich@webkit.org | 7b04fef | 2008-06-30 06:17:01 +0000 | [diff] [blame] | 774 | break; |
| 775 | } |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 776 | case op_loop_if_less: { |
| 777 | int r0 = (++it)->u.operand; |
| 778 | int r1 = (++it)->u.operand; |
| 779 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 780 | printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 781 | break; |
| 782 | } |
cwzwarich@webkit.org | 4be196a | 2008-09-14 23:01:03 +0000 | [diff] [blame] | 783 | case op_loop_if_lesseq: { |
| 784 | int r0 = (++it)->u.operand; |
| 785 | int r1 = (++it)->u.operand; |
| 786 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 787 | printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); |
cwzwarich@webkit.org | 4be196a | 2008-09-14 23:01:03 +0000 | [diff] [blame] | 788 | break; |
| 789 | } |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 790 | case op_switch_imm: { |
| 791 | int tableIndex = (++it)->u.operand; |
| 792 | int defaultTarget = (++it)->u.operand; |
| 793 | int scrutineeRegister = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 794 | printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 795 | break; |
| 796 | } |
| 797 | case op_switch_char: { |
| 798 | int tableIndex = (++it)->u.operand; |
| 799 | int defaultTarget = (++it)->u.operand; |
| 800 | int scrutineeRegister = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 801 | printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 802 | break; |
| 803 | } |
| 804 | case op_switch_string: { |
| 805 | int tableIndex = (++it)->u.operand; |
| 806 | int defaultTarget = (++it)->u.operand; |
| 807 | int scrutineeRegister = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 808 | printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 809 | break; |
| 810 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 811 | case op_new_func: { |
| 812 | int r0 = (++it)->u.operand; |
| 813 | int f0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 814 | printf("[%4d] new_func\t\t %s, f%d\n", location, registerName(r0).c_str(), f0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 815 | break; |
| 816 | } |
| 817 | case op_new_func_exp: { |
| 818 | int r0 = (++it)->u.operand; |
| 819 | int f0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 820 | printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(r0).c_str(), f0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 821 | break; |
| 822 | } |
| 823 | case op_call: { |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 824 | int dst = (++it)->u.operand; |
| 825 | int func = (++it)->u.operand; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 826 | int argCount = (++it)->u.operand; |
ggaren@apple.com | 107bd0e | 2008-09-24 00:27:18 +0000 | [diff] [blame] | 827 | int registerOffset = (++it)->u.operand; |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 828 | printf("[%4d] call\t\t %s, %s, %d, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 829 | break; |
| 830 | } |
| 831 | case op_call_eval: { |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 832 | int dst = (++it)->u.operand; |
| 833 | int func = (++it)->u.operand; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 834 | int argCount = (++it)->u.operand; |
ggaren@apple.com | 107bd0e | 2008-09-24 00:27:18 +0000 | [diff] [blame] | 835 | int registerOffset = (++it)->u.operand; |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 836 | printf("[%4d] call_eval\t %s, %s, %d, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 837 | break; |
| 838 | } |
cwzwarich@webkit.org | a3b5f8a | 2008-10-06 06:00:58 +0000 | [diff] [blame] | 839 | case op_tear_off_activation: { |
mjs@apple.com | 6c3268c | 2008-10-06 18:31:07 +0000 | [diff] [blame] | 840 | int r0 = (++it)->u.operand; |
| 841 | printf("[%4d] tear_off_activation\t %s\n", location, registerName(r0).c_str()); |
cwzwarich@webkit.org | a3b5f8a | 2008-10-06 06:00:58 +0000 | [diff] [blame] | 842 | break; |
| 843 | } |
| 844 | case op_tear_off_arguments: { |
cwzwarich@webkit.org | 5f5bc9e | 2008-10-07 03:53:47 +0000 | [diff] [blame] | 845 | printf("[%4d] tear_off_arguments\n", location); |
cwzwarich@webkit.org | a3b5f8a | 2008-10-06 06:00:58 +0000 | [diff] [blame] | 846 | break; |
| 847 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 848 | case op_ret: { |
| 849 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 850 | printf("[%4d] ret\t\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 851 | break; |
| 852 | } |
| 853 | case op_construct: { |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 854 | int dst = (++it)->u.operand; |
| 855 | int func = (++it)->u.operand; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 856 | int argCount = (++it)->u.operand; |
ggaren@apple.com | 107bd0e | 2008-09-24 00:27:18 +0000 | [diff] [blame] | 857 | int registerOffset = (++it)->u.operand; |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 858 | int proto = (++it)->u.operand; |
| 859 | int thisRegister = (++it)->u.operand; |
| 860 | printf("[%4d] construct\t %s, %s, %d, %d, %s, %s\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset, registerName(proto).c_str(), registerName(thisRegister).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 861 | break; |
| 862 | } |
ggaren@apple.com | 743b98b | 2008-09-15 23:37:31 +0000 | [diff] [blame] | 863 | case op_construct_verify: { |
| 864 | int r0 = (++it)->u.operand; |
| 865 | int r1 = (++it)->u.operand; |
| 866 | printf("[%4d] construct_verify\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); |
| 867 | break; |
| 868 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 869 | case op_get_pnames: { |
| 870 | int r0 = (++it)->u.operand; |
| 871 | int r1 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 872 | printf("[%4d] get_pnames\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 873 | break; |
| 874 | } |
| 875 | case op_next_pname: { |
| 876 | int dest = (++it)->u.operand; |
| 877 | int iter = (++it)->u.operand; |
| 878 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 879 | printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, locationForOffset(begin, it, offset)); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 880 | break; |
| 881 | } |
| 882 | case op_push_scope: { |
| 883 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 884 | printf("[%4d] push_scope\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 885 | break; |
| 886 | } |
| 887 | case op_pop_scope: { |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 888 | printf("[%4d] pop_scope\n", location); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 889 | break; |
| 890 | } |
oliver@apple.com | f66dcf9 | 2008-08-03 09:58:21 +0000 | [diff] [blame] | 891 | case op_push_new_scope: { |
| 892 | int r0 = (++it)->u.operand; |
| 893 | int id0 = (++it)->u.operand; |
| 894 | int r1 = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 895 | printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); |
oliver@apple.com | f66dcf9 | 2008-08-03 09:58:21 +0000 | [diff] [blame] | 896 | break; |
| 897 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 898 | case op_jmp_scopes: { |
| 899 | int scopeDelta = (++it)->u.operand; |
| 900 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 901 | printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, locationForOffset(begin, it, offset)); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 902 | break; |
| 903 | } |
| 904 | case op_catch: { |
| 905 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 906 | printf("[%4d] catch\t\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 907 | break; |
| 908 | } |
| 909 | case op_throw: { |
| 910 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 911 | printf("[%4d] throw\t\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 912 | break; |
| 913 | } |
| 914 | case op_new_error: { |
| 915 | int r0 = (++it)->u.operand; |
| 916 | int errorType = (++it)->u.operand; |
| 917 | int k0 = (++it)->u.operand; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 918 | printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, unexpectedConstant(k0)).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 919 | break; |
| 920 | } |
| 921 | case op_jsr: { |
| 922 | int retAddrDst = (++it)->u.operand; |
| 923 | int offset = (++it)->u.operand; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 924 | printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, locationForOffset(begin, it, offset)); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 925 | break; |
| 926 | } |
| 927 | case op_sret: { |
| 928 | int retAddrSrc = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 929 | printf("[%4d] sret\t\t %s\n", location, registerName(retAddrSrc).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 930 | break; |
| 931 | } |
| 932 | case op_debug: { |
| 933 | int debugHookID = (++it)->u.operand; |
| 934 | int firstLine = (++it)->u.operand; |
| 935 | int lastLine = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 936 | printf("[%4d] debug\t\t %s, %d, %d\n", location, debugHookName(debugHookID), firstLine, lastLine); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 937 | break; |
| 938 | } |
ggaren@apple.com | 4b8c0fb | 2008-10-20 16:48:30 +0000 | [diff] [blame] | 939 | case op_profile_will_call: { |
| 940 | int function = (++it)->u.operand; |
| 941 | printf("[%4d] profile_will_call %s\n", location, registerName(function).c_str()); |
| 942 | break; |
| 943 | } |
| 944 | case op_profile_did_call: { |
| 945 | int function = (++it)->u.operand; |
| 946 | printf("[%4d] profile_did_call\t %s\n", location, registerName(function).c_str()); |
| 947 | break; |
| 948 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 949 | case op_end: { |
| 950 | int r0 = (++it)->u.operand; |
aroben@apple.com | 82c3236 | 2008-05-27 23:25:09 +0000 | [diff] [blame] | 951 | printf("[%4d] end\t\t %s\n", location, registerName(r0).c_str()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 952 | break; |
| 953 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 954 | } |
| 955 | } |
| 956 | |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 957 | #endif // !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 958 | |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 959 | #if DUMP_CODE_BLOCK_STATISTICS |
| 960 | static HashSet<CodeBlock*> liveCodeBlockSet; |
| 961 | #endif |
| 962 | |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 963 | #define FOR_EACH_MEMBER_VECTOR(macro) \ |
| 964 | macro(instructions) \ |
| 965 | macro(globalResolveInstructions) \ |
| 966 | macro(propertyAccessInstructions) \ |
| 967 | macro(callLinkInfos) \ |
| 968 | macro(linkedCallerList) \ |
| 969 | macro(identifiers) \ |
| 970 | macro(functionExpressions) \ |
| 971 | macro(constantRegisters) \ |
| 972 | macro(expressionInfo) \ |
| 973 | macro(lineInfo) \ |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 974 | |
| 975 | #define FOR_EACH_MEMBER_VECTOR_RARE_DATA(macro) \ |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 976 | macro(regexps) \ |
| 977 | macro(functions) \ |
| 978 | macro(unexpectedConstants) \ |
| 979 | macro(exceptionHandlers) \ |
| 980 | macro(immediateSwitchJumpTables) \ |
| 981 | macro(characterSwitchJumpTables) \ |
| 982 | macro(stringSwitchJumpTables) |
| 983 | |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 984 | void CodeBlock::dumpStatistics() |
| 985 | { |
| 986 | #if DUMP_CODE_BLOCK_STATISTICS |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 987 | |
| 988 | #define DEFINE_VARS(name) size_t name##IsNotEmpty = 0; |
| 989 | FOR_EACH_MEMBER_VECTOR(DEFINE_VARS) |
weinig@apple.com | 15d4009 | 2008-12-09 05:27:10 +0000 | [diff] [blame] | 990 | FOR_EACH_MEMBER_VECTOR_RARE_DATA(DEFINE_VARS) |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 991 | #undef DEFINE_VARS |
| 992 | |
| 993 | // Non-vector data members |
| 994 | size_t jitReturnAddressVPCMapIsNotEmpty = 0; |
| 995 | size_t evalCodeCacheIsNotEmpty = 0; |
| 996 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 997 | size_t hasRareData = 0; |
| 998 | |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 999 | HashSet<CodeBlock*>::const_iterator end = liveCodeBlockSet.end(); |
| 1000 | for (HashSet<CodeBlock*>::const_iterator it = liveCodeBlockSet.begin(); it != end; ++it) { |
| 1001 | CodeBlock* codeBlock = *it; |
| 1002 | |
| 1003 | #define GET_STATS(name) if (!codeBlock->m_##name.isEmpty()) { name##IsNotEmpty++; } |
| 1004 | FOR_EACH_MEMBER_VECTOR(GET_STATS) |
| 1005 | #undef GET_STATS |
| 1006 | |
| 1007 | if (!codeBlock->m_jitReturnAddressVPCMap.isEmpty()) |
| 1008 | jitReturnAddressVPCMapIsNotEmpty++; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1009 | |
| 1010 | if (codeBlock->m_rareData) { |
| 1011 | hasRareData++; |
| 1012 | #define GET_STATS(name) if (!codeBlock->m_rareData->m_##name.isEmpty()) { name##IsNotEmpty++; } |
| 1013 | FOR_EACH_MEMBER_VECTOR_RARE_DATA(GET_STATS) |
| 1014 | #undef GET_STATS |
| 1015 | |
| 1016 | if (!codeBlock->m_rareData->m_evalCodeCache.isEmpty()) |
| 1017 | evalCodeCacheIsNotEmpty++; |
| 1018 | } |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 1021 | printf("Number of live CodeBlocks: %d\n", liveCodeBlockSet.size()); |
| 1022 | printf("Size of a single CodeBlock [sizeof(CodeBlock)]: %zu\n", sizeof(CodeBlock)); |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1023 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1024 | printf("Number of CodeBlocks with rare data: %zu\n", hasRareData); |
| 1025 | |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1026 | #define PRINT_STATS(name) printf("Number of CodeBlocks with " #name ": %zu\n", name##IsNotEmpty); |
| 1027 | FOR_EACH_MEMBER_VECTOR(PRINT_STATS) |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1028 | FOR_EACH_MEMBER_VECTOR_RARE_DATA(PRINT_STATS) |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1029 | #undef PRINT_STATS |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1030 | |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1031 | printf("Number of CodeBlocks with jitReturnAddressVPCMap: %zu\n", jitReturnAddressVPCMapIsNotEmpty); |
| 1032 | printf("Number of CodeBlocks with evalCodeCache: %zu\n", evalCodeCacheIsNotEmpty); |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 1033 | #else |
| 1034 | printf("Dumping CodeBlock statistics is not enabled.\n"); |
| 1035 | #endif |
| 1036 | } |
| 1037 | |
| 1038 | |
weinig@apple.com | 0e9a7ee | 2008-12-06 22:31:14 +0000 | [diff] [blame] | 1039 | CodeBlock::CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset) |
| 1040 | : m_numCalleeRegisters(0) |
| 1041 | , m_numConstants(0) |
| 1042 | , m_numVars(0) |
| 1043 | , m_numParameters(0) |
| 1044 | , m_ownerNode(ownerNode) |
| 1045 | , m_globalData(0) |
| 1046 | #if ENABLE(JIT) |
| 1047 | , m_jitCode(0) |
| 1048 | #endif |
| 1049 | , m_needsFullScopeChain(ownerNode->needsActivation()) |
| 1050 | , m_usesEval(ownerNode->usesEval()) |
| 1051 | , m_codeType(codeType) |
| 1052 | , m_source(sourceProvider) |
| 1053 | , m_sourceOffset(sourceOffset) |
| 1054 | { |
| 1055 | ASSERT(m_source); |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 1056 | |
| 1057 | #if DUMP_CODE_BLOCK_STATISTICS |
| 1058 | liveCodeBlockSet.add(this); |
| 1059 | #endif |
weinig@apple.com | 0e9a7ee | 2008-12-06 22:31:14 +0000 | [diff] [blame] | 1060 | } |
| 1061 | |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1062 | CodeBlock::~CodeBlock() |
| 1063 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1064 | for (size_t size = m_globalResolveInstructions.size(), i = 0; i < size; ++i) |
| 1065 | derefStructures(&m_instructions[m_globalResolveInstructions[i]]); |
| 1066 | |
| 1067 | for (size_t size = m_propertyAccessInstructions.size(), i = 0; i < size; ++i) { |
| 1068 | derefStructures(&m_instructions[m_propertyAccessInstructions[i].bytecodeIndex]); |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 1069 | } |
| 1070 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1071 | for (size_t size = m_callLinkInfos.size(), i = 0; i < size; ++i) { |
| 1072 | CallLinkInfo* callLinkInfo = &m_callLinkInfos[i]; |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 1073 | if (callLinkInfo->isLinked()) |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1074 | callLinkInfo->callee->removeCaller(callLinkInfo); |
barraclough@apple.com | 71500d5 | 2008-09-15 02:18:13 +0000 | [diff] [blame] | 1075 | } |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1076 | |
ggaren@apple.com | f272d2d | 2008-11-17 04:25:37 +0000 | [diff] [blame] | 1077 | #if ENABLE(JIT) |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1078 | unlinkCallers(); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 1079 | #endif |
weinig@apple.com | 3f9a959 | 2008-12-08 21:40:15 +0000 | [diff] [blame] | 1080 | |
| 1081 | #if DUMP_CODE_BLOCK_STATISTICS |
| 1082 | liveCodeBlockSet.remove(this); |
| 1083 | #endif |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
ggaren@apple.com | f272d2d | 2008-11-17 04:25:37 +0000 | [diff] [blame] | 1086 | #if ENABLE(JIT) |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1087 | void CodeBlock::unlinkCallers() |
| 1088 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1089 | size_t size = m_linkedCallerList.size(); |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1090 | for (size_t i = 0; i < size; ++i) { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1091 | CallLinkInfo* currentCaller = m_linkedCallerList[i]; |
ggaren@apple.com | 4f7d7a9 | 2008-11-17 03:34:05 +0000 | [diff] [blame] | 1092 | JIT::unlinkCall(currentCaller); |
barraclough@apple.com | e964265 | 2008-10-23 22:29:54 +0000 | [diff] [blame] | 1093 | currentCaller->setUnlinked(); |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1094 | } |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1095 | m_linkedCallerList.clear(); |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 1096 | } |
| 1097 | #endif |
| 1098 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1099 | void CodeBlock::derefStructures(Instruction* vPC) const |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1100 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1101 | Interpreter* interpreter = m_globalData->interpreter; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1102 | |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1103 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1104 | vPC[4].u.structure->deref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1105 | return; |
| 1106 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1107 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1108 | vPC[4].u.structure->deref(); |
| 1109 | vPC[5].u.structure->deref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1110 | return; |
| 1111 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1112 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1113 | vPC[4].u.structure->deref(); |
| 1114 | vPC[5].u.structureChain->deref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1115 | return; |
| 1116 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1117 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1118 | vPC[4].u.structure->deref(); |
| 1119 | vPC[5].u.structure->deref(); |
| 1120 | vPC[6].u.structureChain->deref(); |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 1121 | return; |
| 1122 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1123 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1124 | vPC[4].u.structure->deref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1125 | return; |
| 1126 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1127 | if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1128 | if(vPC[4].u.structure) |
| 1129 | vPC[4].u.structure->deref(); |
oliver@apple.com | 70579b5 | 2008-09-16 05:53:15 +0000 | [diff] [blame] | 1130 | return; |
| 1131 | } |
barraclough@apple.com | bc0fea6 | 2008-11-22 03:34:43 +0000 | [diff] [blame] | 1132 | if ((vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto_list)) |
| 1133 | || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self_list))) { |
| 1134 | PolymorphicAccessStructureList* polymorphicStructures = vPC[4].u.polymorphicStructures; |
| 1135 | polymorphicStructures->derefStructures(vPC[5].u.operand); |
| 1136 | delete polymorphicStructures; |
barraclough@apple.com | f5f7482 | 2008-11-21 05:04:19 +0000 | [diff] [blame] | 1137 | return; |
| 1138 | } |
| 1139 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1140 | // These instructions don't ref their Structures. |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1141 | ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_get_array_length) || vPC[0].u.opcode == interpreter->getOpcode(op_get_string_length)); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1144 | void CodeBlock::refStructures(Instruction* vPC) const |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1145 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1146 | Interpreter* interpreter = m_globalData->interpreter; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1147 | |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1148 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1149 | vPC[4].u.structure->ref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1150 | return; |
| 1151 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1152 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1153 | vPC[4].u.structure->ref(); |
| 1154 | vPC[5].u.structure->ref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1155 | return; |
| 1156 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1157 | if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1158 | vPC[4].u.structure->ref(); |
| 1159 | vPC[5].u.structureChain->ref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1160 | return; |
| 1161 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1162 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1163 | vPC[4].u.structure->ref(); |
| 1164 | vPC[5].u.structure->ref(); |
| 1165 | vPC[6].u.structureChain->ref(); |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 1166 | return; |
| 1167 | } |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1168 | if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) { |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1169 | vPC[4].u.structure->ref(); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1170 | return; |
| 1171 | } |
| 1172 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 1173 | // These instructions don't ref their Structures. |
ggaren@apple.com | 47d3f05 | 2008-11-15 21:37:49 +0000 | [diff] [blame] | 1174 | ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic)); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1175 | } |
cwzwarich@webkit.org | 217b540 | 2008-08-09 11:00:38 +0000 | [diff] [blame] | 1176 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1177 | void CodeBlock::mark() |
| 1178 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1179 | for (size_t i = 0; i < m_constantRegisters.size(); ++i) |
| 1180 | if (!m_constantRegisters[i].marked()) |
| 1181 | m_constantRegisters[i].mark(); |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 1182 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1183 | for (size_t i = 0; i < m_functionExpressions.size(); ++i) |
| 1184 | m_functionExpressions[i]->body()->mark(); |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1185 | |
| 1186 | if (m_rareData) { |
| 1187 | for (size_t i = 0; i < m_rareData->m_functions.size(); ++i) |
| 1188 | m_rareData->m_functions[i]->body()->mark(); |
| 1189 | |
| 1190 | for (size_t i = 0; i < m_rareData->m_unexpectedConstants.size(); ++i) { |
| 1191 | if (!m_rareData->m_unexpectedConstants[i]->marked()) |
| 1192 | m_rareData->m_unexpectedConstants[i]->mark(); |
| 1193 | } |
| 1194 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | bool CodeBlock::getHandlerForVPC(const Instruction* vPC, Instruction*& target, int& scopeDepth) |
| 1198 | { |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1199 | if (!m_rareData) |
| 1200 | return false; |
| 1201 | |
| 1202 | Vector<HandlerInfo>::iterator ptr = m_rareData->m_exceptionHandlers.begin(); |
| 1203 | Vector<HandlerInfo>::iterator end = m_rareData->m_exceptionHandlers.end(); |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1204 | unsigned addressOffset = vPC - m_instructions.begin(); |
| 1205 | ASSERT(addressOffset < m_instructions.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1206 | |
| 1207 | for (; ptr != end; ++ptr) { |
| 1208 | // Handlers are ordered innermost first, so the first handler we encounter |
| 1209 | // that contains the source address is the correct handler to use. |
| 1210 | if (ptr->start <= addressOffset && ptr->end >= addressOffset) { |
| 1211 | scopeDepth = ptr->scopeDepth; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1212 | target = m_instructions.begin() + ptr->target; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1213 | return true; |
| 1214 | } |
| 1215 | } |
| 1216 | return false; |
| 1217 | } |
| 1218 | |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 1219 | void* CodeBlock::nativeExceptionCodeForHandlerVPC(const Instruction* handlerVPC) |
| 1220 | { |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1221 | if (!m_rareData) |
| 1222 | return 0; |
| 1223 | |
| 1224 | Vector<HandlerInfo>::iterator ptr = m_rareData->m_exceptionHandlers.begin(); |
| 1225 | Vector<HandlerInfo>::iterator end = m_rareData->m_exceptionHandlers.end(); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 1226 | |
| 1227 | for (; ptr != end; ++ptr) { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1228 | Instruction*target = m_instructions.begin() + ptr->target; |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 1229 | if (handlerVPC == target) |
| 1230 | return ptr->nativeCode; |
| 1231 | } |
| 1232 | |
| 1233 | return 0; |
| 1234 | } |
| 1235 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1236 | int CodeBlock::lineNumberForVPC(const Instruction* vPC) |
| 1237 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1238 | unsigned instructionOffset = vPC - m_instructions.begin(); |
| 1239 | ASSERT(instructionOffset < m_instructions.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1240 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1241 | if (!m_lineInfo.size()) |
| 1242 | return m_ownerNode->source().firstLine(); // Empty function |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1243 | |
| 1244 | int low = 0; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1245 | int high = m_lineInfo.size(); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1246 | while (low < high) { |
| 1247 | int mid = low + (high - low) / 2; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1248 | if (m_lineInfo[mid].instructionOffset <= instructionOffset) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1249 | low = mid + 1; |
| 1250 | else |
| 1251 | high = mid; |
| 1252 | } |
ggaren@apple.com | be95ccf | 2008-10-25 19:59:47 +0000 | [diff] [blame] | 1253 | |
| 1254 | if (!low) |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1255 | return m_ownerNode->source().firstLine(); |
| 1256 | return m_lineInfo[low - 1].lineNumber; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1259 | int CodeBlock::expressionRangeForVPC(const Instruction* vPC, int& divot, int& startOffset, int& endOffset) |
| 1260 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1261 | unsigned instructionOffset = vPC - m_instructions.begin(); |
| 1262 | ASSERT(instructionOffset < m_instructions.size()); |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1263 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1264 | if (!m_expressionInfo.size()) { |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1265 | // We didn't think anything could throw. Apparently we were wrong. |
| 1266 | startOffset = 0; |
| 1267 | endOffset = 0; |
| 1268 | divot = 0; |
| 1269 | return lineNumberForVPC(vPC); |
| 1270 | } |
| 1271 | |
| 1272 | int low = 0; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1273 | int high = m_expressionInfo.size(); |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1274 | while (low < high) { |
| 1275 | int mid = low + (high - low) / 2; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1276 | if (m_expressionInfo[mid].instructionOffset <= instructionOffset) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1277 | low = mid + 1; |
| 1278 | else |
| 1279 | high = mid; |
| 1280 | } |
| 1281 | |
| 1282 | ASSERT(low); |
| 1283 | if (!low) { |
| 1284 | startOffset = 0; |
| 1285 | endOffset = 0; |
| 1286 | divot = 0; |
| 1287 | return lineNumberForVPC(vPC); |
| 1288 | } |
| 1289 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1290 | startOffset = m_expressionInfo[low - 1].startOffset; |
| 1291 | endOffset = m_expressionInfo[low - 1].endOffset; |
| 1292 | divot = m_expressionInfo[low - 1].divotPoint + m_sourceOffset; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1293 | return lineNumberForVPC(vPC); |
| 1294 | } |
| 1295 | |
weinig@apple.com | 9d9d25d | 2008-12-05 20:27:58 +0000 | [diff] [blame] | 1296 | void CodeBlock::shrinkToFit() |
| 1297 | { |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1298 | m_instructions.shrinkToFit(); |
| 1299 | |
| 1300 | m_globalResolveInstructions.shrinkToFit(); |
| 1301 | m_propertyAccessInstructions.shrinkToFit(); |
| 1302 | m_callLinkInfos.shrinkToFit(); |
| 1303 | m_linkedCallerList.shrinkToFit(); |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1304 | m_expressionInfo.shrinkToFit(); |
| 1305 | m_lineInfo.shrinkToFit(); |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1306 | m_identifiers.shrinkToFit(); |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1307 | m_functionExpressions.shrinkToFit(); |
| 1308 | m_constantRegisters.shrinkToFit(); |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 1309 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1310 | if (m_rareData) { |
| 1311 | m_rareData->m_exceptionHandlers.shrinkToFit(); |
| 1312 | m_rareData->m_functions.shrinkToFit(); |
| 1313 | m_rareData->m_unexpectedConstants.shrinkToFit(); |
| 1314 | m_rareData->m_regexps.shrinkToFit(); |
| 1315 | m_rareData->m_immediateSwitchJumpTables.shrinkToFit(); |
| 1316 | m_rareData->m_characterSwitchJumpTables.shrinkToFit(); |
| 1317 | m_rareData->m_stringSwitchJumpTables.shrinkToFit(); |
| 1318 | } |
weinig@apple.com | 9d9d25d | 2008-12-05 20:27:58 +0000 | [diff] [blame] | 1319 | } |
| 1320 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 1321 | } // namespace JSC |