mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008-2010, 2012-2015 Apple Inc. All rights reserved. |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 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. |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 14 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 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 | |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 33 | #include "BasicBlockLocation.h" |
barraclough@apple.com | c2527d6 | 2010-08-11 19:52:41 +0000 | [diff] [blame] | 34 | #include "BytecodeGenerator.h" |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 35 | #include "BytecodeUseDef.h" |
fpizlo@apple.com | 806b582 | 2013-01-08 01:23:38 +0000 | [diff] [blame] | 36 | #include "CallLinkStatus.h" |
fpizlo@apple.com | 452cb41 | 2011-09-08 21:38:04 +0000 | [diff] [blame] | 37 | #include "DFGCapabilities.h" |
fpizlo@apple.com | 1e89af3 | 2012-11-19 02:55:14 +0000 | [diff] [blame] | 38 | #include "DFGCommon.h" |
fpizlo@apple.com | 62b6af8 | 2013-08-29 18:25:36 +0000 | [diff] [blame] | 39 | #include "DFGDriver.h" |
fpizlo@apple.com | b426f86 | 2014-02-10 02:51:13 +0000 | [diff] [blame] | 40 | #include "DFGJITCode.h" |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 41 | #include "DFGWorklist.h" |
barraclough@apple.com | c2527d6 | 2010-08-11 19:52:41 +0000 | [diff] [blame] | 42 | #include "Debugger.h" |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 43 | #include "FunctionExecutableDump.h" |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 44 | #include "GetPutInfo.h" |
ggaren@apple.com | 0dc469d | 2015-08-18 19:28:37 +0000 | [diff] [blame] | 45 | #include "InlineCallFrame.h" |
ggaren@apple.com | 901a8a2 | 2008-11-17 20:57:18 +0000 | [diff] [blame] | 46 | #include "Interpreter.h" |
fpizlo@apple.com | 81bb8bb | 2013-11-23 00:36:55 +0000 | [diff] [blame] | 47 | #include "JIT.h" |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 48 | #include "JITStubs.h" |
oliver@apple.com | d04e0a0 | 2014-02-01 01:37:59 +0000 | [diff] [blame] | 49 | #include "JSCJSValue.h" |
barraclough@apple.com | 3dc1233 | 2009-08-12 05:22:33 +0000 | [diff] [blame] | 50 | #include "JSFunction.h" |
oliver@apple.com | a7dfb4d | 2014-09-11 18:18:14 +0000 | [diff] [blame] | 51 | #include "JSLexicalEnvironment.h" |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 52 | #include "JSModuleEnvironment.h" |
fpizlo@apple.com | 81bb8bb | 2013-11-23 00:36:55 +0000 | [diff] [blame] | 53 | #include "LLIntEntrypoint.h" |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 54 | #include "LowLevelInterpreter.h" |
fpizlo@apple.com | fb7eff2 | 2014-02-11 01:45:50 +0000 | [diff] [blame] | 55 | #include "JSCInlines.h" |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 56 | #include "PolymorphicAccess.h" |
akling@apple.com | 5a0a87e | 2014-03-22 20:57:04 +0000 | [diff] [blame] | 57 | #include "ProfilerDatabase.h" |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 58 | #include "ReduceWhitespace.h" |
mark.lam@apple.com | 9df8b83 | 2013-09-26 20:27:14 +0000 | [diff] [blame] | 59 | #include "Repatch.h" |
mark.lam@apple.com | a4fe7ab | 2012-11-09 03:03:44 +0000 | [diff] [blame] | 60 | #include "SlotVisitorInlines.h" |
msaboff@apple.com | 4d563e4 | 2014-08-16 01:45:40 +0000 | [diff] [blame] | 61 | #include "StackVisitor.h" |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 62 | #include "TypeLocationCache.h" |
| 63 | #include "TypeProfiler.h" |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 64 | #include "UnlinkedInstructionStream.h" |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 65 | #include <wtf/BagToHashMap.h> |
fpizlo@apple.com | 806b582 | 2013-01-08 01:23:38 +0000 | [diff] [blame] | 66 | #include <wtf/CommaPrinter.h> |
aroben@apple.com | a2fd570 | 2008-09-02 15:15:21 +0000 | [diff] [blame] | 67 | #include <wtf/StringExtras.h> |
fpizlo@apple.com | 9fe4913 | 2012-12-04 19:29:13 +0000 | [diff] [blame] | 68 | #include <wtf/StringPrintStream.h> |
utatane.tea@gmail.com | 8268d39 | 2015-05-23 18:41:53 +0000 | [diff] [blame] | 69 | #include <wtf/text/UniquedStringImpl.h> |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 70 | |
msaboff@apple.com | 0208546 | 2015-09-10 17:47:16 +0000 | [diff] [blame] | 71 | #if ENABLE(JIT) |
| 72 | #include "RegisterAtOffsetList.h" |
| 73 | #endif |
| 74 | |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 75 | #if ENABLE(DFG_JIT) |
| 76 | #include "DFGOperations.h" |
| 77 | #endif |
| 78 | |
carlosgc@webkit.org | 13f6daf2 | 2013-07-30 06:42:00 +0000 | [diff] [blame] | 79 | #if ENABLE(FTL_JIT) |
| 80 | #include "FTLJITCode.h" |
| 81 | #endif |
| 82 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 83 | namespace JSC { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 84 | |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 85 | CString CodeBlock::inferredName() const |
fpizlo@apple.com | 1a6da21 | 2012-12-10 18:38:15 +0000 | [diff] [blame] | 86 | { |
| 87 | switch (codeType()) { |
| 88 | case GlobalCode: |
| 89 | return "<global>"; |
| 90 | case EvalCode: |
| 91 | return "<eval>"; |
| 92 | case FunctionCode: |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 93 | return jsCast<FunctionExecutable*>(ownerExecutable())->inferredName().utf8(); |
utatane.tea@gmail.com | a8309d9 | 2015-09-01 02:05:30 +0000 | [diff] [blame] | 94 | case ModuleCode: |
| 95 | return "<module>"; |
fpizlo@apple.com | 1a6da21 | 2012-12-10 18:38:15 +0000 | [diff] [blame] | 96 | default: |
| 97 | CRASH(); |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 98 | return CString("", 0); |
fpizlo@apple.com | 1a6da21 | 2012-12-10 18:38:15 +0000 | [diff] [blame] | 99 | } |
| 100 | } |
| 101 | |
mhahnenberg@apple.com | 0c662a4 | 2013-08-02 21:50:56 +0000 | [diff] [blame] | 102 | bool CodeBlock::hasHash() const |
| 103 | { |
| 104 | return !!m_hash; |
| 105 | } |
| 106 | |
| 107 | bool CodeBlock::isSafeToComputeHash() const |
| 108 | { |
| 109 | return !isCompilationThread(); |
| 110 | } |
| 111 | |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 112 | CodeBlockHash CodeBlock::hash() const |
| 113 | { |
oliver@apple.com | acdde49 | 2013-07-25 04:02:57 +0000 | [diff] [blame] | 114 | if (!m_hash) { |
mhahnenberg@apple.com | 0c662a4 | 2013-08-02 21:50:56 +0000 | [diff] [blame] | 115 | RELEASE_ASSERT(isSafeToComputeHash()); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 116 | m_hash = CodeBlockHash(ownerScriptExecutable()->source(), specializationKind()); |
oliver@apple.com | acdde49 | 2013-07-25 04:02:57 +0000 | [diff] [blame] | 117 | } |
| 118 | return m_hash; |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 119 | } |
| 120 | |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 121 | CString CodeBlock::sourceCodeForTools() const |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 122 | { |
| 123 | if (codeType() != FunctionCode) |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 124 | return ownerScriptExecutable()->source().toUTF8(); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 125 | |
| 126 | SourceProvider* provider = source(); |
| 127 | FunctionExecutable* executable = jsCast<FunctionExecutable*>(ownerExecutable()); |
| 128 | UnlinkedFunctionExecutable* unlinked = executable->unlinkedExecutable(); |
| 129 | unsigned unlinkedStartOffset = unlinked->startOffset(); |
| 130 | unsigned linkedStartOffset = executable->source().startOffset(); |
| 131 | int delta = linkedStartOffset - unlinkedStartOffset; |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 132 | unsigned rangeStart = delta + unlinked->unlinkedFunctionNameStart(); |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 133 | unsigned rangeEnd = delta + unlinked->startOffset() + unlinked->sourceLength(); |
| 134 | return toCString( |
| 135 | "function ", |
| 136 | provider->source().impl()->utf8ForRange(rangeStart, rangeEnd - rangeStart)); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 137 | } |
| 138 | |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 139 | CString CodeBlock::sourceCodeOnOneLine() const |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 140 | { |
| 141 | return reduceWhitespace(sourceCodeForTools()); |
| 142 | } |
| 143 | |
fpizlo@apple.com | f285f71 | 2014-03-13 01:50:41 +0000 | [diff] [blame] | 144 | CString CodeBlock::hashAsStringIfPossible() const |
| 145 | { |
| 146 | if (hasHash() || isSafeToComputeHash()) |
| 147 | return toCString(hash()); |
| 148 | return "<no-hash>"; |
| 149 | } |
| 150 | |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 151 | void CodeBlock::dumpAssumingJITType(PrintStream& out, JITCode::JITType jitType) const |
| 152 | { |
fpizlo@apple.com | f285f71 | 2014-03-13 01:50:41 +0000 | [diff] [blame] | 153 | out.print(inferredName(), "#", hashAsStringIfPossible()); |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 154 | out.print(":[", RawPointer(this), "->"); |
| 155 | if (!!m_alternative) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 156 | out.print(RawPointer(m_alternative.get()), "->"); |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 157 | out.print(RawPointer(ownerExecutable()), ", ", jitType, codeType()); |
mhahnenberg@apple.com | 0c662a4 | 2013-08-02 21:50:56 +0000 | [diff] [blame] | 158 | |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 159 | if (codeType() == FunctionCode) |
| 160 | out.print(specializationKind()); |
fpizlo@apple.com | 9df7fef | 2013-12-29 21:50:55 +0000 | [diff] [blame] | 161 | out.print(", ", instructionCount()); |
oliver@apple.com | b3e5acb | 2013-07-25 04:02:53 +0000 | [diff] [blame] | 162 | if (this->jitType() == JITCode::BaselineJIT && m_shouldAlwaysBeInlined) |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 163 | out.print(" (ShouldAlwaysBeInlined)"); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 164 | if (ownerScriptExecutable()->neverInline()) |
oliver@apple.com | 4e67ae5 | 2013-07-25 04:01:24 +0000 | [diff] [blame] | 165 | out.print(" (NeverInline)"); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 166 | if (ownerScriptExecutable()->neverOptimize()) |
mark.lam@apple.com | 49e71b9 | 2015-08-28 05:59:44 +0000 | [diff] [blame] | 167 | out.print(" (NeverOptimize)"); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 168 | if (ownerScriptExecutable()->didTryToEnterInLoop()) |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 169 | out.print(" (DidTryToEnterInLoop)"); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 170 | if (ownerScriptExecutable()->isStrictMode()) |
fpizlo@apple.com | 018818d | 2013-09-13 23:18:19 +0000 | [diff] [blame] | 171 | out.print(" (StrictMode)"); |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 172 | if (this->jitType() == JITCode::BaselineJIT && m_didFailFTLCompilation) |
| 173 | out.print(" (FTLFail)"); |
| 174 | if (this->jitType() == JITCode::BaselineJIT && m_hasBeenCompiledWithFTL) |
| 175 | out.print(" (HadFTLReplacement)"); |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 176 | out.print("]"); |
| 177 | } |
| 178 | |
| 179 | void CodeBlock::dump(PrintStream& out) const |
| 180 | { |
oliver@apple.com | 5a24fdd | 2013-07-25 04:00:54 +0000 | [diff] [blame] | 181 | dumpAssumingJITType(out, jitType()); |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 182 | } |
| 183 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 184 | static CString idName(int id0, const Identifier& ident) |
| 185 | { |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 186 | return toCString(ident.impl(), "(@id", id0, ")"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 187 | } |
| 188 | |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 189 | CString CodeBlock::registerName(int r) const |
mrowe@apple.com | d531609 | 2009-11-05 02:22:08 +0000 | [diff] [blame] | 190 | { |
mrowe@apple.com | d531609 | 2009-11-05 02:22:08 +0000 | [diff] [blame] | 191 | if (isConstantRegisterIndex(r)) |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 192 | return constantName(r); |
mrowe@apple.com | d531609 | 2009-11-05 02:22:08 +0000 | [diff] [blame] | 193 | |
fpizlo@apple.com | 240c7a5 | 2015-02-02 23:32:00 +0000 | [diff] [blame] | 194 | return toCString(VirtualRegister(r)); |
mrowe@apple.com | d531609 | 2009-11-05 02:22:08 +0000 | [diff] [blame] | 195 | } |
| 196 | |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 197 | CString CodeBlock::constantName(int index) const |
| 198 | { |
| 199 | JSValue value = getConstant(index); |
| 200 | return toCString(value, "(", VirtualRegister(index), ")"); |
| 201 | } |
| 202 | |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 203 | static CString regexpToSourceString(RegExp* regExp) |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 204 | { |
| 205 | char postfix[5] = { '/', 0, 0, 0, 0 }; |
| 206 | int index = 1; |
| 207 | if (regExp->global()) |
| 208 | postfix[index++] = 'g'; |
| 209 | if (regExp->ignoreCase()) |
| 210 | postfix[index++] = 'i'; |
| 211 | if (regExp->multiline()) |
| 212 | postfix[index] = 'm'; |
| 213 | |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 214 | return toCString("/", regExp->pattern().impl(), postfix); |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | static CString regexpName(int re, RegExp* regexp) |
| 218 | { |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 219 | return toCString(regexpToSourceString(regexp), "(@re", re, ")"); |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 220 | } |
| 221 | |
ggaren@apple.com | d0740c8 | 2008-05-28 20:47:13 +0000 | [diff] [blame] | 222 | NEVER_INLINE static const char* debugHookName(int debugHookID) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 223 | { |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 224 | switch (static_cast<DebugHookID>(debugHookID)) { |
| 225 | case DidEnterCallFrame: |
| 226 | return "didEnterCallFrame"; |
| 227 | case WillLeaveCallFrame: |
| 228 | return "willLeaveCallFrame"; |
| 229 | case WillExecuteStatement: |
| 230 | return "willExecuteStatement"; |
| 231 | case WillExecuteProgram: |
| 232 | return "willExecuteProgram"; |
| 233 | case DidExecuteProgram: |
| 234 | return "didExecuteProgram"; |
| 235 | case DidReachBreakpoint: |
| 236 | return "didReachBreakpoint"; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 237 | } |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 238 | |
oliver@apple.com | 5598c18 | 2013-01-23 22:25:07 +0000 | [diff] [blame] | 239 | RELEASE_ASSERT_NOT_REACHED(); |
ggaren@apple.com | d0740c8 | 2008-05-28 20:47:13 +0000 | [diff] [blame] | 240 | return ""; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 241 | } |
| 242 | |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 243 | void CodeBlock::printUnaryOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 244 | { |
| 245 | int r0 = (++it)->u.operand; |
| 246 | int r1 = (++it)->u.operand; |
| 247 | |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 248 | printLocationAndOp(out, exec, location, it, op); |
| 249 | out.printf("%s, %s", registerName(r0).data(), registerName(r1).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 250 | } |
| 251 | |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 252 | void CodeBlock::printBinaryOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 253 | { |
| 254 | int r0 = (++it)->u.operand; |
| 255 | int r1 = (++it)->u.operand; |
| 256 | int r2 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 257 | printLocationAndOp(out, exec, location, it, op); |
| 258 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 259 | } |
| 260 | |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 261 | void CodeBlock::printConditionalJump(PrintStream& out, ExecState* exec, const Instruction*, const Instruction*& it, int location, const char* op) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 262 | { |
| 263 | int r0 = (++it)->u.operand; |
| 264 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 265 | printLocationAndOp(out, exec, location, it, op); |
| 266 | out.printf("%s, %d(->%d)", registerName(r0).data(), offset, location + offset); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 267 | } |
| 268 | |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 269 | void CodeBlock::printGetByIdOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it) |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 270 | { |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 271 | const char* op; |
| 272 | switch (exec->interpreter()->getOpcodeID(it->u.opcode)) { |
| 273 | case op_get_by_id: |
| 274 | op = "get_by_id"; |
| 275 | break; |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 276 | case op_get_array_length: |
| 277 | op = "array_length"; |
| 278 | break; |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 279 | default: |
oliver@apple.com | 5598c18 | 2013-01-23 22:25:07 +0000 | [diff] [blame] | 280 | RELEASE_ASSERT_NOT_REACHED(); |
mjs@apple.com | 0a66116 | 2014-09-08 02:16:47 +0000 | [diff] [blame] | 281 | #if COMPILER_QUIRK(CONSIDERS_UNREACHABLE_CODE) |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 282 | op = 0; |
mjs@apple.com | 0a66116 | 2014-09-08 02:16:47 +0000 | [diff] [blame] | 283 | #endif |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 284 | } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 285 | int r0 = (++it)->u.operand; |
| 286 | int r1 = (++it)->u.operand; |
| 287 | int id0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 288 | printLocationAndOp(out, exec, location, it, op); |
| 289 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), idName(id0, identifier(id0)).data()); |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 290 | it += 4; // Increment up to the value profiler. |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 291 | } |
| 292 | |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 293 | static void dumpStructure(PrintStream& out, const char* name, Structure* structure, const Identifier& ident) |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 294 | { |
| 295 | if (!structure) |
| 296 | return; |
| 297 | |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 298 | out.printf("%s = %p", name, structure); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 299 | |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 300 | PropertyOffset offset = structure->getConcurrently(ident.impl()); |
fpizlo@apple.com | 961a956 | 2012-07-24 02:13:19 +0000 | [diff] [blame] | 301 | if (offset != invalidOffset) |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 302 | out.printf(" (offset = %d)", offset); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 303 | } |
| 304 | |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 305 | static void dumpChain(PrintStream& out, StructureChain* chain, const Identifier& ident) |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 306 | { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 307 | out.printf("chain = %p: [", chain); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 308 | bool first = true; |
| 309 | for (WriteBarrier<Structure>* currentStructure = chain->head(); |
| 310 | *currentStructure; |
| 311 | ++currentStructure) { |
| 312 | if (first) |
| 313 | first = false; |
| 314 | else |
fpizlo@apple.com | 304fbca | 2012-12-17 21:38:51 +0000 | [diff] [blame] | 315 | out.printf(", "); |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 316 | dumpStructure(out, "struct", currentStructure->get(), ident); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 317 | } |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 318 | out.printf("]"); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 319 | } |
| 320 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 321 | void CodeBlock::printGetByIdCacheStatus(PrintStream& out, ExecState* exec, int location, const StubInfoMap& map) |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 322 | { |
| 323 | Instruction* instruction = instructions().begin() + location; |
| 324 | |
oliver@apple.com | 9b65276 | 2013-08-12 22:39:13 +0000 | [diff] [blame] | 325 | const Identifier& ident = identifier(instruction[3].u.operand); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 326 | |
fpizlo@apple.com | b75911b | 2012-06-13 20:53:52 +0000 | [diff] [blame] | 327 | UNUSED_PARAM(ident); // tell the compiler to shut up in certain platform configurations. |
| 328 | |
fpizlo@apple.com | 4cafdbd | 2012-09-11 20:00:31 +0000 | [diff] [blame] | 329 | if (exec->interpreter()->getOpcodeID(instruction[0].u.opcode) == op_get_array_length) |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 330 | out.printf(" llint(array_length)"); |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 331 | else if (StructureID structureID = instruction[4].u.structureID) { |
| 332 | Structure* structure = m_vm->heap.structureIDTable().get(structureID); |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 333 | out.printf(" llint("); |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 334 | dumpStructure(out, "struct", structure, ident); |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 335 | out.printf(")"); |
fpizlo@apple.com | 4cafdbd | 2012-09-11 20:00:31 +0000 | [diff] [blame] | 336 | } |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 337 | |
| 338 | #if ENABLE(JIT) |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 339 | if (StructureStubInfo* stubPtr = map.get(CodeOrigin(location))) { |
| 340 | StructureStubInfo& stubInfo = *stubPtr; |
fpizlo@apple.com | 12803e2 | 2014-02-02 06:38:51 +0000 | [diff] [blame] | 341 | if (stubInfo.resetByGC) |
| 342 | out.print(" (Reset By GC)"); |
| 343 | |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 344 | if (stubInfo.seen) { |
| 345 | out.printf(" jit("); |
| 346 | |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 347 | Structure* baseStructure = nullptr; |
| 348 | PolymorphicAccess* stub = nullptr; |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 349 | |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 350 | switch (stubInfo.cacheType) { |
| 351 | case CacheType::GetByIdSelf: |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 352 | out.printf("self"); |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 353 | baseStructure = stubInfo.u.byIdSelf.baseObjectStructure.get(); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 354 | break; |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 355 | case CacheType::Stub: |
| 356 | out.printf("stub"); |
| 357 | stub = stubInfo.u.stub; |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 358 | break; |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 359 | case CacheType::Unset: |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 360 | out.printf("unset"); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 361 | break; |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 362 | default: |
oliver@apple.com | 5598c18 | 2013-01-23 22:25:07 +0000 | [diff] [blame] | 363 | RELEASE_ASSERT_NOT_REACHED(); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 364 | break; |
| 365 | } |
| 366 | |
| 367 | if (baseStructure) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 368 | out.printf(", "); |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 369 | dumpStructure(out, "struct", baseStructure, ident); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 370 | } |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 371 | |
| 372 | if (stub) |
| 373 | out.print(", ", *stub); |
| 374 | |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 375 | out.printf(")"); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 376 | } |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 377 | } |
mark.lam@apple.com | b1ea3ea | 2013-10-24 16:10:59 +0000 | [diff] [blame] | 378 | #else |
| 379 | UNUSED_PARAM(map); |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 380 | #endif |
| 381 | } |
| 382 | |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 383 | void CodeBlock::printPutByIdCacheStatus(PrintStream& out, int location, const StubInfoMap& map) |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 384 | { |
| 385 | Instruction* instruction = instructions().begin() + location; |
| 386 | |
| 387 | const Identifier& ident = identifier(instruction[2].u.operand); |
| 388 | |
| 389 | UNUSED_PARAM(ident); // tell the compiler to shut up in certain platform configurations. |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 390 | |
| 391 | out.print(", ", instruction[8].u.putByIdFlags); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 392 | |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 393 | if (StructureID structureID = instruction[4].u.structureID) { |
| 394 | Structure* structure = m_vm->heap.structureIDTable().get(structureID); |
| 395 | out.print(" llint("); |
| 396 | if (StructureID newStructureID = instruction[6].u.structureID) { |
| 397 | Structure* newStructure = m_vm->heap.structureIDTable().get(newStructureID); |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 398 | dumpStructure(out, "prev", structure, ident); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 399 | out.print(", "); |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 400 | dumpStructure(out, "next", newStructure, ident); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 401 | if (StructureChain* chain = instruction[7].u.structureChain.get()) { |
| 402 | out.print(", "); |
fpizlo@apple.com | 15ec1b2 | 2014-09-21 19:18:40 +0000 | [diff] [blame] | 403 | dumpChain(out, chain, ident); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 404 | } |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 405 | } else |
| 406 | dumpStructure(out, "struct", structure, ident); |
| 407 | out.print(")"); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | #if ENABLE(JIT) |
| 411 | if (StructureStubInfo* stubPtr = map.get(CodeOrigin(location))) { |
| 412 | StructureStubInfo& stubInfo = *stubPtr; |
| 413 | if (stubInfo.resetByGC) |
| 414 | out.print(" (Reset By GC)"); |
| 415 | |
| 416 | if (stubInfo.seen) { |
| 417 | out.printf(" jit("); |
| 418 | |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 419 | switch (stubInfo.cacheType) { |
| 420 | case CacheType::PutByIdReplace: |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 421 | out.print("replace, "); |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 422 | dumpStructure(out, "struct", stubInfo.u.byIdSelf.baseObjectStructure.get(), ident); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 423 | break; |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 424 | case CacheType::Stub: { |
| 425 | out.print("stub, ", *stubInfo.u.stub); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 426 | break; |
| 427 | } |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 428 | case CacheType::Unset: |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 429 | out.printf("unset"); |
| 430 | break; |
| 431 | default: |
| 432 | RELEASE_ASSERT_NOT_REACHED(); |
| 433 | break; |
| 434 | } |
| 435 | out.printf(")"); |
| 436 | } |
| 437 | } |
| 438 | #else |
| 439 | UNUSED_PARAM(map); |
| 440 | #endif |
| 441 | } |
| 442 | |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 443 | void CodeBlock::printCallOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op, CacheDumpMode cacheDumpMode, bool& hasPrintedProfiling, const CallLinkInfoMap& map) |
ggaren@apple.com | 6f82ad5 | 2012-01-12 01:00:58 +0000 | [diff] [blame] | 444 | { |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 445 | int dst = (++it)->u.operand; |
ggaren@apple.com | 6f82ad5 | 2012-01-12 01:00:58 +0000 | [diff] [blame] | 446 | int func = (++it)->u.operand; |
| 447 | int argCount = (++it)->u.operand; |
| 448 | int registerOffset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 449 | printLocationAndOp(out, exec, location, it, op); |
| 450 | out.printf("%s, %s, %d, %d", registerName(dst).data(), registerName(func).data(), argCount, registerOffset); |
fpizlo@apple.com | c644611 | 2012-05-23 20:52:42 +0000 | [diff] [blame] | 451 | if (cacheDumpMode == DumpCaches) { |
fpizlo@apple.com | c644611 | 2012-05-23 20:52:42 +0000 | [diff] [blame] | 452 | LLIntCallLinkInfo* callLinkInfo = it[1].u.callLinkInfo; |
| 453 | if (callLinkInfo->lastSeenCallee) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 454 | out.printf( |
| 455 | " llint(%p, exec %p)", |
| 456 | callLinkInfo->lastSeenCallee.get(), |
| 457 | callLinkInfo->lastSeenCallee->executable()); |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 458 | } |
fpizlo@apple.com | c644611 | 2012-05-23 20:52:42 +0000 | [diff] [blame] | 459 | #if ENABLE(JIT) |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 460 | if (CallLinkInfo* info = map.get(CodeOrigin(location))) { |
msaboff@apple.com | 203a56e | 2015-06-24 22:37:30 +0000 | [diff] [blame] | 461 | JSFunction* target = info->lastSeenCallee(); |
fpizlo@apple.com | 5e3852d | 2012-05-24 00:05:21 +0000 | [diff] [blame] | 462 | if (target) |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 463 | out.printf(" jit(%p, exec %p)", target, target->executable()); |
fpizlo@apple.com | 5e3852d | 2012-05-24 00:05:21 +0000 | [diff] [blame] | 464 | } |
mark.lam@apple.com | 507b94e | 2015-04-17 00:25:14 +0000 | [diff] [blame] | 465 | |
| 466 | if (jitType() != JITCode::FTLJIT) |
| 467 | out.print(" status(", CallLinkStatus::computeFor(this, location, map), ")"); |
fpizlo@apple.com | f7100b6 | 2014-03-24 17:29:51 +0000 | [diff] [blame] | 468 | #else |
| 469 | UNUSED_PARAM(map); |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 470 | #endif |
fpizlo@apple.com | c644611 | 2012-05-23 20:52:42 +0000 | [diff] [blame] | 471 | } |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 472 | ++it; |
oliver@apple.com | 7ff89b1 | 2014-02-21 22:37:29 +0000 | [diff] [blame] | 473 | ++it; |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 474 | dumpArrayProfiling(out, it, hasPrintedProfiling); |
| 475 | dumpValueProfiling(out, it, hasPrintedProfiling); |
ggaren@apple.com | 6f82ad5 | 2012-01-12 01:00:58 +0000 | [diff] [blame] | 476 | } |
| 477 | |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 478 | void CodeBlock::printPutByIdOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op) |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 479 | { |
| 480 | int r0 = (++it)->u.operand; |
| 481 | int id0 = (++it)->u.operand; |
| 482 | int r1 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 483 | printLocationAndOp(out, exec, location, it, op); |
| 484 | out.printf("%s, %s, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), registerName(r1).data()); |
oliver@apple.com | ef690aa | 2010-07-15 20:00:31 +0000 | [diff] [blame] | 485 | it += 5; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 486 | } |
| 487 | |
mark.lam@apple.com | e7f8884 | 2015-04-02 22:46:52 +0000 | [diff] [blame] | 488 | void CodeBlock::dumpSource() |
| 489 | { |
| 490 | dumpSource(WTF::dataFile()); |
| 491 | } |
| 492 | |
| 493 | void CodeBlock::dumpSource(PrintStream& out) |
| 494 | { |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 495 | ScriptExecutable* executable = ownerScriptExecutable(); |
mark.lam@apple.com | e7f8884 | 2015-04-02 22:46:52 +0000 | [diff] [blame] | 496 | if (executable->isFunctionExecutable()) { |
| 497 | FunctionExecutable* functionExecutable = reinterpret_cast<FunctionExecutable*>(executable); |
| 498 | String source = functionExecutable->source().provider()->getRange( |
| 499 | functionExecutable->parametersStartOffset(), |
| 500 | functionExecutable->typeProfilingEndOffset() + 1); // Type profiling end offset is the character before the '}'. |
| 501 | |
| 502 | out.print("function ", inferredName(), source); |
| 503 | return; |
| 504 | } |
| 505 | out.print(executable->source().toString()); |
| 506 | } |
| 507 | |
| 508 | void CodeBlock::dumpBytecode() |
| 509 | { |
| 510 | dumpBytecode(WTF::dataFile()); |
| 511 | } |
| 512 | |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 513 | void CodeBlock::dumpBytecode(PrintStream& out) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 514 | { |
fpizlo@apple.com | 1949f32 | 2012-11-22 00:46:57 +0000 | [diff] [blame] | 515 | // We only use the ExecState* for things that don't actually lead to JS execution, |
| 516 | // like converting a JSString to a String. Hence the globalExec is appropriate. |
| 517 | ExecState* exec = m_globalObject->globalExec(); |
| 518 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 519 | size_t instructionCount = 0; |
weinig@apple.com | 0aaf82a | 2008-12-12 08:02:09 +0000 | [diff] [blame] | 520 | |
fpizlo@apple.com | 9ac73f1 | 2011-11-10 04:37:32 +0000 | [diff] [blame] | 521 | for (size_t i = 0; i < instructions().size(); i += opcodeLengths[exec->interpreter()->getOpcodeID(instructions()[i].u.opcode)]) |
weinig@apple.com | 0aaf82a | 2008-12-12 08:02:09 +0000 | [diff] [blame] | 522 | ++instructionCount; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 523 | |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 524 | out.print(*this); |
| 525 | out.printf( |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 526 | ": %lu m_instructions; %lu bytes; %d parameter(s); %d callee register(s); %d variable(s)", |
fpizlo@apple.com | ebe232e | 2012-02-27 02:07:34 +0000 | [diff] [blame] | 527 | static_cast<unsigned long>(instructions().size()), |
fpizlo@apple.com | 9ac73f1 | 2011-11-10 04:37:32 +0000 | [diff] [blame] | 528 | static_cast<unsigned long>(instructions().size() * sizeof(Instruction)), |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 529 | m_numParameters, m_numCalleeRegisters, m_numVars); |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 530 | if (needsActivation() && codeType() == FunctionCode) |
oliver@apple.com | a7dfb4d | 2014-09-11 18:18:14 +0000 | [diff] [blame] | 531 | out.printf("; lexical environment in r%d", activationRegister().offset()); |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 532 | out.printf("\n"); |
| 533 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 534 | StubInfoMap stubInfos; |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 535 | CallLinkInfoMap callLinkInfos; |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 536 | getStubInfoMap(stubInfos); |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 537 | getCallLinkInfoMap(callLinkInfos); |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 538 | |
fpizlo@apple.com | 1949f32 | 2012-11-22 00:46:57 +0000 | [diff] [blame] | 539 | const Instruction* begin = instructions().begin(); |
| 540 | const Instruction* end = instructions().end(); |
| 541 | for (const Instruction* it = begin; it != end; ++it) |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 542 | dumpBytecode(out, exec, begin, it, stubInfos, callLinkInfos); |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 543 | |
oliver@apple.com | 9b65276 | 2013-08-12 22:39:13 +0000 | [diff] [blame] | 544 | if (numberOfIdentifiers()) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 545 | out.printf("\nIdentifiers:\n"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 546 | size_t i = 0; |
| 547 | do { |
oliver@apple.com | 9b65276 | 2013-08-12 22:39:13 +0000 | [diff] [blame] | 548 | out.printf(" id%u = %s\n", static_cast<unsigned>(i), identifier(i).string().utf8().data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 549 | ++i; |
oliver@apple.com | 9b65276 | 2013-08-12 22:39:13 +0000 | [diff] [blame] | 550 | } while (i != numberOfIdentifiers()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 551 | } |
| 552 | |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 553 | if (!m_constantRegisters.isEmpty()) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 554 | out.printf("\nConstants:\n"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 555 | size_t i = 0; |
| 556 | do { |
mark.lam@apple.com | 61ba1f3 | 2015-03-10 19:29:13 +0000 | [diff] [blame] | 557 | const char* sourceCodeRepresentationDescription = nullptr; |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 558 | switch (m_constantsSourceCodeRepresentation[i]) { |
| 559 | case SourceCodeRepresentation::Double: |
| 560 | sourceCodeRepresentationDescription = ": in source as double"; |
| 561 | break; |
| 562 | case SourceCodeRepresentation::Integer: |
| 563 | sourceCodeRepresentationDescription = ": in source as integer"; |
| 564 | break; |
| 565 | case SourceCodeRepresentation::Other: |
| 566 | sourceCodeRepresentationDescription = ""; |
| 567 | break; |
| 568 | } |
| 569 | out.printf(" k%u = %s%s\n", static_cast<unsigned>(i), toCString(m_constantRegisters[i].get()).data(), sourceCodeRepresentationDescription); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 570 | ++i; |
weinig@apple.com | cb26d81 | 2008-12-06 22:01:05 +0000 | [diff] [blame] | 571 | } while (i < m_constantRegisters.size()); |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 572 | } |
| 573 | |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 574 | if (size_t count = m_unlinkedCode->numberOfRegExps()) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 575 | out.printf("\nm_regexps:\n"); |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 576 | size_t i = 0; |
| 577 | do { |
oliver@apple.com | 0203946 | 2013-07-25 03:59:29 +0000 | [diff] [blame] | 578 | out.printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_unlinkedCode->regexp(i)).data()); |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 579 | ++i; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 580 | } while (i < count); |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 581 | } |
| 582 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 583 | if (m_rareData && !m_rareData->m_exceptionHandlers.isEmpty()) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 584 | out.printf("\nException Handlers:\n"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 585 | unsigned i = 0; |
| 586 | do { |
mark.lam@apple.com | 4585ce9 | 2015-05-30 00:19:01 +0000 | [diff] [blame] | 587 | HandlerInfo& handler = m_rareData->m_exceptionHandlers[i]; |
saambarati1@gmail.com | e85426c | 2015-08-07 17:41:22 +0000 | [diff] [blame] | 588 | out.printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] } %s\n", |
| 589 | i + 1, handler.start, handler.end, handler.target, handler.typeName()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 590 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 591 | } while (i < m_rareData->m_exceptionHandlers.size()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 592 | } |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 593 | |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 594 | if (m_rareData && !m_rareData->m_switchJumpTables.isEmpty()) { |
| 595 | out.printf("Switch Jump Tables:\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 596 | unsigned i = 0; |
| 597 | do { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 598 | out.printf(" %1d = {\n", i); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 599 | int entry = 0; |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 600 | Vector<int32_t>::const_iterator end = m_rareData->m_switchJumpTables[i].branchOffsets.end(); |
| 601 | for (Vector<int32_t>::const_iterator iter = m_rareData->m_switchJumpTables[i].branchOffsets.begin(); iter != end; ++iter, ++entry) { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 602 | if (!*iter) |
| 603 | continue; |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 604 | out.printf("\t\t%4d => %04d\n", entry + m_rareData->m_switchJumpTables[i].min, *iter); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 605 | } |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 606 | out.printf(" }\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 607 | ++i; |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 608 | } while (i < m_rareData->m_switchJumpTables.size()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 609 | } |
| 610 | |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 611 | if (m_rareData && !m_rareData->m_stringSwitchJumpTables.isEmpty()) { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 612 | out.printf("\nString Switch Jump Tables:\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 613 | unsigned i = 0; |
| 614 | do { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 615 | out.printf(" %1d = {\n", i); |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 616 | StringJumpTable::StringOffsetTable::const_iterator end = m_rareData->m_stringSwitchJumpTables[i].offsetTable.end(); |
| 617 | for (StringJumpTable::StringOffsetTable::const_iterator iter = m_rareData->m_stringSwitchJumpTables[i].offsetTable.begin(); iter != end; ++iter) |
msaboff@apple.com | c2d9471 | 2014-04-29 01:36:14 +0000 | [diff] [blame] | 618 | out.printf("\t\t\"%s\" => %04d\n", iter->key->utf8().data(), iter->value.branchOffset); |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 619 | out.printf(" }\n"); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 620 | ++i; |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 621 | } while (i < m_rareData->m_stringSwitchJumpTables.size()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 622 | } |
| 623 | |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 624 | out.printf("\n"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 625 | } |
| 626 | |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 627 | void CodeBlock::beginDumpProfiling(PrintStream& out, bool& hasPrintedProfiling) |
| 628 | { |
| 629 | if (hasPrintedProfiling) { |
| 630 | out.print("; "); |
| 631 | return; |
| 632 | } |
| 633 | |
| 634 | out.print(" "); |
| 635 | hasPrintedProfiling = true; |
| 636 | } |
| 637 | |
| 638 | void CodeBlock::dumpValueProfiling(PrintStream& out, const Instruction*& it, bool& hasPrintedProfiling) |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 639 | { |
oliver@apple.com | d205666 | 2013-07-25 04:00:37 +0000 | [diff] [blame] | 640 | ConcurrentJITLocker locker(m_lock); |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 641 | |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 642 | ++it; |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 643 | CString description = it->u.profile->briefDescription(locker); |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 644 | if (!description.length()) |
| 645 | return; |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 646 | beginDumpProfiling(out, hasPrintedProfiling); |
| 647 | out.print(description); |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 648 | } |
| 649 | |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 650 | void CodeBlock::dumpArrayProfiling(PrintStream& out, const Instruction*& it, bool& hasPrintedProfiling) |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 651 | { |
oliver@apple.com | d205666 | 2013-07-25 04:00:37 +0000 | [diff] [blame] | 652 | ConcurrentJITLocker locker(m_lock); |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 653 | |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 654 | ++it; |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 655 | if (!it->u.arrayProfile) |
| 656 | return; |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 657 | CString description = it->u.arrayProfile->briefDescription(locker, this); |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 658 | if (!description.length()) |
| 659 | return; |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 660 | beginDumpProfiling(out, hasPrintedProfiling); |
| 661 | out.print(description); |
fpizlo@apple.com | 77ef0e3 | 2012-12-12 00:21:43 +0000 | [diff] [blame] | 662 | } |
| 663 | |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 664 | void CodeBlock::dumpRareCaseProfile(PrintStream& out, const char* name, RareCaseProfile* profile, bool& hasPrintedProfiling) |
| 665 | { |
| 666 | if (!profile || !profile->m_counter) |
| 667 | return; |
| 668 | |
| 669 | beginDumpProfiling(out, hasPrintedProfiling); |
| 670 | out.print(name, profile->m_counter); |
| 671 | } |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 672 | |
fpizlo@apple.com | 12803e2 | 2014-02-02 06:38:51 +0000 | [diff] [blame] | 673 | void CodeBlock::printLocationAndOp(PrintStream& out, ExecState*, int location, const Instruction*&, const char* op) |
| 674 | { |
| 675 | out.printf("[%4d] %-17s ", location, op); |
| 676 | } |
| 677 | |
| 678 | void CodeBlock::printLocationOpAndRegisterOperand(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op, int operand) |
| 679 | { |
| 680 | printLocationAndOp(out, exec, location, it, op); |
| 681 | out.printf("%s", registerName(operand).data()); |
| 682 | } |
| 683 | |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 684 | void CodeBlock::dumpBytecode( |
| 685 | PrintStream& out, ExecState* exec, const Instruction* begin, const Instruction*& it, |
| 686 | const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 687 | { |
| 688 | int location = it - begin; |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 689 | bool hasPrintedProfiling = false; |
oliver@apple.com | 177c2b9 | 2014-03-28 01:10:25 +0000 | [diff] [blame] | 690 | OpcodeID opcode = exec->interpreter()->getOpcodeID(it->u.opcode); |
| 691 | switch (opcode) { |
mjs@apple.com | 8b246d6 | 2008-10-04 07:15:33 +0000 | [diff] [blame] | 692 | case op_enter: { |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 693 | printLocationAndOp(out, exec, location, it, "enter"); |
oliver@apple.com | ecfd224 | 2008-09-20 03:00:43 +0000 | [diff] [blame] | 694 | break; |
| 695 | } |
msaboff@apple.com | 8b6b341 | 2014-11-04 03:36:28 +0000 | [diff] [blame] | 696 | case op_get_scope: { |
| 697 | int r0 = (++it)->u.operand; |
| 698 | printLocationOpAndRegisterOperand(out, exec, location, it, "get_scope", r0); |
| 699 | break; |
| 700 | } |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 701 | case op_load_arrowfunction_this: { |
| 702 | int r0 = (++it)->u.operand; |
| 703 | printLocationOpAndRegisterOperand(out, exec, location, it, "load_arrowfunction_this", r0); |
| 704 | break; |
| 705 | } |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 706 | case op_create_direct_arguments: { |
ggaren@apple.com | 83ce11c | 2010-05-19 05:10:11 +0000 | [diff] [blame] | 707 | int r0 = (++it)->u.operand; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 708 | printLocationAndOp(out, exec, location, it, "create_direct_arguments"); |
| 709 | out.printf("%s", registerName(r0).data()); |
cwzwarich@webkit.org | 9e464ca | 2008-09-29 03:04:08 +0000 | [diff] [blame] | 710 | break; |
| 711 | } |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 712 | case op_create_scoped_arguments: { |
ggaren@apple.com | 83ce11c | 2010-05-19 05:10:11 +0000 | [diff] [blame] | 713 | int r0 = (++it)->u.operand; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 714 | int r1 = (++it)->u.operand; |
| 715 | printLocationAndOp(out, exec, location, it, "create_scoped_arguments"); |
| 716 | out.printf("%s, %s", registerName(r0).data(), registerName(r1).data()); |
| 717 | break; |
| 718 | } |
| 719 | case op_create_out_of_band_arguments: { |
| 720 | int r0 = (++it)->u.operand; |
| 721 | printLocationAndOp(out, exec, location, it, "create_out_of_band_arguments"); |
| 722 | out.printf("%s", registerName(r0).data()); |
oliver@apple.com | be38ac4 | 2009-05-12 08:58:56 +0000 | [diff] [blame] | 723 | break; |
| 724 | } |
barraclough@apple.com | fd8c28a | 2010-05-25 03:04:43 +0000 | [diff] [blame] | 725 | case op_create_this: { |
| 726 | int r0 = (++it)->u.operand; |
fpizlo@apple.com | c2c6763 | 2012-11-17 08:37:14 +0000 | [diff] [blame] | 727 | int r1 = (++it)->u.operand; |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 728 | unsigned inferredInlineCapacity = (++it)->u.operand; |
rniwa@webkit.org | 1b971d7 | 2015-05-14 04:19:18 +0000 | [diff] [blame] | 729 | unsigned cachedFunction = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 730 | printLocationAndOp(out, exec, location, it, "create_this"); |
rniwa@webkit.org | 1b971d7 | 2015-05-14 04:19:18 +0000 | [diff] [blame] | 731 | out.printf("%s, %s, %u, %u", registerName(r0).data(), registerName(r1).data(), inferredInlineCapacity, cachedFunction); |
barraclough@apple.com | fd8c28a | 2010-05-25 03:04:43 +0000 | [diff] [blame] | 732 | break; |
| 733 | } |
oliver@apple.com | e2fe4ce | 2013-07-25 03:59:41 +0000 | [diff] [blame] | 734 | case op_to_this: { |
mjs@apple.com | 8b246d6 | 2008-10-04 07:15:33 +0000 | [diff] [blame] | 735 | int r0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 736 | printLocationOpAndRegisterOperand(out, exec, location, it, "to_this", r0); |
fpizlo@apple.com | 12803e2 | 2014-02-02 06:38:51 +0000 | [diff] [blame] | 737 | Structure* structure = (++it)->u.structure.get(); |
| 738 | if (structure) |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 739 | out.print(", cache(struct = ", RawPointer(structure), ")"); |
| 740 | out.print(", ", (++it)->u.toThisStatus); |
mjs@apple.com | 8b246d6 | 2008-10-04 07:15:33 +0000 | [diff] [blame] | 741 | break; |
| 742 | } |
rniwa@webkit.org | eb7ac19 | 2015-03-13 01:11:15 +0000 | [diff] [blame] | 743 | case op_check_tdz: { |
| 744 | int r0 = (++it)->u.operand; |
| 745 | printLocationOpAndRegisterOperand(out, exec, location, it, "op_check_tdz", r0); |
| 746 | break; |
| 747 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 748 | case op_new_object: { |
| 749 | int r0 = (++it)->u.operand; |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 750 | unsigned inferredInlineCapacity = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 751 | printLocationAndOp(out, exec, location, it, "new_object"); |
| 752 | out.printf("%s, %u", registerName(r0).data(), inferredInlineCapacity); |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 753 | ++it; // Skip object allocation profile. |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 754 | break; |
| 755 | } |
| 756 | case op_new_array: { |
darin@apple.com | 9ce7902 | 2008-06-28 15:50:49 +0000 | [diff] [blame] | 757 | int dst = (++it)->u.operand; |
| 758 | int argv = (++it)->u.operand; |
| 759 | int argc = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 760 | printLocationAndOp(out, exec, location, it, "new_array"); |
| 761 | out.printf("%s, %s, %d", registerName(dst).data(), registerName(argv).data(), argc); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 762 | ++it; // Skip array allocation profile. |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 763 | break; |
| 764 | } |
fpizlo@apple.com | 4500e35 | 2012-10-17 21:39:11 +0000 | [diff] [blame] | 765 | case op_new_array_with_size: { |
| 766 | int dst = (++it)->u.operand; |
| 767 | int length = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 768 | printLocationAndOp(out, exec, location, it, "new_array_with_size"); |
| 769 | out.printf("%s, %s", registerName(dst).data(), registerName(length).data()); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 770 | ++it; // Skip array allocation profile. |
fpizlo@apple.com | 4500e35 | 2012-10-17 21:39:11 +0000 | [diff] [blame] | 771 | break; |
| 772 | } |
oliver@apple.com | a991d69 | 2011-06-14 23:39:25 +0000 | [diff] [blame] | 773 | case op_new_array_buffer: { |
| 774 | int dst = (++it)->u.operand; |
| 775 | int argv = (++it)->u.operand; |
| 776 | int argc = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 777 | printLocationAndOp(out, exec, location, it, "new_array_buffer"); |
| 778 | out.printf("%s, %d, %d", registerName(dst).data(), argv, argc); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 779 | ++it; // Skip array allocation profile. |
oliver@apple.com | a991d69 | 2011-06-14 23:39:25 +0000 | [diff] [blame] | 780 | break; |
| 781 | } |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 782 | case op_new_regexp: { |
| 783 | int r0 = (++it)->u.operand; |
| 784 | int re0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 785 | printLocationAndOp(out, exec, location, it, "new_regexp"); |
| 786 | out.printf("%s, ", registerName(r0).data()); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 787 | if (r0 >=0 && r0 < (int)m_unlinkedCode->numberOfRegExps()) |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 788 | out.printf("%s", regexpName(re0, regexp(re0)).data()); |
fpizlo@apple.com | 68186e1 | 2011-08-17 20:54:32 +0000 | [diff] [blame] | 789 | else |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 790 | out.printf("bad_regexp(%d)", re0); |
oliver@apple.com | 22d55c3 | 2010-05-10 01:41:07 +0000 | [diff] [blame] | 791 | break; |
| 792 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 793 | case op_mov: { |
| 794 | int r0 = (++it)->u.operand; |
| 795 | int r1 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 796 | printLocationAndOp(out, exec, location, it, "mov"); |
| 797 | out.printf("%s, %s", registerName(r0).data(), registerName(r1).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 798 | break; |
| 799 | } |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 800 | case op_profile_type: { |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 801 | int r0 = (++it)->u.operand; |
| 802 | ++it; |
| 803 | ++it; |
commit-queue@webkit.org | 0163f12 | 2014-08-21 02:29:47 +0000 | [diff] [blame] | 804 | ++it; |
| 805 | ++it; |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 806 | printLocationAndOp(out, exec, location, it, "op_profile_type"); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 807 | out.printf("%s", registerName(r0).data()); |
| 808 | break; |
| 809 | } |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 810 | case op_profile_control_flow: { |
| 811 | BasicBlockLocation* basicBlockLocation = (++it)->u.basicBlockLocation; |
| 812 | printLocationAndOp(out, exec, location, it, "profile_control_flow"); |
| 813 | out.printf("[%d, %d]", basicBlockLocation->startOffset(), basicBlockLocation->endOffset()); |
| 814 | break; |
| 815 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 816 | case op_not: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 817 | printUnaryOp(out, exec, location, it, "not"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 818 | break; |
| 819 | } |
| 820 | case op_eq: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 821 | printBinaryOp(out, exec, location, it, "eq"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 822 | break; |
| 823 | } |
ggaren@apple.com | f15b1880 | 2008-09-03 02:58:14 +0000 | [diff] [blame] | 824 | case op_eq_null: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 825 | printUnaryOp(out, exec, location, it, "eq_null"); |
ggaren@apple.com | f15b1880 | 2008-09-03 02:58:14 +0000 | [diff] [blame] | 826 | break; |
| 827 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 828 | case op_neq: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 829 | printBinaryOp(out, exec, location, it, "neq"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 830 | break; |
| 831 | } |
ggaren@apple.com | f15b1880 | 2008-09-03 02:58:14 +0000 | [diff] [blame] | 832 | case op_neq_null: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 833 | printUnaryOp(out, exec, location, it, "neq_null"); |
ggaren@apple.com | f15b1880 | 2008-09-03 02:58:14 +0000 | [diff] [blame] | 834 | break; |
| 835 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 836 | case op_stricteq: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 837 | printBinaryOp(out, exec, location, it, "stricteq"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 838 | break; |
| 839 | } |
| 840 | case op_nstricteq: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 841 | printBinaryOp(out, exec, location, it, "nstricteq"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 842 | break; |
| 843 | } |
| 844 | case op_less: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 845 | printBinaryOp(out, exec, location, it, "less"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 846 | break; |
| 847 | } |
| 848 | case op_lesseq: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 849 | printBinaryOp(out, exec, location, it, "lesseq"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 850 | break; |
| 851 | } |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 852 | case op_greater: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 853 | printBinaryOp(out, exec, location, it, "greater"); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 854 | break; |
| 855 | } |
| 856 | case op_greatereq: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 857 | printBinaryOp(out, exec, location, it, "greatereq"); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 858 | break; |
| 859 | } |
ggaren@apple.com | f303611 | 2013-04-27 23:14:04 +0000 | [diff] [blame] | 860 | case op_inc: { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 861 | int r0 = (++it)->u.operand; |
fpizlo@apple.com | 9bca4b8 | 2013-11-11 21:46:37 +0000 | [diff] [blame] | 862 | printLocationOpAndRegisterOperand(out, exec, location, it, "inc", r0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 863 | break; |
| 864 | } |
ggaren@apple.com | f303611 | 2013-04-27 23:14:04 +0000 | [diff] [blame] | 865 | case op_dec: { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 866 | int r0 = (++it)->u.operand; |
fpizlo@apple.com | 9bca4b8 | 2013-11-11 21:46:37 +0000 | [diff] [blame] | 867 | printLocationOpAndRegisterOperand(out, exec, location, it, "dec", r0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 868 | break; |
| 869 | } |
ggaren@apple.com | f303611 | 2013-04-27 23:14:04 +0000 | [diff] [blame] | 870 | case op_to_number: { |
| 871 | printUnaryOp(out, exec, location, it, "to_number"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 872 | break; |
| 873 | } |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 874 | case op_to_string: { |
| 875 | printUnaryOp(out, exec, location, it, "to_string"); |
| 876 | break; |
| 877 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 878 | case op_negate: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 879 | printUnaryOp(out, exec, location, it, "negate"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 880 | break; |
| 881 | } |
| 882 | case op_add: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 883 | printBinaryOp(out, exec, location, it, "add"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 884 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 885 | break; |
| 886 | } |
| 887 | case op_mul: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 888 | printBinaryOp(out, exec, location, it, "mul"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 889 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 890 | break; |
| 891 | } |
| 892 | case op_div: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 893 | printBinaryOp(out, exec, location, it, "div"); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 894 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 895 | break; |
| 896 | } |
| 897 | case op_mod: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 898 | printBinaryOp(out, exec, location, it, "mod"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 899 | break; |
| 900 | } |
| 901 | case op_sub: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 902 | printBinaryOp(out, exec, location, it, "sub"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 903 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 904 | break; |
| 905 | } |
| 906 | case op_lshift: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 907 | printBinaryOp(out, exec, location, it, "lshift"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 908 | break; |
| 909 | } |
| 910 | case op_rshift: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 911 | printBinaryOp(out, exec, location, it, "rshift"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 912 | break; |
| 913 | } |
| 914 | case op_urshift: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 915 | printBinaryOp(out, exec, location, it, "urshift"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 916 | break; |
| 917 | } |
| 918 | case op_bitand: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 919 | printBinaryOp(out, exec, location, it, "bitand"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 920 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 921 | break; |
| 922 | } |
| 923 | case op_bitxor: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 924 | printBinaryOp(out, exec, location, it, "bitxor"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 925 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 926 | break; |
| 927 | } |
| 928 | case op_bitor: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 929 | printBinaryOp(out, exec, location, it, "bitor"); |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 930 | ++it; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 931 | break; |
| 932 | } |
barraclough@apple.com | 8da6d97 | 2010-11-16 21:11:26 +0000 | [diff] [blame] | 933 | case op_check_has_instance: { |
barraclough@apple.com | b46d57b4 | 2012-09-22 00:43:03 +0000 | [diff] [blame] | 934 | int r0 = (++it)->u.operand; |
| 935 | int r1 = (++it)->u.operand; |
| 936 | int r2 = (++it)->u.operand; |
| 937 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 938 | printLocationAndOp(out, exec, location, it, "check_has_instance"); |
| 939 | out.printf("%s, %s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), registerName(r2).data(), offset, location + offset); |
barraclough@apple.com | 8da6d97 | 2010-11-16 21:11:26 +0000 | [diff] [blame] | 940 | break; |
| 941 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 942 | case op_instanceof: { |
mjs@apple.com | 988df6c | 2008-09-15 02:13:10 +0000 | [diff] [blame] | 943 | int r0 = (++it)->u.operand; |
| 944 | int r1 = (++it)->u.operand; |
| 945 | int r2 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 946 | printLocationAndOp(out, exec, location, it, "instanceof"); |
| 947 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 948 | break; |
| 949 | } |
fpizlo@apple.com | 9089acb | 2013-12-14 06:33:42 +0000 | [diff] [blame] | 950 | case op_unsigned: { |
| 951 | printUnaryOp(out, exec, location, it, "unsigned"); |
| 952 | break; |
| 953 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 954 | case op_typeof: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 955 | printUnaryOp(out, exec, location, it, "typeof"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 956 | break; |
| 957 | } |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 958 | case op_is_undefined: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 959 | printUnaryOp(out, exec, location, it, "is_undefined"); |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 960 | break; |
| 961 | } |
| 962 | case op_is_boolean: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 963 | printUnaryOp(out, exec, location, it, "is_boolean"); |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 964 | break; |
| 965 | } |
| 966 | case op_is_number: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 967 | printUnaryOp(out, exec, location, it, "is_number"); |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 968 | break; |
| 969 | } |
| 970 | case op_is_string: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 971 | printUnaryOp(out, exec, location, it, "is_string"); |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 972 | break; |
| 973 | } |
| 974 | case op_is_object: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 975 | printUnaryOp(out, exec, location, it, "is_object"); |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 976 | break; |
| 977 | } |
utatane.tea@gmail.com | 0bfb74c | 2015-02-24 23:01:58 +0000 | [diff] [blame] | 978 | case op_is_object_or_null: { |
| 979 | printUnaryOp(out, exec, location, it, "is_object_or_null"); |
| 980 | break; |
| 981 | } |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 982 | case op_is_function: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 983 | printUnaryOp(out, exec, location, it, "is_function"); |
cwzwarich@webkit.org | 3234662 | 2008-09-15 00:26:08 +0000 | [diff] [blame] | 984 | break; |
| 985 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 986 | case op_in: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 987 | printBinaryOp(out, exec, location, it, "in"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 988 | break; |
| 989 | } |
fpizlo@apple.com | d52a794 | 2012-05-21 22:32:40 +0000 | [diff] [blame] | 990 | case op_get_by_id: |
fpizlo@apple.com | 970d8a9 | 2014-02-14 05:37:38 +0000 | [diff] [blame] | 991 | case op_get_array_length: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 992 | printGetByIdOp(out, exec, location, it); |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 993 | printGetByIdCacheStatus(out, exec, location, stubInfos); |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 994 | dumpValueProfiling(out, it, hasPrintedProfiling); |
ggaren@apple.com | bc36309 | 2008-09-03 05:04:39 +0000 | [diff] [blame] | 995 | break; |
| 996 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 997 | case op_put_by_id: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 998 | printPutByIdOp(out, exec, location, it, "put_by_id"); |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 999 | printPutByIdCacheStatus(out, location, stubInfos); |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 1000 | break; |
| 1001 | } |
commit-queue@webkit.org | fb471b4 | 2015-05-14 01:32:25 +0000 | [diff] [blame] | 1002 | case op_put_getter_by_id: { |
| 1003 | int r0 = (++it)->u.operand; |
| 1004 | int id0 = (++it)->u.operand; |
rniwa@webkit.org | 87ae29c | 2015-08-14 23:50:25 +0000 | [diff] [blame] | 1005 | int n0 = (++it)->u.operand; |
commit-queue@webkit.org | fb471b4 | 2015-05-14 01:32:25 +0000 | [diff] [blame] | 1006 | int r1 = (++it)->u.operand; |
| 1007 | printLocationAndOp(out, exec, location, it, "put_getter_by_id"); |
rniwa@webkit.org | 87ae29c | 2015-08-14 23:50:25 +0000 | [diff] [blame] | 1008 | out.printf("%s, %s, %d, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), n0, registerName(r1).data()); |
commit-queue@webkit.org | fb471b4 | 2015-05-14 01:32:25 +0000 | [diff] [blame] | 1009 | break; |
| 1010 | } |
| 1011 | case op_put_setter_by_id: { |
| 1012 | int r0 = (++it)->u.operand; |
| 1013 | int id0 = (++it)->u.operand; |
rniwa@webkit.org | 87ae29c | 2015-08-14 23:50:25 +0000 | [diff] [blame] | 1014 | int n0 = (++it)->u.operand; |
commit-queue@webkit.org | fb471b4 | 2015-05-14 01:32:25 +0000 | [diff] [blame] | 1015 | int r1 = (++it)->u.operand; |
| 1016 | printLocationAndOp(out, exec, location, it, "put_setter_by_id"); |
rniwa@webkit.org | 87ae29c | 2015-08-14 23:50:25 +0000 | [diff] [blame] | 1017 | out.printf("%s, %s, %d, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), n0, registerName(r1).data()); |
commit-queue@webkit.org | fb471b4 | 2015-05-14 01:32:25 +0000 | [diff] [blame] | 1018 | break; |
| 1019 | } |
barraclough@apple.com | 09a5568 | 2012-01-30 18:28:39 +0000 | [diff] [blame] | 1020 | case op_put_getter_setter: { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1021 | int r0 = (++it)->u.operand; |
| 1022 | int id0 = (++it)->u.operand; |
rniwa@webkit.org | 87ae29c | 2015-08-14 23:50:25 +0000 | [diff] [blame] | 1023 | int n0 = (++it)->u.operand; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1024 | int r1 = (++it)->u.operand; |
barraclough@apple.com | 09a5568 | 2012-01-30 18:28:39 +0000 | [diff] [blame] | 1025 | int r2 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1026 | printLocationAndOp(out, exec, location, it, "put_getter_setter"); |
rniwa@webkit.org | 87ae29c | 2015-08-14 23:50:25 +0000 | [diff] [blame] | 1027 | out.printf("%s, %s, %d, %s, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), n0, registerName(r1).data(), registerName(r2).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1028 | break; |
| 1029 | } |
utatane.tea@gmail.com | f0153d0 | 2015-09-08 19:43:58 +0000 | [diff] [blame] | 1030 | case op_put_getter_by_val: { |
| 1031 | int r0 = (++it)->u.operand; |
| 1032 | int r1 = (++it)->u.operand; |
| 1033 | int n0 = (++it)->u.operand; |
| 1034 | int r2 = (++it)->u.operand; |
| 1035 | printLocationAndOp(out, exec, location, it, "put_getter_by_val"); |
| 1036 | out.printf("%s, %s, %d, %s", registerName(r0).data(), registerName(r1).data(), n0, registerName(r2).data()); |
| 1037 | break; |
| 1038 | } |
| 1039 | case op_put_setter_by_val: { |
| 1040 | int r0 = (++it)->u.operand; |
| 1041 | int r1 = (++it)->u.operand; |
| 1042 | int n0 = (++it)->u.operand; |
| 1043 | int r2 = (++it)->u.operand; |
| 1044 | printLocationAndOp(out, exec, location, it, "put_setter_by_val"); |
| 1045 | out.printf("%s, %s, %d, %s", registerName(r0).data(), registerName(r1).data(), n0, registerName(r2).data()); |
| 1046 | break; |
| 1047 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1048 | case op_del_by_id: { |
| 1049 | int r0 = (++it)->u.operand; |
| 1050 | int r1 = (++it)->u.operand; |
| 1051 | int id0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1052 | printLocationAndOp(out, exec, location, it, "del_by_id"); |
| 1053 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), idName(id0, identifier(id0)).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1054 | break; |
| 1055 | } |
| 1056 | case op_get_by_val: { |
| 1057 | int r0 = (++it)->u.operand; |
| 1058 | int r1 = (++it)->u.operand; |
| 1059 | int r2 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1060 | printLocationAndOp(out, exec, location, it, "get_by_val"); |
| 1061 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data()); |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 1062 | dumpArrayProfiling(out, it, hasPrintedProfiling); |
| 1063 | dumpValueProfiling(out, it, hasPrintedProfiling); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1064 | break; |
| 1065 | } |
| 1066 | case op_put_by_val: { |
| 1067 | int r0 = (++it)->u.operand; |
| 1068 | int r1 = (++it)->u.operand; |
| 1069 | int r2 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1070 | printLocationAndOp(out, exec, location, it, "put_by_val"); |
| 1071 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data()); |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 1072 | dumpArrayProfiling(out, it, hasPrintedProfiling); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1073 | break; |
| 1074 | } |
oliver@apple.com | e050d64 | 2013-10-19 00:09:28 +0000 | [diff] [blame] | 1075 | case op_put_by_val_direct: { |
| 1076 | int r0 = (++it)->u.operand; |
| 1077 | int r1 = (++it)->u.operand; |
| 1078 | int r2 = (++it)->u.operand; |
| 1079 | printLocationAndOp(out, exec, location, it, "put_by_val_direct"); |
| 1080 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data()); |
| 1081 | dumpArrayProfiling(out, it, hasPrintedProfiling); |
| 1082 | break; |
| 1083 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1084 | case op_del_by_val: { |
| 1085 | int r0 = (++it)->u.operand; |
| 1086 | int r1 = (++it)->u.operand; |
| 1087 | int r2 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1088 | printLocationAndOp(out, exec, location, it, "del_by_val"); |
| 1089 | out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1090 | break; |
| 1091 | } |
| 1092 | case op_put_by_index: { |
| 1093 | int r0 = (++it)->u.operand; |
| 1094 | unsigned n0 = (++it)->u.operand; |
| 1095 | int r1 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1096 | printLocationAndOp(out, exec, location, it, "put_by_index"); |
| 1097 | out.printf("%s, %u, %s", registerName(r0).data(), n0, registerName(r1).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1098 | break; |
| 1099 | } |
| 1100 | case op_jmp: { |
| 1101 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1102 | printLocationAndOp(out, exec, location, it, "jmp"); |
| 1103 | out.printf("%d(->%d)", offset, location + offset); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1104 | break; |
| 1105 | } |
| 1106 | case op_jtrue: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 1107 | printConditionalJump(out, exec, begin, it, location, "jtrue"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1108 | break; |
| 1109 | } |
| 1110 | case op_jfalse: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 1111 | printConditionalJump(out, exec, begin, it, location, "jfalse"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1112 | break; |
| 1113 | } |
cwzwarich@webkit.org | b8b3024 | 2008-10-22 21:06:30 +0000 | [diff] [blame] | 1114 | case op_jeq_null: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 1115 | printConditionalJump(out, exec, begin, it, location, "jeq_null"); |
cwzwarich@webkit.org | b8b3024 | 2008-10-22 21:06:30 +0000 | [diff] [blame] | 1116 | break; |
| 1117 | } |
| 1118 | case op_jneq_null: { |
fpizlo@apple.com | 1afcdf0 | 2012-12-02 08:00:14 +0000 | [diff] [blame] | 1119 | printConditionalJump(out, exec, begin, it, location, "jneq_null"); |
cwzwarich@webkit.org | b8b3024 | 2008-10-22 21:06:30 +0000 | [diff] [blame] | 1120 | break; |
| 1121 | } |
oliver@apple.com | 6c10600 | 2009-03-28 03:50:39 +0000 | [diff] [blame] | 1122 | case op_jneq_ptr: { |
cwzwarich@webkit.org | 7b04fef | 2008-06-30 06:17:01 +0000 | [diff] [blame] | 1123 | int r0 = (++it)->u.operand; |
fpizlo@apple.com | 4500e35 | 2012-10-17 21:39:11 +0000 | [diff] [blame] | 1124 | Special::Pointer pointer = (++it)->u.specialPointer; |
cwzwarich@webkit.org | 7b04fef | 2008-06-30 06:17:01 +0000 | [diff] [blame] | 1125 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1126 | printLocationAndOp(out, exec, location, it, "jneq_ptr"); |
| 1127 | out.printf("%s, %d (%p), %d(->%d)", registerName(r0).data(), pointer, m_globalObject->actualPointerFor(pointer), offset, location + offset); |
oliver@apple.com | 6c10600 | 2009-03-28 03:50:39 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | } |
mjs@apple.com | a46c49c | 2009-12-06 09:42:03 +0000 | [diff] [blame] | 1130 | case op_jless: { |
| 1131 | int r0 = (++it)->u.operand; |
| 1132 | int r1 = (++it)->u.operand; |
| 1133 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1134 | printLocationAndOp(out, exec, location, it, "jless"); |
| 1135 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
mjs@apple.com | a46c49c | 2009-12-06 09:42:03 +0000 | [diff] [blame] | 1136 | break; |
| 1137 | } |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 1138 | case op_jlesseq: { |
| 1139 | int r0 = (++it)->u.operand; |
| 1140 | int r1 = (++it)->u.operand; |
| 1141 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1142 | printLocationAndOp(out, exec, location, it, "jlesseq"); |
| 1143 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 1144 | break; |
| 1145 | } |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1146 | case op_jgreater: { |
| 1147 | int r0 = (++it)->u.operand; |
| 1148 | int r1 = (++it)->u.operand; |
| 1149 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1150 | printLocationAndOp(out, exec, location, it, "jgreater"); |
| 1151 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1152 | break; |
| 1153 | } |
| 1154 | case op_jgreatereq: { |
| 1155 | int r0 = (++it)->u.operand; |
| 1156 | int r1 = (++it)->u.operand; |
| 1157 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1158 | printLocationAndOp(out, exec, location, it, "jgreatereq"); |
| 1159 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1160 | break; |
| 1161 | } |
| 1162 | case op_jnless: { |
| 1163 | int r0 = (++it)->u.operand; |
| 1164 | int r1 = (++it)->u.operand; |
| 1165 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1166 | printLocationAndOp(out, exec, location, it, "jnless"); |
| 1167 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1168 | break; |
| 1169 | } |
| 1170 | case op_jnlesseq: { |
| 1171 | int r0 = (++it)->u.operand; |
| 1172 | int r1 = (++it)->u.operand; |
| 1173 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1174 | printLocationAndOp(out, exec, location, it, "jnlesseq"); |
| 1175 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1176 | break; |
| 1177 | } |
| 1178 | case op_jngreater: { |
| 1179 | int r0 = (++it)->u.operand; |
| 1180 | int r1 = (++it)->u.operand; |
| 1181 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1182 | printLocationAndOp(out, exec, location, it, "jngreater"); |
| 1183 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1184 | break; |
| 1185 | } |
| 1186 | case op_jngreatereq: { |
| 1187 | int r0 = (++it)->u.operand; |
| 1188 | int r1 = (++it)->u.operand; |
| 1189 | int offset = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1190 | printLocationAndOp(out, exec, location, it, "jngreatereq"); |
| 1191 | out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1192 | break; |
| 1193 | } |
fpizlo@apple.com | a71ab05 | 2011-09-13 05:35:53 +0000 | [diff] [blame] | 1194 | case op_loop_hint: { |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1195 | printLocationAndOp(out, exec, location, it, "loop_hint"); |
fpizlo@apple.com | a71ab05 | 2011-09-13 05:35:53 +0000 | [diff] [blame] | 1196 | break; |
| 1197 | } |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 1198 | case op_switch_imm: { |
| 1199 | int tableIndex = (++it)->u.operand; |
| 1200 | int defaultTarget = (++it)->u.operand; |
| 1201 | int scrutineeRegister = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1202 | printLocationAndOp(out, exec, location, it, "switch_imm"); |
| 1203 | out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 1204 | break; |
| 1205 | } |
| 1206 | case op_switch_char: { |
| 1207 | int tableIndex = (++it)->u.operand; |
| 1208 | int defaultTarget = (++it)->u.operand; |
| 1209 | int scrutineeRegister = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1210 | printLocationAndOp(out, exec, location, it, "switch_char"); |
| 1211 | out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 1212 | break; |
| 1213 | } |
| 1214 | case op_switch_string: { |
| 1215 | int tableIndex = (++it)->u.operand; |
| 1216 | int defaultTarget = (++it)->u.operand; |
| 1217 | int scrutineeRegister = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1218 | printLocationAndOp(out, exec, location, it, "switch_string"); |
| 1219 | out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data()); |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 1220 | break; |
| 1221 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1222 | case op_new_func: { |
| 1223 | int r0 = (++it)->u.operand; |
msaboff@apple.com | ea77cd0 | 2014-11-14 01:07:48 +0000 | [diff] [blame] | 1224 | int r1 = (++it)->u.operand; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1225 | int f0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1226 | printLocationAndOp(out, exec, location, it, "new_func"); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1227 | out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1228 | break; |
| 1229 | } |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 1230 | case op_new_arrow_func_exp: { |
| 1231 | int r0 = (++it)->u.operand; |
| 1232 | int r1 = (++it)->u.operand; |
| 1233 | int f0 = (++it)->u.operand; |
| 1234 | int r2 = (++it)->u.operand; |
| 1235 | printLocationAndOp(out, exec, location, it, "op_new_arrow_func_exp"); |
| 1236 | out.printf("%s, %s, f%d, %s", registerName(r0).data(), registerName(r1).data(), f0, registerName(r2).data()); |
| 1237 | break; |
| 1238 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1239 | case op_new_func_exp: { |
| 1240 | int r0 = (++it)->u.operand; |
msaboff@apple.com | ea77cd0 | 2014-11-14 01:07:48 +0000 | [diff] [blame] | 1241 | int r1 = (++it)->u.operand; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1242 | int f0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1243 | printLocationAndOp(out, exec, location, it, "new_func_exp"); |
msaboff@apple.com | ea77cd0 | 2014-11-14 01:07:48 +0000 | [diff] [blame] | 1244 | out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1245 | break; |
| 1246 | } |
| 1247 | case op_call: { |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 1248 | printCallOp(out, exec, location, it, "call", DumpCaches, hasPrintedProfiling, callLinkInfos); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1249 | break; |
| 1250 | } |
msaboff@apple.com | c15ae7e | 2015-09-16 23:40:35 +0000 | [diff] [blame] | 1251 | case op_tail_call: { |
| 1252 | printCallOp(out, exec, location, it, "tail_call", DumpCaches, hasPrintedProfiling, callLinkInfos); |
| 1253 | break; |
| 1254 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1255 | case op_call_eval: { |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 1256 | printCallOp(out, exec, location, it, "call_eval", DontDumpCaches, hasPrintedProfiling, callLinkInfos); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1257 | break; |
| 1258 | } |
oliver@apple.com | 177c2b9 | 2014-03-28 01:10:25 +0000 | [diff] [blame] | 1259 | |
| 1260 | case op_construct_varargs: |
msaboff@apple.com | c15ae7e | 2015-09-16 23:40:35 +0000 | [diff] [blame] | 1261 | case op_call_varargs: |
| 1262 | case op_tail_call_varargs: { |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1263 | int result = (++it)->u.operand; |
ggaren@apple.com | 539d1bb | 2011-11-14 19:21:40 +0000 | [diff] [blame] | 1264 | int callee = (++it)->u.operand; |
| 1265 | int thisValue = (++it)->u.operand; |
| 1266 | int arguments = (++it)->u.operand; |
| 1267 | int firstFreeRegister = (++it)->u.operand; |
oliver@apple.com | 2f5c83b | 2014-02-25 06:59:38 +0000 | [diff] [blame] | 1268 | int varArgOffset = (++it)->u.operand; |
oliver@apple.com | dc48dc3 | 2013-07-25 04:01:42 +0000 | [diff] [blame] | 1269 | ++it; |
msaboff@apple.com | c15ae7e | 2015-09-16 23:40:35 +0000 | [diff] [blame] | 1270 | printLocationAndOp(out, exec, location, it, opcode == op_call_varargs ? "call_varargs" : opcode == op_construct_varargs ? "construct_varargs" : "tail_call_varargs"); |
oliver@apple.com | 2f5c83b | 2014-02-25 06:59:38 +0000 | [diff] [blame] | 1271 | out.printf("%s, %s, %s, %s, %d, %d", registerName(result).data(), registerName(callee).data(), registerName(thisValue).data(), registerName(arguments).data(), firstFreeRegister, varArgOffset); |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1272 | dumpValueProfiling(out, it, hasPrintedProfiling); |
oliver@apple.com | 65e286e | 2009-04-08 23:08:28 +0000 | [diff] [blame] | 1273 | break; |
| 1274 | } |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 1275 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1276 | case op_ret: { |
| 1277 | int r0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1278 | printLocationOpAndRegisterOperand(out, exec, location, it, "ret", r0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1279 | break; |
| 1280 | } |
| 1281 | case op_construct: { |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 1282 | printCallOp(out, exec, location, it, "construct", DumpCaches, hasPrintedProfiling, callLinkInfos); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1283 | break; |
| 1284 | } |
barraclough@apple.com | 14dc4e1 | 2009-05-07 00:06:07 +0000 | [diff] [blame] | 1285 | case op_strcat: { |
| 1286 | int r0 = (++it)->u.operand; |
| 1287 | int r1 = (++it)->u.operand; |
| 1288 | int count = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1289 | printLocationAndOp(out, exec, location, it, "strcat"); |
| 1290 | out.printf("%s, %s, %d", registerName(r0).data(), registerName(r1).data(), count); |
barraclough@apple.com | 14dc4e1 | 2009-05-07 00:06:07 +0000 | [diff] [blame] | 1291 | break; |
| 1292 | } |
| 1293 | case op_to_primitive: { |
| 1294 | int r0 = (++it)->u.operand; |
| 1295 | int r1 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1296 | printLocationAndOp(out, exec, location, it, "to_primitive"); |
| 1297 | out.printf("%s, %s", registerName(r0).data(), registerName(r1).data()); |
barraclough@apple.com | 14dc4e1 | 2009-05-07 00:06:07 +0000 | [diff] [blame] | 1298 | break; |
| 1299 | } |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1300 | case op_get_enumerable_length: { |
| 1301 | int dst = it[1].u.operand; |
| 1302 | int base = it[2].u.operand; |
| 1303 | printLocationAndOp(out, exec, location, it, "op_get_enumerable_length"); |
| 1304 | out.printf("%s, %s", registerName(dst).data(), registerName(base).data()); |
| 1305 | it += OPCODE_LENGTH(op_get_enumerable_length) - 1; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1306 | break; |
| 1307 | } |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1308 | case op_has_indexed_property: { |
| 1309 | int dst = it[1].u.operand; |
xan@webkit.org | b469f50 | 2010-10-13 15:39:37 +0000 | [diff] [blame] | 1310 | int base = it[2].u.operand; |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1311 | int propertyName = it[3].u.operand; |
| 1312 | ArrayProfile* arrayProfile = it[4].u.arrayProfile; |
| 1313 | printLocationAndOp(out, exec, location, it, "op_has_indexed_property"); |
| 1314 | out.printf("%s, %s, %s, %p", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data(), arrayProfile); |
| 1315 | it += OPCODE_LENGTH(op_has_indexed_property) - 1; |
| 1316 | break; |
| 1317 | } |
| 1318 | case op_has_structure_property: { |
| 1319 | int dst = it[1].u.operand; |
| 1320 | int base = it[2].u.operand; |
| 1321 | int propertyName = it[3].u.operand; |
| 1322 | int enumerator = it[4].u.operand; |
| 1323 | printLocationAndOp(out, exec, location, it, "op_has_structure_property"); |
| 1324 | out.printf("%s, %s, %s, %s", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data(), registerName(enumerator).data()); |
| 1325 | it += OPCODE_LENGTH(op_has_structure_property) - 1; |
| 1326 | break; |
| 1327 | } |
| 1328 | case op_has_generic_property: { |
| 1329 | int dst = it[1].u.operand; |
| 1330 | int base = it[2].u.operand; |
| 1331 | int propertyName = it[3].u.operand; |
| 1332 | printLocationAndOp(out, exec, location, it, "op_has_generic_property"); |
| 1333 | out.printf("%s, %s, %s", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data()); |
| 1334 | it += OPCODE_LENGTH(op_has_generic_property) - 1; |
| 1335 | break; |
| 1336 | } |
| 1337 | case op_get_direct_pname: { |
| 1338 | int dst = it[1].u.operand; |
| 1339 | int base = it[2].u.operand; |
| 1340 | int propertyName = it[3].u.operand; |
| 1341 | int index = it[4].u.operand; |
| 1342 | int enumerator = it[5].u.operand; |
| 1343 | ValueProfile* profile = it[6].u.profile; |
| 1344 | printLocationAndOp(out, exec, location, it, "op_get_direct_pname"); |
| 1345 | out.printf("%s, %s, %s, %s, %s, %p", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data(), registerName(index).data(), registerName(enumerator).data(), profile); |
| 1346 | it += OPCODE_LENGTH(op_get_direct_pname) - 1; |
| 1347 | break; |
| 1348 | |
| 1349 | } |
msaboff@apple.com | b644c25 | 2015-03-24 10:05:21 +0000 | [diff] [blame] | 1350 | case op_get_property_enumerator: { |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1351 | int dst = it[1].u.operand; |
| 1352 | int base = it[2].u.operand; |
msaboff@apple.com | b644c25 | 2015-03-24 10:05:21 +0000 | [diff] [blame] | 1353 | printLocationAndOp(out, exec, location, it, "op_get_property_enumerator"); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1354 | out.printf("%s, %s", registerName(dst).data(), registerName(base).data()); |
msaboff@apple.com | b644c25 | 2015-03-24 10:05:21 +0000 | [diff] [blame] | 1355 | it += OPCODE_LENGTH(op_get_property_enumerator) - 1; |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1356 | break; |
| 1357 | } |
msaboff@apple.com | b644c25 | 2015-03-24 10:05:21 +0000 | [diff] [blame] | 1358 | case op_enumerator_structure_pname: { |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1359 | int dst = it[1].u.operand; |
| 1360 | int enumerator = it[2].u.operand; |
| 1361 | int index = it[3].u.operand; |
msaboff@apple.com | b644c25 | 2015-03-24 10:05:21 +0000 | [diff] [blame] | 1362 | printLocationAndOp(out, exec, location, it, "op_enumerator_structure_pname"); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1363 | out.printf("%s, %s, %s", registerName(dst).data(), registerName(enumerator).data(), registerName(index).data()); |
msaboff@apple.com | b644c25 | 2015-03-24 10:05:21 +0000 | [diff] [blame] | 1364 | it += OPCODE_LENGTH(op_enumerator_structure_pname) - 1; |
| 1365 | break; |
| 1366 | } |
| 1367 | case op_enumerator_generic_pname: { |
| 1368 | int dst = it[1].u.operand; |
| 1369 | int enumerator = it[2].u.operand; |
| 1370 | int index = it[3].u.operand; |
| 1371 | printLocationAndOp(out, exec, location, it, "op_enumerator_generic_pname"); |
| 1372 | out.printf("%s, %s, %s", registerName(dst).data(), registerName(enumerator).data(), registerName(index).data()); |
| 1373 | it += OPCODE_LENGTH(op_enumerator_generic_pname) - 1; |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1374 | break; |
| 1375 | } |
| 1376 | case op_to_index_string: { |
| 1377 | int dst = it[1].u.operand; |
| 1378 | int index = it[2].u.operand; |
| 1379 | printLocationAndOp(out, exec, location, it, "op_to_index_string"); |
| 1380 | out.printf("%s, %s", registerName(dst).data(), registerName(index).data()); |
| 1381 | it += OPCODE_LENGTH(op_to_index_string) - 1; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1382 | break; |
| 1383 | } |
ggaren@apple.com | 170d6f2 | 2012-09-02 21:27:23 +0000 | [diff] [blame] | 1384 | case op_push_with_scope: { |
msaboff@apple.com | c5b9539 | 2014-10-31 21:27:10 +0000 | [diff] [blame] | 1385 | int dst = (++it)->u.operand; |
| 1386 | int newScope = (++it)->u.operand; |
saambarati1@gmail.com | e85426c | 2015-08-07 17:41:22 +0000 | [diff] [blame] | 1387 | int currentScope = (++it)->u.operand; |
msaboff@apple.com | c5b9539 | 2014-10-31 21:27:10 +0000 | [diff] [blame] | 1388 | printLocationAndOp(out, exec, location, it, "push_with_scope"); |
saambarati1@gmail.com | e85426c | 2015-08-07 17:41:22 +0000 | [diff] [blame] | 1389 | out.printf("%s, %s, %s", registerName(dst).data(), registerName(newScope).data(), registerName(currentScope).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1390 | break; |
| 1391 | } |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1392 | case op_get_parent_scope: { |
| 1393 | int dst = (++it)->u.operand; |
| 1394 | int parentScope = (++it)->u.operand; |
| 1395 | printLocationAndOp(out, exec, location, it, "get_parent_scope"); |
| 1396 | out.printf("%s, %s", registerName(dst).data(), registerName(parentScope).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1397 | break; |
| 1398 | } |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1399 | case op_create_lexical_environment: { |
| 1400 | int dst = (++it)->u.operand; |
| 1401 | int scope = (++it)->u.operand; |
| 1402 | int symbolTable = (++it)->u.operand; |
| 1403 | int initialValue = (++it)->u.operand; |
| 1404 | printLocationAndOp(out, exec, location, it, "create_lexical_environment"); |
| 1405 | out.printf("%s, %s, %s, %s", |
| 1406 | registerName(dst).data(), registerName(scope).data(), registerName(symbolTable).data(), registerName(initialValue).data()); |
| 1407 | break; |
| 1408 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1409 | case op_catch: { |
| 1410 | int r0 = (++it)->u.operand; |
mark.lam@apple.com | 6ed0827 | 2015-06-05 18:52:12 +0000 | [diff] [blame] | 1411 | int r1 = (++it)->u.operand; |
| 1412 | printLocationAndOp(out, exec, location, it, "catch"); |
| 1413 | out.printf("%s, %s", registerName(r0).data(), registerName(r1).data()); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1414 | break; |
| 1415 | } |
| 1416 | case op_throw: { |
| 1417 | int r0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1418 | printLocationOpAndRegisterOperand(out, exec, location, it, "throw", r0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1419 | break; |
| 1420 | } |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1421 | case op_throw_static_error: { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1422 | int k0 = (++it)->u.operand; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1423 | int k1 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1424 | printLocationAndOp(out, exec, location, it, "throw_static_error"); |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 1425 | out.printf("%s, %s", constantName(k0).data(), k1 ? "true" : "false"); |
barraclough@apple.com | 4920ae9 | 2010-11-12 03:06:07 +0000 | [diff] [blame] | 1426 | break; |
| 1427 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1428 | case op_debug: { |
| 1429 | int debugHookID = (++it)->u.operand; |
mark.lam@apple.com | 945b139 | 2014-01-23 07:39:58 +0000 | [diff] [blame] | 1430 | int hasBreakpointFlag = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1431 | printLocationAndOp(out, exec, location, it, "debug"); |
mark.lam@apple.com | 945b139 | 2014-01-23 07:39:58 +0000 | [diff] [blame] | 1432 | out.printf("%s %d", debugHookName(debugHookID), hasBreakpointFlag); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1433 | break; |
| 1434 | } |
commit-queue@webkit.org | 90ba187 | 2010-11-17 08:05:39 +0000 | [diff] [blame] | 1435 | case op_profile_will_call: { |
| 1436 | int function = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1437 | printLocationOpAndRegisterOperand(out, exec, location, it, "profile_will_call", function); |
ggaren@apple.com | 4b8c0fb | 2008-10-20 16:48:30 +0000 | [diff] [blame] | 1438 | break; |
| 1439 | } |
commit-queue@webkit.org | 90ba187 | 2010-11-17 08:05:39 +0000 | [diff] [blame] | 1440 | case op_profile_did_call: { |
| 1441 | int function = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1442 | printLocationOpAndRegisterOperand(out, exec, location, it, "profile_did_call", function); |
ggaren@apple.com | 4b8c0fb | 2008-10-20 16:48:30 +0000 | [diff] [blame] | 1443 | break; |
| 1444 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1445 | case op_end: { |
| 1446 | int r0 = (++it)->u.operand; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1447 | printLocationOpAndRegisterOperand(out, exec, location, it, "end", r0); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1448 | break; |
| 1449 | } |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1450 | case op_resolve_scope: { |
| 1451 | int r0 = (++it)->u.operand; |
msaboff@apple.com | 44641f0 | 2014-11-03 17:56:29 +0000 | [diff] [blame] | 1452 | int scope = (++it)->u.operand; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1453 | int id0 = (++it)->u.operand; |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1454 | ResolveType resolveType = static_cast<ResolveType>((++it)->u.operand); |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 1455 | int depth = (++it)->u.operand; |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1456 | void* pointer = (++it)->u.pointer; |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1457 | printLocationAndOp(out, exec, location, it, "resolve_scope"); |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1458 | out.printf("%s, %s, %s, <%s>, %d, %p", registerName(r0).data(), registerName(scope).data(), idName(id0, identifier(id0)).data(), resolveTypeName(resolveType), depth, pointer); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1459 | break; |
| 1460 | } |
| 1461 | case op_get_from_scope: { |
| 1462 | int r0 = (++it)->u.operand; |
| 1463 | int r1 = (++it)->u.operand; |
| 1464 | int id0 = (++it)->u.operand; |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1465 | GetPutInfo getPutInfo = GetPutInfo((++it)->u.operand); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1466 | ++it; // Structure |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 1467 | int operand = (++it)->u.operand; // Operand |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1468 | printLocationAndOp(out, exec, location, it, "get_from_scope"); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1469 | out.print(registerName(r0), ", ", registerName(r1)); |
| 1470 | if (static_cast<unsigned>(id0) == UINT_MAX) |
| 1471 | out.print(", anonymous"); |
| 1472 | else |
| 1473 | out.print(", ", idName(id0, identifier(id0))); |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1474 | out.print(", ", getPutInfo.operand(), "<", resolveModeName(getPutInfo.resolveMode()), "|", resolveTypeName(getPutInfo.resolveType()), "|", initializationModeName(getPutInfo.initializationMode()), ">, ", operand); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1475 | dumpValueProfiling(out, it, hasPrintedProfiling); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1476 | break; |
| 1477 | } |
| 1478 | case op_put_to_scope: { |
| 1479 | int r0 = (++it)->u.operand; |
| 1480 | int id0 = (++it)->u.operand; |
| 1481 | int r1 = (++it)->u.operand; |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1482 | GetPutInfo getPutInfo = GetPutInfo((++it)->u.operand); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1483 | ++it; // Structure |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 1484 | int operand = (++it)->u.operand; // Operand |
msaboff@apple.com | c580864 | 2013-09-05 23:27:41 +0000 | [diff] [blame] | 1485 | printLocationAndOp(out, exec, location, it, "put_to_scope"); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1486 | out.print(registerName(r0)); |
| 1487 | if (static_cast<unsigned>(id0) == UINT_MAX) |
| 1488 | out.print(", anonymous"); |
| 1489 | else |
| 1490 | out.print(", ", idName(id0, identifier(id0))); |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1491 | out.print(", ", registerName(r1), ", ", getPutInfo.operand(), "<", resolveModeName(getPutInfo.resolveMode()), "|", resolveTypeName(getPutInfo.resolveType()), "|", initializationModeName(getPutInfo.initializationMode()), ">, <structure>, ", operand); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1492 | break; |
| 1493 | } |
| 1494 | case op_get_from_arguments: { |
| 1495 | int r0 = (++it)->u.operand; |
| 1496 | int r1 = (++it)->u.operand; |
| 1497 | int offset = (++it)->u.operand; |
| 1498 | printLocationAndOp(out, exec, location, it, "get_from_arguments"); |
| 1499 | out.printf("%s, %s, %d", registerName(r0).data(), registerName(r1).data(), offset); |
| 1500 | dumpValueProfiling(out, it, hasPrintedProfiling); |
| 1501 | break; |
| 1502 | } |
| 1503 | case op_put_to_arguments: { |
| 1504 | int r0 = (++it)->u.operand; |
| 1505 | int offset = (++it)->u.operand; |
| 1506 | int r1 = (++it)->u.operand; |
| 1507 | printLocationAndOp(out, exec, location, it, "put_to_arguments"); |
| 1508 | out.printf("%s, %d, %s", registerName(r0).data(), offset, registerName(r1).data()); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1509 | break; |
| 1510 | } |
commit-queue@webkit.org | e13567f | 2012-09-01 17:36:51 +0000 | [diff] [blame] | 1511 | default: |
oliver@apple.com | 903b0c0 | 2013-01-24 01:40:37 +0000 | [diff] [blame] | 1512 | RELEASE_ASSERT_NOT_REACHED(); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1513 | } |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 1514 | |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 1515 | dumpRareCaseProfile(out, "rare case: ", rareCaseProfileForBytecodeOffset(location), hasPrintedProfiling); |
| 1516 | dumpRareCaseProfile(out, "special fast case: ", specialFastCaseProfileForBytecodeOffset(location), hasPrintedProfiling); |
fpizlo@apple.com | ca3a85b | 2012-12-17 07:16:18 +0000 | [diff] [blame] | 1517 | |
fpizlo@apple.com | 105ea9b | 2013-02-17 05:36:48 +0000 | [diff] [blame] | 1518 | #if ENABLE(DFG_JIT) |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 1519 | Vector<DFG::FrequentExitSite> exitSites = exitProfile().exitSitesFor(location); |
fpizlo@apple.com | 105ea9b | 2013-02-17 05:36:48 +0000 | [diff] [blame] | 1520 | if (!exitSites.isEmpty()) { |
| 1521 | out.print(" !! frequent exits: "); |
| 1522 | CommaPrinter comma; |
| 1523 | for (unsigned i = 0; i < exitSites.size(); ++i) |
fpizlo@apple.com | 51614cc | 2014-02-17 06:35:32 +0000 | [diff] [blame] | 1524 | out.print(comma, exitSites[i].kind(), " ", exitSites[i].jitType()); |
fpizlo@apple.com | 105ea9b | 2013-02-17 05:36:48 +0000 | [diff] [blame] | 1525 | } |
| 1526 | #else // ENABLE(DFG_JIT) |
| 1527 | UNUSED_PARAM(location); |
| 1528 | #endif // ENABLE(DFG_JIT) |
| 1529 | out.print("\n"); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1530 | } |
| 1531 | |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 1532 | void CodeBlock::dumpBytecode( |
| 1533 | PrintStream& out, unsigned bytecodeOffset, |
| 1534 | const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos) |
fpizlo@apple.com | 1949f32 | 2012-11-22 00:46:57 +0000 | [diff] [blame] | 1535 | { |
| 1536 | ExecState* exec = m_globalObject->globalExec(); |
| 1537 | const Instruction* it = instructions().begin() + bytecodeOffset; |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 1538 | dumpBytecode(out, exec, instructions().begin(), it, stubInfos, callLinkInfos); |
fpizlo@apple.com | 1949f32 | 2012-11-22 00:46:57 +0000 | [diff] [blame] | 1539 | } |
| 1540 | |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1541 | #define FOR_EACH_MEMBER_VECTOR(macro) \ |
| 1542 | macro(instructions) \ |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1543 | macro(callLinkInfos) \ |
| 1544 | macro(linkedCallerList) \ |
| 1545 | macro(identifiers) \ |
| 1546 | macro(functionExpressions) \ |
weinig@apple.com | 9367554 | 2009-01-09 18:47:37 +0000 | [diff] [blame] | 1547 | macro(constantRegisters) |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 1548 | |
| 1549 | #define FOR_EACH_MEMBER_VECTOR_RARE_DATA(macro) \ |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1550 | macro(regexps) \ |
| 1551 | macro(functions) \ |
weinig@apple.com | 67940d5 | 2008-12-09 00:14:58 +0000 | [diff] [blame] | 1552 | macro(exceptionHandlers) \ |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 1553 | macro(switchJumpTables) \ |
weinig@apple.com | c7b1989 | 2008-12-18 00:00:01 +0000 | [diff] [blame] | 1554 | macro(stringSwitchJumpTables) \ |
barraclough@apple.com | 87dbd5e | 2010-11-19 02:35:25 +0000 | [diff] [blame] | 1555 | macro(evalCodeCache) \ |
weinig@apple.com | af0231a | 2009-01-08 01:46:14 +0000 | [diff] [blame] | 1556 | macro(expressionInfo) \ |
| 1557 | macro(lineInfo) \ |
barraclough@apple.com | 87dbd5e | 2010-11-19 02:35:25 +0000 | [diff] [blame] | 1558 | macro(callReturnIndexVector) |
weinig@apple.com | af0231a | 2009-01-08 01:46:14 +0000 | [diff] [blame] | 1559 | |
weinig@apple.com | ff037a0 | 2008-12-10 20:05:53 +0000 | [diff] [blame] | 1560 | template<typename T> |
| 1561 | static size_t sizeInBytes(const Vector<T>& vector) |
| 1562 | { |
| 1563 | return vector.capacity() * sizeof(T); |
| 1564 | } |
| 1565 | |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 1566 | namespace { |
| 1567 | |
| 1568 | class PutToScopeFireDetail : public FireDetail { |
| 1569 | public: |
| 1570 | PutToScopeFireDetail(CodeBlock* codeBlock, const Identifier& ident) |
| 1571 | : m_codeBlock(codeBlock) |
| 1572 | , m_ident(ident) |
| 1573 | { |
| 1574 | } |
| 1575 | |
| 1576 | virtual void dump(PrintStream& out) const override |
| 1577 | { |
| 1578 | out.print("Linking put_to_scope in ", FunctionExecutableDump(jsCast<FunctionExecutable*>(m_codeBlock->ownerExecutable())), " for ", m_ident); |
| 1579 | } |
| 1580 | |
| 1581 | private: |
| 1582 | CodeBlock* m_codeBlock; |
| 1583 | const Identifier& m_ident; |
| 1584 | }; |
| 1585 | |
| 1586 | } // anonymous namespace |
| 1587 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1588 | CodeBlock::CodeBlock(CopyParsedBlockTag, CodeBlock& other) |
| 1589 | : m_globalObject(other.m_globalObject) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1590 | , m_heap(other.m_heap) |
| 1591 | , m_numCalleeRegisters(other.m_numCalleeRegisters) |
| 1592 | , m_numVars(other.m_numVars) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1593 | , m_isConstructor(other.m_isConstructor) |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 1594 | , m_shouldAlwaysBeInlined(true) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 1595 | , m_didFailFTLCompilation(false) |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 1596 | , m_hasBeenCompiledWithFTL(false) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1597 | , m_unlinkedCode(*other.m_vm, other.m_ownerExecutable.get(), other.m_unlinkedCode.get()) |
mark.lam@apple.com | 3dec4c6 | 2014-03-03 22:12:10 +0000 | [diff] [blame] | 1598 | , m_hasDebuggerStatement(false) |
mark.lam@apple.com | 9c30488 | 2014-01-24 19:07:31 +0000 | [diff] [blame] | 1599 | , m_steppingMode(SteppingModeDisabled) |
mark.lam@apple.com | 945b139 | 2014-01-23 07:39:58 +0000 | [diff] [blame] | 1600 | , m_numBreakpoints(0) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1601 | , m_ownerExecutable(*other.m_vm, other.m_ownerExecutable.get(), other.m_ownerExecutable.get()) |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 1602 | , m_vm(other.m_vm) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1603 | , m_instructions(other.m_instructions) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1604 | , m_thisRegister(other.m_thisRegister) |
msaboff@apple.com | 5e62e3f | 2014-11-21 23:41:26 +0000 | [diff] [blame] | 1605 | , m_scopeRegister(other.m_scopeRegister) |
oliver@apple.com | a7dfb4d | 2014-09-11 18:18:14 +0000 | [diff] [blame] | 1606 | , m_lexicalEnvironmentRegister(other.m_lexicalEnvironmentRegister) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1607 | , m_isStrictMode(other.m_isStrictMode) |
oliver@apple.com | 75f804e | 2013-03-07 00:25:20 +0000 | [diff] [blame] | 1608 | , m_needsActivation(other.m_needsActivation) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1609 | , m_source(other.m_source) |
| 1610 | , m_sourceOffset(other.m_sourceOffset) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1611 | , m_firstLineColumnOffset(other.m_firstLineColumnOffset) |
oliver@apple.com | 75f804e | 2013-03-07 00:25:20 +0000 | [diff] [blame] | 1612 | , m_codeType(other.m_codeType) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1613 | , m_constantRegisters(other.m_constantRegisters) |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 1614 | , m_constantsSourceCodeRepresentation(other.m_constantsSourceCodeRepresentation) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1615 | , m_functionDecls(other.m_functionDecls) |
| 1616 | , m_functionExprs(other.m_functionExprs) |
fpizlo@apple.com | 39c94a4 | 2012-07-10 09:18:47 +0000 | [diff] [blame] | 1617 | , m_osrExitCounter(0) |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1618 | , m_optimizationDelayCounter(0) |
| 1619 | , m_reoptimizationRetryCounter(0) |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 1620 | , m_creationTime(std::chrono::steady_clock::now()) |
oliver@apple.com | acdde49 | 2013-07-25 04:02:57 +0000 | [diff] [blame] | 1621 | , m_hash(other.m_hash) |
barraclough@apple.com | a2d7734 | 2012-01-30 20:38:32 +0000 | [diff] [blame] | 1622 | #if ENABLE(JIT) |
oliver@apple.com | 07f66d4 | 2013-07-25 04:00:58 +0000 | [diff] [blame] | 1623 | , m_capabilityLevelState(DFG::CapabilityLevelNotSet) |
barraclough@apple.com | a2d7734 | 2012-01-30 20:38:32 +0000 | [diff] [blame] | 1624 | #endif |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1625 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1626 | m_visitStronglyHasBeenCalled.store(false, std::memory_order_relaxed); |
| 1627 | m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); |
mark.lam@apple.com | 5d1b2b6 | 2015-03-13 18:02:40 +0000 | [diff] [blame] | 1628 | |
fpizlo@apple.com | 195d7b8 | 2013-09-03 16:39:29 +0000 | [diff] [blame] | 1629 | ASSERT(m_heap->isDeferred()); |
msaboff@apple.com | 2f145bc | 2015-01-23 19:52:25 +0000 | [diff] [blame] | 1630 | ASSERT(m_scopeRegister.isLocal()); |
| 1631 | |
fpizlo@apple.com | c4d5496 | 2012-01-10 22:08:47 +0000 | [diff] [blame] | 1632 | setNumParameters(other.numParameters()); |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1633 | optimizeAfterWarmUp(); |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 1634 | jitAfterWarmUp(); |
commit-queue@webkit.org | 3e0a1a0 | 2012-06-19 06:07:28 +0000 | [diff] [blame] | 1635 | |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1636 | if (other.m_rareData) { |
| 1637 | createRareDataIfNecessary(); |
| 1638 | |
| 1639 | m_rareData->m_exceptionHandlers = other.m_rareData->m_exceptionHandlers; |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1640 | m_rareData->m_constantBuffers = other.m_rareData->m_constantBuffers; |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 1641 | m_rareData->m_switchJumpTables = other.m_rareData->m_switchJumpTables; |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1642 | m_rareData->m_stringSwitchJumpTables = other.m_rareData->m_stringSwitchJumpTables; |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1643 | } |
fpizlo@apple.com | 195d7b8 | 2013-09-03 16:39:29 +0000 | [diff] [blame] | 1644 | |
| 1645 | m_heap->m_codeBlocks.add(this); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1646 | m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock)); |
fpizlo@apple.com | f5e1fe1 | 2011-11-10 21:59:39 +0000 | [diff] [blame] | 1647 | } |
| 1648 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1649 | CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset) |
| 1650 | : m_globalObject(scope->globalObject()->vm(), ownerExecutable, scope->globalObject()) |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 1651 | , m_heap(&m_globalObject->vm().heap) |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1652 | , m_numCalleeRegisters(unlinkedCodeBlock->m_numCalleeRegisters) |
| 1653 | , m_numVars(unlinkedCodeBlock->m_numVars) |
| 1654 | , m_isConstructor(unlinkedCodeBlock->isConstructor()) |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 1655 | , m_shouldAlwaysBeInlined(true) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 1656 | , m_didFailFTLCompilation(false) |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 1657 | , m_hasBeenCompiledWithFTL(false) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1658 | , m_unlinkedCode(m_globalObject->vm(), ownerExecutable, unlinkedCodeBlock) |
mark.lam@apple.com | 3dec4c6 | 2014-03-03 22:12:10 +0000 | [diff] [blame] | 1659 | , m_hasDebuggerStatement(false) |
mark.lam@apple.com | 9c30488 | 2014-01-24 19:07:31 +0000 | [diff] [blame] | 1660 | , m_steppingMode(SteppingModeDisabled) |
mark.lam@apple.com | 945b139 | 2014-01-23 07:39:58 +0000 | [diff] [blame] | 1661 | , m_numBreakpoints(0) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1662 | , m_ownerExecutable(m_globalObject->vm(), ownerExecutable, ownerExecutable) |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 1663 | , m_vm(unlinkedCodeBlock->vm()) |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1664 | , m_thisRegister(unlinkedCodeBlock->thisRegister()) |
msaboff@apple.com | 5e62e3f | 2014-11-21 23:41:26 +0000 | [diff] [blame] | 1665 | , m_scopeRegister(unlinkedCodeBlock->scopeRegister()) |
oliver@apple.com | a7dfb4d | 2014-09-11 18:18:14 +0000 | [diff] [blame] | 1666 | , m_lexicalEnvironmentRegister(unlinkedCodeBlock->activationRegister()) |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1667 | , m_isStrictMode(unlinkedCodeBlock->isStrictMode()) |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 1668 | , m_needsActivation(unlinkedCodeBlock->hasActivationRegister() && unlinkedCodeBlock->codeType() == FunctionCode) |
weinig@apple.com | 0e9a7ee | 2008-12-06 22:31:14 +0000 | [diff] [blame] | 1669 | , m_source(sourceProvider) |
| 1670 | , m_sourceOffset(sourceOffset) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1671 | , m_firstLineColumnOffset(firstLineColumnOffset) |
oliver@apple.com | 75f804e | 2013-03-07 00:25:20 +0000 | [diff] [blame] | 1672 | , m_codeType(unlinkedCodeBlock->codeType()) |
fpizlo@apple.com | 39c94a4 | 2012-07-10 09:18:47 +0000 | [diff] [blame] | 1673 | , m_osrExitCounter(0) |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 1674 | , m_optimizationDelayCounter(0) |
fpizlo@apple.com | 706f5f3 | 2011-09-21 23:36:35 +0000 | [diff] [blame] | 1675 | , m_reoptimizationRetryCounter(0) |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 1676 | , m_creationTime(std::chrono::steady_clock::now()) |
oliver@apple.com | acdde49 | 2013-07-25 04:02:57 +0000 | [diff] [blame] | 1677 | #if ENABLE(JIT) |
| 1678 | , m_capabilityLevelState(DFG::CapabilityLevelNotSet) |
| 1679 | #endif |
weinig@apple.com | 0e9a7ee | 2008-12-06 22:31:14 +0000 | [diff] [blame] | 1680 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1681 | m_visitStronglyHasBeenCalled.store(false, std::memory_order_relaxed); |
| 1682 | m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); |
mark.lam@apple.com | 5d1b2b6 | 2015-03-13 18:02:40 +0000 | [diff] [blame] | 1683 | |
fpizlo@apple.com | 195d7b8 | 2013-09-03 16:39:29 +0000 | [diff] [blame] | 1684 | ASSERT(m_heap->isDeferred()); |
msaboff@apple.com | 2f145bc | 2015-01-23 19:52:25 +0000 | [diff] [blame] | 1685 | ASSERT(m_scopeRegister.isLocal()); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1686 | |
weinig@apple.com | 0e9a7ee | 2008-12-06 22:31:14 +0000 | [diff] [blame] | 1687 | ASSERT(m_source); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1688 | setNumParameters(unlinkedCodeBlock->numParameters()); |
oliver@apple.com | c909f5f | 2012-10-18 23:37:40 +0000 | [diff] [blame] | 1689 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1690 | if (vm()->typeProfiler() || vm()->controlFlowProfiler()) |
| 1691 | vm()->functionHasExecutedCache()->removeUnexecutedRange(ownerExecutable->sourceID(), ownerExecutable->typeProfilingStartOffset(), ownerExecutable->typeProfilingEndOffset()); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1692 | |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 1693 | setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation()); |
oliver@apple.com | 75f804e | 2013-03-07 00:25:20 +0000 | [diff] [blame] | 1694 | if (unlinkedCodeBlock->usesGlobalObject()) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1695 | m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(*m_vm, ownerExecutable, m_globalObject.get()); |
rniwa@webkit.org | 49d0cc1 | 2015-04-25 22:03:30 +0000 | [diff] [blame] | 1696 | |
| 1697 | for (unsigned i = 0; i < LinkTimeConstantCount; i++) { |
| 1698 | LinkTimeConstant type = static_cast<LinkTimeConstant>(i); |
| 1699 | if (unsigned registerIndex = unlinkedCodeBlock->registerIndexForLinkTimeConstant(type)) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1700 | m_constantRegisters[registerIndex].set(*m_vm, ownerExecutable, m_globalObject->jsCellForLinkTimeConstant(type)); |
rniwa@webkit.org | 49d0cc1 | 2015-04-25 22:03:30 +0000 | [diff] [blame] | 1701 | } |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 1702 | |
| 1703 | HashSet<int, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> clonedConstantSymbolTables; |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 1704 | { |
| 1705 | HashSet<SymbolTable*> clonedSymbolTables; |
| 1706 | for (unsigned i = 0; i < m_constantRegisters.size(); i++) { |
| 1707 | if (m_constantRegisters[i].get().isEmpty()) |
| 1708 | continue; |
| 1709 | if (SymbolTable* symbolTable = jsDynamicCast<SymbolTable*>(m_constantRegisters[i].get())) { |
| 1710 | RELEASE_ASSERT(clonedSymbolTables.add(symbolTable).isNewEntry); |
| 1711 | if (m_vm->typeProfiler()) { |
| 1712 | ConcurrentJITLocker locker(symbolTable->m_lock); |
| 1713 | symbolTable->prepareForTypeProfiling(locker); |
| 1714 | } |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1715 | m_constantRegisters[i].set(*m_vm, ownerExecutable, symbolTable->cloneScopePart(*m_vm)); |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 1716 | clonedConstantSymbolTables.add(i + FirstConstantRegisterIndex); |
| 1717 | } |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1718 | } |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 1719 | } |
rniwa@webkit.org | 49d0cc1 | 2015-04-25 22:03:30 +0000 | [diff] [blame] | 1720 | |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 1721 | // We already have the cloned symbol table for the module environment since we need to instantiate |
| 1722 | // the module environments before linking the code block. We replace the stored symbol table with the already cloned one. |
| 1723 | if (UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock = jsDynamicCast<UnlinkedModuleProgramCodeBlock*>(unlinkedCodeBlock)) { |
| 1724 | SymbolTable* clonedSymbolTable = jsCast<ModuleProgramExecutable*>(ownerExecutable)->moduleEnvironmentSymbolTable(); |
| 1725 | if (m_vm->typeProfiler()) { |
| 1726 | ConcurrentJITLocker locker(clonedSymbolTable->m_lock); |
| 1727 | clonedSymbolTable->prepareForTypeProfiling(locker); |
| 1728 | } |
| 1729 | replaceConstant(unlinkedModuleProgramCodeBlock->moduleEnvironmentSymbolTableConstantRegisterOffset(), clonedSymbolTable); |
| 1730 | } |
| 1731 | |
akling@apple.com | f124169 | 2014-01-18 23:35:34 +0000 | [diff] [blame] | 1732 | m_functionDecls.resizeToFit(unlinkedCodeBlock->numberOfFunctionDecls()); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1733 | for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) { |
| 1734 | UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1735 | if (vm()->typeProfiler() || vm()->controlFlowProfiler()) |
| 1736 | vm()->functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset()); |
| 1737 | m_functionDecls[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source())); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1738 | } |
| 1739 | |
akling@apple.com | f124169 | 2014-01-18 23:35:34 +0000 | [diff] [blame] | 1740 | m_functionExprs.resizeToFit(unlinkedCodeBlock->numberOfFunctionExprs()); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1741 | for (size_t count = unlinkedCodeBlock->numberOfFunctionExprs(), i = 0; i < count; ++i) { |
| 1742 | UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1743 | if (vm()->typeProfiler() || vm()->controlFlowProfiler()) |
| 1744 | vm()->functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset()); |
| 1745 | m_functionExprs[i].set(*m_vm, ownerExecutable, unlinkedExecutable->link(*m_vm, ownerExecutable->source())); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1746 | } |
| 1747 | |
| 1748 | if (unlinkedCodeBlock->hasRareData()) { |
| 1749 | createRareDataIfNecessary(); |
| 1750 | if (size_t count = unlinkedCodeBlock->constantBufferCount()) { |
| 1751 | m_rareData->m_constantBuffers.grow(count); |
| 1752 | for (size_t i = 0; i < count; i++) { |
| 1753 | const UnlinkedCodeBlock::ConstantBuffer& buffer = unlinkedCodeBlock->constantBuffer(i); |
| 1754 | m_rareData->m_constantBuffers[i] = buffer; |
| 1755 | } |
| 1756 | } |
| 1757 | if (size_t count = unlinkedCodeBlock->numberOfExceptionHandlers()) { |
akling@apple.com | b2ad169 | 2014-01-18 23:09:48 +0000 | [diff] [blame] | 1758 | m_rareData->m_exceptionHandlers.resizeToFit(count); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1759 | for (size_t i = 0; i < count; i++) { |
mark.lam@apple.com | 4585ce9 | 2015-05-30 00:19:01 +0000 | [diff] [blame] | 1760 | const UnlinkedHandlerInfo& unlinkedHandler = unlinkedCodeBlock->exceptionHandler(i); |
| 1761 | HandlerInfo& handler = m_rareData->m_exceptionHandlers[i]; |
mark.lam@apple.com | 3280e07 | 2015-06-01 17:57:18 +0000 | [diff] [blame] | 1762 | #if ENABLE(JIT) |
saambarati1@gmail.com | e85426c | 2015-08-07 17:41:22 +0000 | [diff] [blame] | 1763 | handler.initialize(unlinkedHandler, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(op_catch)))); |
mark.lam@apple.com | 3280e07 | 2015-06-01 17:57:18 +0000 | [diff] [blame] | 1764 | #else |
saambarati1@gmail.com | e85426c | 2015-08-07 17:41:22 +0000 | [diff] [blame] | 1765 | handler.initialize(unlinkedHandler); |
mark.lam@apple.com | 3280e07 | 2015-06-01 17:57:18 +0000 | [diff] [blame] | 1766 | #endif |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1767 | } |
| 1768 | } |
| 1769 | |
| 1770 | if (size_t count = unlinkedCodeBlock->numberOfStringSwitchJumpTables()) { |
| 1771 | m_rareData->m_stringSwitchJumpTables.grow(count); |
| 1772 | for (size_t i = 0; i < count; i++) { |
| 1773 | UnlinkedStringJumpTable::StringOffsetTable::iterator ptr = unlinkedCodeBlock->stringSwitchJumpTable(i).offsetTable.begin(); |
| 1774 | UnlinkedStringJumpTable::StringOffsetTable::iterator end = unlinkedCodeBlock->stringSwitchJumpTable(i).offsetTable.end(); |
| 1775 | for (; ptr != end; ++ptr) { |
| 1776 | OffsetLocation offset; |
| 1777 | offset.branchOffset = ptr->value; |
| 1778 | m_rareData->m_stringSwitchJumpTables[i].offsetTable.add(ptr->key, offset); |
| 1779 | } |
| 1780 | } |
| 1781 | } |
| 1782 | |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 1783 | if (size_t count = unlinkedCodeBlock->numberOfSwitchJumpTables()) { |
| 1784 | m_rareData->m_switchJumpTables.grow(count); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1785 | for (size_t i = 0; i < count; i++) { |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 1786 | UnlinkedSimpleJumpTable& sourceTable = unlinkedCodeBlock->switchJumpTable(i); |
| 1787 | SimpleJumpTable& destTable = m_rareData->m_switchJumpTables[i]; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1788 | destTable.branchOffsets = sourceTable.branchOffsets; |
| 1789 | destTable.min = sourceTable.min; |
| 1790 | } |
| 1791 | } |
| 1792 | } |
| 1793 | |
| 1794 | // Allocate metadata buffers for the bytecode |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1795 | if (size_t size = unlinkedCodeBlock->numberOfLLintCallLinkInfos()) |
akling@apple.com | 8b46ebc | 2013-08-30 01:21:23 +0000 | [diff] [blame] | 1796 | m_llintCallLinkInfos.resizeToFit(size); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1797 | if (size_t size = unlinkedCodeBlock->numberOfArrayProfiles()) |
| 1798 | m_arrayProfiles.grow(size); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 1799 | if (size_t size = unlinkedCodeBlock->numberOfArrayAllocationProfiles()) |
akling@apple.com | e25e769 | 2013-11-12 07:56:39 +0000 | [diff] [blame] | 1800 | m_arrayAllocationProfiles.resizeToFit(size); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1801 | if (size_t size = unlinkedCodeBlock->numberOfValueProfiles()) |
akling@apple.com | e25e769 | 2013-11-12 07:56:39 +0000 | [diff] [blame] | 1802 | m_valueProfiles.resizeToFit(size); |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 1803 | if (size_t size = unlinkedCodeBlock->numberOfObjectAllocationProfiles()) |
akling@apple.com | e25e769 | 2013-11-12 07:56:39 +0000 | [diff] [blame] | 1804 | m_objectAllocationProfiles.resizeToFit(size); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1805 | |
msaboff@apple.com | 0208546 | 2015-09-10 17:47:16 +0000 | [diff] [blame] | 1806 | #if ENABLE(JIT) |
| 1807 | setCalleeSaveRegisters(RegisterSet::llintBaselineCalleeSaveRegisters()); |
| 1808 | #endif |
| 1809 | |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1810 | // Copy and translate the UnlinkedInstructions |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1811 | unsigned instructionCount = unlinkedCodeBlock->instructions().count(); |
| 1812 | UnlinkedInstructionStream::Reader instructionReader(unlinkedCodeBlock->instructions()); |
| 1813 | |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 1814 | // Bookkeep the strongly referenced module environments. |
| 1815 | HashSet<JSModuleEnvironment*> stronglyReferencedModuleEnvironments; |
| 1816 | |
oliver@apple.com | 4e3f965 | 2013-04-08 04:14:50 +0000 | [diff] [blame] | 1817 | Vector<Instruction, 0, UnsafeVectorOverflow> instructions(instructionCount); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1818 | |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1819 | for (unsigned i = 0; !instructionReader.atEnd(); ) { |
| 1820 | const UnlinkedInstruction* pc = instructionReader.next(); |
| 1821 | |
| 1822 | unsigned opLength = opcodeLength(pc[0].u.opcode); |
| 1823 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1824 | instructions[i] = vm()->interpreter->getOpcode(pc[0].u.opcode); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1825 | for (size_t j = 1; j < opLength; ++j) { |
| 1826 | if (sizeof(int32_t) != sizeof(intptr_t)) |
| 1827 | instructions[i + j].u.pointer = 0; |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1828 | instructions[i + j].u.operand = pc[j].u.operand; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1829 | } |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1830 | switch (pc[0].u.opcode) { |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1831 | case op_has_indexed_property: { |
| 1832 | int arrayProfileIndex = pc[opLength - 1].u.operand; |
| 1833 | m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i); |
| 1834 | |
| 1835 | instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex]; |
| 1836 | break; |
| 1837 | } |
msaboff@apple.com | 74aef1f | 2014-02-01 15:30:41 +0000 | [diff] [blame] | 1838 | case op_call_varargs: |
msaboff@apple.com | c15ae7e | 2015-09-16 23:40:35 +0000 | [diff] [blame] | 1839 | case op_tail_call_varargs: |
oliver@apple.com | 177c2b9 | 2014-03-28 01:10:25 +0000 | [diff] [blame] | 1840 | case op_construct_varargs: |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1841 | case op_get_by_val: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1842 | int arrayProfileIndex = pc[opLength - 2].u.operand; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1843 | m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i); |
| 1844 | |
| 1845 | instructions[i + opLength - 2] = &m_arrayProfiles[arrayProfileIndex]; |
joepeck@webkit.org | 899544a | 2014-01-28 04:04:45 +0000 | [diff] [blame] | 1846 | FALLTHROUGH; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1847 | } |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1848 | case op_get_direct_pname: |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1849 | case op_get_by_id: |
| 1850 | case op_get_from_arguments: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1851 | ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand]; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1852 | ASSERT(profile->m_bytecodeOffset == -1); |
| 1853 | profile->m_bytecodeOffset = i; |
| 1854 | instructions[i + opLength - 1] = profile; |
| 1855 | break; |
| 1856 | } |
| 1857 | case op_put_by_val: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1858 | int arrayProfileIndex = pc[opLength - 1].u.operand; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1859 | m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i); |
| 1860 | instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex]; |
| 1861 | break; |
| 1862 | } |
oliver@apple.com | e050d64 | 2013-10-19 00:09:28 +0000 | [diff] [blame] | 1863 | case op_put_by_val_direct: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1864 | int arrayProfileIndex = pc[opLength - 1].u.operand; |
oliver@apple.com | e050d64 | 2013-10-19 00:09:28 +0000 | [diff] [blame] | 1865 | m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i); |
| 1866 | instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex]; |
| 1867 | break; |
| 1868 | } |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1869 | |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 1870 | case op_new_array: |
| 1871 | case op_new_array_buffer: |
| 1872 | case op_new_array_with_size: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1873 | int arrayAllocationProfileIndex = pc[opLength - 1].u.operand; |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 1874 | instructions[i + opLength - 1] = &m_arrayAllocationProfiles[arrayAllocationProfileIndex]; |
| 1875 | break; |
| 1876 | } |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 1877 | case op_new_object: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1878 | int objectAllocationProfileIndex = pc[opLength - 1].u.operand; |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 1879 | ObjectAllocationProfile* objectAllocationProfile = &m_objectAllocationProfiles[objectAllocationProfileIndex]; |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1880 | int inferredInlineCapacity = pc[opLength - 2].u.operand; |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 1881 | |
| 1882 | instructions[i + opLength - 1] = objectAllocationProfile; |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1883 | objectAllocationProfile->initialize(*vm(), |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 1884 | ownerExecutable, m_globalObject->objectPrototype(), inferredInlineCapacity); |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 1885 | break; |
| 1886 | } |
| 1887 | |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1888 | case op_call: |
msaboff@apple.com | c15ae7e | 2015-09-16 23:40:35 +0000 | [diff] [blame] | 1889 | case op_tail_call: |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1890 | case op_call_eval: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1891 | ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand]; |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1892 | ASSERT(profile->m_bytecodeOffset == -1); |
| 1893 | profile->m_bytecodeOffset = i; |
| 1894 | instructions[i + opLength - 1] = profile; |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1895 | int arrayProfileIndex = pc[opLength - 2].u.operand; |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1896 | m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i); |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1897 | instructions[i + opLength - 2] = &m_arrayProfiles[arrayProfileIndex]; |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1898 | instructions[i + 5] = &m_llintCallLinkInfos[pc[5].u.operand]; |
fpizlo@apple.com | 0ed51fc | 2012-11-09 01:27:25 +0000 | [diff] [blame] | 1899 | break; |
| 1900 | } |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1901 | case op_construct: { |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1902 | instructions[i + 5] = &m_llintCallLinkInfos[pc[5].u.operand]; |
akling@apple.com | 8427aaf | 2014-01-27 05:45:30 +0000 | [diff] [blame] | 1903 | ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand]; |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1904 | ASSERT(profile->m_bytecodeOffset == -1); |
| 1905 | profile->m_bytecodeOffset = i; |
| 1906 | instructions[i + opLength - 1] = profile; |
fpizlo@apple.com | 0ed51fc | 2012-11-09 01:27:25 +0000 | [diff] [blame] | 1907 | break; |
oliver@apple.com | cf0e6c4 | 2013-07-25 04:01:45 +0000 | [diff] [blame] | 1908 | } |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1909 | case op_get_array_length: |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 1910 | CRASH(); |
| 1911 | |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 1912 | case op_create_lexical_environment: { |
| 1913 | int symbolTableIndex = pc[3].u.operand; |
| 1914 | RELEASE_ASSERT(clonedConstantSymbolTables.contains(symbolTableIndex)); |
| 1915 | break; |
| 1916 | } |
| 1917 | |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1918 | case op_resolve_scope: { |
msaboff@apple.com | 44641f0 | 2014-11-03 17:56:29 +0000 | [diff] [blame] | 1919 | const Identifier& ident = identifier(pc[3].u.operand); |
| 1920 | ResolveType type = static_cast<ResolveType>(pc[4].u.operand); |
fpizlo@apple.com | a97ccfd | 2015-03-02 02:08:26 +0000 | [diff] [blame] | 1921 | RELEASE_ASSERT(type != LocalClosureVar); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1922 | int localScopeDepth = pc[5].u.operand; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1923 | |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1924 | ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, type, NotInitialization); |
msaboff@apple.com | 44641f0 | 2014-11-03 17:56:29 +0000 | [diff] [blame] | 1925 | instructions[i + 4].u.operand = op.type; |
| 1926 | instructions[i + 5].u.operand = op.depth; |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 1927 | if (op.lexicalEnvironment) { |
| 1928 | if (op.type == ModuleVar) { |
| 1929 | // Keep the linked module environment strongly referenced. |
| 1930 | if (stronglyReferencedModuleEnvironments.add(jsCast<JSModuleEnvironment*>(op.lexicalEnvironment)).isNewEntry) |
| 1931 | addConstant(op.lexicalEnvironment); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1932 | instructions[i + 6].u.jsCell.set(*vm(), ownerExecutable, op.lexicalEnvironment); |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 1933 | } else |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1934 | instructions[i + 6].u.symbolTable.set(*vm(), ownerExecutable, op.lexicalEnvironment->symbolTable()); |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 1935 | } else if (JSScope* constantScope = JSScope::constantScopeForCodeBlock(op.type, this)) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1936 | instructions[i + 6].u.jsCell.set(*vm(), ownerExecutable, constantScope); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1937 | else |
| 1938 | instructions[i + 6].u.pointer = nullptr; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1939 | break; |
| 1940 | } |
| 1941 | |
| 1942 | case op_get_from_scope: { |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 1943 | ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand]; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1944 | ASSERT(profile->m_bytecodeOffset == -1); |
| 1945 | profile->m_bytecodeOffset = i; |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 1946 | instructions[i + opLength - 1] = profile; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1947 | |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1948 | // get_from_scope dst, scope, id, GetPutInfo, Structure, Operand |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 1949 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1950 | int localScopeDepth = pc[5].u.operand; |
| 1951 | instructions[i + 5].u.pointer = nullptr; |
| 1952 | |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1953 | GetPutInfo getPutInfo = GetPutInfo(pc[4].u.operand); |
| 1954 | ASSERT(getPutInfo.initializationMode() == NotInitialization); |
| 1955 | if (getPutInfo.resolveType() == LocalClosureVar) { |
| 1956 | instructions[i + 4] = GetPutInfo(getPutInfo.resolveMode(), ClosureVar, getPutInfo.initializationMode()).operand(); |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 1957 | break; |
| 1958 | } |
| 1959 | |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1960 | const Identifier& ident = identifier(pc[3].u.operand); |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1961 | ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, getPutInfo.resolveType(), NotInitialization); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1962 | |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1963 | instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), op.type, getPutInfo.initializationMode()).operand(); |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 1964 | if (op.type == ModuleVar) |
| 1965 | instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), ClosureVar, getPutInfo.initializationMode()).operand(); |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1966 | if (op.type == GlobalVar || op.type == GlobalVarWithVarInjectionChecks || op.type == GlobalLexicalVar || op.type == GlobalLexicalVarWithVarInjectionChecks) |
fpizlo@apple.com | 1a72409 | 2013-11-28 07:10:10 +0000 | [diff] [blame] | 1967 | instructions[i + 5].u.watchpointSet = op.watchpointSet; |
| 1968 | else if (op.structure) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 1969 | instructions[i + 5].u.structure.set(*vm(), ownerExecutable, op.structure); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1970 | instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand); |
| 1971 | break; |
| 1972 | } |
| 1973 | |
| 1974 | case op_put_to_scope: { |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1975 | // put_to_scope scope, id, value, GetPutInfo, Structure, Operand |
| 1976 | GetPutInfo getPutInfo = GetPutInfo(pc[4].u.operand); |
| 1977 | if (getPutInfo.resolveType() == LocalClosureVar) { |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1978 | // Only do watching if the property we're putting to is not anonymous. |
| 1979 | if (static_cast<unsigned>(pc[2].u.operand) != UINT_MAX) { |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1980 | int symbolTableIndex = pc[5].u.operand; |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 1981 | RELEASE_ASSERT(clonedConstantSymbolTables.contains(symbolTableIndex)); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1982 | SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex)); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1983 | const Identifier& ident = identifier(pc[2].u.operand); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1984 | ConcurrentJITLocker locker(symbolTable->m_lock); |
| 1985 | auto iter = symbolTable->find(locker, ident.impl()); |
| 1986 | RELEASE_ASSERT(iter != symbolTable->end(locker)); |
fpizlo@apple.com | 3a2fa4c | 2015-04-13 22:13:12 +0000 | [diff] [blame] | 1987 | iter->value.prepareToWatch(); |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 1988 | instructions[i + 5].u.watchpointSet = iter->value.watchpointSet(); |
| 1989 | } else |
| 1990 | instructions[i + 5].u.watchpointSet = nullptr; |
| 1991 | break; |
| 1992 | } |
| 1993 | |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1994 | const Identifier& ident = identifier(pc[2].u.operand); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1995 | int localScopeDepth = pc[5].u.operand; |
| 1996 | instructions[i + 5].u.pointer = nullptr; |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1997 | ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Put, getPutInfo.resolveType(), getPutInfo.initializationMode()); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 1998 | |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 1999 | instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), op.type, getPutInfo.initializationMode()).operand(); |
| 2000 | if (op.type == GlobalVar || op.type == GlobalVarWithVarInjectionChecks || op.type == GlobalLexicalVar || op.type == GlobalLexicalVarWithVarInjectionChecks) |
fpizlo@apple.com | 40f7cbf | 2013-11-18 23:19:53 +0000 | [diff] [blame] | 2001 | instructions[i + 5].u.watchpointSet = op.watchpointSet; |
fpizlo@apple.com | 88fedde | 2013-12-04 19:29:19 +0000 | [diff] [blame] | 2002 | else if (op.type == ClosureVar || op.type == ClosureVarWithVarInjectionChecks) { |
| 2003 | if (op.watchpointSet) |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2004 | op.watchpointSet->invalidate(PutToScopeFireDetail(this, ident)); |
fpizlo@apple.com | 88fedde | 2013-12-04 19:29:19 +0000 | [diff] [blame] | 2005 | } else if (op.structure) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2006 | instructions[i + 5].u.structure.set(*vm(), ownerExecutable, op.structure); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 2007 | instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand); |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 2008 | |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 2009 | break; |
| 2010 | } |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 2011 | |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2012 | case op_profile_type: { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2013 | RELEASE_ASSERT(vm()->typeProfiler()); |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2014 | // The format of this instruction is: op_profile_type regToProfile, TypeLocation*, flag, identifier?, resolveType? |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2015 | size_t instructionOffset = i + opLength - 1; |
| 2016 | unsigned divotStart, divotEnd; |
mark.lam@apple.com | ca860af | 2014-10-06 22:17:09 +0000 | [diff] [blame] | 2017 | GlobalVariableID globalVariableID = 0; |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 2018 | RefPtr<TypeSet> globalTypeSet; |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2019 | bool shouldAnalyze = m_unlinkedCode->typeProfilerExpressionInfoForBytecodeOffset(instructionOffset, divotStart, divotEnd); |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2020 | VirtualRegister profileRegister(pc[1].u.operand); |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2021 | ProfileTypeBytecodeFlag flag = static_cast<ProfileTypeBytecodeFlag>(pc[3].u.operand); |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2022 | SymbolTable* symbolTable = nullptr; |
| 2023 | |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2024 | switch (flag) { |
saambarati1@gmail.com | f07b1bc | 2015-07-28 22:39:12 +0000 | [diff] [blame] | 2025 | case ProfileTypeBytecodeClosureVar: { |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2026 | const Identifier& ident = identifier(pc[4].u.operand); |
saambarati1@gmail.com | f07b1bc | 2015-07-28 22:39:12 +0000 | [diff] [blame] | 2027 | int localScopeDepth = pc[2].u.operand; |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2028 | ResolveType type = static_cast<ResolveType>(pc[5].u.operand); |
saambarati1@gmail.com | f07b1bc | 2015-07-28 22:39:12 +0000 | [diff] [blame] | 2029 | // Even though type profiling may be profiling either a Get or a Put, we can always claim a Get because |
| 2030 | // we're abstractly "read"ing from a JSScope. |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 2031 | ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, type, NotInitialization); |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2032 | |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 2033 | if (op.type == ClosureVar || op.type == ModuleVar) |
oliver@apple.com | a7dfb4d | 2014-09-11 18:18:14 +0000 | [diff] [blame] | 2034 | symbolTable = op.lexicalEnvironment->symbolTable(); |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2035 | else if (op.type == GlobalVar) |
| 2036 | symbolTable = m_globalObject.get()->symbolTable(); |
utatane.tea@gmail.com | 6c38958 | 2015-09-04 04:29:04 +0000 | [diff] [blame] | 2037 | |
| 2038 | UniquedStringImpl* impl = (op.type == ModuleVar) ? op.importedName.get() : ident.impl(); |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2039 | if (symbolTable) { |
| 2040 | ConcurrentJITLocker locker(symbolTable->m_lock); |
| 2041 | // If our parent scope was created while profiling was disabled, it will not have prepared for profiling yet. |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2042 | symbolTable->prepareForTypeProfiling(locker); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2043 | globalVariableID = symbolTable->uniqueIDForVariable(locker, impl, *vm()); |
| 2044 | globalTypeSet = symbolTable->globalTypeSetForVariable(locker, impl, *vm()); |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2045 | } else |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2046 | globalVariableID = TypeProfilerNoGlobalIDExists; |
commit-queue@webkit.org | eafc9b3 | 2014-08-14 23:59:44 +0000 | [diff] [blame] | 2047 | |
| 2048 | break; |
| 2049 | } |
saambarati1@gmail.com | f07b1bc | 2015-07-28 22:39:12 +0000 | [diff] [blame] | 2050 | case ProfileTypeBytecodeLocallyResolved: { |
| 2051 | int symbolTableIndex = pc[2].u.operand; |
| 2052 | RELEASE_ASSERT(clonedConstantSymbolTables.contains(symbolTableIndex)); |
| 2053 | SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex)); |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 2054 | const Identifier& ident = identifier(pc[4].u.operand); |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 2055 | ConcurrentJITLocker locker(symbolTable->m_lock); |
| 2056 | // If our parent scope was created while profiling was disabled, it will not have prepared for profiling yet. |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2057 | globalVariableID = symbolTable->uniqueIDForVariable(locker, ident.impl(), *vm()); |
| 2058 | globalTypeSet = symbolTable->globalTypeSetForVariable(locker, ident.impl(), *vm()); |
oliver@apple.com | f129dfb | 2014-10-02 20:35:58 +0000 | [diff] [blame] | 2059 | |
| 2060 | break; |
| 2061 | } |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2062 | case ProfileTypeBytecodeDoesNotHaveGlobalID: |
| 2063 | case ProfileTypeBytecodeFunctionArgument: { |
| 2064 | globalVariableID = TypeProfilerNoGlobalIDExists; |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 2065 | break; |
| 2066 | } |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2067 | case ProfileTypeBytecodeFunctionReturnStatement: { |
commit-queue@webkit.org | f6bd2fb | 2014-08-26 02:17:58 +0000 | [diff] [blame] | 2068 | RELEASE_ASSERT(ownerExecutable->isFunctionExecutable()); |
| 2069 | globalTypeSet = jsCast<FunctionExecutable*>(ownerExecutable)->returnStatementTypeSet(); |
commit-queue@webkit.org | 2ed31ec | 2014-08-21 01:03:20 +0000 | [diff] [blame] | 2070 | globalVariableID = TypeProfilerReturnStatement; |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2071 | if (!shouldAnalyze) { |
commit-queue@webkit.org | 9653c66 | 2014-08-26 04:36:42 +0000 | [diff] [blame] | 2072 | // Because a return statement can be added implicitly to return undefined at the end of a function, |
| 2073 | // and these nodes don't emit expression ranges because they aren't in the actual source text of |
| 2074 | // the user's program, give the type profiler some range to identify these return statements. |
commit-queue@webkit.org | f1d9ed8 | 2015-08-17 22:57:23 +0000 | [diff] [blame] | 2075 | // Currently, the text offset that is used as identification is "f" in the function keyword |
commit-queue@webkit.org | 9653c66 | 2014-08-26 04:36:42 +0000 | [diff] [blame] | 2076 | // and is stored on TypeLocation's m_divotForFunctionOffsetIfReturnStatement member variable. |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2077 | divotStart = divotEnd = ownerExecutable->typeProfilingStartOffset(); |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2078 | shouldAnalyze = true; |
| 2079 | } |
| 2080 | break; |
| 2081 | } |
| 2082 | } |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 2083 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2084 | std::pair<TypeLocation*, bool> locationPair = vm()->typeProfiler()->typeLocationCache()->getTypeLocation(globalVariableID, |
| 2085 | ownerExecutable->sourceID(), divotStart, divotEnd, globalTypeSet, vm()); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 2086 | TypeLocation* location = locationPair.first; |
| 2087 | bool isNewLocation = locationPair.second; |
| 2088 | |
commit-queue@webkit.org | 9653c66 | 2014-08-26 04:36:42 +0000 | [diff] [blame] | 2089 | if (flag == ProfileTypeBytecodeFunctionReturnStatement) |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2090 | location->m_divotForFunctionOffsetIfReturnStatement = ownerExecutable->typeProfilingStartOffset(); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 2091 | |
| 2092 | if (shouldAnalyze && isNewLocation) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2093 | vm()->typeProfiler()->insertNewLocation(location); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 2094 | |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 2095 | instructions[i + 2].u.location = location; |
| 2096 | break; |
| 2097 | } |
| 2098 | |
mark.lam@apple.com | 3dec4c6 | 2014-03-03 22:12:10 +0000 | [diff] [blame] | 2099 | case op_debug: { |
| 2100 | if (pc[1].u.index == DidReachBreakpoint) |
| 2101 | m_hasDebuggerStatement = true; |
| 2102 | break; |
| 2103 | } |
| 2104 | |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 2105 | default: |
| 2106 | break; |
| 2107 | } |
| 2108 | i += opLength; |
| 2109 | } |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 2110 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2111 | if (vm()->controlFlowProfiler()) |
saambarati1@gmail.com | d60d941 | 2015-01-20 04:47:55 +0000 | [diff] [blame] | 2112 | insertBasicBlockBoundariesForControlFlowProfiler(instructions); |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 2113 | |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 2114 | m_instructions = WTF::RefCountedArray<Instruction>(instructions); |
| 2115 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 2116 | // Set optimization thresholds only after m_instructions is initialized, since these |
| 2117 | // rely on the instruction count (and are in theory permitted to also inspect the |
| 2118 | // instruction stream to more accurate assess the cost of tier-up). |
| 2119 | optimizeAfterWarmUp(); |
| 2120 | jitAfterWarmUp(); |
| 2121 | |
oliver@apple.com | 9e1c809 | 2013-07-25 04:03:16 +0000 | [diff] [blame] | 2122 | // If the concurrent thread will want the code block's hash, then compute it here |
| 2123 | // synchronously. |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 2124 | if (Options::alwaysComputeHash()) |
oliver@apple.com | 9e1c809 | 2013-07-25 04:03:16 +0000 | [diff] [blame] | 2125 | hash(); |
| 2126 | |
msaboff@apple.com | 77adfde | 2012-11-29 03:16:11 +0000 | [diff] [blame] | 2127 | if (Options::dumpGeneratedBytecodes()) |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 2128 | dumpBytecode(); |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 2129 | |
fpizlo@apple.com | 195d7b8 | 2013-09-03 16:39:29 +0000 | [diff] [blame] | 2130 | m_heap->m_codeBlocks.add(this); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2131 | m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock) + m_instructions.size() * sizeof(Instruction)); |
weinig@apple.com | 0e9a7ee | 2008-12-06 22:31:14 +0000 | [diff] [blame] | 2132 | } |
| 2133 | |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2134 | #if ENABLE(WEBASSEMBLY) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2135 | CodeBlock::CodeBlock(WebAssemblyExecutable* ownerExecutable, VM& vm, JSGlobalObject* globalObject) |
| 2136 | : m_globalObject(globalObject->vm(), ownerExecutable, globalObject) |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2137 | , m_heap(&m_globalObject->vm().heap) |
| 2138 | , m_numCalleeRegisters(0) |
| 2139 | , m_numVars(0) |
| 2140 | , m_isConstructor(false) |
| 2141 | , m_shouldAlwaysBeInlined(false) |
| 2142 | , m_didFailFTLCompilation(false) |
| 2143 | , m_hasBeenCompiledWithFTL(false) |
| 2144 | , m_hasDebuggerStatement(false) |
| 2145 | , m_steppingMode(SteppingModeDisabled) |
| 2146 | , m_numBreakpoints(0) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2147 | , m_ownerExecutable(m_globalObject->vm(), ownerExecutable, ownerExecutable) |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2148 | , m_vm(&vm) |
| 2149 | , m_isStrictMode(false) |
| 2150 | , m_needsActivation(false) |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2151 | , m_codeType(FunctionCode) |
| 2152 | , m_osrExitCounter(0) |
| 2153 | , m_optimizationDelayCounter(0) |
| 2154 | , m_reoptimizationRetryCounter(0) |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2155 | , m_creationTime(std::chrono::steady_clock::now()) |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2156 | #if ENABLE(JIT) |
| 2157 | , m_capabilityLevelState(DFG::CannotCompile) |
| 2158 | #endif |
| 2159 | { |
| 2160 | ASSERT(m_heap->isDeferred()); |
| 2161 | |
| 2162 | m_heap->m_codeBlocks.add(this); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2163 | m_heap->reportExtraMemoryAllocated(sizeof(CodeBlock)); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2164 | } |
| 2165 | #endif |
| 2166 | |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 2167 | CodeBlock::~CodeBlock() |
| 2168 | { |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 2169 | if (m_vm->m_perBytecodeProfiler) |
| 2170 | m_vm->m_perBytecodeProfiler->notifyDestruction(this); |
fpizlo@apple.com | 4a81fa4 | 2012-12-05 01:26:13 +0000 | [diff] [blame] | 2171 | |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 2172 | #if ENABLE(VERBOSE_VALUE_PROFILE) |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 2173 | dumpValueProfiles(); |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 2174 | #endif |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2175 | while (m_incomingLLIntCalls.begin() != m_incomingLLIntCalls.end()) |
| 2176 | m_incomingLLIntCalls.begin()->remove(); |
| 2177 | #if ENABLE(JIT) |
fpizlo@apple.com | a474964 | 2011-09-07 02:05:02 +0000 | [diff] [blame] | 2178 | // We may be destroyed before any CodeBlocks that refer to us are destroyed. |
| 2179 | // Consider that two CodeBlocks become unreachable at the same time. There |
| 2180 | // is no guarantee about the order in which the CodeBlocks are destroyed. |
| 2181 | // So, if we don't remove incoming calls, and get destroyed before the |
| 2182 | // CodeBlock(s) that have calls into us, then the CallLinkInfo vector's |
| 2183 | // destructor will try to remove nodes from our (no longer valid) linked list. |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2184 | while (m_incomingCalls.begin() != m_incomingCalls.end()) |
| 2185 | m_incomingCalls.begin()->remove(); |
| 2186 | while (m_incomingPolymorphicCalls.begin() != m_incomingPolymorphicCalls.end()) |
| 2187 | m_incomingPolymorphicCalls.begin()->remove(); |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 2188 | |
| 2189 | // Note that our outgoing calls will be removed from other CodeBlocks' |
| 2190 | // m_incomingCalls linked lists through the execution of the ~CallLinkInfo |
| 2191 | // destructors. |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 2192 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 2193 | for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter) |
| 2194 | (*iter)->deref(); |
oliver@apple.com | 942e37d | 2010-07-07 01:35:56 +0000 | [diff] [blame] | 2195 | #endif // ENABLE(JIT) |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 2196 | } |
| 2197 | |
fpizlo@apple.com | c4d5496 | 2012-01-10 22:08:47 +0000 | [diff] [blame] | 2198 | void CodeBlock::setNumParameters(int newValue) |
| 2199 | { |
| 2200 | m_numParameters = newValue; |
| 2201 | |
akling@apple.com | d22d1e8 | 2013-07-18 16:50:38 +0000 | [diff] [blame] | 2202 | m_argumentValueProfiles.resizeToFit(newValue); |
fpizlo@apple.com | c4d5496 | 2012-01-10 22:08:47 +0000 | [diff] [blame] | 2203 | } |
| 2204 | |
oliver@apple.com | 433d02f | 2011-04-21 23:08:15 +0000 | [diff] [blame] | 2205 | void EvalCodeCache::visitAggregate(SlotVisitor& visitor) |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 2206 | { |
| 2207 | EvalCacheMap::iterator end = m_cacheMap.end(); |
| 2208 | for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr) |
benjamin@webkit.org | ee55405 | 2012-10-07 23:12:07 +0000 | [diff] [blame] | 2209 | visitor.append(&ptr->value); |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 2210 | } |
| 2211 | |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 2212 | CodeBlock* CodeBlock::specialOSREntryBlockOrNull() |
| 2213 | { |
| 2214 | #if ENABLE(FTL_JIT) |
| 2215 | if (jitType() != JITCode::DFGJIT) |
| 2216 | return 0; |
| 2217 | DFG::JITCode* jitCode = m_jitCode->dfg(); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2218 | return jitCode->osrEntryBlock.get(); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 2219 | #else // ENABLE(FTL_JIT) |
| 2220 | return 0; |
| 2221 | #endif // ENABLE(FTL_JIT) |
| 2222 | } |
| 2223 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2224 | void CodeBlock::visitStrongly(SlotVisitor& visitor) |
ggaren@apple.com | 51be9a2 | 2015-09-09 22:00:58 +0000 | [diff] [blame] | 2225 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2226 | bool setByMe = m_visitStronglyHasBeenCalled.compareExchangeStrong(false, true); |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2227 | if (!setByMe) |
| 2228 | return; |
| 2229 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2230 | visitAggregate(visitor); |
ggaren@apple.com | ec9fd6c | 2015-10-02 04:48:24 +0000 | [diff] [blame] | 2231 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2232 | stronglyVisitStrongReferences(visitor); |
| 2233 | stronglyVisitWeakReferences(visitor); |
| 2234 | propagateTransitions(visitor); |
| 2235 | } |
| 2236 | |
| 2237 | void CodeBlock::visitAggregate(SlotVisitor& visitor) |
| 2238 | { |
| 2239 | // I may be asked to scan myself more than once, and it may even happen concurrently. |
| 2240 | // To this end, use an atomic operation to check (and set) if I've been called already. |
| 2241 | // Only one thread may proceed past this point - whichever one wins the atomic set race. |
| 2242 | bool setByMe = m_visitAggregateHasBeenCalled.compareExchangeStrong(false, true); |
| 2243 | if (!setByMe) |
ggaren@apple.com | 0e29f57 | 2015-10-02 21:16:20 +0000 | [diff] [blame] | 2244 | return; |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2245 | |
| 2246 | if (!!m_alternative) |
| 2247 | m_alternative->visitAggregate(visitor); |
| 2248 | |
| 2249 | if (CodeBlock* otherBlock = specialOSREntryBlockOrNull()) |
| 2250 | otherBlock->visitAggregate(visitor); |
| 2251 | |
| 2252 | visitor.reportExtraMemoryVisited(ownerExecutable(), sizeof(CodeBlock)); |
| 2253 | if (m_jitCode) |
| 2254 | visitor.reportExtraMemoryVisited(ownerExecutable(), m_jitCode->size()); |
| 2255 | if (m_instructions.size()) { |
| 2256 | // Divide by refCount() because m_instructions points to something that is shared |
| 2257 | // by multiple CodeBlocks, and we only want to count it towards the heap size once. |
| 2258 | // Having each CodeBlock report only its proportional share of the size is one way |
| 2259 | // of accomplishing this. |
| 2260 | visitor.reportExtraMemoryVisited(ownerExecutable(), m_instructions.size() * sizeof(Instruction) / m_instructions.refCount()); |
fpizlo@apple.com | 7c084e0 | 2013-09-04 05:48:06 +0000 | [diff] [blame] | 2261 | } |
| 2262 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2263 | visitor.append(&m_unlinkedCode); |
| 2264 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2265 | // There are two things that may use unconditional finalizers: inline cache clearing |
| 2266 | // and jettisoning. The probability of us wanting to do at least one of those things |
| 2267 | // is probably quite close to 1. So we add one no matter what and when it runs, it |
| 2268 | // figures out whether it has any work to do. |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2269 | visitor.addUnconditionalFinalizer(this); |
| 2270 | |
| 2271 | m_allTransitionsHaveBeenMarked = false; |
| 2272 | |
| 2273 | if (shouldVisitStrongly()) { |
| 2274 | visitStrongly(visitor); |
| 2275 | return; |
| 2276 | } |
| 2277 | |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2278 | if (!JITCode::isOptimizingJIT(jitType())) |
| 2279 | return; |
| 2280 | |
mhahnenberg@apple.com | 7d223bb | 2014-04-02 23:50:25 +0000 | [diff] [blame] | 2281 | // There are two things that we use weak reference harvesters for: DFG fixpoint for |
| 2282 | // jettisoning, and trying to find structures that would be live based on some |
| 2283 | // inline cache. So it makes sense to register them regardless. |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2284 | visitor.addWeakReferenceHarvester(this); |
mhahnenberg@apple.com | 7d223bb | 2014-04-02 23:50:25 +0000 | [diff] [blame] | 2285 | |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2286 | #if ENABLE(DFG_JIT) |
| 2287 | // We get here if we're live in the sense that our owner executable is live, |
| 2288 | // but we're not yet live for sure in another sense: we may yet decide that this |
| 2289 | // code block should be jettisoned based on its outgoing weak references being |
| 2290 | // stale. Set a flag to indicate that we're still assuming that we're dead, and |
| 2291 | // perform one round of determining if we're live. The GC may determine, based on |
| 2292 | // either us marking additional objects, or by other objects being marked for |
| 2293 | // other reasons, that this iteration should run again; it will notify us of this |
| 2294 | // decision by calling harvestWeakReferences(). |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2295 | |
ggaren@apple.com | 0e29f57 | 2015-10-02 21:16:20 +0000 | [diff] [blame] | 2296 | m_jitCode->dfgCommon()->livenessHasBeenProved = false; |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2297 | |
| 2298 | propagateTransitions(visitor); |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2299 | determineLiveness(visitor); |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2300 | #endif // ENABLE(DFG_JIT) |
| 2301 | } |
| 2302 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2303 | bool CodeBlock::shouldVisitStrongly() |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2304 | { |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2305 | if (Options::forceCodeBlockLiveness()) |
| 2306 | return true; |
| 2307 | |
| 2308 | if (shouldJettisonDueToOldAge()) |
| 2309 | return false; |
| 2310 | |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2311 | // Interpreter and Baseline JIT CodeBlocks don't need to be jettisoned when |
| 2312 | // their weak references go stale. So if a basline JIT CodeBlock gets |
| 2313 | // scanned, we can assume that this means that it's live. |
| 2314 | if (!JITCode::isOptimizingJIT(jitType())) |
| 2315 | return true; |
| 2316 | |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2317 | return false; |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2318 | } |
| 2319 | |
| 2320 | bool CodeBlock::isKnownToBeLiveDuringGC() |
| 2321 | { |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2322 | // This should return true for: |
| 2323 | // - Code blocks that behave like normal objects - i.e. if they are referenced then they |
| 2324 | // are live. |
| 2325 | // - Code blocks that were running on the stack. |
| 2326 | // - Code blocks that survived the last GC if the current GC is an Eden GC. This is |
ggaren@apple.com | 51be9a2 | 2015-09-09 22:00:58 +0000 | [diff] [blame] | 2327 | // because livenessHasBeenProved would have survived as true. |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2328 | // - Code blocks that don't have any dead weak references. |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2329 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2330 | if (m_visitStronglyHasBeenCalled.load(std::memory_order_relaxed)) |
| 2331 | return true; |
| 2332 | |
| 2333 | #if ENABLE(DFG_JIT) |
| 2334 | if (JITCode::isOptimizingJIT(jitType())) { |
| 2335 | if (m_jitCode->dfgCommon()->livenessHasBeenProved) |
| 2336 | return true; |
| 2337 | } |
| 2338 | #endif |
| 2339 | |
| 2340 | return false; |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2341 | } |
| 2342 | |
| 2343 | bool CodeBlock::shouldJettisonDueToWeakReference() |
| 2344 | { |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2345 | if (!JITCode::isOptimizingJIT(jitType())) |
| 2346 | return false; |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2347 | return !isKnownToBeLiveDuringGC(); |
| 2348 | } |
| 2349 | |
| 2350 | bool CodeBlock::shouldJettisonDueToOldAge() |
| 2351 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2352 | if (m_visitStronglyHasBeenCalled.load(std::memory_order_relaxed)) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2353 | return false; |
| 2354 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2355 | if (timeSinceCreation() < JITCode::timeToLive(jitType())) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2356 | return false; |
| 2357 | |
| 2358 | return true; |
fpizlo@apple.com | 04a048c | 2014-04-28 19:01:07 +0000 | [diff] [blame] | 2359 | } |
| 2360 | |
fpizlo@apple.com | 4adaa96 | 2014-08-06 05:55:39 +0000 | [diff] [blame] | 2361 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2362 | static bool shouldMarkTransition(DFG::WeakReferenceTransition& transition) |
| 2363 | { |
| 2364 | if (transition.m_codeOrigin && !Heap::isMarked(transition.m_codeOrigin.get())) |
| 2365 | return false; |
| 2366 | |
| 2367 | if (!Heap::isMarked(transition.m_from.get())) |
| 2368 | return false; |
| 2369 | |
| 2370 | return true; |
| 2371 | } |
fpizlo@apple.com | 4adaa96 | 2014-08-06 05:55:39 +0000 | [diff] [blame] | 2372 | #endif // ENABLE(DFG_JIT) |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2373 | |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2374 | void CodeBlock::propagateTransitions(SlotVisitor& visitor) |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2375 | { |
| 2376 | UNUSED_PARAM(visitor); |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2377 | |
| 2378 | if (m_allTransitionsHaveBeenMarked) |
| 2379 | return; |
| 2380 | |
| 2381 | bool allAreMarkedSoFar = true; |
| 2382 | |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2383 | Interpreter* interpreter = m_vm->interpreter; |
| 2384 | if (jitType() == JITCode::InterpreterThunk) { |
| 2385 | const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions(); |
oliver@apple.com | c0a31d7 | 2013-07-25 04:03:36 +0000 | [diff] [blame] | 2386 | for (size_t i = 0; i < propertyAccessInstructions.size(); ++i) { |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2387 | Instruction* instruction = &instructions()[propertyAccessInstructions[i]]; |
| 2388 | switch (interpreter->getOpcodeID(instruction[0].u.opcode)) { |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 2389 | case op_put_by_id: { |
| 2390 | StructureID oldStructureID = instruction[4].u.structureID; |
| 2391 | StructureID newStructureID = instruction[6].u.structureID; |
| 2392 | if (!oldStructureID || !newStructureID) |
| 2393 | break; |
| 2394 | Structure* oldStructure = |
| 2395 | m_vm->heap.structureIDTable().get(oldStructureID); |
| 2396 | Structure* newStructure = |
| 2397 | m_vm->heap.structureIDTable().get(newStructureID); |
| 2398 | if (Heap::isMarked(oldStructure)) |
| 2399 | visitor.appendUnbarrieredReadOnlyPointer(newStructure); |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2400 | else |
| 2401 | allAreMarkedSoFar = false; |
| 2402 | break; |
| 2403 | } |
| 2404 | default: |
| 2405 | break; |
| 2406 | } |
| 2407 | } |
| 2408 | } |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2409 | |
| 2410 | #if ENABLE(JIT) |
| 2411 | if (JITCode::isJIT(jitType())) { |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 2412 | for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter) { |
| 2413 | StructureStubInfo& stubInfo = **iter; |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 2414 | if (stubInfo.cacheType != CacheType::Stub) |
| 2415 | continue; |
| 2416 | PolymorphicAccess* list = stubInfo.u.stub; |
| 2417 | JSCell* origin = stubInfo.codeOrigin.codeOriginOwner(); |
| 2418 | if (origin && !Heap::isMarked(origin)) { |
| 2419 | allAreMarkedSoFar = false; |
| 2420 | continue; |
| 2421 | } |
| 2422 | for (unsigned j = list->size(); j--;) { |
| 2423 | const AccessCase& access = list->at(j); |
| 2424 | if (access.type() != AccessCase::Transition) |
| 2425 | continue; |
| 2426 | if (Heap::isMarked(access.structure())) |
| 2427 | visitor.appendUnbarrieredReadOnlyPointer(access.newStructure()); |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2428 | else |
| 2429 | allAreMarkedSoFar = false; |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2430 | } |
| 2431 | } |
| 2432 | } |
| 2433 | #endif // ENABLE(JIT) |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2434 | |
| 2435 | #if ENABLE(DFG_JIT) |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2436 | if (JITCode::isOptimizingJIT(jitType())) { |
| 2437 | DFG::CommonData* dfgCommon = m_jitCode->dfgCommon(); |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2438 | |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2439 | for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) { |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2440 | if (shouldMarkTransition(dfgCommon->transitions[i])) { |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2441 | // If the following three things are live, then the target of the |
| 2442 | // transition is also live: |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2443 | // |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2444 | // - This code block. We know it's live already because otherwise |
| 2445 | // we wouldn't be scanning ourselves. |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2446 | // |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2447 | // - The code origin of the transition. Transitions may arise from |
| 2448 | // code that was inlined. They are not relevant if the user's |
| 2449 | // object that is required for the inlinee to run is no longer |
| 2450 | // live. |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2451 | // |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2452 | // - The source of the transition. The transition checks if some |
| 2453 | // heap location holds the source, and if so, stores the target. |
| 2454 | // Hence the source must be live for the transition to be live. |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2455 | // |
| 2456 | // We also short-circuit the liveness if the structure is harmless |
| 2457 | // to mark (i.e. its global object and prototype are both already |
| 2458 | // live). |
| 2459 | |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2460 | visitor.append(&dfgCommon->transitions[i].m_to); |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2461 | } else |
| 2462 | allAreMarkedSoFar = false; |
| 2463 | } |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2464 | } |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2465 | #endif // ENABLE(DFG_JIT) |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2466 | |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2467 | if (allAreMarkedSoFar) |
| 2468 | m_allTransitionsHaveBeenMarked = true; |
| 2469 | } |
| 2470 | |
| 2471 | void CodeBlock::determineLiveness(SlotVisitor& visitor) |
| 2472 | { |
| 2473 | UNUSED_PARAM(visitor); |
| 2474 | |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2475 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2476 | // Check if we have any remaining work to do. |
oliver@apple.com | a152471 | 2013-07-25 04:01:56 +0000 | [diff] [blame] | 2477 | DFG::CommonData* dfgCommon = m_jitCode->dfgCommon(); |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2478 | if (dfgCommon->livenessHasBeenProved) |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2479 | return; |
| 2480 | |
| 2481 | // Now check all of our weak references. If all of them are live, then we |
| 2482 | // have proved liveness and so we scan our strong references. If at end of |
| 2483 | // GC we still have not proved liveness, then this code block is toast. |
| 2484 | bool allAreLiveSoFar = true; |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2485 | for (unsigned i = 0; i < dfgCommon->weakReferences.size(); ++i) { |
| 2486 | if (!Heap::isMarked(dfgCommon->weakReferences[i].get())) { |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2487 | allAreLiveSoFar = false; |
| 2488 | break; |
| 2489 | } |
| 2490 | } |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2491 | if (allAreLiveSoFar) { |
| 2492 | for (unsigned i = 0; i < dfgCommon->weakStructureReferences.size(); ++i) { |
| 2493 | if (!Heap::isMarked(dfgCommon->weakStructureReferences[i].get())) { |
| 2494 | allAreLiveSoFar = false; |
| 2495 | break; |
| 2496 | } |
| 2497 | } |
| 2498 | } |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2499 | |
| 2500 | // If some weak references are dead, then this fixpoint iteration was |
| 2501 | // unsuccessful. |
| 2502 | if (!allAreLiveSoFar) |
| 2503 | return; |
| 2504 | |
| 2505 | // All weak references are live. Record this information so we don't |
| 2506 | // come back here again, and scan the strong references. |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2507 | dfgCommon->livenessHasBeenProved = true; |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2508 | stronglyVisitStrongReferences(visitor); |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2509 | #endif // ENABLE(DFG_JIT) |
| 2510 | } |
| 2511 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2512 | void CodeBlock::visitWeakReferences(SlotVisitor& visitor) |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2513 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2514 | propagateTransitions(visitor); |
| 2515 | determineLiveness(visitor); |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2516 | } |
| 2517 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2518 | void CodeBlock::finalizeLLIntInlineCaches() |
fpizlo@apple.com | cf71612 | 2012-07-13 06:41:18 +0000 | [diff] [blame] | 2519 | { |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2520 | #if ENABLE(WEBASSEMBLY) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2521 | if (m_ownerExecutable->isWebAssemblyExecutable()) |
| 2522 | return; |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2523 | #endif |
oliver@apple.com | c909f5f | 2012-10-18 23:37:40 +0000 | [diff] [blame] | 2524 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2525 | Interpreter* interpreter = m_vm->interpreter; |
| 2526 | const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions(); |
| 2527 | for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) { |
| 2528 | Instruction* curInstruction = &instructions()[propertyAccessInstructions[i]]; |
| 2529 | switch (interpreter->getOpcodeID(curInstruction[0].u.opcode)) { |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 2530 | case op_get_by_id: { |
| 2531 | StructureID oldStructureID = curInstruction[4].u.structureID; |
| 2532 | if (!oldStructureID || Heap::isMarked(m_vm->heap.structureIDTable().get(oldStructureID))) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2533 | break; |
| 2534 | if (Options::verboseOSR()) |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 2535 | dataLogF("Clearing LLInt property access.\n"); |
| 2536 | curInstruction[4].u.structureID = 0; |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2537 | curInstruction[5].u.operand = 0; |
| 2538 | break; |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 2539 | } |
| 2540 | case op_put_by_id: { |
| 2541 | StructureID oldStructureID = curInstruction[4].u.structureID; |
| 2542 | StructureID newStructureID = curInstruction[6].u.structureID; |
| 2543 | StructureChain* chain = curInstruction[7].u.structureChain.get(); |
| 2544 | if ((!oldStructureID || Heap::isMarked(m_vm->heap.structureIDTable().get(oldStructureID))) && |
| 2545 | (!newStructureID || Heap::isMarked(m_vm->heap.structureIDTable().get(newStructureID))) && |
| 2546 | (!chain || Heap::isMarked(chain))) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2547 | break; |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 2548 | if (Options::verboseOSR()) |
| 2549 | dataLogF("Clearing LLInt put transition.\n"); |
| 2550 | curInstruction[4].u.structureID = 0; |
| 2551 | curInstruction[5].u.operand = 0; |
| 2552 | curInstruction[6].u.structureID = 0; |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2553 | curInstruction[7].u.structureChain.clear(); |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2554 | break; |
fpizlo@apple.com | e7ec7fb | 2015-09-15 00:55:17 +0000 | [diff] [blame] | 2555 | } |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2556 | case op_get_array_length: |
| 2557 | break; |
| 2558 | case op_to_this: |
| 2559 | if (!curInstruction[2].u.structure || Heap::isMarked(curInstruction[2].u.structure.get())) |
| 2560 | break; |
| 2561 | if (Options::verboseOSR()) |
| 2562 | dataLogF("Clearing LLInt to_this with structure %p.\n", curInstruction[2].u.structure.get()); |
| 2563 | curInstruction[2].u.structure.clear(); |
| 2564 | curInstruction[3].u.toThisStatus = merge( |
| 2565 | curInstruction[3].u.toThisStatus, ToThisClearedByGC); |
| 2566 | break; |
| 2567 | case op_create_this: { |
| 2568 | auto& cacheWriteBarrier = curInstruction[4].u.jsCell; |
| 2569 | if (!cacheWriteBarrier || cacheWriteBarrier.unvalidatedGet() == JSCell::seenMultipleCalleeObjects()) |
| 2570 | break; |
| 2571 | JSCell* cachedFunction = cacheWriteBarrier.get(); |
| 2572 | if (Heap::isMarked(cachedFunction)) |
| 2573 | break; |
| 2574 | if (Options::verboseOSR()) |
| 2575 | dataLogF("Clearing LLInt create_this with cached callee %p.\n", cachedFunction); |
| 2576 | cacheWriteBarrier.clear(); |
| 2577 | break; |
| 2578 | } |
| 2579 | case op_resolve_scope: { |
| 2580 | // Right now this isn't strictly necessary. Any symbol tables that this will refer to |
| 2581 | // are for outer functions, and we refer to those functions strongly, and they refer |
| 2582 | // to the symbol table strongly. But it's nice to be on the safe side. |
| 2583 | WriteBarrierBase<SymbolTable>& symbolTable = curInstruction[6].u.symbolTable; |
| 2584 | if (!symbolTable || Heap::isMarked(symbolTable.get())) |
| 2585 | break; |
| 2586 | if (Options::verboseOSR()) |
| 2587 | dataLogF("Clearing dead symbolTable %p.\n", symbolTable.get()); |
| 2588 | symbolTable.clear(); |
| 2589 | break; |
| 2590 | } |
| 2591 | case op_get_from_scope: |
| 2592 | case op_put_to_scope: { |
| 2593 | GetPutInfo getPutInfo = GetPutInfo(curInstruction[4].u.operand); |
| 2594 | if (getPutInfo.resolveType() == GlobalVar || getPutInfo.resolveType() == GlobalVarWithVarInjectionChecks |
| 2595 | || getPutInfo.resolveType() == LocalClosureVar || getPutInfo.resolveType() == GlobalLexicalVar || getPutInfo.resolveType() == GlobalLexicalVarWithVarInjectionChecks) |
| 2596 | continue; |
| 2597 | WriteBarrierBase<Structure>& structure = curInstruction[5].u.structure; |
| 2598 | if (!structure || Heap::isMarked(structure.get())) |
| 2599 | break; |
| 2600 | if (Options::verboseOSR()) |
| 2601 | dataLogF("Clearing scope access with structure %p.\n", structure.get()); |
| 2602 | structure.clear(); |
| 2603 | break; |
| 2604 | } |
| 2605 | default: |
| 2606 | OpcodeID opcodeID = interpreter->getOpcodeID(curInstruction[0].u.opcode); |
| 2607 | ASSERT_WITH_MESSAGE_UNUSED(opcodeID, false, "Unhandled opcode in CodeBlock::finalizeUnconditionally, %s(%d) at bc %u", opcodeNames[opcodeID], opcodeID, propertyAccessInstructions[i]); |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 2608 | } |
fpizlo@apple.com | cd8eb2c | 2013-09-20 18:42:41 +0000 | [diff] [blame] | 2609 | } |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 2610 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2611 | for (unsigned i = 0; i < m_llintCallLinkInfos.size(); ++i) { |
| 2612 | if (m_llintCallLinkInfos[i].isLinked() && !Heap::isMarked(m_llintCallLinkInfos[i].callee.get())) { |
| 2613 | if (Options::verboseOSR()) |
| 2614 | dataLog("Clearing LLInt call from ", *this, "\n"); |
| 2615 | m_llintCallLinkInfos[i].unlink(); |
fpizlo@apple.com | 1e89af3 | 2012-11-19 02:55:14 +0000 | [diff] [blame] | 2616 | } |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2617 | if (!!m_llintCallLinkInfos[i].lastSeenCallee && !Heap::isMarked(m_llintCallLinkInfos[i].lastSeenCallee.get())) |
| 2618 | m_llintCallLinkInfos[i].lastSeenCallee.clear(); |
| 2619 | } |
| 2620 | } |
| 2621 | |
| 2622 | void CodeBlock::finalizeBaselineJITInlineCaches() |
| 2623 | { |
ggaren@apple.com | 95bf67e | 2015-09-11 17:35:59 +0000 | [diff] [blame] | 2624 | #if ENABLE(JIT) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2625 | for (auto iter = callLinkInfosBegin(); !!iter; ++iter) |
| 2626 | (*iter)->visitWeak(*vm()); |
| 2627 | |
| 2628 | for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter) { |
| 2629 | StructureStubInfo& stubInfo = **iter; |
| 2630 | stubInfo.visitWeakReferences(this); |
| 2631 | } |
ggaren@apple.com | 95bf67e | 2015-09-11 17:35:59 +0000 | [diff] [blame] | 2632 | #endif |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2633 | } |
| 2634 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2635 | void CodeBlock::finalizeUnconditionally() |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2636 | { |
| 2637 | #if ENABLE(DFG_JIT) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2638 | if (shouldJettisonDueToWeakReference()) { |
| 2639 | jettison(Profiler::JettisonDueToWeakReference); |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2640 | return; |
| 2641 | } |
| 2642 | #endif // ENABLE(DFG_JIT) |
oliver@apple.com | c909f5f | 2012-10-18 23:37:40 +0000 | [diff] [blame] | 2643 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2644 | if (shouldJettisonDueToOldAge()) { |
| 2645 | jettison(Profiler::JettisonDueToOldAge); |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2646 | return; |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2647 | } |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2648 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2649 | if (JITCode::couldBeInterpreted(jitType())) |
| 2650 | finalizeLLIntInlineCaches(); |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 2651 | |
| 2652 | #if ENABLE(JIT) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2653 | if (!!jitCode()) |
| 2654 | finalizeBaselineJITInlineCaches(); |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2655 | #endif |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2656 | } |
| 2657 | |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 2658 | void CodeBlock::getStubInfoMap(const ConcurrentJITLocker&, StubInfoMap& result) |
| 2659 | { |
| 2660 | #if ENABLE(JIT) |
| 2661 | toHashMap(m_stubInfos, getStructureStubInfoCodeOrigin, result); |
| 2662 | #else |
| 2663 | UNUSED_PARAM(result); |
| 2664 | #endif |
| 2665 | } |
| 2666 | |
| 2667 | void CodeBlock::getStubInfoMap(StubInfoMap& result) |
| 2668 | { |
| 2669 | ConcurrentJITLocker locker(m_lock); |
| 2670 | getStubInfoMap(locker, result); |
| 2671 | } |
| 2672 | |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 2673 | void CodeBlock::getCallLinkInfoMap(const ConcurrentJITLocker&, CallLinkInfoMap& result) |
| 2674 | { |
| 2675 | #if ENABLE(JIT) |
| 2676 | toHashMap(m_callLinkInfos, getCallLinkInfoCodeOrigin, result); |
| 2677 | #else |
| 2678 | UNUSED_PARAM(result); |
| 2679 | #endif |
| 2680 | } |
| 2681 | |
| 2682 | void CodeBlock::getCallLinkInfoMap(CallLinkInfoMap& result) |
| 2683 | { |
| 2684 | ConcurrentJITLocker locker(m_lock); |
| 2685 | getCallLinkInfoMap(locker, result); |
| 2686 | } |
| 2687 | |
utatane.tea@gmail.com | fccd136 | 2015-08-11 22:02:09 +0000 | [diff] [blame] | 2688 | void CodeBlock::getByValInfoMap(const ConcurrentJITLocker&, ByValInfoMap& result) |
| 2689 | { |
| 2690 | #if ENABLE(JIT) |
| 2691 | for (auto* byValInfo : m_byValInfos) |
| 2692 | result.add(CodeOrigin(byValInfo->bytecodeIndex), byValInfo); |
| 2693 | #else |
| 2694 | UNUSED_PARAM(result); |
| 2695 | #endif |
| 2696 | } |
| 2697 | |
| 2698 | void CodeBlock::getByValInfoMap(ByValInfoMap& result) |
| 2699 | { |
| 2700 | ConcurrentJITLocker locker(m_lock); |
| 2701 | getByValInfoMap(locker, result); |
| 2702 | } |
| 2703 | |
fpizlo@apple.com | cf71612 | 2012-07-13 06:41:18 +0000 | [diff] [blame] | 2704 | #if ENABLE(JIT) |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 2705 | StructureStubInfo* CodeBlock::addStubInfo(AccessType accessType) |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 2706 | { |
| 2707 | ConcurrentJITLocker locker(m_lock); |
fpizlo@apple.com | b26b524 | 2015-09-10 19:49:36 +0000 | [diff] [blame] | 2708 | return m_stubInfos.add(accessType); |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 2709 | } |
| 2710 | |
fpizlo@apple.com | 4c6b8ad | 2014-07-22 21:08:50 +0000 | [diff] [blame] | 2711 | StructureStubInfo* CodeBlock::findStubInfo(CodeOrigin codeOrigin) |
| 2712 | { |
| 2713 | for (StructureStubInfo* stubInfo : m_stubInfos) { |
| 2714 | if (stubInfo->codeOrigin == codeOrigin) |
| 2715 | return stubInfo; |
| 2716 | } |
| 2717 | return nullptr; |
| 2718 | } |
| 2719 | |
utatane.tea@gmail.com | fccd136 | 2015-08-11 22:02:09 +0000 | [diff] [blame] | 2720 | ByValInfo* CodeBlock::addByValInfo() |
| 2721 | { |
| 2722 | ConcurrentJITLocker locker(m_lock); |
| 2723 | return m_byValInfos.add(); |
| 2724 | } |
| 2725 | |
fpizlo@apple.com | ba262b2 | 2014-03-23 04:34:38 +0000 | [diff] [blame] | 2726 | CallLinkInfo* CodeBlock::addCallLinkInfo() |
| 2727 | { |
| 2728 | ConcurrentJITLocker locker(m_lock); |
| 2729 | return m_callLinkInfos.add(); |
| 2730 | } |
| 2731 | |
fpizlo@apple.com | f7100b6 | 2014-03-24 17:29:51 +0000 | [diff] [blame] | 2732 | CallLinkInfo* CodeBlock::getCallLinkInfoForBytecodeIndex(unsigned index) |
| 2733 | { |
| 2734 | for (auto iter = m_callLinkInfos.begin(); !!iter; ++iter) { |
msaboff@apple.com | 203a56e | 2015-06-24 22:37:30 +0000 | [diff] [blame] | 2735 | if ((*iter)->codeOrigin() == CodeOrigin(index)) |
fpizlo@apple.com | f7100b6 | 2014-03-24 17:29:51 +0000 | [diff] [blame] | 2736 | return *iter; |
| 2737 | } |
| 2738 | return nullptr; |
| 2739 | } |
fpizlo@apple.com | cf71612 | 2012-07-13 06:41:18 +0000 | [diff] [blame] | 2740 | #endif |
| 2741 | |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2742 | void CodeBlock::visitOSRExitTargets(SlotVisitor& visitor) |
| 2743 | { |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2744 | // We strongly visit OSR exits targets because we don't want to deal with |
| 2745 | // the complexity of generating an exit target CodeBlock on demand and |
| 2746 | // guaranteeing that it matches the details of the CodeBlock we compiled |
| 2747 | // the OSR exit against. |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2748 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2749 | alternative()->visitStrongly(visitor); |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2750 | |
ggaren@apple.com | 6520f0c | 2015-09-09 22:26:16 +0000 | [diff] [blame] | 2751 | #if ENABLE(DFG_JIT) |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2752 | DFG::CommonData* dfgCommon = m_jitCode->dfgCommon(); |
| 2753 | if (dfgCommon->inlineCallFrames) { |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2754 | for (auto* inlineCallFrame : *dfgCommon->inlineCallFrames) { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2755 | ASSERT(inlineCallFrame->baselineCodeBlock()); |
| 2756 | inlineCallFrame->baselineCodeBlock()->visitStrongly(visitor); |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 2757 | } |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2758 | } |
ggaren@apple.com | 6520f0c | 2015-09-09 22:26:16 +0000 | [diff] [blame] | 2759 | #endif |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2760 | } |
| 2761 | |
fpizlo@apple.com | a147a4d | 2011-11-21 04:45:17 +0000 | [diff] [blame] | 2762 | void CodeBlock::stronglyVisitStrongReferences(SlotVisitor& visitor) |
| 2763 | { |
oliver@apple.com | 433d02f | 2011-04-21 23:08:15 +0000 | [diff] [blame] | 2764 | visitor.append(&m_globalObject); |
| 2765 | visitor.append(&m_ownerExecutable); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 2766 | visitor.append(&m_unlinkedCode); |
| 2767 | if (m_rareData) |
oliver@apple.com | 433d02f | 2011-04-21 23:08:15 +0000 | [diff] [blame] | 2768 | m_rareData->m_evalCodeCache.visitAggregate(visitor); |
| 2769 | visitor.appendValues(m_constantRegisters.data(), m_constantRegisters.size()); |
barraclough@apple.com | 306bb12 | 2009-08-18 05:34:52 +0000 | [diff] [blame] | 2770 | for (size_t i = 0; i < m_functionExprs.size(); ++i) |
oliver@apple.com | 433d02f | 2011-04-21 23:08:15 +0000 | [diff] [blame] | 2771 | visitor.append(&m_functionExprs[i]); |
barraclough@apple.com | 306bb12 | 2009-08-18 05:34:52 +0000 | [diff] [blame] | 2772 | for (size_t i = 0; i < m_functionDecls.size(); ++i) |
oliver@apple.com | 433d02f | 2011-04-21 23:08:15 +0000 | [diff] [blame] | 2773 | visitor.append(&m_functionDecls[i]); |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 2774 | for (unsigned i = 0; i < m_objectAllocationProfiles.size(); ++i) |
| 2775 | m_objectAllocationProfiles[i].visitAggregate(visitor); |
fpizlo@apple.com | d13163d | 2011-09-03 05:14:04 +0000 | [diff] [blame] | 2776 | |
ggaren@apple.com | 156eb59 | 2015-09-09 22:06:49 +0000 | [diff] [blame] | 2777 | #if ENABLE(DFG_JIT) |
| 2778 | if (JITCode::isOptimizingJIT(jitType())) |
| 2779 | visitOSRExitTargets(visitor); |
| 2780 | #endif |
| 2781 | |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 2782 | updateAllPredictions(); |
fpizlo@apple.com | 5e37f9a | 2011-11-17 00:49:50 +0000 | [diff] [blame] | 2783 | } |
| 2784 | |
| 2785 | void CodeBlock::stronglyVisitWeakReferences(SlotVisitor& visitor) |
| 2786 | { |
ggaren@apple.com | 7ac9ed8 | 2011-11-17 01:43:48 +0000 | [diff] [blame] | 2787 | UNUSED_PARAM(visitor); |
| 2788 | |
| 2789 | #if ENABLE(DFG_JIT) |
oliver@apple.com | 5a24fdd | 2013-07-25 04:00:54 +0000 | [diff] [blame] | 2790 | if (!JITCode::isOptimizingJIT(jitType())) |
fpizlo@apple.com | 5e37f9a | 2011-11-17 00:49:50 +0000 | [diff] [blame] | 2791 | return; |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2792 | |
| 2793 | DFG::CommonData* dfgCommon = m_jitCode->dfgCommon(); |
ggaren@apple.com | 7ac9ed8 | 2011-11-17 01:43:48 +0000 | [diff] [blame] | 2794 | |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2795 | for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) { |
| 2796 | if (!!dfgCommon->transitions[i].m_codeOrigin) |
| 2797 | visitor.append(&dfgCommon->transitions[i].m_codeOrigin); // Almost certainly not necessary, since the code origin should also be a weak reference. Better to be safe, though. |
| 2798 | visitor.append(&dfgCommon->transitions[i].m_from); |
| 2799 | visitor.append(&dfgCommon->transitions[i].m_to); |
fpizlo@apple.com | 5e37f9a | 2011-11-17 00:49:50 +0000 | [diff] [blame] | 2800 | } |
| 2801 | |
oliver@apple.com | 02b179b | 2013-07-25 03:58:20 +0000 | [diff] [blame] | 2802 | for (unsigned i = 0; i < dfgCommon->weakReferences.size(); ++i) |
| 2803 | visitor.append(&dfgCommon->weakReferences[i]); |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 2804 | |
| 2805 | for (unsigned i = 0; i < dfgCommon->weakStructureReferences.size(); ++i) |
| 2806 | visitor.append(&dfgCommon->weakStructureReferences[i]); |
ggaren@apple.com | 51be9a2 | 2015-09-09 22:00:58 +0000 | [diff] [blame] | 2807 | |
| 2808 | dfgCommon->livenessHasBeenProved = true; |
ggaren@apple.com | 7ac9ed8 | 2011-11-17 01:43:48 +0000 | [diff] [blame] | 2809 | #endif |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 2810 | } |
| 2811 | |
fpizlo@apple.com | 501e606 | 2013-11-01 22:10:52 +0000 | [diff] [blame] | 2812 | CodeBlock* CodeBlock::baselineAlternative() |
| 2813 | { |
| 2814 | #if ENABLE(JIT) |
| 2815 | CodeBlock* result = this; |
| 2816 | while (result->alternative()) |
| 2817 | result = result->alternative(); |
| 2818 | RELEASE_ASSERT(result); |
| 2819 | RELEASE_ASSERT(JITCode::isBaselineCode(result->jitType()) || result->jitType() == JITCode::None); |
| 2820 | return result; |
| 2821 | #else |
| 2822 | return this; |
| 2823 | #endif |
| 2824 | } |
| 2825 | |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2826 | CodeBlock* CodeBlock::baselineVersion() |
| 2827 | { |
fpizlo@apple.com | 501e606 | 2013-11-01 22:10:52 +0000 | [diff] [blame] | 2828 | #if ENABLE(JIT) |
fpizlo@apple.com | 669223d | 2013-09-01 02:02:47 +0000 | [diff] [blame] | 2829 | if (JITCode::isBaselineCode(jitType())) |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2830 | return this; |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2831 | CodeBlock* result = replacement(); |
fpizlo@apple.com | cd8eb2c | 2013-09-20 18:42:41 +0000 | [diff] [blame] | 2832 | if (!result) { |
| 2833 | // This can happen if we're creating the original CodeBlock for an executable. |
| 2834 | // Assume that we're the baseline CodeBlock. |
fpizlo@apple.com | 501e606 | 2013-11-01 22:10:52 +0000 | [diff] [blame] | 2835 | RELEASE_ASSERT(jitType() == JITCode::None); |
fpizlo@apple.com | cd8eb2c | 2013-09-20 18:42:41 +0000 | [diff] [blame] | 2836 | return this; |
| 2837 | } |
fpizlo@apple.com | 501e606 | 2013-11-01 22:10:52 +0000 | [diff] [blame] | 2838 | result = result->baselineAlternative(); |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2839 | return result; |
| 2840 | #else |
fpizlo@apple.com | cd8eb2c | 2013-09-20 18:42:41 +0000 | [diff] [blame] | 2841 | return this; |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2842 | #endif |
| 2843 | } |
| 2844 | |
| 2845 | #if ENABLE(JIT) |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 2846 | bool CodeBlock::hasOptimizedReplacement(JITCode::JITType typeToReplace) |
| 2847 | { |
| 2848 | return JITCode::isHigherTier(replacement()->jitType(), typeToReplace); |
| 2849 | } |
| 2850 | |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2851 | bool CodeBlock::hasOptimizedReplacement() |
| 2852 | { |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 2853 | return hasOptimizedReplacement(jitType()); |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 2854 | } |
| 2855 | #endif |
| 2856 | |
mark.lam@apple.com | 6ed0827 | 2015-06-05 18:52:12 +0000 | [diff] [blame] | 2857 | HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset, RequiredHandler requiredHandler) |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 2858 | { |
oliver@apple.com | 49a2c14 | 2013-04-04 21:25:26 +0000 | [diff] [blame] | 2859 | RELEASE_ASSERT(bytecodeOffset < instructions().size()); |
sbarati@apple.com | 36c1340 | 2015-09-18 23:37:42 +0000 | [diff] [blame] | 2860 | return handlerForIndex(bytecodeOffset, requiredHandler); |
| 2861 | } |
weinig@apple.com | 06885cf | 2008-12-17 21:25:40 +0000 | [diff] [blame] | 2862 | |
sbarati@apple.com | 36c1340 | 2015-09-18 23:37:42 +0000 | [diff] [blame] | 2863 | HandlerInfo* CodeBlock::handlerForIndex(unsigned index, RequiredHandler requiredHandler) |
| 2864 | { |
weinig@apple.com | 4557e84 | 2008-12-09 01:06:14 +0000 | [diff] [blame] | 2865 | if (!m_rareData) |
| 2866 | return 0; |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 2867 | |
weinig@apple.com | 18064e7 | 2008-12-10 00:26:13 +0000 | [diff] [blame] | 2868 | Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers; |
| 2869 | for (size_t i = 0; i < exceptionHandlers.size(); ++i) { |
mark.lam@apple.com | 4585ce9 | 2015-05-30 00:19:01 +0000 | [diff] [blame] | 2870 | HandlerInfo& handler = exceptionHandlers[i]; |
mark.lam@apple.com | 6ed0827 | 2015-06-05 18:52:12 +0000 | [diff] [blame] | 2871 | if ((requiredHandler == RequiredHandler::CatchHandler) && !handler.isCatchHandler()) |
| 2872 | continue; |
| 2873 | |
weinig@apple.com | 18064e7 | 2008-12-10 00:26:13 +0000 | [diff] [blame] | 2874 | // Handlers are ordered innermost first, so the first handler we encounter |
| 2875 | // that contains the source address is the correct handler to use. |
sbarati@apple.com | 36c1340 | 2015-09-18 23:37:42 +0000 | [diff] [blame] | 2876 | // This index used is either the BytecodeOffset or a CallSiteIndex. |
| 2877 | if (handler.start <= index && handler.end > index) |
mark.lam@apple.com | 4585ce9 | 2015-05-30 00:19:01 +0000 | [diff] [blame] | 2878 | return &handler; |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 2879 | } |
| 2880 | |
| 2881 | return 0; |
| 2882 | } |
| 2883 | |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 2884 | unsigned CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 2885 | { |
oliver@apple.com | 903b0c0 | 2013-01-24 01:40:37 +0000 | [diff] [blame] | 2886 | RELEASE_ASSERT(bytecodeOffset < instructions().size()); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2887 | return ownerScriptExecutable()->firstLine() + m_unlinkedCode->lineNumberForBytecodeOffset(bytecodeOffset); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 2888 | } |
| 2889 | |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 2890 | unsigned CodeBlock::columnNumberForBytecodeOffset(unsigned bytecodeOffset) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 2891 | { |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 2892 | int divot; |
| 2893 | int startOffset; |
| 2894 | int endOffset; |
| 2895 | unsigned line; |
| 2896 | unsigned column; |
| 2897 | expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column); |
| 2898 | return column; |
| 2899 | } |
| 2900 | |
| 2901 | void CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) |
| 2902 | { |
| 2903 | m_unlinkedCode->expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column); |
oliver@apple.com | f0c01b8 | 2012-11-07 00:13:54 +0000 | [diff] [blame] | 2904 | divot += m_sourceOffset; |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 2905 | column += line ? 1 : firstLineColumnOffset(); |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2906 | line += ownerScriptExecutable()->firstLine(); |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 2907 | } |
| 2908 | |
mark.lam@apple.com | 945b139 | 2014-01-23 07:39:58 +0000 | [diff] [blame] | 2909 | bool CodeBlock::hasOpDebugForLineAndColumn(unsigned line, unsigned column) |
| 2910 | { |
| 2911 | Interpreter* interpreter = vm()->interpreter; |
| 2912 | const Instruction* begin = instructions().begin(); |
| 2913 | const Instruction* end = instructions().end(); |
| 2914 | for (const Instruction* it = begin; it != end;) { |
| 2915 | OpcodeID opcodeID = interpreter->getOpcodeID(it->u.opcode); |
| 2916 | if (opcodeID == op_debug) { |
| 2917 | unsigned bytecodeOffset = it - begin; |
| 2918 | int unused; |
| 2919 | unsigned opDebugLine; |
| 2920 | unsigned opDebugColumn; |
| 2921 | expressionRangeForBytecodeOffset(bytecodeOffset, unused, unused, unused, opDebugLine, opDebugColumn); |
| 2922 | if (line == opDebugLine && (column == Breakpoint::unspecifiedColumn || column == opDebugColumn)) |
| 2923 | return true; |
| 2924 | } |
| 2925 | it += opcodeLengths[opcodeID]; |
| 2926 | } |
| 2927 | return false; |
| 2928 | } |
| 2929 | |
fpizlo@apple.com | db79da2 | 2012-05-16 00:56:54 +0000 | [diff] [blame] | 2930 | void CodeBlock::shrinkToFit(ShrinkMode shrinkMode) |
weinig@apple.com | 9d9d25d | 2008-12-05 20:27:58 +0000 | [diff] [blame] | 2931 | { |
fpizlo@apple.com | db79da2 | 2012-05-16 00:56:54 +0000 | [diff] [blame] | 2932 | m_rareCaseProfiles.shrinkToFit(); |
| 2933 | m_specialFastCaseProfiles.shrinkToFit(); |
fpizlo@apple.com | db79da2 | 2012-05-16 00:56:54 +0000 | [diff] [blame] | 2934 | |
| 2935 | if (shrinkMode == EarlyShrink) { |
fpizlo@apple.com | db79da2 | 2012-05-16 00:56:54 +0000 | [diff] [blame] | 2936 | m_constantRegisters.shrinkToFit(); |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 2937 | m_constantsSourceCodeRepresentation.shrinkToFit(); |
oliver@apple.com | 9b7647b | 2013-07-25 04:03:00 +0000 | [diff] [blame] | 2938 | |
| 2939 | if (m_rareData) { |
oliver@apple.com | a14cea5 | 2013-07-25 04:03:23 +0000 | [diff] [blame] | 2940 | m_rareData->m_switchJumpTables.shrinkToFit(); |
oliver@apple.com | 9b7647b | 2013-07-25 04:03:00 +0000 | [diff] [blame] | 2941 | m_rareData->m_stringSwitchJumpTables.shrinkToFit(); |
| 2942 | } |
fpizlo@apple.com | db79da2 | 2012-05-16 00:56:54 +0000 | [diff] [blame] | 2943 | } // else don't shrink these, because we would have already pointed pointers into these tables. |
weinig@apple.com | 9d9d25d | 2008-12-05 20:27:58 +0000 | [diff] [blame] | 2944 | } |
| 2945 | |
oliver@apple.com | 1db480d | 2011-06-28 01:32:01 +0000 | [diff] [blame] | 2946 | #if ENABLE(JIT) |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 2947 | void CodeBlock::linkIncomingCall(ExecState* callerFrame, CallLinkInfo* incoming) |
| 2948 | { |
| 2949 | noticeIncomingCall(callerFrame); |
| 2950 | m_incomingCalls.push(incoming); |
| 2951 | } |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 2952 | |
| 2953 | void CodeBlock::linkIncomingPolymorphicCall(ExecState* callerFrame, PolymorphicCallNode* incoming) |
| 2954 | { |
| 2955 | noticeIncomingCall(callerFrame); |
| 2956 | m_incomingPolymorphicCalls.push(incoming); |
| 2957 | } |
fpizlo@apple.com | 62b6af8 | 2013-08-29 18:25:36 +0000 | [diff] [blame] | 2958 | #endif // ENABLE(JIT) |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 2959 | |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 2960 | void CodeBlock::unlinkIncomingCalls() |
| 2961 | { |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 2962 | while (m_incomingLLIntCalls.begin() != m_incomingLLIntCalls.end()) |
| 2963 | m_incomingLLIntCalls.begin()->unlink(); |
fpizlo@apple.com | 62b6af8 | 2013-08-29 18:25:36 +0000 | [diff] [blame] | 2964 | #if ENABLE(JIT) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2965 | if (m_incomingCalls.isEmpty() && m_incomingPolymorphicCalls.isEmpty()) |
| 2966 | return; |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 2967 | while (m_incomingCalls.begin() != m_incomingCalls.end()) |
fpizlo@apple.com | 7a79726 | 2015-09-03 21:11:59 +0000 | [diff] [blame] | 2968 | m_incomingCalls.begin()->unlink(*vm()); |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 2969 | while (m_incomingPolymorphicCalls.begin() != m_incomingPolymorphicCalls.end()) |
fpizlo@apple.com | 7a79726 | 2015-09-03 21:11:59 +0000 | [diff] [blame] | 2970 | m_incomingPolymorphicCalls.begin()->unlink(*vm()); |
commit-queue@webkit.org | ea1f902 | 2013-08-29 16:41:07 +0000 | [diff] [blame] | 2971 | #endif // ENABLE(JIT) |
fpizlo@apple.com | 62b6af8 | 2013-08-29 18:25:36 +0000 | [diff] [blame] | 2972 | } |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 2973 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 2974 | void CodeBlock::linkIncomingCall(ExecState* callerFrame, LLIntCallLinkInfo* incoming) |
| 2975 | { |
| 2976 | noticeIncomingCall(callerFrame); |
| 2977 | m_incomingLLIntCalls.push(incoming); |
| 2978 | } |
commit-queue@webkit.org | f76b9d5 | 2012-08-20 23:48:00 +0000 | [diff] [blame] | 2979 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2980 | PassRefPtr<CodeBlock> CodeBlock::newReplacement() |
fpizlo@apple.com | 62b6af8 | 2013-08-29 18:25:36 +0000 | [diff] [blame] | 2981 | { |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 2982 | return ownerScriptExecutable()->newReplacementCodeBlockFor(specializationKind()); |
fpizlo@apple.com | 62b6af8 | 2013-08-29 18:25:36 +0000 | [diff] [blame] | 2983 | } |
| 2984 | |
fpizlo@apple.com | af478bb | 2011-09-06 23:36:51 +0000 | [diff] [blame] | 2985 | #if ENABLE(JIT) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2986 | CodeBlock* ProgramCodeBlock::replacement() |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 2987 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2988 | return jsCast<ProgramExecutable*>(ownerExecutable())->codeBlock(); |
| 2989 | } |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 2990 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2991 | CodeBlock* ModuleProgramCodeBlock::replacement() |
| 2992 | { |
| 2993 | return jsCast<ModuleProgramExecutable*>(ownerExecutable())->codeBlock(); |
| 2994 | } |
utatane.tea@gmail.com | a8309d9 | 2015-09-01 02:05:30 +0000 | [diff] [blame] | 2995 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 2996 | CodeBlock* EvalCodeBlock::replacement() |
| 2997 | { |
| 2998 | return jsCast<EvalExecutable*>(ownerExecutable())->codeBlock(); |
| 2999 | } |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 3000 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3001 | CodeBlock* FunctionCodeBlock::replacement() |
| 3002 | { |
| 3003 | return jsCast<FunctionExecutable*>(ownerExecutable())->codeBlockFor(m_isConstructor ? CodeForConstruct : CodeForCall); |
| 3004 | } |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 3005 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3006 | DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal() |
| 3007 | { |
| 3008 | return DFG::programCapabilityLevel(this); |
| 3009 | } |
| 3010 | |
| 3011 | DFG::CapabilityLevel ModuleProgramCodeBlock::capabilityLevelInternal() |
| 3012 | { |
| 3013 | return DFG::programCapabilityLevel(this); |
| 3014 | } |
| 3015 | |
| 3016 | DFG::CapabilityLevel EvalCodeBlock::capabilityLevelInternal() |
| 3017 | { |
| 3018 | return DFG::evalCapabilityLevel(this); |
| 3019 | } |
| 3020 | |
| 3021 | DFG::CapabilityLevel FunctionCodeBlock::capabilityLevelInternal() |
| 3022 | { |
| 3023 | if (m_isConstructor) |
| 3024 | return DFG::functionForConstructCapabilityLevel(this); |
| 3025 | return DFG::functionForCallCapabilityLevel(this); |
| 3026 | } |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 3027 | |
| 3028 | #if ENABLE(WEBASSEMBLY) |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3029 | CodeBlock* WebAssemblyCodeBlock::replacement() |
| 3030 | { |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 3031 | return nullptr; |
| 3032 | } |
| 3033 | |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3034 | DFG::CapabilityLevel WebAssemblyCodeBlock::capabilityLevelInternal() |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 3035 | { |
| 3036 | return DFG::CannotCompile; |
| 3037 | } |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3038 | #endif |
| 3039 | #endif |
fpizlo@apple.com | 706f5f3 | 2011-09-21 23:36:35 +0000 | [diff] [blame] | 3040 | |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 3041 | void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mode, const FireDetail* detail) |
fpizlo@apple.com | 706f5f3 | 2011-09-21 23:36:35 +0000 | [diff] [blame] | 3042 | { |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3043 | #if !ENABLE(DFG_JIT) |
| 3044 | UNUSED_PARAM(mode); |
| 3045 | UNUSED_PARAM(detail); |
| 3046 | #endif |
| 3047 | |
fpizlo@apple.com | 0dda6d7 | 2014-02-02 02:25:13 +0000 | [diff] [blame] | 3048 | RELEASE_ASSERT(reason != Profiler::NotJettisoned); |
| 3049 | |
fpizlo@apple.com | 580c6f0 | 2013-10-30 20:22:40 +0000 | [diff] [blame] | 3050 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3051 | if (DFG::shouldShowDisassembly()) { |
| 3052 | dataLog("Jettisoning ", *this); |
| 3053 | if (mode == CountReoptimization) |
| 3054 | dataLog(" and counting reoptimization"); |
fpizlo@apple.com | 2c4a7e9 | 2014-08-06 05:27:46 +0000 | [diff] [blame] | 3055 | dataLog(" due to ", reason); |
| 3056 | if (detail) |
| 3057 | dataLog(", ", *detail); |
| 3058 | dataLog(".\n"); |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3059 | } |
| 3060 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3061 | if (reason == Profiler::JettisonDueToWeakReference) { |
| 3062 | if (DFG::shouldShowDisassembly()) { |
| 3063 | dataLog(*this, " will be jettisoned because of the following dead references:\n"); |
| 3064 | DFG::CommonData* dfgCommon = m_jitCode->dfgCommon(); |
| 3065 | for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) { |
| 3066 | DFG::WeakReferenceTransition& transition = dfgCommon->transitions[i]; |
| 3067 | JSCell* origin = transition.m_codeOrigin.get(); |
| 3068 | JSCell* from = transition.m_from.get(); |
| 3069 | JSCell* to = transition.m_to.get(); |
| 3070 | if ((!origin || Heap::isMarked(origin)) && Heap::isMarked(from)) |
| 3071 | continue; |
| 3072 | dataLog(" Transition under ", RawPointer(origin), ", ", RawPointer(from), " -> ", RawPointer(to), ".\n"); |
| 3073 | } |
| 3074 | for (unsigned i = 0; i < dfgCommon->weakReferences.size(); ++i) { |
| 3075 | JSCell* weak = dfgCommon->weakReferences[i].get(); |
| 3076 | if (Heap::isMarked(weak)) |
| 3077 | continue; |
| 3078 | dataLog(" Weak reference ", RawPointer(weak), ".\n"); |
| 3079 | } |
| 3080 | } |
| 3081 | } |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3082 | #endif // ENABLE(DFG_JIT) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3083 | |
fpizlo@apple.com | 4917df2 | 2013-10-31 03:52:23 +0000 | [diff] [blame] | 3084 | DeferGCForAWhile deferGC(*m_heap); |
fpizlo@apple.com | 0dda6d7 | 2014-02-02 02:25:13 +0000 | [diff] [blame] | 3085 | |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3086 | // We want to accomplish two things here: |
| 3087 | // 1) Make sure that if this CodeBlock is on the stack right now, then if we return to it |
| 3088 | // we should OSR exit at the top of the next bytecode instruction after the return. |
| 3089 | // 2) Make sure that if we call the owner executable, then we shouldn't call this CodeBlock. |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3090 | |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3091 | #if ENABLE(DFG_JIT) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3092 | if (reason != Profiler::JettisonDueToOldAge) { |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3093 | if (Profiler::Compilation* compilation = jitCode()->dfgCommon()->compilation.get()) |
| 3094 | compilation->setJettisonReason(reason, detail); |
| 3095 | |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3096 | // This accomplishes (1), and does its own book-keeping about whether it has already happened. |
| 3097 | if (!jitCode()->dfgCommon()->invalidate()) { |
| 3098 | // We've already been invalidated. |
| 3099 | RELEASE_ASSERT(this != replacement()); |
| 3100 | return; |
| 3101 | } |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3102 | } |
| 3103 | |
| 3104 | if (DFG::shouldShowDisassembly()) |
| 3105 | dataLog(" Did invalidate ", *this, "\n"); |
| 3106 | |
| 3107 | // Count the reoptimization if that's what the user wanted. |
| 3108 | if (mode == CountReoptimization) { |
fpizlo@apple.com | 78e1b2b | 2013-11-03 00:32:23 +0000 | [diff] [blame] | 3109 | // FIXME: Maybe this should call alternative(). |
| 3110 | // https://bugs.webkit.org/show_bug.cgi?id=123677 |
| 3111 | baselineAlternative()->countReoptimization(); |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3112 | if (DFG::shouldShowDisassembly()) |
| 3113 | dataLog(" Did count reoptimization for ", *this, "\n"); |
| 3114 | } |
| 3115 | |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3116 | if (this != replacement()) { |
| 3117 | // This means that we were never the entrypoint. This can happen for OSR entry code |
| 3118 | // blocks. |
| 3119 | return; |
| 3120 | } |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3121 | |
| 3122 | if (alternative()) |
| 3123 | alternative()->optimizeAfterWarmUp(); |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3124 | |
| 3125 | if (reason != Profiler::JettisonDueToOldAge) |
| 3126 | tallyFrequentExitSites(); |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3127 | #endif // ENABLE(DFG_JIT) |
ggaren@apple.com | 111b3fa | 2015-09-11 16:08:39 +0000 | [diff] [blame] | 3128 | |
ggaren@apple.com | 0548385 | 2015-09-17 00:28:34 +0000 | [diff] [blame] | 3129 | // This accomplishes (2). |
| 3130 | ownerScriptExecutable()->installCode( |
| 3131 | m_globalObject->vm(), alternative(), codeType(), specializationKind()); |
| 3132 | |
| 3133 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | d84425d | 2013-10-30 19:58:08 +0000 | [diff] [blame] | 3134 | if (DFG::shouldShowDisassembly()) |
| 3135 | dataLog(" Did install baseline version of ", *this, "\n"); |
fpizlo@apple.com | 580c6f0 | 2013-10-30 20:22:40 +0000 | [diff] [blame] | 3136 | #endif // ENABLE(DFG_JIT) |
fpizlo@apple.com | 706f5f3 | 2011-09-21 23:36:35 +0000 | [diff] [blame] | 3137 | } |
fpizlo@apple.com | 594887a | 2011-09-06 09:23:55 +0000 | [diff] [blame] | 3138 | |
fpizlo@apple.com | 5e2296a | 2013-01-07 02:24:58 +0000 | [diff] [blame] | 3139 | JSGlobalObject* CodeBlock::globalObjectFor(CodeOrigin codeOrigin) |
| 3140 | { |
| 3141 | if (!codeOrigin.inlineCallFrame) |
| 3142 | return globalObject(); |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3143 | return jsCast<FunctionExecutable*>(codeOrigin.inlineCallFrame->executable.get())->eitherCodeBlock()->globalObject(); |
fpizlo@apple.com | 5e2296a | 2013-01-07 02:24:58 +0000 | [diff] [blame] | 3144 | } |
| 3145 | |
msaboff@apple.com | 4d563e4 | 2014-08-16 01:45:40 +0000 | [diff] [blame] | 3146 | class RecursionCheckFunctor { |
| 3147 | public: |
| 3148 | RecursionCheckFunctor(CallFrame* startCallFrame, CodeBlock* codeBlock, unsigned depthToCheck) |
| 3149 | : m_startCallFrame(startCallFrame) |
| 3150 | , m_codeBlock(codeBlock) |
| 3151 | , m_depthToCheck(depthToCheck) |
| 3152 | , m_foundStartCallFrame(false) |
| 3153 | , m_didRecurse(false) |
| 3154 | { } |
| 3155 | |
| 3156 | StackVisitor::Status operator()(StackVisitor& visitor) |
| 3157 | { |
| 3158 | CallFrame* currentCallFrame = visitor->callFrame(); |
| 3159 | |
| 3160 | if (currentCallFrame == m_startCallFrame) |
| 3161 | m_foundStartCallFrame = true; |
| 3162 | |
| 3163 | if (m_foundStartCallFrame) { |
| 3164 | if (visitor->callFrame()->codeBlock() == m_codeBlock) { |
| 3165 | m_didRecurse = true; |
| 3166 | return StackVisitor::Done; |
| 3167 | } |
| 3168 | |
| 3169 | if (!m_depthToCheck--) |
| 3170 | return StackVisitor::Done; |
| 3171 | } |
| 3172 | |
| 3173 | return StackVisitor::Continue; |
| 3174 | } |
| 3175 | |
| 3176 | bool didRecurse() const { return m_didRecurse; } |
| 3177 | |
| 3178 | private: |
| 3179 | CallFrame* m_startCallFrame; |
| 3180 | CodeBlock* m_codeBlock; |
| 3181 | unsigned m_depthToCheck; |
| 3182 | bool m_foundStartCallFrame; |
| 3183 | bool m_didRecurse; |
| 3184 | }; |
| 3185 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3186 | void CodeBlock::noticeIncomingCall(ExecState* callerFrame) |
| 3187 | { |
| 3188 | CodeBlock* callerCodeBlock = callerFrame->codeBlock(); |
| 3189 | |
oliver@apple.com | afa7e3a | 2013-07-25 04:02:04 +0000 | [diff] [blame] | 3190 | if (Options::verboseCallLink()) |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 3191 | dataLog("Noticing call link from ", pointerDump(callerCodeBlock), " to ", *this, "\n"); |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3192 | |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 3193 | #if ENABLE(DFG_JIT) |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3194 | if (!m_shouldAlwaysBeInlined) |
| 3195 | return; |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 3196 | |
| 3197 | if (!callerCodeBlock) { |
| 3198 | m_shouldAlwaysBeInlined = false; |
| 3199 | if (Options::verboseCallLink()) |
| 3200 | dataLog(" Clearing SABI because caller is native.\n"); |
| 3201 | return; |
| 3202 | } |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3203 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3204 | if (!hasBaselineJITProfiling()) |
| 3205 | return; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3206 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3207 | if (!DFG::mightInlineFunction(this)) |
| 3208 | return; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3209 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3210 | if (!canInline(m_capabilityLevelState)) |
| 3211 | return; |
fpizlo@apple.com | afeb1a9 | 2014-02-23 18:48:43 +0000 | [diff] [blame] | 3212 | |
| 3213 | if (!DFG::isSmallEnoughToInlineCodeInto(callerCodeBlock)) { |
| 3214 | m_shouldAlwaysBeInlined = false; |
| 3215 | if (Options::verboseCallLink()) |
| 3216 | dataLog(" Clearing SABI because caller is too large.\n"); |
| 3217 | return; |
| 3218 | } |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3219 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3220 | if (callerCodeBlock->jitType() == JITCode::InterpreterThunk) { |
| 3221 | // If the caller is still in the interpreter, then we can't expect inlining to |
| 3222 | // happen anytime soon. Assume it's profitable to optimize it separately. This |
| 3223 | // ensures that a function is SABI only if it is called no more frequently than |
| 3224 | // any of its callers. |
| 3225 | m_shouldAlwaysBeInlined = false; |
oliver@apple.com | afa7e3a | 2013-07-25 04:02:04 +0000 | [diff] [blame] | 3226 | if (Options::verboseCallLink()) |
fpizlo@apple.com | afeb1a9 | 2014-02-23 18:48:43 +0000 | [diff] [blame] | 3227 | dataLog(" Clearing SABI because caller is in LLInt.\n"); |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3228 | return; |
| 3229 | } |
| 3230 | |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 3231 | if (JITCode::isOptimizingJIT(callerCodeBlock->jitType())) { |
| 3232 | m_shouldAlwaysBeInlined = false; |
| 3233 | if (Options::verboseCallLink()) |
| 3234 | dataLog(" Clearing SABI bcause caller was already optimized.\n"); |
| 3235 | return; |
| 3236 | } |
| 3237 | |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3238 | if (callerCodeBlock->codeType() != FunctionCode) { |
| 3239 | // If the caller is either eval or global code, assume that that won't be |
| 3240 | // optimized anytime soon. For eval code this is particularly true since we |
| 3241 | // delay eval optimization by a *lot*. |
| 3242 | m_shouldAlwaysBeInlined = false; |
oliver@apple.com | afa7e3a | 2013-07-25 04:02:04 +0000 | [diff] [blame] | 3243 | if (Options::verboseCallLink()) |
fpizlo@apple.com | afeb1a9 | 2014-02-23 18:48:43 +0000 | [diff] [blame] | 3244 | dataLog(" Clearing SABI because caller is not a function.\n"); |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3245 | return; |
| 3246 | } |
msaboff@apple.com | 4d563e4 | 2014-08-16 01:45:40 +0000 | [diff] [blame] | 3247 | |
| 3248 | // Recursive calls won't be inlined. |
| 3249 | RecursionCheckFunctor functor(callerFrame, this, Options::maximumInliningDepth()); |
| 3250 | vm()->topCallFrame->iterate(functor); |
| 3251 | |
| 3252 | if (functor.didRecurse()) { |
| 3253 | if (Options::verboseCallLink()) |
| 3254 | dataLog(" Clearing SABI because recursion was detected.\n"); |
| 3255 | m_shouldAlwaysBeInlined = false; |
| 3256 | return; |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3257 | } |
fpizlo@apple.com | 8a5fd18 | 2015-02-02 18:38:08 +0000 | [diff] [blame] | 3258 | |
| 3259 | if (callerCodeBlock->m_capabilityLevelState == DFG::CapabilityLevelNotSet) { |
| 3260 | dataLog("In call from ", *callerCodeBlock, " ", callerFrame->codeOrigin(), " to ", *this, ": caller's DFG capability level is not set.\n"); |
| 3261 | CRASH(); |
| 3262 | } |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3263 | |
| 3264 | if (canCompile(callerCodeBlock->m_capabilityLevelState)) |
| 3265 | return; |
| 3266 | |
oliver@apple.com | afa7e3a | 2013-07-25 04:02:04 +0000 | [diff] [blame] | 3267 | if (Options::verboseCallLink()) |
fpizlo@apple.com | afeb1a9 | 2014-02-23 18:48:43 +0000 | [diff] [blame] | 3268 | dataLog(" Clearing SABI because the caller is not a DFG candidate.\n"); |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3269 | |
| 3270 | m_shouldAlwaysBeInlined = false; |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3271 | #endif |
oliver@apple.com | d2cdd31 | 2013-07-25 04:01:00 +0000 | [diff] [blame] | 3272 | } |
| 3273 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3274 | unsigned CodeBlock::reoptimizationRetryCounter() const |
| 3275 | { |
mhahnenberg@apple.com | d79127e | 2014-02-05 01:35:31 +0000 | [diff] [blame] | 3276 | #if ENABLE(JIT) |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3277 | ASSERT(m_reoptimizationRetryCounter <= Options::reoptimizationRetryCounterMax()); |
| 3278 | return m_reoptimizationRetryCounter; |
mhahnenberg@apple.com | d79127e | 2014-02-05 01:35:31 +0000 | [diff] [blame] | 3279 | #else |
| 3280 | return 0; |
| 3281 | #endif // ENABLE(JIT) |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3282 | } |
| 3283 | |
mhahnenberg@apple.com | d79127e | 2014-02-05 01:35:31 +0000 | [diff] [blame] | 3284 | #if ENABLE(JIT) |
msaboff@apple.com | 0208546 | 2015-09-10 17:47:16 +0000 | [diff] [blame] | 3285 | void CodeBlock::setCalleeSaveRegisters(RegisterSet calleeSaveRegisters) |
| 3286 | { |
| 3287 | m_calleeSaveRegisters = std::make_unique<RegisterAtOffsetList>(calleeSaveRegisters); |
| 3288 | } |
| 3289 | |
| 3290 | void CodeBlock::setCalleeSaveRegisters(std::unique_ptr<RegisterAtOffsetList> registerAtOffsetList) |
| 3291 | { |
| 3292 | m_calleeSaveRegisters = WTF::move(registerAtOffsetList); |
| 3293 | } |
| 3294 | |
| 3295 | static size_t roundCalleeSaveSpaceAsVirtualRegisters(size_t calleeSaveRegisters) |
| 3296 | { |
| 3297 | static const unsigned cpuRegisterSize = sizeof(void*); |
| 3298 | return (WTF::roundUpToMultipleOf(sizeof(Register), calleeSaveRegisters * cpuRegisterSize) / sizeof(Register)); |
| 3299 | |
| 3300 | } |
| 3301 | |
| 3302 | size_t CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters() |
| 3303 | { |
| 3304 | return roundCalleeSaveSpaceAsVirtualRegisters(numberOfLLIntBaselineCalleeSaveRegisters()); |
| 3305 | } |
| 3306 | |
| 3307 | size_t CodeBlock::calleeSaveSpaceAsVirtualRegisters() |
| 3308 | { |
| 3309 | return roundCalleeSaveSpaceAsVirtualRegisters(m_calleeSaveRegisters->size()); |
| 3310 | } |
| 3311 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3312 | void CodeBlock::countReoptimization() |
| 3313 | { |
| 3314 | m_reoptimizationRetryCounter++; |
| 3315 | if (m_reoptimizationRetryCounter > Options::reoptimizationRetryCounterMax()) |
| 3316 | m_reoptimizationRetryCounter = Options::reoptimizationRetryCounterMax(); |
| 3317 | } |
| 3318 | |
oliver@apple.com | 37172f8 | 2013-07-25 04:01:17 +0000 | [diff] [blame] | 3319 | unsigned CodeBlock::numberOfDFGCompiles() |
| 3320 | { |
| 3321 | ASSERT(JITCode::isBaselineCode(jitType())); |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 3322 | if (Options::testTheFTL()) { |
| 3323 | if (m_didFailFTLCompilation) |
| 3324 | return 1000000; |
| 3325 | return (m_hasBeenCompiledWithFTL ? 1 : 0) + m_reoptimizationRetryCounter; |
| 3326 | } |
oliver@apple.com | 37172f8 | 2013-07-25 04:01:17 +0000 | [diff] [blame] | 3327 | return (JITCode::isOptimizingJIT(replacement()->jitType()) ? 1 : 0) + m_reoptimizationRetryCounter; |
| 3328 | } |
| 3329 | |
fpizlo@apple.com | d29f963 | 2012-12-18 22:49:40 +0000 | [diff] [blame] | 3330 | int32_t CodeBlock::codeTypeThresholdMultiplier() const |
| 3331 | { |
| 3332 | if (codeType() == EvalCode) |
| 3333 | return Options::evalThresholdMultiplier(); |
| 3334 | |
| 3335 | return 1; |
| 3336 | } |
| 3337 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3338 | double CodeBlock::optimizationThresholdScalingFactor() |
| 3339 | { |
ggaren@apple.com | f019398 | 2013-04-03 01:41:16 +0000 | [diff] [blame] | 3340 | // This expression arises from doing a least-squares fit of |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3341 | // |
| 3342 | // F[x_] =: a * Sqrt[x + b] + Abs[c * x] + d |
| 3343 | // |
| 3344 | // against the data points: |
| 3345 | // |
| 3346 | // x F[x_] |
| 3347 | // 10 0.9 (smallest reasonable code block) |
| 3348 | // 200 1.0 (typical small-ish code block) |
| 3349 | // 320 1.2 (something I saw in 3d-cube that I wanted to optimize) |
| 3350 | // 1268 5.0 (something I saw in 3d-cube that I didn't want to optimize) |
| 3351 | // 4000 5.5 (random large size, used to cause the function to converge to a shallow curve of some sort) |
| 3352 | // 10000 6.0 (similar to above) |
| 3353 | // |
ggaren@apple.com | f019398 | 2013-04-03 01:41:16 +0000 | [diff] [blame] | 3354 | // I achieve the minimization using the following Mathematica code: |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3355 | // |
| 3356 | // MyFunctionTemplate[x_, a_, b_, c_, d_] := a*Sqrt[x + b] + Abs[c*x] + d |
| 3357 | // |
| 3358 | // samples = {{10, 0.9}, {200, 1}, {320, 1.2}, {1268, 5}, {4000, 5.5}, {10000, 6}} |
| 3359 | // |
| 3360 | // solution = |
| 3361 | // Minimize[Plus @@ ((MyFunctionTemplate[#[[1]], a, b, c, d] - #[[2]])^2 & /@ samples), |
| 3362 | // {a, b, c, d}][[2]] |
| 3363 | // |
| 3364 | // And the code below (to initialize a, b, c, d) is generated by: |
| 3365 | // |
| 3366 | // Print["const double " <> ToString[#[[1]]] <> " = " <> |
| 3367 | // If[#[[2]] < 0.00001, "0.0", ToString[#[[2]]]] <> ";"] & /@ solution |
| 3368 | // |
| 3369 | // We've long known the following to be true: |
| 3370 | // - Small code blocks are cheap to optimize and so we should do it sooner rather |
| 3371 | // than later. |
| 3372 | // - Large code blocks are expensive to optimize and so we should postpone doing so, |
| 3373 | // and sometimes have a large enough threshold that we never optimize them. |
| 3374 | // - The difference in cost is not totally linear because (a) just invoking the |
| 3375 | // DFG incurs some base cost and (b) for large code blocks there is enough slop |
| 3376 | // in the correlation between instruction count and the actual compilation cost |
| 3377 | // that for those large blocks, the instruction count should not have a strong |
| 3378 | // influence on our threshold. |
| 3379 | // |
| 3380 | // I knew the goals but I didn't know how to achieve them; so I picked an interesting |
| 3381 | // example where the heuristics were right (code block in 3d-cube with instruction |
| 3382 | // count 320, which got compiled early as it should have been) and one where they were |
| 3383 | // totally wrong (code block in 3d-cube with instruction count 1268, which was expensive |
| 3384 | // to compile and didn't run often enough to warrant compilation in my opinion), and |
| 3385 | // then threw in additional data points that represented my own guess of what our |
| 3386 | // heuristics should do for some round-numbered examples. |
| 3387 | // |
| 3388 | // The expression to which I decided to fit the data arose because I started with an |
| 3389 | // affine function, and then did two things: put the linear part in an Abs to ensure |
| 3390 | // that the fit didn't end up choosing a negative value of c (which would result in |
| 3391 | // the function turning over and going negative for large x) and I threw in a Sqrt |
| 3392 | // term because Sqrt represents my intution that the function should be more sensitive |
| 3393 | // to small changes in small values of x, but less sensitive when x gets large. |
ggaren@apple.com | f019398 | 2013-04-03 01:41:16 +0000 | [diff] [blame] | 3394 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3395 | // Note that the current fit essentially eliminates the linear portion of the |
| 3396 | // expression (c == 0.0). |
| 3397 | const double a = 0.061504; |
| 3398 | const double b = 1.02406; |
| 3399 | const double c = 0.0; |
| 3400 | const double d = 0.825914; |
| 3401 | |
ggaren@apple.com | f019398 | 2013-04-03 01:41:16 +0000 | [diff] [blame] | 3402 | double instructionCount = this->instructionCount(); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3403 | |
ggaren@apple.com | f019398 | 2013-04-03 01:41:16 +0000 | [diff] [blame] | 3404 | ASSERT(instructionCount); // Make sure this is called only after we have an instruction stream; otherwise it'll just return the value of d, which makes no sense. |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3405 | |
ggaren@apple.com | f019398 | 2013-04-03 01:41:16 +0000 | [diff] [blame] | 3406 | double result = d + a * sqrt(instructionCount + b) + c * instructionCount; |
fpizlo@apple.com | 3ce9323 | 2014-03-03 05:42:29 +0000 | [diff] [blame] | 3407 | |
| 3408 | result *= codeTypeThresholdMultiplier(); |
| 3409 | |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3410 | if (Options::verboseOSR()) { |
| 3411 | dataLog( |
| 3412 | *this, ": instruction count is ", instructionCount, |
| 3413 | ", scaling execution counter by ", result, " * ", codeTypeThresholdMultiplier(), |
| 3414 | "\n"); |
| 3415 | } |
fpizlo@apple.com | 3ce9323 | 2014-03-03 05:42:29 +0000 | [diff] [blame] | 3416 | return result; |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3417 | } |
| 3418 | |
| 3419 | static int32_t clipThreshold(double threshold) |
| 3420 | { |
| 3421 | if (threshold < 1.0) |
| 3422 | return 1; |
| 3423 | |
| 3424 | if (threshold > static_cast<double>(std::numeric_limits<int32_t>::max())) |
| 3425 | return std::numeric_limits<int32_t>::max(); |
| 3426 | |
| 3427 | return static_cast<int32_t>(threshold); |
| 3428 | } |
| 3429 | |
fpizlo@apple.com | e5b6864 | 2013-08-29 20:27:15 +0000 | [diff] [blame] | 3430 | int32_t CodeBlock::adjustedCounterValue(int32_t desiredThreshold) |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3431 | { |
| 3432 | return clipThreshold( |
fpizlo@apple.com | e5b6864 | 2013-08-29 20:27:15 +0000 | [diff] [blame] | 3433 | static_cast<double>(desiredThreshold) * |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3434 | optimizationThresholdScalingFactor() * |
| 3435 | (1 << reoptimizationRetryCounter())); |
| 3436 | } |
| 3437 | |
| 3438 | bool CodeBlock::checkIfOptimizationThresholdReached() |
| 3439 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3440 | #if ENABLE(DFG_JIT) |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 3441 | if (DFG::Worklist* worklist = DFG::existingGlobalDFGWorklistOrNull()) { |
fpizlo@apple.com | 6931c47 | 2013-08-29 23:45:26 +0000 | [diff] [blame] | 3442 | if (worklist->compilationState(DFG::CompilationKey(this, DFG::DFGMode)) |
| 3443 | == DFG::Worklist::Compiled) { |
| 3444 | optimizeNextInvocation(); |
| 3445 | return true; |
| 3446 | } |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3447 | } |
| 3448 | #endif |
| 3449 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3450 | return m_jitExecuteCounter.checkIfThresholdCrossedAndSet(this); |
| 3451 | } |
| 3452 | |
| 3453 | void CodeBlock::optimizeNextInvocation() |
| 3454 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3455 | if (Options::verboseOSR()) |
| 3456 | dataLog(*this, ": Optimizing next invocation.\n"); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3457 | m_jitExecuteCounter.setNewThreshold(0, this); |
| 3458 | } |
| 3459 | |
| 3460 | void CodeBlock::dontOptimizeAnytimeSoon() |
| 3461 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3462 | if (Options::verboseOSR()) |
| 3463 | dataLog(*this, ": Not optimizing anytime soon.\n"); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3464 | m_jitExecuteCounter.deferIndefinitely(); |
| 3465 | } |
| 3466 | |
| 3467 | void CodeBlock::optimizeAfterWarmUp() |
| 3468 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3469 | if (Options::verboseOSR()) |
| 3470 | dataLog(*this, ": Optimizing after warm-up.\n"); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3471 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | e5b6864 | 2013-08-29 20:27:15 +0000 | [diff] [blame] | 3472 | m_jitExecuteCounter.setNewThreshold( |
| 3473 | adjustedCounterValue(Options::thresholdForOptimizeAfterWarmUp()), this); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3474 | #endif |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3475 | } |
| 3476 | |
| 3477 | void CodeBlock::optimizeAfterLongWarmUp() |
| 3478 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3479 | if (Options::verboseOSR()) |
| 3480 | dataLog(*this, ": Optimizing after long warm-up.\n"); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3481 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | e5b6864 | 2013-08-29 20:27:15 +0000 | [diff] [blame] | 3482 | m_jitExecuteCounter.setNewThreshold( |
| 3483 | adjustedCounterValue(Options::thresholdForOptimizeAfterLongWarmUp()), this); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3484 | #endif |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3485 | } |
| 3486 | |
| 3487 | void CodeBlock::optimizeSoon() |
| 3488 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3489 | if (Options::verboseOSR()) |
| 3490 | dataLog(*this, ": Optimizing soon.\n"); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3491 | #if ENABLE(DFG_JIT) |
fpizlo@apple.com | e5b6864 | 2013-08-29 20:27:15 +0000 | [diff] [blame] | 3492 | m_jitExecuteCounter.setNewThreshold( |
| 3493 | adjustedCounterValue(Options::thresholdForOptimizeSoon()), this); |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3494 | #endif |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3495 | } |
| 3496 | |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3497 | void CodeBlock::forceOptimizationSlowPathConcurrently() |
| 3498 | { |
| 3499 | if (Options::verboseOSR()) |
| 3500 | dataLog(*this, ": Forcing slow path concurrently.\n"); |
| 3501 | m_jitExecuteCounter.forceSlowPathConcurrently(); |
| 3502 | } |
| 3503 | |
oliver@apple.com | 58c8675 | 2013-07-25 04:02:40 +0000 | [diff] [blame] | 3504 | #if ENABLE(DFG_JIT) |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3505 | void CodeBlock::setOptimizationThresholdBasedOnCompilationResult(CompilationResult result) |
| 3506 | { |
fpizlo@apple.com | e7a417d | 2014-05-08 21:51:03 +0000 | [diff] [blame] | 3507 | JITCode::JITType type = jitType(); |
| 3508 | if (type != JITCode::BaselineJIT) { |
| 3509 | dataLog(*this, ": expected to have baseline code but have ", type, "\n"); |
| 3510 | RELEASE_ASSERT_NOT_REACHED(); |
| 3511 | } |
| 3512 | |
| 3513 | CodeBlock* theReplacement = replacement(); |
| 3514 | if ((result == CompilationSuccessful) != (theReplacement != this)) { |
| 3515 | dataLog(*this, ": we have result = ", result, " but "); |
| 3516 | if (theReplacement == this) |
| 3517 | dataLog("we are our own replacement.\n"); |
| 3518 | else |
| 3519 | dataLog("our replacement is ", pointerDump(theReplacement), "\n"); |
| 3520 | RELEASE_ASSERT_NOT_REACHED(); |
| 3521 | } |
| 3522 | |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3523 | switch (result) { |
| 3524 | case CompilationSuccessful: |
oliver@apple.com | 5a24fdd | 2013-07-25 04:00:54 +0000 | [diff] [blame] | 3525 | RELEASE_ASSERT(JITCode::isOptimizingJIT(replacement()->jitType())); |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3526 | optimizeNextInvocation(); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 3527 | return; |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3528 | case CompilationFailed: |
| 3529 | dontOptimizeAnytimeSoon(); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 3530 | return; |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3531 | case CompilationDeferred: |
| 3532 | // We'd like to do dontOptimizeAnytimeSoon() but we cannot because |
| 3533 | // forceOptimizationSlowPathConcurrently() is inherently racy. It won't |
| 3534 | // necessarily guarantee anything. So, we make sure that even if that |
| 3535 | // function ends up being a no-op, we still eventually retry and realize |
| 3536 | // that we have optimized code ready. |
| 3537 | optimizeAfterWarmUp(); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 3538 | return; |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3539 | case CompilationInvalidated: |
| 3540 | // Retry with exponential backoff. |
| 3541 | countReoptimization(); |
| 3542 | optimizeAfterWarmUp(); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 3543 | return; |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3544 | } |
fpizlo@apple.com | e7a417d | 2014-05-08 21:51:03 +0000 | [diff] [blame] | 3545 | |
| 3546 | dataLog("Unrecognized result: ", static_cast<int>(result), "\n"); |
fpizlo@apple.com | 532f1e5 | 2013-09-04 06:26:04 +0000 | [diff] [blame] | 3547 | RELEASE_ASSERT_NOT_REACHED(); |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3548 | } |
| 3549 | |
oliver@apple.com | 807e7e1 | 2013-07-25 20:22:45 +0000 | [diff] [blame] | 3550 | #endif |
| 3551 | |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3552 | uint32_t CodeBlock::adjustedExitCountThreshold(uint32_t desiredThreshold) |
| 3553 | { |
oliver@apple.com | 5a24fdd | 2013-07-25 04:00:54 +0000 | [diff] [blame] | 3554 | ASSERT(JITCode::isOptimizingJIT(jitType())); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3555 | // Compute this the lame way so we don't saturate. This is called infrequently |
| 3556 | // enough that this loop won't hurt us. |
| 3557 | unsigned result = desiredThreshold; |
| 3558 | for (unsigned n = baselineVersion()->reoptimizationRetryCounter(); n--;) { |
| 3559 | unsigned newResult = result << 1; |
| 3560 | if (newResult < result) |
| 3561 | return std::numeric_limits<uint32_t>::max(); |
| 3562 | result = newResult; |
| 3563 | } |
| 3564 | return result; |
| 3565 | } |
| 3566 | |
| 3567 | uint32_t CodeBlock::exitCountThresholdForReoptimization() |
| 3568 | { |
fpizlo@apple.com | d29f963 | 2012-12-18 22:49:40 +0000 | [diff] [blame] | 3569 | return adjustedExitCountThreshold(Options::osrExitCountForReoptimization() * codeTypeThresholdMultiplier()); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3570 | } |
| 3571 | |
| 3572 | uint32_t CodeBlock::exitCountThresholdForReoptimizationFromLoop() |
| 3573 | { |
fpizlo@apple.com | d29f963 | 2012-12-18 22:49:40 +0000 | [diff] [blame] | 3574 | return adjustedExitCountThreshold(Options::osrExitCountForReoptimizationFromLoop() * codeTypeThresholdMultiplier()); |
fpizlo@apple.com | 7f7ba49 | 2012-12-09 20:41:09 +0000 | [diff] [blame] | 3575 | } |
| 3576 | |
| 3577 | bool CodeBlock::shouldReoptimizeNow() |
| 3578 | { |
| 3579 | return osrExitCounter() >= exitCountThresholdForReoptimization(); |
| 3580 | } |
| 3581 | |
| 3582 | bool CodeBlock::shouldReoptimizeFromLoopNow() |
| 3583 | { |
| 3584 | return osrExitCounter() >= exitCountThresholdForReoptimizationFromLoop(); |
| 3585 | } |
| 3586 | #endif |
| 3587 | |
fpizlo@apple.com | f24804c | 2012-08-15 02:48:35 +0000 | [diff] [blame] | 3588 | ArrayProfile* CodeBlock::getArrayProfile(unsigned bytecodeOffset) |
| 3589 | { |
| 3590 | for (unsigned i = 0; i < m_arrayProfiles.size(); ++i) { |
| 3591 | if (m_arrayProfiles[i].bytecodeOffset() == bytecodeOffset) |
| 3592 | return &m_arrayProfiles[i]; |
| 3593 | } |
| 3594 | return 0; |
| 3595 | } |
| 3596 | |
| 3597 | ArrayProfile* CodeBlock::getOrAddArrayProfile(unsigned bytecodeOffset) |
| 3598 | { |
| 3599 | ArrayProfile* result = getArrayProfile(bytecodeOffset); |
| 3600 | if (result) |
| 3601 | return result; |
| 3602 | return addArrayProfile(bytecodeOffset); |
| 3603 | } |
| 3604 | |
fpizlo@apple.com | 8e470a2 | 2015-09-21 20:10:04 +0000 | [diff] [blame] | 3605 | #if ENABLE(DFG_JIT) |
| 3606 | Vector<CodeOrigin, 0, UnsafeVectorOverflow>& CodeBlock::codeOrigins() |
| 3607 | { |
| 3608 | return m_jitCode->dfgCommon()->codeOrigins; |
| 3609 | } |
| 3610 | |
| 3611 | size_t CodeBlock::numberOfDFGIdentifiers() const |
| 3612 | { |
| 3613 | if (!JITCode::isOptimizingJIT(jitType())) |
| 3614 | return 0; |
| 3615 | |
| 3616 | return m_jitCode->dfgCommon()->dfgIdentifiers.size(); |
| 3617 | } |
| 3618 | |
| 3619 | const Identifier& CodeBlock::identifier(int index) const |
| 3620 | { |
| 3621 | size_t unlinkedIdentifiers = m_unlinkedCode->numberOfIdentifiers(); |
| 3622 | if (static_cast<unsigned>(index) < unlinkedIdentifiers) |
| 3623 | return m_unlinkedCode->identifier(index); |
| 3624 | ASSERT(JITCode::isOptimizingJIT(jitType())); |
| 3625 | return m_jitCode->dfgCommon()->dfgIdentifiers[index - unlinkedIdentifiers]; |
| 3626 | } |
| 3627 | #endif // ENABLE(DFG_JIT) |
| 3628 | |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3629 | void CodeBlock::updateAllPredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles) |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3630 | { |
oliver@apple.com | d205666 | 2013-07-25 04:00:37 +0000 | [diff] [blame] | 3631 | ConcurrentJITLocker locker(m_lock); |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 3632 | |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3633 | numberOfLiveNonArgumentValueProfiles = 0; |
| 3634 | numberOfSamplesInProfiles = 0; // If this divided by ValueProfile::numberOfBuckets equals numberOfValueProfiles() then value profiles are full. |
| 3635 | for (unsigned i = 0; i < totalNumberOfValueProfiles(); ++i) { |
| 3636 | ValueProfile* profile = getFromAllValueProfiles(i); |
| 3637 | unsigned numSamples = profile->totalNumberOfSamples(); |
| 3638 | if (numSamples > ValueProfile::numberOfBuckets) |
| 3639 | numSamples = ValueProfile::numberOfBuckets; // We don't want profiles that are extremely hot to be given more weight. |
| 3640 | numberOfSamplesInProfiles += numSamples; |
| 3641 | if (profile->m_bytecodeOffset < 0) { |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3642 | profile->computeUpdatedPrediction(locker); |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3643 | continue; |
| 3644 | } |
| 3645 | if (profile->numberOfSamples() || profile->m_prediction != SpecNone) |
| 3646 | numberOfLiveNonArgumentValueProfiles++; |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3647 | profile->computeUpdatedPrediction(locker); |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | #if ENABLE(DFG_JIT) |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3651 | m_lazyOperandValueProfiles.computeUpdatedPredictions(locker); |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3652 | #endif |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 3653 | } |
| 3654 | |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3655 | void CodeBlock::updateAllValueProfilePredictions() |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 3656 | { |
| 3657 | unsigned ignoredValue1, ignoredValue2; |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3658 | updateAllPredictionsAndCountLiveness(ignoredValue1, ignoredValue2); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 3659 | } |
| 3660 | |
oliver@apple.com | 58cdc33 | 2013-07-25 04:04:59 +0000 | [diff] [blame] | 3661 | void CodeBlock::updateAllArrayPredictions() |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 3662 | { |
oliver@apple.com | d205666 | 2013-07-25 04:00:37 +0000 | [diff] [blame] | 3663 | ConcurrentJITLocker locker(m_lock); |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 3664 | |
fpizlo@apple.com | f24804c | 2012-08-15 02:48:35 +0000 | [diff] [blame] | 3665 | for (unsigned i = m_arrayProfiles.size(); i--;) |
oliver@apple.com | 58cdc33 | 2013-07-25 04:04:59 +0000 | [diff] [blame] | 3666 | m_arrayProfiles[i].computeUpdatedPrediction(locker, this); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 3667 | |
| 3668 | // Don't count these either, for similar reasons. |
| 3669 | for (unsigned i = m_arrayAllocationProfiles.size(); i--;) |
| 3670 | m_arrayAllocationProfiles[i].updateIndexingType(); |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3671 | } |
| 3672 | |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3673 | void CodeBlock::updateAllPredictions() |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3674 | { |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 3675 | #if ENABLE(WEBASSEMBLY) |
| 3676 | if (m_ownerExecutable->isWebAssemblyExecutable()) |
| 3677 | return; |
| 3678 | #endif |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3679 | updateAllValueProfilePredictions(); |
oliver@apple.com | 58cdc33 | 2013-07-25 04:04:59 +0000 | [diff] [blame] | 3680 | updateAllArrayPredictions(); |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3681 | } |
| 3682 | |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3683 | bool CodeBlock::shouldOptimizeNow() |
| 3684 | { |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3685 | if (Options::verboseOSR()) |
| 3686 | dataLog("Considering optimizing ", *this, "...\n"); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3687 | |
commit-queue@webkit.org | fbda60c | 2012-07-03 19:19:22 +0000 | [diff] [blame] | 3688 | if (m_optimizationDelayCounter >= Options::maximumOptimizationDelay()) |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3689 | return true; |
| 3690 | |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 3691 | updateAllArrayPredictions(); |
| 3692 | |
fpizlo@apple.com | 3745dbc | 2012-06-26 02:14:07 +0000 | [diff] [blame] | 3693 | unsigned numberOfLiveNonArgumentValueProfiles; |
| 3694 | unsigned numberOfSamplesInProfiles; |
mhahnenberg@apple.com | c568471 | 2013-09-26 17:16:47 +0000 | [diff] [blame] | 3695 | updateAllPredictionsAndCountLiveness(numberOfLiveNonArgumentValueProfiles, numberOfSamplesInProfiles); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3696 | |
oliver@apple.com | 284cc3d | 2013-07-25 04:00:33 +0000 | [diff] [blame] | 3697 | if (Options::verboseOSR()) { |
| 3698 | dataLogF( |
| 3699 | "Profile hotness: %lf (%u / %u), %lf (%u / %u)\n", |
| 3700 | (double)numberOfLiveNonArgumentValueProfiles / numberOfValueProfiles(), |
| 3701 | numberOfLiveNonArgumentValueProfiles, numberOfValueProfiles(), |
| 3702 | (double)numberOfSamplesInProfiles / ValueProfile::numberOfBuckets / numberOfValueProfiles(), |
| 3703 | numberOfSamplesInProfiles, ValueProfile::numberOfBuckets * numberOfValueProfiles()); |
| 3704 | } |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3705 | |
commit-queue@webkit.org | fbda60c | 2012-07-03 19:19:22 +0000 | [diff] [blame] | 3706 | if ((!numberOfValueProfiles() || (double)numberOfLiveNonArgumentValueProfiles / numberOfValueProfiles() >= Options::desiredProfileLivenessRate()) |
| 3707 | && (!totalNumberOfValueProfiles() || (double)numberOfSamplesInProfiles / ValueProfile::numberOfBuckets / totalNumberOfValueProfiles() >= Options::desiredProfileFullnessRate()) |
| 3708 | && static_cast<unsigned>(m_optimizationDelayCounter) + 1 >= Options::minimumOptimizationDelay()) |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3709 | return true; |
| 3710 | |
fpizlo@apple.com | 4043e81 | 2011-11-06 11:54:59 +0000 | [diff] [blame] | 3711 | ASSERT(m_optimizationDelayCounter < std::numeric_limits<uint8_t>::max()); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3712 | m_optimizationDelayCounter++; |
| 3713 | optimizeAfterWarmUp(); |
| 3714 | return false; |
| 3715 | } |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3716 | |
fpizlo@apple.com | 4ef9c87 | 2011-12-13 19:49:49 +0000 | [diff] [blame] | 3717 | #if ENABLE(DFG_JIT) |
| 3718 | void CodeBlock::tallyFrequentExitSites() |
| 3719 | { |
oliver@apple.com | 5a24fdd | 2013-07-25 04:00:54 +0000 | [diff] [blame] | 3720 | ASSERT(JITCode::isOptimizingJIT(jitType())); |
| 3721 | ASSERT(alternative()->jitType() == JITCode::BaselineJIT); |
fpizlo@apple.com | 4ef9c87 | 2011-12-13 19:49:49 +0000 | [diff] [blame] | 3722 | |
| 3723 | CodeBlock* profiledBlock = alternative(); |
| 3724 | |
oliver@apple.com | 5a24fdd | 2013-07-25 04:00:54 +0000 | [diff] [blame] | 3725 | switch (jitType()) { |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3726 | case JITCode::DFGJIT: { |
| 3727 | DFG::JITCode* jitCode = m_jitCode->dfg(); |
| 3728 | for (unsigned i = 0; i < jitCode->osrExit.size(); ++i) { |
| 3729 | DFG::OSRExit& exit = jitCode->osrExit[i]; |
benjamin@webkit.org | 6f63a8b | 2015-02-18 07:04:10 +0000 | [diff] [blame] | 3730 | exit.considerAddingAsFrequentExitSite(profiledBlock); |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3731 | } |
| 3732 | break; |
| 3733 | } |
oliver@apple.com | 0c1b13e | 2013-07-25 03:58:43 +0000 | [diff] [blame] | 3734 | |
| 3735 | #if ENABLE(FTL_JIT) |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3736 | case JITCode::FTLJIT: { |
| 3737 | // There is no easy way to avoid duplicating this code since the FTL::JITCode::osrExit |
| 3738 | // vector contains a totally different type, that just so happens to behave like |
| 3739 | // DFG::JITCode::osrExit. |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3740 | FTL::JITCode* jitCode = m_jitCode->ftl(); |
| 3741 | for (unsigned i = 0; i < jitCode->osrExit.size(); ++i) { |
| 3742 | FTL::OSRExit& exit = jitCode->osrExit[i]; |
benjamin@webkit.org | 6f63a8b | 2015-02-18 07:04:10 +0000 | [diff] [blame] | 3743 | exit.considerAddingAsFrequentExitSite(profiledBlock); |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3744 | } |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3745 | break; |
oliver@apple.com | 0c1b13e | 2013-07-25 03:58:43 +0000 | [diff] [blame] | 3746 | } |
| 3747 | #endif |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 3748 | |
| 3749 | default: |
| 3750 | RELEASE_ASSERT_NOT_REACHED(); |
| 3751 | break; |
fpizlo@apple.com | 4ef9c87 | 2011-12-13 19:49:49 +0000 | [diff] [blame] | 3752 | } |
| 3753 | } |
| 3754 | #endif // ENABLE(DFG_JIT) |
| 3755 | |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3756 | #if ENABLE(VERBOSE_VALUE_PROFILE) |
| 3757 | void CodeBlock::dumpValueProfiles() |
| 3758 | { |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 3759 | dataLog("ValueProfile for ", *this, ":\n"); |
fpizlo@apple.com | 086d2af | 2011-12-21 02:29:15 +0000 | [diff] [blame] | 3760 | for (unsigned i = 0; i < totalNumberOfValueProfiles(); ++i) { |
| 3761 | ValueProfile* profile = getFromAllValueProfiles(i); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3762 | if (profile->m_bytecodeOffset < 0) { |
| 3763 | ASSERT(profile->m_bytecodeOffset == -1); |
fpizlo@apple.com | 01902c8 | 2012-11-22 04:23:36 +0000 | [diff] [blame] | 3764 | dataLogF(" arg = %u: ", i); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3765 | } else |
fpizlo@apple.com | 01902c8 | 2012-11-22 04:23:36 +0000 | [diff] [blame] | 3766 | dataLogF(" bc = %d: ", profile->m_bytecodeOffset); |
fpizlo@apple.com | 6233616 | 2012-06-07 01:35:59 +0000 | [diff] [blame] | 3767 | if (!profile->numberOfSamples() && profile->m_prediction == SpecNone) { |
fpizlo@apple.com | 01902c8 | 2012-11-22 04:23:36 +0000 | [diff] [blame] | 3768 | dataLogF("<empty>\n"); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3769 | continue; |
| 3770 | } |
fpizlo@apple.com | d095b24 | 2012-02-12 03:21:32 +0000 | [diff] [blame] | 3771 | profile->dump(WTF::dataFile()); |
fpizlo@apple.com | 01902c8 | 2012-11-22 04:23:36 +0000 | [diff] [blame] | 3772 | dataLogF("\n"); |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3773 | } |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 3774 | dataLog("RareCaseProfile for ", *this, ":\n"); |
barraclough@apple.com | e32d4ec | 2011-09-21 22:43:11 +0000 | [diff] [blame] | 3775 | for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) { |
| 3776 | RareCaseProfile* profile = rareCaseProfile(i); |
fpizlo@apple.com | 01902c8 | 2012-11-22 04:23:36 +0000 | [diff] [blame] | 3777 | dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter); |
fpizlo@apple.com | 9b0b31e | 2011-09-19 22:27:38 +0000 | [diff] [blame] | 3778 | } |
fpizlo@apple.com | 0bfcc38 | 2012-11-30 03:42:29 +0000 | [diff] [blame] | 3779 | dataLog("SpecialFastCaseProfile for ", *this, ":\n"); |
fpizlo@apple.com | 706f5f3 | 2011-09-21 23:36:35 +0000 | [diff] [blame] | 3780 | for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i) { |
| 3781 | RareCaseProfile* profile = specialFastCaseProfile(i); |
fpizlo@apple.com | 01902c8 | 2012-11-22 04:23:36 +0000 | [diff] [blame] | 3782 | dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter); |
fpizlo@apple.com | 706f5f3 | 2011-09-21 23:36:35 +0000 | [diff] [blame] | 3783 | } |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3784 | } |
fpizlo@apple.com | 8618e4b | 2012-07-03 01:27:16 +0000 | [diff] [blame] | 3785 | #endif // ENABLE(VERBOSE_VALUE_PROFILE) |
fpizlo@apple.com | 7f2d234 | 2011-09-14 23:00:26 +0000 | [diff] [blame] | 3786 | |
fpizlo@apple.com | 81bb8bb | 2013-11-23 00:36:55 +0000 | [diff] [blame] | 3787 | unsigned CodeBlock::frameRegisterCount() |
| 3788 | { |
| 3789 | switch (jitType()) { |
fpizlo@apple.com | 81bb8bb | 2013-11-23 00:36:55 +0000 | [diff] [blame] | 3790 | case JITCode::InterpreterThunk: |
| 3791 | return LLInt::frameRegisterCountFor(this); |
fpizlo@apple.com | 81bb8bb | 2013-11-23 00:36:55 +0000 | [diff] [blame] | 3792 | |
| 3793 | #if ENABLE(JIT) |
| 3794 | case JITCode::BaselineJIT: |
| 3795 | return JIT::frameRegisterCountFor(this); |
| 3796 | #endif // ENABLE(JIT) |
| 3797 | |
| 3798 | #if ENABLE(DFG_JIT) |
| 3799 | case JITCode::DFGJIT: |
| 3800 | case JITCode::FTLJIT: |
| 3801 | return jitCode()->dfgCommon()->frameRegisterCount; |
| 3802 | #endif // ENABLE(DFG_JIT) |
| 3803 | |
| 3804 | default: |
| 3805 | RELEASE_ASSERT_NOT_REACHED(); |
| 3806 | return 0; |
| 3807 | } |
| 3808 | } |
| 3809 | |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 3810 | int CodeBlock::stackPointerOffset() |
| 3811 | { |
| 3812 | return virtualRegisterForLocal(frameRegisterCount() - 1).offset(); |
| 3813 | } |
| 3814 | |
fpizlo@apple.com | 254d43b | 2012-03-05 06:52:44 +0000 | [diff] [blame] | 3815 | size_t CodeBlock::predictedMachineCodeSize() |
| 3816 | { |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 3817 | // This will be called from CodeBlock::CodeBlock before either m_vm or the |
fpizlo@apple.com | 254d43b | 2012-03-05 06:52:44 +0000 | [diff] [blame] | 3818 | // instructions have been initialized. It's OK to return 0 because what will really |
| 3819 | // matter is the recomputation of this value when the slow path is triggered. |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 3820 | if (!m_vm) |
fpizlo@apple.com | 254d43b | 2012-03-05 06:52:44 +0000 | [diff] [blame] | 3821 | return 0; |
| 3822 | |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 3823 | if (!m_vm->machineCodeBytesPerBytecodeWordForBaselineJIT) |
fpizlo@apple.com | 254d43b | 2012-03-05 06:52:44 +0000 | [diff] [blame] | 3824 | return 0; // It's as good of a prediction as we'll get. |
| 3825 | |
| 3826 | // Be conservative: return a size that will be an overestimation 84% of the time. |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 3827 | double multiplier = m_vm->machineCodeBytesPerBytecodeWordForBaselineJIT.mean() + |
| 3828 | m_vm->machineCodeBytesPerBytecodeWordForBaselineJIT.standardDeviation(); |
fpizlo@apple.com | 254d43b | 2012-03-05 06:52:44 +0000 | [diff] [blame] | 3829 | |
| 3830 | // Be paranoid: silently reject bogus multipiers. Silently doing the "wrong" thing |
| 3831 | // here is OK, since this whole method is just a heuristic. |
| 3832 | if (multiplier < 0 || multiplier > 1000) |
| 3833 | return 0; |
| 3834 | |
| 3835 | double doubleResult = multiplier * m_instructions.size(); |
| 3836 | |
| 3837 | // Be even more paranoid: silently reject values that won't fit into a size_t. If |
| 3838 | // the function is so huge that we can't even fit it into virtual memory then we |
| 3839 | // should probably have some other guards in place to prevent us from even getting |
| 3840 | // to this point. |
| 3841 | if (doubleResult > std::numeric_limits<size_t>::max()) |
| 3842 | return 0; |
| 3843 | |
| 3844 | return static_cast<size_t>(doubleResult); |
| 3845 | } |
| 3846 | |
fpizlo@apple.com | c828f14 | 2011-10-25 21:56:31 +0000 | [diff] [blame] | 3847 | bool CodeBlock::usesOpcode(OpcodeID opcodeID) |
| 3848 | { |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 3849 | Interpreter* interpreter = vm()->interpreter; |
fpizlo@apple.com | c828f14 | 2011-10-25 21:56:31 +0000 | [diff] [blame] | 3850 | Instruction* instructionsBegin = instructions().begin(); |
| 3851 | unsigned instructionCount = instructions().size(); |
| 3852 | |
| 3853 | for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) { |
| 3854 | switch (interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) { |
| 3855 | #define DEFINE_OP(curOpcode, length) \ |
| 3856 | case curOpcode: \ |
| 3857 | if (curOpcode == opcodeID) \ |
| 3858 | return true; \ |
| 3859 | bytecodeOffset += length; \ |
| 3860 | break; |
| 3861 | FOR_EACH_OPCODE_ID(DEFINE_OP) |
| 3862 | #undef DEFINE_OP |
| 3863 | default: |
oliver@apple.com | 5598c18 | 2013-01-23 22:25:07 +0000 | [diff] [blame] | 3864 | RELEASE_ASSERT_NOT_REACHED(); |
fpizlo@apple.com | c828f14 | 2011-10-25 21:56:31 +0000 | [diff] [blame] | 3865 | break; |
| 3866 | } |
| 3867 | } |
| 3868 | |
| 3869 | return false; |
| 3870 | } |
fpizlo@apple.com | c828f14 | 2011-10-25 21:56:31 +0000 | [diff] [blame] | 3871 | |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 3872 | String CodeBlock::nameForRegister(VirtualRegister virtualRegister) |
oliver@apple.com | a08210b | 2012-07-18 23:26:06 +0000 | [diff] [blame] | 3873 | { |
saambarati1@gmail.com | 3321f09 | 2015-07-20 21:16:41 +0000 | [diff] [blame] | 3874 | for (unsigned i = 0; i < m_constantRegisters.size(); i++) { |
| 3875 | if (m_constantRegisters[i].get().isEmpty()) |
| 3876 | continue; |
| 3877 | if (SymbolTable* symbolTable = jsDynamicCast<SymbolTable*>(m_constantRegisters[i].get())) { |
| 3878 | ConcurrentJITLocker locker(symbolTable->m_lock); |
| 3879 | auto end = symbolTable->end(locker); |
| 3880 | for (auto ptr = symbolTable->begin(locker); ptr != end; ++ptr) { |
| 3881 | if (ptr->value.varOffset() == VarOffset(virtualRegister)) { |
| 3882 | // FIXME: This won't work from the compilation thread. |
| 3883 | // https://bugs.webkit.org/show_bug.cgi?id=115300 |
| 3884 | return ptr->key.get(); |
| 3885 | } |
| 3886 | } |
oliver@apple.com | f72e22e | 2013-07-25 03:59:04 +0000 | [diff] [blame] | 3887 | } |
oliver@apple.com | a08210b | 2012-07-18 23:26:06 +0000 | [diff] [blame] | 3888 | } |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 3889 | if (virtualRegister == thisRegister()) |
benjamin@webkit.org | 762e2c6 | 2012-09-04 21:19:25 +0000 | [diff] [blame] | 3890 | return ASCIILiteral("this"); |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 3891 | if (virtualRegister.isArgument()) |
commit-queue@webkit.org | 29e710c | 2014-08-29 21:33:30 +0000 | [diff] [blame] | 3892 | return String::format("arguments[%3d]", virtualRegister.toArgument()); |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 3893 | |
oliver@apple.com | a08210b | 2012-07-18 23:26:06 +0000 | [diff] [blame] | 3894 | return ""; |
| 3895 | } |
| 3896 | |
fpizlo@apple.com | 3a2fa4c | 2015-04-13 22:13:12 +0000 | [diff] [blame] | 3897 | ValueProfile* CodeBlock::valueProfileForBytecodeOffset(int bytecodeOffset) |
| 3898 | { |
| 3899 | ValueProfile* result = binarySearch<ValueProfile, int>( |
| 3900 | m_valueProfiles, m_valueProfiles.size(), bytecodeOffset, |
| 3901 | getValueProfileBytecodeOffset<ValueProfile>); |
| 3902 | ASSERT(result->m_bytecodeOffset != -1); |
| 3903 | ASSERT(instructions()[bytecodeOffset + opcodeLength( |
| 3904 | m_vm->interpreter->getOpcodeID( |
| 3905 | instructions()[bytecodeOffset].u.opcode)) - 1].u.profile == result); |
| 3906 | return result; |
| 3907 | } |
| 3908 | |
fpizlo@apple.com | 2eb67ec | 2013-11-27 23:15:48 +0000 | [diff] [blame] | 3909 | void CodeBlock::validate() |
| 3910 | { |
| 3911 | BytecodeLivenessAnalysis liveness(this); // Compute directly from scratch so it doesn't effect CodeBlock footprint. |
| 3912 | |
| 3913 | FastBitVector liveAtHead = liveness.getLivenessInfoAtBytecodeOffset(0); |
| 3914 | |
| 3915 | if (liveAtHead.numBits() != static_cast<size_t>(m_numCalleeRegisters)) { |
| 3916 | beginValidationDidFail(); |
| 3917 | dataLog(" Wrong number of bits in result!\n"); |
| 3918 | dataLog(" Result: ", liveAtHead, "\n"); |
| 3919 | dataLog(" Bit count: ", liveAtHead.numBits(), "\n"); |
| 3920 | endValidationDidFail(); |
| 3921 | } |
| 3922 | |
| 3923 | for (unsigned i = m_numCalleeRegisters; i--;) { |
fpizlo@apple.com | 2eb67ec | 2013-11-27 23:15:48 +0000 | [diff] [blame] | 3924 | VirtualRegister reg = virtualRegisterForLocal(i); |
| 3925 | |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 3926 | if (liveAtHead.get(i)) { |
| 3927 | beginValidationDidFail(); |
| 3928 | dataLog(" Variable ", reg, " is expected to be dead.\n"); |
| 3929 | dataLog(" Result: ", liveAtHead, "\n"); |
| 3930 | endValidationDidFail(); |
fpizlo@apple.com | 2eb67ec | 2013-11-27 23:15:48 +0000 | [diff] [blame] | 3931 | } |
| 3932 | } |
| 3933 | } |
| 3934 | |
| 3935 | void CodeBlock::beginValidationDidFail() |
| 3936 | { |
| 3937 | dataLog("Validation failure in ", *this, ":\n"); |
| 3938 | dataLog("\n"); |
| 3939 | } |
| 3940 | |
| 3941 | void CodeBlock::endValidationDidFail() |
| 3942 | { |
| 3943 | dataLog("\n"); |
| 3944 | dumpBytecode(); |
| 3945 | dataLog("\n"); |
| 3946 | dataLog("Validation failure.\n"); |
| 3947 | RELEASE_ASSERT_NOT_REACHED(); |
| 3948 | } |
| 3949 | |
mark.lam@apple.com | 6c4085b | 2014-01-28 17:43:07 +0000 | [diff] [blame] | 3950 | void CodeBlock::addBreakpoint(unsigned numBreakpoints) |
| 3951 | { |
| 3952 | m_numBreakpoints += numBreakpoints; |
| 3953 | ASSERT(m_numBreakpoints); |
mark.lam@apple.com | 51ccaab | 2014-02-01 20:29:23 +0000 | [diff] [blame] | 3954 | if (JITCode::isOptimizingJIT(jitType())) |
fpizlo@apple.com | 0dda6d7 | 2014-02-02 02:25:13 +0000 | [diff] [blame] | 3955 | jettison(Profiler::JettisonDueToDebuggerBreakpoint); |
mark.lam@apple.com | 6c4085b | 2014-01-28 17:43:07 +0000 | [diff] [blame] | 3956 | } |
| 3957 | |
| 3958 | void CodeBlock::setSteppingMode(CodeBlock::SteppingMode mode) |
| 3959 | { |
| 3960 | m_steppingMode = mode; |
mark.lam@apple.com | 51ccaab | 2014-02-01 20:29:23 +0000 | [diff] [blame] | 3961 | if (mode == SteppingModeEnabled && JITCode::isOptimizingJIT(jitType())) |
fpizlo@apple.com | 0dda6d7 | 2014-02-02 02:25:13 +0000 | [diff] [blame] | 3962 | jettison(Profiler::JettisonDueToDebuggerStepping); |
mark.lam@apple.com | 6c4085b | 2014-01-28 17:43:07 +0000 | [diff] [blame] | 3963 | } |
| 3964 | |
mhahnenberg@apple.com | 1f26507 | 2014-05-02 18:52:10 +0000 | [diff] [blame] | 3965 | RareCaseProfile* CodeBlock::rareCaseProfileForBytecodeOffset(int bytecodeOffset) |
| 3966 | { |
| 3967 | return tryBinarySearch<RareCaseProfile, int>( |
| 3968 | m_rareCaseProfiles, m_rareCaseProfiles.size(), bytecodeOffset, |
| 3969 | getRareCaseProfileBytecodeOffset); |
| 3970 | } |
| 3971 | |
mark.lam@apple.com | ff2c14a | 2015-09-24 18:38:35 +0000 | [diff] [blame] | 3972 | unsigned CodeBlock::rareCaseProfileCountForBytecodeOffset(int bytecodeOffset) |
| 3973 | { |
| 3974 | RareCaseProfile* profile = rareCaseProfileForBytecodeOffset(bytecodeOffset); |
| 3975 | if (profile) |
| 3976 | return profile->m_counter; |
| 3977 | return 0; |
| 3978 | } |
| 3979 | |
mhahnenberg@apple.com | 0ef30c4 | 2014-05-02 21:21:04 +0000 | [diff] [blame] | 3980 | #if ENABLE(JIT) |
mhahnenberg@apple.com | 1f26507 | 2014-05-02 18:52:10 +0000 | [diff] [blame] | 3981 | DFG::CapabilityLevel CodeBlock::capabilityLevel() |
| 3982 | { |
commit-queue@webkit.org | 87dc3e7 | 2015-10-04 01:45:21 +0000 | [diff] [blame] | 3983 | DFG::CapabilityLevel result = capabilityLevelInternal(); |
mhahnenberg@apple.com | 1f26507 | 2014-05-02 18:52:10 +0000 | [diff] [blame] | 3984 | m_capabilityLevelState = result; |
| 3985 | return result; |
| 3986 | } |
mhahnenberg@apple.com | 0ef30c4 | 2014-05-02 21:21:04 +0000 | [diff] [blame] | 3987 | #endif |
mhahnenberg@apple.com | 1f26507 | 2014-05-02 18:52:10 +0000 | [diff] [blame] | 3988 | |
saambarati1@gmail.com | d60d941 | 2015-01-20 04:47:55 +0000 | [diff] [blame] | 3989 | void CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler(Vector<Instruction, 0, UnsafeVectorOverflow>& instructions) |
| 3990 | { |
| 3991 | const Vector<size_t>& bytecodeOffsets = unlinkedCodeBlock()->opProfileControlFlowBytecodeOffsets(); |
| 3992 | for (size_t i = 0, offsetsLength = bytecodeOffsets.size(); i < offsetsLength; i++) { |
| 3993 | // Because op_profile_control_flow is emitted at the beginning of every basic block, finding |
| 3994 | // the next op_profile_control_flow will give us the text range of a single basic block. |
| 3995 | size_t startIdx = bytecodeOffsets[i]; |
| 3996 | RELEASE_ASSERT(vm()->interpreter->getOpcodeID(instructions[startIdx].u.opcode) == op_profile_control_flow); |
| 3997 | int basicBlockStartOffset = instructions[startIdx + 1].u.operand; |
| 3998 | int basicBlockEndOffset; |
| 3999 | if (i + 1 < offsetsLength) { |
| 4000 | size_t endIdx = bytecodeOffsets[i + 1]; |
| 4001 | RELEASE_ASSERT(vm()->interpreter->getOpcodeID(instructions[endIdx].u.opcode) == op_profile_control_flow); |
saambarati1@gmail.com | 1595250 | 2015-02-23 22:10:51 +0000 | [diff] [blame] | 4002 | basicBlockEndOffset = instructions[endIdx + 1].u.operand - 1; |
saambarati1@gmail.com | d60d941 | 2015-01-20 04:47:55 +0000 | [diff] [blame] | 4003 | } else { |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 4004 | basicBlockEndOffset = m_sourceOffset + ownerScriptExecutable()->source().length() - 1; // Offset before the closing brace. |
saambarati1@gmail.com | d60d941 | 2015-01-20 04:47:55 +0000 | [diff] [blame] | 4005 | basicBlockStartOffset = std::min(basicBlockStartOffset, basicBlockEndOffset); // Some start offsets may be at the closing brace, ensure it is the offset before. |
| 4006 | } |
| 4007 | |
| 4008 | // The following check allows for the same textual JavaScript basic block to have its bytecode emitted more |
| 4009 | // than once and still play nice with the control flow profiler. When basicBlockStartOffset is larger than |
| 4010 | // basicBlockEndOffset, it indicates that the bytecode generator has emitted code for the same AST node |
| 4011 | // more than once (for example: ForInNode, Finally blocks in TryNode, etc). Though these are different |
| 4012 | // basic blocks at the bytecode level, they are generated from the same textual basic block in the JavaScript |
| 4013 | // program. The condition: |
| 4014 | // (basicBlockEndOffset < basicBlockStartOffset) |
| 4015 | // is encountered when op_profile_control_flow lies across the boundary of these duplicated bytecode basic |
| 4016 | // blocks and the textual offset goes from the end of the duplicated block back to the beginning. These |
| 4017 | // ranges are dummy ranges and are ignored. The duplicated bytecode basic blocks point to the same |
| 4018 | // internal data structure, so if any of them execute, it will record the same textual basic block in the |
| 4019 | // JavaScript program as executing. |
| 4020 | // At the bytecode level, this situation looks like: |
| 4021 | // j: op_profile_control_flow (from j->k, we have basicBlockEndOffset < basicBlockStartOffset) |
| 4022 | // ... |
| 4023 | // k: op_profile_control_flow (we want to skip over the j->k block and start fresh at offset k as the start of a new basic block k->m). |
| 4024 | // ... |
| 4025 | // m: op_profile_control_flow |
| 4026 | if (basicBlockEndOffset < basicBlockStartOffset) { |
| 4027 | RELEASE_ASSERT(i + 1 < offsetsLength); // We should never encounter dummy blocks at the end of a CodeBlock. |
| 4028 | instructions[startIdx + 1].u.basicBlockLocation = vm()->controlFlowProfiler()->dummyBasicBlock(); |
| 4029 | continue; |
| 4030 | } |
| 4031 | |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 4032 | BasicBlockLocation* basicBlockLocation = vm()->controlFlowProfiler()->getBasicBlockLocation(ownerScriptExecutable()->sourceID(), basicBlockStartOffset, basicBlockEndOffset); |
saambarati1@gmail.com | d60d941 | 2015-01-20 04:47:55 +0000 | [diff] [blame] | 4033 | |
| 4034 | // Find all functions that are enclosed within the range: [basicBlockStartOffset, basicBlockEndOffset] |
| 4035 | // and insert these functions' start/end offsets as gaps in the current BasicBlockLocation. |
| 4036 | // This is necessary because in the original source text of a JavaScript program, |
| 4037 | // function literals form new basic blocks boundaries, but they aren't represented |
| 4038 | // inside the CodeBlock's instruction stream. |
| 4039 | auto insertFunctionGaps = [basicBlockLocation, basicBlockStartOffset, basicBlockEndOffset] (const WriteBarrier<FunctionExecutable>& functionExecutable) { |
| 4040 | const UnlinkedFunctionExecutable* executable = functionExecutable->unlinkedExecutable(); |
| 4041 | int functionStart = executable->typeProfilingStartOffset(); |
| 4042 | int functionEnd = executable->typeProfilingEndOffset(); |
| 4043 | if (functionStart >= basicBlockStartOffset && functionEnd <= basicBlockEndOffset) |
| 4044 | basicBlockLocation->insertGap(functionStart, functionEnd); |
| 4045 | }; |
| 4046 | |
| 4047 | for (const WriteBarrier<FunctionExecutable>& executable : m_functionDecls) |
| 4048 | insertFunctionGaps(executable); |
| 4049 | for (const WriteBarrier<FunctionExecutable>& executable : m_functionExprs) |
| 4050 | insertFunctionGaps(executable); |
| 4051 | |
| 4052 | instructions[startIdx + 1].u.basicBlockLocation = basicBlockLocation; |
| 4053 | } |
| 4054 | } |
| 4055 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 4056 | } // namespace JSC |