References from code to Structures should be stronger than weak
[WebKit.git] / Source / JavaScriptCore / bytecode / CodeBlock.cpp
1 /*
2  * Copyright (C) 2008-2010, 2012-2016 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "config.h"
31 #include "CodeBlock.h"
32
33 #include "BasicBlockLocation.h"
34 #include "BytecodeGenerator.h"
35 #include "BytecodeUseDef.h"
36 #include "CallLinkStatus.h"
37 #include "DFGCapabilities.h"
38 #include "DFGCommon.h"
39 #include "DFGDriver.h"
40 #include "DFGJITCode.h"
41 #include "DFGWorklist.h"
42 #include "Debugger.h"
43 #include "FunctionExecutableDump.h"
44 #include "GetPutInfo.h"
45 #include "InlineCallFrame.h"
46 #include "Interpreter.h"
47 #include "JIT.h"
48 #include "JSCJSValue.h"
49 #include "JSFunction.h"
50 #include "JSLexicalEnvironment.h"
51 #include "JSModuleEnvironment.h"
52 #include "LLIntEntrypoint.h"
53 #include "LowLevelInterpreter.h"
54 #include "JSCInlines.h"
55 #include "PCToCodeOriginMap.h"
56 #include "PolymorphicAccess.h"
57 #include "ProfilerDatabase.h"
58 #include "ReduceWhitespace.h"
59 #include "Repatch.h"
60 #include "SlotVisitorInlines.h"
61 #include "StackVisitor.h"
62 #include "StructureStubInfo.h"
63 #include "TypeLocationCache.h"
64 #include "TypeProfiler.h"
65 #include "UnlinkedInstructionStream.h"
66 #include <wtf/BagToHashMap.h>
67 #include <wtf/CommaPrinter.h>
68 #include <wtf/StringExtras.h>
69 #include <wtf/StringPrintStream.h>
70 #include <wtf/text/UniquedStringImpl.h>
71
72 #if ENABLE(JIT)
73 #include "RegisterAtOffsetList.h"
74 #endif
75
76 #if ENABLE(DFG_JIT)
77 #include "DFGOperations.h"
78 #endif
79
80 #if ENABLE(FTL_JIT)
81 #include "FTLJITCode.h"
82 #endif
83
84 namespace JSC {
85
86 const ClassInfo CodeBlock::s_info = {
87     "CodeBlock", 0, 0,
88     CREATE_METHOD_TABLE(CodeBlock)
89 };
90
91 const ClassInfo FunctionCodeBlock::s_info = {
92     "FunctionCodeBlock", &Base::s_info, 0,
93     CREATE_METHOD_TABLE(FunctionCodeBlock)
94 };
95
96 #if ENABLE(WEBASSEMBLY)
97 const ClassInfo WebAssemblyCodeBlock::s_info = {
98     "WebAssemblyCodeBlock", &Base::s_info, 0,
99     CREATE_METHOD_TABLE(WebAssemblyCodeBlock)
100 };
101 #endif
102
103 const ClassInfo GlobalCodeBlock::s_info = {
104     "GlobalCodeBlock", &Base::s_info, 0,
105     CREATE_METHOD_TABLE(GlobalCodeBlock)
106 };
107
108 const ClassInfo ProgramCodeBlock::s_info = {
109     "ProgramCodeBlock", &Base::s_info, 0,
110     CREATE_METHOD_TABLE(ProgramCodeBlock)
111 };
112
113 const ClassInfo ModuleProgramCodeBlock::s_info = {
114     "ModuleProgramCodeBlock", &Base::s_info, 0,
115     CREATE_METHOD_TABLE(ModuleProgramCodeBlock)
116 };
117
118 const ClassInfo EvalCodeBlock::s_info = {
119     "EvalCodeBlock", &Base::s_info, 0,
120     CREATE_METHOD_TABLE(EvalCodeBlock)
121 };
122
123 void FunctionCodeBlock::destroy(JSCell* cell)
124 {
125     jsCast<FunctionCodeBlock*>(cell)->~FunctionCodeBlock();
126 }
127
128 #if ENABLE(WEBASSEMBLY)
129 void WebAssemblyCodeBlock::destroy(JSCell* cell)
130 {
131     jsCast<WebAssemblyCodeBlock*>(cell)->~WebAssemblyCodeBlock();
132 }
133 #endif
134
135 void ProgramCodeBlock::destroy(JSCell* cell)
136 {
137     jsCast<ProgramCodeBlock*>(cell)->~ProgramCodeBlock();
138 }
139
140 void ModuleProgramCodeBlock::destroy(JSCell* cell)
141 {
142     jsCast<ModuleProgramCodeBlock*>(cell)->~ModuleProgramCodeBlock();
143 }
144
145 void EvalCodeBlock::destroy(JSCell* cell)
146 {
147     jsCast<EvalCodeBlock*>(cell)->~EvalCodeBlock();
148 }
149
150 CString CodeBlock::inferredName() const
151 {
152     switch (codeType()) {
153     case GlobalCode:
154         return "<global>";
155     case EvalCode:
156         return "<eval>";
157     case FunctionCode:
158         return jsCast<FunctionExecutable*>(ownerExecutable())->inferredName().utf8();
159     case ModuleCode:
160         return "<module>";
161     default:
162         CRASH();
163         return CString("", 0);
164     }
165 }
166
167 bool CodeBlock::hasHash() const
168 {
169     return !!m_hash;
170 }
171
172 bool CodeBlock::isSafeToComputeHash() const
173 {
174     return !isCompilationThread();
175 }
176
177 CodeBlockHash CodeBlock::hash() const
178 {
179     if (!m_hash) {
180         RELEASE_ASSERT(isSafeToComputeHash());
181         m_hash = CodeBlockHash(ownerScriptExecutable()->source(), specializationKind());
182     }
183     return m_hash;
184 }
185
186 CString CodeBlock::sourceCodeForTools() const
187 {
188     if (codeType() != FunctionCode)
189         return ownerScriptExecutable()->source().toUTF8();
190     
191     SourceProvider* provider = source();
192     FunctionExecutable* executable = jsCast<FunctionExecutable*>(ownerExecutable());
193     UnlinkedFunctionExecutable* unlinked = executable->unlinkedExecutable();
194     unsigned unlinkedStartOffset = unlinked->startOffset();
195     unsigned linkedStartOffset = executable->source().startOffset();
196     int delta = linkedStartOffset - unlinkedStartOffset;
197     unsigned rangeStart = delta + unlinked->unlinkedFunctionNameStart();
198     unsigned rangeEnd = delta + unlinked->startOffset() + unlinked->sourceLength();
199     return toCString(
200         "function ",
201         provider->source().substring(rangeStart, rangeEnd - rangeStart).utf8());
202 }
203
204 CString CodeBlock::sourceCodeOnOneLine() const
205 {
206     return reduceWhitespace(sourceCodeForTools());
207 }
208
209 CString CodeBlock::hashAsStringIfPossible() const
210 {
211     if (hasHash() || isSafeToComputeHash())
212         return toCString(hash());
213     return "<no-hash>";
214 }
215
216 void CodeBlock::dumpAssumingJITType(PrintStream& out, JITCode::JITType jitType) const
217 {
218     out.print(inferredName(), "#", hashAsStringIfPossible());
219     out.print(":[", RawPointer(this), "->");
220     if (!!m_alternative)
221         out.print(RawPointer(alternative()), "->");
222     out.print(RawPointer(ownerExecutable()), ", ", jitType, codeType());
223
224     if (codeType() == FunctionCode)
225         out.print(specializationKind());
226     out.print(", ", instructionCount());
227     if (this->jitType() == JITCode::BaselineJIT && m_shouldAlwaysBeInlined)
228         out.print(" (ShouldAlwaysBeInlined)");
229     if (ownerScriptExecutable()->neverInline())
230         out.print(" (NeverInline)");
231     if (ownerScriptExecutable()->neverOptimize())
232         out.print(" (NeverOptimize)");
233     else if (ownerScriptExecutable()->neverFTLOptimize())
234         out.print(" (NeverFTLOptimize)");
235     if (ownerScriptExecutable()->didTryToEnterInLoop())
236         out.print(" (DidTryToEnterInLoop)");
237     if (ownerScriptExecutable()->isStrictMode())
238         out.print(" (StrictMode)");
239     if (this->jitType() == JITCode::BaselineJIT && m_didFailFTLCompilation)
240         out.print(" (FTLFail)");
241     if (this->jitType() == JITCode::BaselineJIT && m_hasBeenCompiledWithFTL)
242         out.print(" (HadFTLReplacement)");
243     out.print("]");
244 }
245
246 void CodeBlock::dump(PrintStream& out) const
247 {
248     dumpAssumingJITType(out, jitType());
249 }
250
251 static CString idName(int id0, const Identifier& ident)
252 {
253     return toCString(ident.impl(), "(@id", id0, ")");
254 }
255
256 CString CodeBlock::registerName(int r) const
257 {
258     if (isConstantRegisterIndex(r))
259         return constantName(r);
260
261     return toCString(VirtualRegister(r));
262 }
263
264 CString CodeBlock::constantName(int index) const
265 {
266     JSValue value = getConstant(index);
267     return toCString(value, "(", VirtualRegister(index), ")");
268 }
269
270 static CString regexpToSourceString(RegExp* regExp)
271 {
272     char postfix[5] = { '/', 0, 0, 0, 0 };
273     int index = 1;
274     if (regExp->global())
275         postfix[index++] = 'g';
276     if (regExp->ignoreCase())
277         postfix[index++] = 'i';
278     if (regExp->multiline())
279         postfix[index] = 'm';
280     if (regExp->sticky())
281         postfix[index++] = 'y';
282     if (regExp->unicode())
283         postfix[index++] = 'u';
284
285     return toCString("/", regExp->pattern().impl(), postfix);
286 }
287
288 static CString regexpName(int re, RegExp* regexp)
289 {
290     return toCString(regexpToSourceString(regexp), "(@re", re, ")");
291 }
292
293 NEVER_INLINE static const char* debugHookName(int debugHookID)
294 {
295     switch (static_cast<DebugHookID>(debugHookID)) {
296         case DidEnterCallFrame:
297             return "didEnterCallFrame";
298         case WillLeaveCallFrame:
299             return "willLeaveCallFrame";
300         case WillExecuteStatement:
301             return "willExecuteStatement";
302         case WillExecuteProgram:
303             return "willExecuteProgram";
304         case DidExecuteProgram:
305             return "didExecuteProgram";
306         case DidReachBreakpoint:
307             return "didReachBreakpoint";
308     }
309
310     RELEASE_ASSERT_NOT_REACHED();
311     return "";
312 }
313
314 void CodeBlock::printUnaryOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op)
315 {
316     int r0 = (++it)->u.operand;
317     int r1 = (++it)->u.operand;
318
319     printLocationAndOp(out, exec, location, it, op);
320     out.printf("%s, %s", registerName(r0).data(), registerName(r1).data());
321 }
322
323 void CodeBlock::printBinaryOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op)
324 {
325     int r0 = (++it)->u.operand;
326     int r1 = (++it)->u.operand;
327     int r2 = (++it)->u.operand;
328     printLocationAndOp(out, exec, location, it, op);
329     out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
330 }
331
332 void CodeBlock::printConditionalJump(PrintStream& out, ExecState* exec, const Instruction*, const Instruction*& it, int location, const char* op)
333 {
334     int r0 = (++it)->u.operand;
335     int offset = (++it)->u.operand;
336     printLocationAndOp(out, exec, location, it, op);
337     out.printf("%s, %d(->%d)", registerName(r0).data(), offset, location + offset);
338 }
339
340 void CodeBlock::printGetByIdOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it)
341 {
342     const char* op;
343     switch (exec->interpreter()->getOpcodeID(it->u.opcode)) {
344     case op_get_by_id:
345         op = "get_by_id";
346         break;
347     case op_get_array_length:
348         op = "array_length";
349         break;
350     default:
351         RELEASE_ASSERT_NOT_REACHED();
352 #if COMPILER_QUIRK(CONSIDERS_UNREACHABLE_CODE)
353         op = 0;
354 #endif
355     }
356     int r0 = (++it)->u.operand;
357     int r1 = (++it)->u.operand;
358     int id0 = (++it)->u.operand;
359     printLocationAndOp(out, exec, location, it, op);
360     out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), idName(id0, identifier(id0)).data());
361     it += 4; // Increment up to the value profiler.
362 }
363
364 static void dumpStructure(PrintStream& out, const char* name, Structure* structure, const Identifier& ident)
365 {
366     if (!structure)
367         return;
368     
369     out.printf("%s = %p", name, structure);
370     
371     PropertyOffset offset = structure->getConcurrently(ident.impl());
372     if (offset != invalidOffset)
373         out.printf(" (offset = %d)", offset);
374 }
375
376 static void dumpChain(PrintStream& out, StructureChain* chain, const Identifier& ident)
377 {
378     out.printf("chain = %p: [", chain);
379     bool first = true;
380     for (WriteBarrier<Structure>* currentStructure = chain->head();
381          *currentStructure;
382          ++currentStructure) {
383         if (first)
384             first = false;
385         else
386             out.printf(", ");
387         dumpStructure(out, "struct", currentStructure->get(), ident);
388     }
389     out.printf("]");
390 }
391
392 void CodeBlock::printGetByIdCacheStatus(PrintStream& out, ExecState* exec, int location, const StubInfoMap& map)
393 {
394     Instruction* instruction = instructions().begin() + location;
395
396     const Identifier& ident = identifier(instruction[3].u.operand);
397     
398     UNUSED_PARAM(ident); // tell the compiler to shut up in certain platform configurations.
399     
400     if (exec->interpreter()->getOpcodeID(instruction[0].u.opcode) == op_get_array_length)
401         out.printf(" llint(array_length)");
402     else if (StructureID structureID = instruction[4].u.structureID) {
403         Structure* structure = m_vm->heap.structureIDTable().get(structureID);
404         out.printf(" llint(");
405         dumpStructure(out, "struct", structure, ident);
406         out.printf(")");
407     }
408
409 #if ENABLE(JIT)
410     if (StructureStubInfo* stubPtr = map.get(CodeOrigin(location))) {
411         StructureStubInfo& stubInfo = *stubPtr;
412         if (stubInfo.resetByGC)
413             out.print(" (Reset By GC)");
414         
415         out.printf(" jit(");
416             
417         Structure* baseStructure = nullptr;
418         PolymorphicAccess* stub = nullptr;
419             
420         switch (stubInfo.cacheType) {
421         case CacheType::GetByIdSelf:
422             out.printf("self");
423             baseStructure = stubInfo.u.byIdSelf.baseObjectStructure.get();
424             break;
425         case CacheType::Stub:
426             out.printf("stub");
427             stub = stubInfo.u.stub;
428             break;
429         case CacheType::Unset:
430             out.printf("unset");
431             break;
432         default:
433             RELEASE_ASSERT_NOT_REACHED();
434             break;
435         }
436             
437         if (baseStructure) {
438             out.printf(", ");
439             dumpStructure(out, "struct", baseStructure, ident);
440         }
441
442         if (stub)
443             out.print(", ", *stub);
444
445         out.printf(")");
446     }
447 #else
448     UNUSED_PARAM(map);
449 #endif
450 }
451
452 void CodeBlock::printPutByIdCacheStatus(PrintStream& out, int location, const StubInfoMap& map)
453 {
454     Instruction* instruction = instructions().begin() + location;
455
456     const Identifier& ident = identifier(instruction[2].u.operand);
457     
458     UNUSED_PARAM(ident); // tell the compiler to shut up in certain platform configurations.
459
460     out.print(", ", instruction[8].u.putByIdFlags);
461     
462     if (StructureID structureID = instruction[4].u.structureID) {
463         Structure* structure = m_vm->heap.structureIDTable().get(structureID);
464         out.print(" llint(");
465         if (StructureID newStructureID = instruction[6].u.structureID) {
466             Structure* newStructure = m_vm->heap.structureIDTable().get(newStructureID);
467             dumpStructure(out, "prev", structure, ident);
468             out.print(", ");
469             dumpStructure(out, "next", newStructure, ident);
470             if (StructureChain* chain = instruction[7].u.structureChain.get()) {
471                 out.print(", ");
472                 dumpChain(out, chain, ident);
473             }
474         } else
475             dumpStructure(out, "struct", structure, ident);
476         out.print(")");
477     }
478
479 #if ENABLE(JIT)
480     if (StructureStubInfo* stubPtr = map.get(CodeOrigin(location))) {
481         StructureStubInfo& stubInfo = *stubPtr;
482         if (stubInfo.resetByGC)
483             out.print(" (Reset By GC)");
484         
485         out.printf(" jit(");
486         
487         switch (stubInfo.cacheType) {
488         case CacheType::PutByIdReplace:
489             out.print("replace, ");
490             dumpStructure(out, "struct", stubInfo.u.byIdSelf.baseObjectStructure.get(), ident);
491             break;
492         case CacheType::Stub: {
493             out.print("stub, ", *stubInfo.u.stub);
494             break;
495         }
496         case CacheType::Unset:
497             out.printf("unset");
498             break;
499         default:
500             RELEASE_ASSERT_NOT_REACHED();
501             break;
502         }
503         out.printf(")");
504     }
505 #else
506     UNUSED_PARAM(map);
507 #endif
508 }
509
510 void CodeBlock::printCallOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op, CacheDumpMode cacheDumpMode, bool& hasPrintedProfiling, const CallLinkInfoMap& map)
511 {
512     int dst = (++it)->u.operand;
513     int func = (++it)->u.operand;
514     int argCount = (++it)->u.operand;
515     int registerOffset = (++it)->u.operand;
516     printLocationAndOp(out, exec, location, it, op);
517     out.printf("%s, %s, %d, %d", registerName(dst).data(), registerName(func).data(), argCount, registerOffset);
518     if (cacheDumpMode == DumpCaches) {
519         LLIntCallLinkInfo* callLinkInfo = it[1].u.callLinkInfo;
520         if (callLinkInfo->lastSeenCallee) {
521             out.printf(
522                 " llint(%p, exec %p)",
523                 callLinkInfo->lastSeenCallee.get(),
524                 callLinkInfo->lastSeenCallee->executable());
525         }
526 #if ENABLE(JIT)
527         if (CallLinkInfo* info = map.get(CodeOrigin(location))) {
528             JSFunction* target = info->lastSeenCallee();
529             if (target)
530                 out.printf(" jit(%p, exec %p)", target, target->executable());
531         }
532         
533         if (jitType() != JITCode::FTLJIT)
534             out.print(" status(", CallLinkStatus::computeFor(this, location, map), ")");
535 #else
536         UNUSED_PARAM(map);
537 #endif
538     }
539     ++it;
540     ++it;
541     dumpArrayProfiling(out, it, hasPrintedProfiling);
542     dumpValueProfiling(out, it, hasPrintedProfiling);
543 }
544
545 void CodeBlock::printPutByIdOp(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op)
546 {
547     int r0 = (++it)->u.operand;
548     int id0 = (++it)->u.operand;
549     int r1 = (++it)->u.operand;
550     printLocationAndOp(out, exec, location, it, op);
551     out.printf("%s, %s, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), registerName(r1).data());
552     it += 5;
553 }
554
555 void CodeBlock::dumpSource()
556 {
557     dumpSource(WTF::dataFile());
558 }
559
560 void CodeBlock::dumpSource(PrintStream& out)
561 {
562     ScriptExecutable* executable = ownerScriptExecutable();
563     if (executable->isFunctionExecutable()) {
564         FunctionExecutable* functionExecutable = reinterpret_cast<FunctionExecutable*>(executable);
565         StringView source = functionExecutable->source().provider()->getRange(
566             functionExecutable->parametersStartOffset(),
567             functionExecutable->typeProfilingEndOffset() + 1); // Type profiling end offset is the character before the '}'.
568         
569         out.print("function ", inferredName(), source);
570         return;
571     }
572     out.print(executable->source().view());
573 }
574
575 void CodeBlock::dumpBytecode()
576 {
577     dumpBytecode(WTF::dataFile());
578 }
579
580 void CodeBlock::dumpBytecode(PrintStream& out)
581 {
582     // We only use the ExecState* for things that don't actually lead to JS execution,
583     // like converting a JSString to a String. Hence the globalExec is appropriate.
584     ExecState* exec = m_globalObject->globalExec();
585     
586     size_t instructionCount = 0;
587
588     for (size_t i = 0; i < instructions().size(); i += opcodeLengths[exec->interpreter()->getOpcodeID(instructions()[i].u.opcode)])
589         ++instructionCount;
590
591     out.print(*this);
592     out.printf(
593         ": %lu m_instructions; %lu bytes; %d parameter(s); %d callee register(s); %d variable(s)",
594         static_cast<unsigned long>(instructions().size()),
595         static_cast<unsigned long>(instructions().size() * sizeof(Instruction)),
596         m_numParameters, m_numCalleeLocals, m_numVars);
597     out.printf("\n");
598     
599     StubInfoMap stubInfos;
600     CallLinkInfoMap callLinkInfos;
601     getStubInfoMap(stubInfos);
602     getCallLinkInfoMap(callLinkInfos);
603     
604     const Instruction* begin = instructions().begin();
605     const Instruction* end = instructions().end();
606     for (const Instruction* it = begin; it != end; ++it)
607         dumpBytecode(out, exec, begin, it, stubInfos, callLinkInfos);
608     
609     if (numberOfIdentifiers()) {
610         out.printf("\nIdentifiers:\n");
611         size_t i = 0;
612         do {
613             out.printf("  id%u = %s\n", static_cast<unsigned>(i), identifier(i).string().utf8().data());
614             ++i;
615         } while (i != numberOfIdentifiers());
616     }
617
618     if (!m_constantRegisters.isEmpty()) {
619         out.printf("\nConstants:\n");
620         size_t i = 0;
621         do {
622             const char* sourceCodeRepresentationDescription = nullptr;
623             switch (m_constantsSourceCodeRepresentation[i]) {
624             case SourceCodeRepresentation::Double:
625                 sourceCodeRepresentationDescription = ": in source as double";
626                 break;
627             case SourceCodeRepresentation::Integer:
628                 sourceCodeRepresentationDescription = ": in source as integer";
629                 break;
630             case SourceCodeRepresentation::Other:
631                 sourceCodeRepresentationDescription = "";
632                 break;
633             }
634             out.printf("   k%u = %s%s\n", static_cast<unsigned>(i), toCString(m_constantRegisters[i].get()).data(), sourceCodeRepresentationDescription);
635             ++i;
636         } while (i < m_constantRegisters.size());
637     }
638
639     if (size_t count = m_unlinkedCode->numberOfRegExps()) {
640         out.printf("\nm_regexps:\n");
641         size_t i = 0;
642         do {
643             out.printf("  re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_unlinkedCode->regexp(i)).data());
644             ++i;
645         } while (i < count);
646     }
647
648     dumpExceptionHandlers(out);
649     
650     if (m_rareData && !m_rareData->m_switchJumpTables.isEmpty()) {
651         out.printf("Switch Jump Tables:\n");
652         unsigned i = 0;
653         do {
654             out.printf("  %1d = {\n", i);
655             int entry = 0;
656             Vector<int32_t>::const_iterator end = m_rareData->m_switchJumpTables[i].branchOffsets.end();
657             for (Vector<int32_t>::const_iterator iter = m_rareData->m_switchJumpTables[i].branchOffsets.begin(); iter != end; ++iter, ++entry) {
658                 if (!*iter)
659                     continue;
660                 out.printf("\t\t%4d => %04d\n", entry + m_rareData->m_switchJumpTables[i].min, *iter);
661             }
662             out.printf("      }\n");
663             ++i;
664         } while (i < m_rareData->m_switchJumpTables.size());
665     }
666     
667     if (m_rareData && !m_rareData->m_stringSwitchJumpTables.isEmpty()) {
668         out.printf("\nString Switch Jump Tables:\n");
669         unsigned i = 0;
670         do {
671             out.printf("  %1d = {\n", i);
672             StringJumpTable::StringOffsetTable::const_iterator end = m_rareData->m_stringSwitchJumpTables[i].offsetTable.end();
673             for (StringJumpTable::StringOffsetTable::const_iterator iter = m_rareData->m_stringSwitchJumpTables[i].offsetTable.begin(); iter != end; ++iter)
674                 out.printf("\t\t\"%s\" => %04d\n", iter->key->utf8().data(), iter->value.branchOffset);
675             out.printf("      }\n");
676             ++i;
677         } while (i < m_rareData->m_stringSwitchJumpTables.size());
678     }
679
680     if (m_rareData && !m_rareData->m_liveCalleeLocalsAtYield.isEmpty()) {
681         out.printf("\nLive Callee Locals:\n");
682         unsigned i = 0;
683         do {
684             const FastBitVector& liveness = m_rareData->m_liveCalleeLocalsAtYield[i];
685             out.printf("  live%1u = ", i);
686             liveness.dump(out);
687             out.printf("\n");
688             ++i;
689         } while (i < m_rareData->m_liveCalleeLocalsAtYield.size());
690     }
691
692     out.printf("\n");
693 }
694
695 void CodeBlock::dumpExceptionHandlers(PrintStream& out)
696 {
697     if (m_rareData && !m_rareData->m_exceptionHandlers.isEmpty()) {
698         out.printf("\nException Handlers:\n");
699         unsigned i = 0;
700         do {
701             HandlerInfo& handler = m_rareData->m_exceptionHandlers[i];
702             out.printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] } %s\n",
703                 i + 1, handler.start, handler.end, handler.target, handler.typeName());
704             ++i;
705         } while (i < m_rareData->m_exceptionHandlers.size());
706     }
707 }
708
709 void CodeBlock::beginDumpProfiling(PrintStream& out, bool& hasPrintedProfiling)
710 {
711     if (hasPrintedProfiling) {
712         out.print("; ");
713         return;
714     }
715     
716     out.print("    ");
717     hasPrintedProfiling = true;
718 }
719
720 void CodeBlock::dumpValueProfiling(PrintStream& out, const Instruction*& it, bool& hasPrintedProfiling)
721 {
722     ConcurrentJITLocker locker(m_lock);
723     
724     ++it;
725     CString description = it->u.profile->briefDescription(locker);
726     if (!description.length())
727         return;
728     beginDumpProfiling(out, hasPrintedProfiling);
729     out.print(description);
730 }
731
732 void CodeBlock::dumpArrayProfiling(PrintStream& out, const Instruction*& it, bool& hasPrintedProfiling)
733 {
734     ConcurrentJITLocker locker(m_lock);
735     
736     ++it;
737     if (!it->u.arrayProfile)
738         return;
739     CString description = it->u.arrayProfile->briefDescription(locker, this);
740     if (!description.length())
741         return;
742     beginDumpProfiling(out, hasPrintedProfiling);
743     out.print(description);
744 }
745
746 void CodeBlock::dumpRareCaseProfile(PrintStream& out, const char* name, RareCaseProfile* profile, bool& hasPrintedProfiling)
747 {
748     if (!profile || !profile->m_counter)
749         return;
750
751     beginDumpProfiling(out, hasPrintedProfiling);
752     out.print(name, profile->m_counter);
753 }
754
755 void CodeBlock::dumpResultProfile(PrintStream& out, ResultProfile* profile, bool& hasPrintedProfiling)
756 {
757     if (!profile)
758         return;
759     
760     beginDumpProfiling(out, hasPrintedProfiling);
761     out.print("results: ", *profile);
762 }
763
764 void CodeBlock::printLocationAndOp(PrintStream& out, ExecState*, int location, const Instruction*&, const char* op)
765 {
766     out.printf("[%4d] %-17s ", location, op);
767 }
768
769 void CodeBlock::printLocationOpAndRegisterOperand(PrintStream& out, ExecState* exec, int location, const Instruction*& it, const char* op, int operand)
770 {
771     printLocationAndOp(out, exec, location, it, op);
772     out.printf("%s", registerName(operand).data());
773 }
774
775 void CodeBlock::dumpBytecode(
776     PrintStream& out, ExecState* exec, const Instruction* begin, const Instruction*& it,
777     const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos)
778 {
779     int location = it - begin;
780     bool hasPrintedProfiling = false;
781     OpcodeID opcode = exec->interpreter()->getOpcodeID(it->u.opcode);
782     switch (opcode) {
783         case op_enter: {
784             printLocationAndOp(out, exec, location, it, "enter");
785             break;
786         }
787         case op_get_scope: {
788             int r0 = (++it)->u.operand;
789             printLocationOpAndRegisterOperand(out, exec, location, it, "get_scope", r0);
790             break;
791         }
792         case op_create_direct_arguments: {
793             int r0 = (++it)->u.operand;
794             printLocationAndOp(out, exec, location, it, "create_direct_arguments");
795             out.printf("%s", registerName(r0).data());
796             break;
797         }
798         case op_create_scoped_arguments: {
799             int r0 = (++it)->u.operand;
800             int r1 = (++it)->u.operand;
801             printLocationAndOp(out, exec, location, it, "create_scoped_arguments");
802             out.printf("%s, %s", registerName(r0).data(), registerName(r1).data());
803             break;
804         }
805         case op_create_cloned_arguments: {
806             int r0 = (++it)->u.operand;
807             printLocationAndOp(out, exec, location, it, "create_cloned_arguments");
808             out.printf("%s", registerName(r0).data());
809             break;
810         }
811         case op_copy_rest: {
812             int r0 = (++it)->u.operand;
813             int r1 = (++it)->u.operand;
814             unsigned argumentOffset = (++it)->u.unsignedValue;
815             printLocationAndOp(out, exec, location, it, "copy_rest");
816             out.printf("%s, %s, ", registerName(r0).data(), registerName(r1).data());
817             out.printf("ArgumentsOffset: %u", argumentOffset);
818             break;
819         }
820         case op_get_rest_length: {
821             int r0 = (++it)->u.operand;
822             printLocationAndOp(out, exec, location, it, "get_rest_length");
823             out.printf("%s, ", registerName(r0).data());
824             unsigned argumentOffset = (++it)->u.unsignedValue;
825             out.printf("ArgumentsOffset: %u", argumentOffset);
826             break;
827         }
828         case op_create_this: {
829             int r0 = (++it)->u.operand;
830             int r1 = (++it)->u.operand;
831             unsigned inferredInlineCapacity = (++it)->u.operand;
832             unsigned cachedFunction = (++it)->u.operand;
833             printLocationAndOp(out, exec, location, it, "create_this");
834             out.printf("%s, %s, %u, %u", registerName(r0).data(), registerName(r1).data(), inferredInlineCapacity, cachedFunction);
835             break;
836         }
837         case op_to_this: {
838             int r0 = (++it)->u.operand;
839             printLocationOpAndRegisterOperand(out, exec, location, it, "to_this", r0);
840             Structure* structure = (++it)->u.structure.get();
841             if (structure)
842                 out.print(", cache(struct = ", RawPointer(structure), ")");
843             out.print(", ", (++it)->u.toThisStatus);
844             break;
845         }
846         case op_check_tdz: {
847             int r0 = (++it)->u.operand;
848             printLocationOpAndRegisterOperand(out, exec, location, it, "op_check_tdz", r0);
849             break;
850         }
851         case op_new_object: {
852             int r0 = (++it)->u.operand;
853             unsigned inferredInlineCapacity = (++it)->u.operand;
854             printLocationAndOp(out, exec, location, it, "new_object");
855             out.printf("%s, %u", registerName(r0).data(), inferredInlineCapacity);
856             ++it; // Skip object allocation profile.
857             break;
858         }
859         case op_new_array: {
860             int dst = (++it)->u.operand;
861             int argv = (++it)->u.operand;
862             int argc = (++it)->u.operand;
863             printLocationAndOp(out, exec, location, it, "new_array");
864             out.printf("%s, %s, %d", registerName(dst).data(), registerName(argv).data(), argc);
865             ++it; // Skip array allocation profile.
866             break;
867         }
868         case op_new_array_with_size: {
869             int dst = (++it)->u.operand;
870             int length = (++it)->u.operand;
871             printLocationAndOp(out, exec, location, it, "new_array_with_size");
872             out.printf("%s, %s", registerName(dst).data(), registerName(length).data());
873             ++it; // Skip array allocation profile.
874             break;
875         }
876         case op_new_array_buffer: {
877             int dst = (++it)->u.operand;
878             int argv = (++it)->u.operand;
879             int argc = (++it)->u.operand;
880             printLocationAndOp(out, exec, location, it, "new_array_buffer");
881             out.printf("%s, %d, %d", registerName(dst).data(), argv, argc);
882             ++it; // Skip array allocation profile.
883             break;
884         }
885         case op_new_regexp: {
886             int r0 = (++it)->u.operand;
887             int re0 = (++it)->u.operand;
888             printLocationAndOp(out, exec, location, it, "new_regexp");
889             out.printf("%s, ", registerName(r0).data());
890             if (r0 >=0 && r0 < (int)m_unlinkedCode->numberOfRegExps())
891                 out.printf("%s", regexpName(re0, regexp(re0)).data());
892             else
893                 out.printf("bad_regexp(%d)", re0);
894             break;
895         }
896         case op_mov: {
897             int r0 = (++it)->u.operand;
898             int r1 = (++it)->u.operand;
899             printLocationAndOp(out, exec, location, it, "mov");
900             out.printf("%s, %s", registerName(r0).data(), registerName(r1).data());
901             break;
902         }
903         case op_profile_type: {
904             int r0 = (++it)->u.operand;
905             ++it;
906             ++it;
907             ++it;
908             ++it;
909             printLocationAndOp(out, exec, location, it, "op_profile_type");
910             out.printf("%s", registerName(r0).data());
911             break;
912         }
913         case op_profile_control_flow: {
914             BasicBlockLocation* basicBlockLocation = (++it)->u.basicBlockLocation;
915             printLocationAndOp(out, exec, location, it, "profile_control_flow");
916             out.printf("[%d, %d]", basicBlockLocation->startOffset(), basicBlockLocation->endOffset());
917             break;
918         }
919         case op_not: {
920             printUnaryOp(out, exec, location, it, "not");
921             break;
922         }
923         case op_eq: {
924             printBinaryOp(out, exec, location, it, "eq");
925             break;
926         }
927         case op_eq_null: {
928             printUnaryOp(out, exec, location, it, "eq_null");
929             break;
930         }
931         case op_neq: {
932             printBinaryOp(out, exec, location, it, "neq");
933             break;
934         }
935         case op_neq_null: {
936             printUnaryOp(out, exec, location, it, "neq_null");
937             break;
938         }
939         case op_stricteq: {
940             printBinaryOp(out, exec, location, it, "stricteq");
941             break;
942         }
943         case op_nstricteq: {
944             printBinaryOp(out, exec, location, it, "nstricteq");
945             break;
946         }
947         case op_less: {
948             printBinaryOp(out, exec, location, it, "less");
949             break;
950         }
951         case op_lesseq: {
952             printBinaryOp(out, exec, location, it, "lesseq");
953             break;
954         }
955         case op_greater: {
956             printBinaryOp(out, exec, location, it, "greater");
957             break;
958         }
959         case op_greatereq: {
960             printBinaryOp(out, exec, location, it, "greatereq");
961             break;
962         }
963         case op_inc: {
964             int r0 = (++it)->u.operand;
965             printLocationOpAndRegisterOperand(out, exec, location, it, "inc", r0);
966             break;
967         }
968         case op_dec: {
969             int r0 = (++it)->u.operand;
970             printLocationOpAndRegisterOperand(out, exec, location, it, "dec", r0);
971             break;
972         }
973         case op_to_number: {
974             printUnaryOp(out, exec, location, it, "to_number");
975             break;
976         }
977         case op_to_string: {
978             printUnaryOp(out, exec, location, it, "to_string");
979             break;
980         }
981         case op_negate: {
982             printUnaryOp(out, exec, location, it, "negate");
983             break;
984         }
985         case op_add: {
986             printBinaryOp(out, exec, location, it, "add");
987             ++it;
988             break;
989         }
990         case op_mul: {
991             printBinaryOp(out, exec, location, it, "mul");
992             ++it;
993             break;
994         }
995         case op_div: {
996             printBinaryOp(out, exec, location, it, "div");
997             ++it;
998             break;
999         }
1000         case op_mod: {
1001             printBinaryOp(out, exec, location, it, "mod");
1002             break;
1003         }
1004         case op_sub: {
1005             printBinaryOp(out, exec, location, it, "sub");
1006             ++it;
1007             break;
1008         }
1009         case op_lshift: {
1010             printBinaryOp(out, exec, location, it, "lshift");
1011             break;            
1012         }
1013         case op_rshift: {
1014             printBinaryOp(out, exec, location, it, "rshift");
1015             break;
1016         }
1017         case op_urshift: {
1018             printBinaryOp(out, exec, location, it, "urshift");
1019             break;
1020         }
1021         case op_bitand: {
1022             printBinaryOp(out, exec, location, it, "bitand");
1023             ++it;
1024             break;
1025         }
1026         case op_bitxor: {
1027             printBinaryOp(out, exec, location, it, "bitxor");
1028             ++it;
1029             break;
1030         }
1031         case op_bitor: {
1032             printBinaryOp(out, exec, location, it, "bitor");
1033             ++it;
1034             break;
1035         }
1036         case op_overrides_has_instance: {
1037             int r0 = (++it)->u.operand;
1038             int r1 = (++it)->u.operand;
1039             int r2 = (++it)->u.operand;
1040             printLocationAndOp(out, exec, location, it, "overrides_has_instance");
1041             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
1042             break;
1043         }
1044         case op_instanceof: {
1045             int r0 = (++it)->u.operand;
1046             int r1 = (++it)->u.operand;
1047             int r2 = (++it)->u.operand;
1048             printLocationAndOp(out, exec, location, it, "instanceof");
1049             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
1050             break;
1051         }
1052         case op_instanceof_custom: {
1053             int r0 = (++it)->u.operand;
1054             int r1 = (++it)->u.operand;
1055             int r2 = (++it)->u.operand;
1056             int r3 = (++it)->u.operand;
1057             printLocationAndOp(out, exec, location, it, "instanceof_custom");
1058             out.printf("%s, %s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data(), registerName(r3).data());
1059             break;
1060         }
1061         case op_unsigned: {
1062             printUnaryOp(out, exec, location, it, "unsigned");
1063             break;
1064         }
1065         case op_typeof: {
1066             printUnaryOp(out, exec, location, it, "typeof");
1067             break;
1068         }
1069         case op_is_empty: {
1070             printUnaryOp(out, exec, location, it, "is_empty");
1071             break;
1072         }
1073         case op_is_undefined: {
1074             printUnaryOp(out, exec, location, it, "is_undefined");
1075             break;
1076         }
1077         case op_is_boolean: {
1078             printUnaryOp(out, exec, location, it, "is_boolean");
1079             break;
1080         }
1081         case op_is_number: {
1082             printUnaryOp(out, exec, location, it, "is_number");
1083             break;
1084         }
1085         case op_is_string: {
1086             printUnaryOp(out, exec, location, it, "is_string");
1087             break;
1088         }
1089         case op_is_object: {
1090             printUnaryOp(out, exec, location, it, "is_object");
1091             break;
1092         }
1093         case op_is_object_or_null: {
1094             printUnaryOp(out, exec, location, it, "is_object_or_null");
1095             break;
1096         }
1097         case op_is_function: {
1098             printUnaryOp(out, exec, location, it, "is_function");
1099             break;
1100         }
1101         case op_in: {
1102             printBinaryOp(out, exec, location, it, "in");
1103             break;
1104         }
1105         case op_try_get_by_id: {
1106             int r0 = (++it)->u.operand;
1107             int r1 = (++it)->u.operand;
1108             int id0 = (++it)->u.operand;
1109             printLocationAndOp(out, exec, location, it, "try_get_by_id");
1110             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), idName(id0, identifier(id0)).data());
1111             break;
1112         }
1113         case op_get_by_id:
1114         case op_get_array_length: {
1115             printGetByIdOp(out, exec, location, it);
1116             printGetByIdCacheStatus(out, exec, location, stubInfos);
1117             dumpValueProfiling(out, it, hasPrintedProfiling);
1118             break;
1119         }
1120         case op_put_by_id: {
1121             printPutByIdOp(out, exec, location, it, "put_by_id");
1122             printPutByIdCacheStatus(out, location, stubInfos);
1123             break;
1124         }
1125         case op_put_getter_by_id: {
1126             int r0 = (++it)->u.operand;
1127             int id0 = (++it)->u.operand;
1128             int n0 = (++it)->u.operand;
1129             int r1 = (++it)->u.operand;
1130             printLocationAndOp(out, exec, location, it, "put_getter_by_id");
1131             out.printf("%s, %s, %d, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), n0, registerName(r1).data());
1132             break;
1133         }
1134         case op_put_setter_by_id: {
1135             int r0 = (++it)->u.operand;
1136             int id0 = (++it)->u.operand;
1137             int n0 = (++it)->u.operand;
1138             int r1 = (++it)->u.operand;
1139             printLocationAndOp(out, exec, location, it, "put_setter_by_id");
1140             out.printf("%s, %s, %d, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), n0, registerName(r1).data());
1141             break;
1142         }
1143         case op_put_getter_setter_by_id: {
1144             int r0 = (++it)->u.operand;
1145             int id0 = (++it)->u.operand;
1146             int n0 = (++it)->u.operand;
1147             int r1 = (++it)->u.operand;
1148             int r2 = (++it)->u.operand;
1149             printLocationAndOp(out, exec, location, it, "put_getter_setter_by_id");
1150             out.printf("%s, %s, %d, %s, %s", registerName(r0).data(), idName(id0, identifier(id0)).data(), n0, registerName(r1).data(), registerName(r2).data());
1151             break;
1152         }
1153         case op_put_getter_by_val: {
1154             int r0 = (++it)->u.operand;
1155             int r1 = (++it)->u.operand;
1156             int n0 = (++it)->u.operand;
1157             int r2 = (++it)->u.operand;
1158             printLocationAndOp(out, exec, location, it, "put_getter_by_val");
1159             out.printf("%s, %s, %d, %s", registerName(r0).data(), registerName(r1).data(), n0, registerName(r2).data());
1160             break;
1161         }
1162         case op_put_setter_by_val: {
1163             int r0 = (++it)->u.operand;
1164             int r1 = (++it)->u.operand;
1165             int n0 = (++it)->u.operand;
1166             int r2 = (++it)->u.operand;
1167             printLocationAndOp(out, exec, location, it, "put_setter_by_val");
1168             out.printf("%s, %s, %d, %s", registerName(r0).data(), registerName(r1).data(), n0, registerName(r2).data());
1169             break;
1170         }
1171         case op_del_by_id: {
1172             int r0 = (++it)->u.operand;
1173             int r1 = (++it)->u.operand;
1174             int id0 = (++it)->u.operand;
1175             printLocationAndOp(out, exec, location, it, "del_by_id");
1176             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), idName(id0, identifier(id0)).data());
1177             break;
1178         }
1179         case op_get_by_val: {
1180             int r0 = (++it)->u.operand;
1181             int r1 = (++it)->u.operand;
1182             int r2 = (++it)->u.operand;
1183             printLocationAndOp(out, exec, location, it, "get_by_val");
1184             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
1185             dumpArrayProfiling(out, it, hasPrintedProfiling);
1186             dumpValueProfiling(out, it, hasPrintedProfiling);
1187             break;
1188         }
1189         case op_put_by_val: {
1190             int r0 = (++it)->u.operand;
1191             int r1 = (++it)->u.operand;
1192             int r2 = (++it)->u.operand;
1193             printLocationAndOp(out, exec, location, it, "put_by_val");
1194             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
1195             dumpArrayProfiling(out, it, hasPrintedProfiling);
1196             break;
1197         }
1198         case op_put_by_val_direct: {
1199             int r0 = (++it)->u.operand;
1200             int r1 = (++it)->u.operand;
1201             int r2 = (++it)->u.operand;
1202             printLocationAndOp(out, exec, location, it, "put_by_val_direct");
1203             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
1204             dumpArrayProfiling(out, it, hasPrintedProfiling);
1205             break;
1206         }
1207         case op_del_by_val: {
1208             int r0 = (++it)->u.operand;
1209             int r1 = (++it)->u.operand;
1210             int r2 = (++it)->u.operand;
1211             printLocationAndOp(out, exec, location, it, "del_by_val");
1212             out.printf("%s, %s, %s", registerName(r0).data(), registerName(r1).data(), registerName(r2).data());
1213             break;
1214         }
1215         case op_put_by_index: {
1216             int r0 = (++it)->u.operand;
1217             unsigned n0 = (++it)->u.operand;
1218             int r1 = (++it)->u.operand;
1219             printLocationAndOp(out, exec, location, it, "put_by_index");
1220             out.printf("%s, %u, %s", registerName(r0).data(), n0, registerName(r1).data());
1221             break;
1222         }
1223         case op_jmp: {
1224             int offset = (++it)->u.operand;
1225             printLocationAndOp(out, exec, location, it, "jmp");
1226             out.printf("%d(->%d)", offset, location + offset);
1227             break;
1228         }
1229         case op_jtrue: {
1230             printConditionalJump(out, exec, begin, it, location, "jtrue");
1231             break;
1232         }
1233         case op_jfalse: {
1234             printConditionalJump(out, exec, begin, it, location, "jfalse");
1235             break;
1236         }
1237         case op_jeq_null: {
1238             printConditionalJump(out, exec, begin, it, location, "jeq_null");
1239             break;
1240         }
1241         case op_jneq_null: {
1242             printConditionalJump(out, exec, begin, it, location, "jneq_null");
1243             break;
1244         }
1245         case op_jneq_ptr: {
1246             int r0 = (++it)->u.operand;
1247             Special::Pointer pointer = (++it)->u.specialPointer;
1248             int offset = (++it)->u.operand;
1249             printLocationAndOp(out, exec, location, it, "jneq_ptr");
1250             out.printf("%s, %d (%p), %d(->%d)", registerName(r0).data(), pointer, m_globalObject->actualPointerFor(pointer), offset, location + offset);
1251             break;
1252         }
1253         case op_jless: {
1254             int r0 = (++it)->u.operand;
1255             int r1 = (++it)->u.operand;
1256             int offset = (++it)->u.operand;
1257             printLocationAndOp(out, exec, location, it, "jless");
1258             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1259             break;
1260         }
1261         case op_jlesseq: {
1262             int r0 = (++it)->u.operand;
1263             int r1 = (++it)->u.operand;
1264             int offset = (++it)->u.operand;
1265             printLocationAndOp(out, exec, location, it, "jlesseq");
1266             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1267             break;
1268         }
1269         case op_jgreater: {
1270             int r0 = (++it)->u.operand;
1271             int r1 = (++it)->u.operand;
1272             int offset = (++it)->u.operand;
1273             printLocationAndOp(out, exec, location, it, "jgreater");
1274             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1275             break;
1276         }
1277         case op_jgreatereq: {
1278             int r0 = (++it)->u.operand;
1279             int r1 = (++it)->u.operand;
1280             int offset = (++it)->u.operand;
1281             printLocationAndOp(out, exec, location, it, "jgreatereq");
1282             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1283             break;
1284         }
1285         case op_jnless: {
1286             int r0 = (++it)->u.operand;
1287             int r1 = (++it)->u.operand;
1288             int offset = (++it)->u.operand;
1289             printLocationAndOp(out, exec, location, it, "jnless");
1290             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1291             break;
1292         }
1293         case op_jnlesseq: {
1294             int r0 = (++it)->u.operand;
1295             int r1 = (++it)->u.operand;
1296             int offset = (++it)->u.operand;
1297             printLocationAndOp(out, exec, location, it, "jnlesseq");
1298             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1299             break;
1300         }
1301         case op_jngreater: {
1302             int r0 = (++it)->u.operand;
1303             int r1 = (++it)->u.operand;
1304             int offset = (++it)->u.operand;
1305             printLocationAndOp(out, exec, location, it, "jngreater");
1306             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1307             break;
1308         }
1309         case op_jngreatereq: {
1310             int r0 = (++it)->u.operand;
1311             int r1 = (++it)->u.operand;
1312             int offset = (++it)->u.operand;
1313             printLocationAndOp(out, exec, location, it, "jngreatereq");
1314             out.printf("%s, %s, %d(->%d)", registerName(r0).data(), registerName(r1).data(), offset, location + offset);
1315             break;
1316         }
1317         case op_loop_hint: {
1318             printLocationAndOp(out, exec, location, it, "loop_hint");
1319             break;
1320         }
1321         case op_watchdog: {
1322             printLocationAndOp(out, exec, location, it, "watchdog");
1323             break;
1324         }
1325         case op_log_shadow_chicken_prologue: {
1326             printLocationAndOp(out, exec, location, it, "log_shadow_chicken_prologue");
1327             break;
1328         }
1329         case op_log_shadow_chicken_tail: {
1330             printLocationAndOp(out, exec, location, it, "log_shadow_chicken_tail");
1331             break;
1332         }
1333         case op_switch_imm: {
1334             int tableIndex = (++it)->u.operand;
1335             int defaultTarget = (++it)->u.operand;
1336             int scrutineeRegister = (++it)->u.operand;
1337             printLocationAndOp(out, exec, location, it, "switch_imm");
1338             out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data());
1339             break;
1340         }
1341         case op_switch_char: {
1342             int tableIndex = (++it)->u.operand;
1343             int defaultTarget = (++it)->u.operand;
1344             int scrutineeRegister = (++it)->u.operand;
1345             printLocationAndOp(out, exec, location, it, "switch_char");
1346             out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data());
1347             break;
1348         }
1349         case op_switch_string: {
1350             int tableIndex = (++it)->u.operand;
1351             int defaultTarget = (++it)->u.operand;
1352             int scrutineeRegister = (++it)->u.operand;
1353             printLocationAndOp(out, exec, location, it, "switch_string");
1354             out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data());
1355             break;
1356         }
1357         case op_new_func: {
1358             int r0 = (++it)->u.operand;
1359             int r1 = (++it)->u.operand;
1360             int f0 = (++it)->u.operand;
1361             printLocationAndOp(out, exec, location, it, "new_func");
1362             out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
1363             break;
1364         }
1365         case op_new_generator_func: {
1366             int r0 = (++it)->u.operand;
1367             int r1 = (++it)->u.operand;
1368             int f0 = (++it)->u.operand;
1369             printLocationAndOp(out, exec, location, it, "new_generator_func");
1370             out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
1371             break;
1372         }
1373         case op_new_arrow_func_exp: {
1374             int r0 = (++it)->u.operand;
1375             int r1 = (++it)->u.operand;
1376             int f0 = (++it)->u.operand;
1377             printLocationAndOp(out, exec, location, it, "op_new_arrow_func_exp");
1378             out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
1379             break;
1380         }
1381         case op_new_func_exp: {
1382             int r0 = (++it)->u.operand;
1383             int r1 = (++it)->u.operand;
1384             int f0 = (++it)->u.operand;
1385             printLocationAndOp(out, exec, location, it, "new_func_exp");
1386             out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
1387             break;
1388         }
1389         case op_new_generator_func_exp: {
1390             int r0 = (++it)->u.operand;
1391             int r1 = (++it)->u.operand;
1392             int f0 = (++it)->u.operand;
1393             printLocationAndOp(out, exec, location, it, "new_generator_func_exp");
1394             out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
1395             break;
1396         }
1397         case op_set_function_name: {
1398             int funcReg = (++it)->u.operand;
1399             int nameReg = (++it)->u.operand;
1400             printLocationAndOp(out, exec, location, it, "set_function_name");
1401             out.printf("%s, %s", registerName(funcReg).data(), registerName(nameReg).data());
1402             break;
1403         }
1404         case op_call: {
1405             printCallOp(out, exec, location, it, "call", DumpCaches, hasPrintedProfiling, callLinkInfos);
1406             break;
1407         }
1408         case op_tail_call: {
1409             printCallOp(out, exec, location, it, "tail_call", DumpCaches, hasPrintedProfiling, callLinkInfos);
1410             break;
1411         }
1412         case op_call_eval: {
1413             printCallOp(out, exec, location, it, "call_eval", DontDumpCaches, hasPrintedProfiling, callLinkInfos);
1414             break;
1415         }
1416             
1417         case op_construct_varargs:
1418         case op_call_varargs:
1419         case op_tail_call_varargs: {
1420             int result = (++it)->u.operand;
1421             int callee = (++it)->u.operand;
1422             int thisValue = (++it)->u.operand;
1423             int arguments = (++it)->u.operand;
1424             int firstFreeRegister = (++it)->u.operand;
1425             int varArgOffset = (++it)->u.operand;
1426             ++it;
1427             printLocationAndOp(out, exec, location, it, opcode == op_call_varargs ? "call_varargs" : opcode == op_construct_varargs ? "construct_varargs" : "tail_call_varargs");
1428             out.printf("%s, %s, %s, %s, %d, %d", registerName(result).data(), registerName(callee).data(), registerName(thisValue).data(), registerName(arguments).data(), firstFreeRegister, varArgOffset);
1429             dumpValueProfiling(out, it, hasPrintedProfiling);
1430             break;
1431         }
1432
1433         case op_ret: {
1434             int r0 = (++it)->u.operand;
1435             printLocationOpAndRegisterOperand(out, exec, location, it, "ret", r0);
1436             break;
1437         }
1438         case op_construct: {
1439             printCallOp(out, exec, location, it, "construct", DumpCaches, hasPrintedProfiling, callLinkInfos);
1440             break;
1441         }
1442         case op_strcat: {
1443             int r0 = (++it)->u.operand;
1444             int r1 = (++it)->u.operand;
1445             int count = (++it)->u.operand;
1446             printLocationAndOp(out, exec, location, it, "strcat");
1447             out.printf("%s, %s, %d", registerName(r0).data(), registerName(r1).data(), count);
1448             break;
1449         }
1450         case op_to_primitive: {
1451             int r0 = (++it)->u.operand;
1452             int r1 = (++it)->u.operand;
1453             printLocationAndOp(out, exec, location, it, "to_primitive");
1454             out.printf("%s, %s", registerName(r0).data(), registerName(r1).data());
1455             break;
1456         }
1457         case op_get_enumerable_length: {
1458             int dst = it[1].u.operand;
1459             int base = it[2].u.operand;
1460             printLocationAndOp(out, exec, location, it, "op_get_enumerable_length");
1461             out.printf("%s, %s", registerName(dst).data(), registerName(base).data());
1462             it += OPCODE_LENGTH(op_get_enumerable_length) - 1;
1463             break;
1464         }
1465         case op_has_indexed_property: {
1466             int dst = it[1].u.operand;
1467             int base = it[2].u.operand;
1468             int propertyName = it[3].u.operand;
1469             ArrayProfile* arrayProfile = it[4].u.arrayProfile;
1470             printLocationAndOp(out, exec, location, it, "op_has_indexed_property");
1471             out.printf("%s, %s, %s, %p", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data(), arrayProfile);
1472             it += OPCODE_LENGTH(op_has_indexed_property) - 1;
1473             break;
1474         }
1475         case op_has_structure_property: {
1476             int dst = it[1].u.operand;
1477             int base = it[2].u.operand;
1478             int propertyName = it[3].u.operand;
1479             int enumerator = it[4].u.operand;
1480             printLocationAndOp(out, exec, location, it, "op_has_structure_property");
1481             out.printf("%s, %s, %s, %s", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data(), registerName(enumerator).data());
1482             it += OPCODE_LENGTH(op_has_structure_property) - 1;
1483             break;
1484         }
1485         case op_has_generic_property: {
1486             int dst = it[1].u.operand;
1487             int base = it[2].u.operand;
1488             int propertyName = it[3].u.operand;
1489             printLocationAndOp(out, exec, location, it, "op_has_generic_property");
1490             out.printf("%s, %s, %s", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data());
1491             it += OPCODE_LENGTH(op_has_generic_property) - 1;
1492             break;
1493         }
1494         case op_get_direct_pname: {
1495             int dst = it[1].u.operand;
1496             int base = it[2].u.operand;
1497             int propertyName = it[3].u.operand;
1498             int index = it[4].u.operand;
1499             int enumerator = it[5].u.operand;
1500             ValueProfile* profile = it[6].u.profile;
1501             printLocationAndOp(out, exec, location, it, "op_get_direct_pname");
1502             out.printf("%s, %s, %s, %s, %s, %p", registerName(dst).data(), registerName(base).data(), registerName(propertyName).data(), registerName(index).data(), registerName(enumerator).data(), profile);
1503             it += OPCODE_LENGTH(op_get_direct_pname) - 1;
1504             break;
1505
1506         }
1507         case op_get_property_enumerator: {
1508             int dst = it[1].u.operand;
1509             int base = it[2].u.operand;
1510             printLocationAndOp(out, exec, location, it, "op_get_property_enumerator");
1511             out.printf("%s, %s", registerName(dst).data(), registerName(base).data());
1512             it += OPCODE_LENGTH(op_get_property_enumerator) - 1;
1513             break;
1514         }
1515         case op_enumerator_structure_pname: {
1516             int dst = it[1].u.operand;
1517             int enumerator = it[2].u.operand;
1518             int index = it[3].u.operand;
1519             printLocationAndOp(out, exec, location, it, "op_enumerator_structure_pname");
1520             out.printf("%s, %s, %s", registerName(dst).data(), registerName(enumerator).data(), registerName(index).data());
1521             it += OPCODE_LENGTH(op_enumerator_structure_pname) - 1;
1522             break;
1523         }
1524         case op_enumerator_generic_pname: {
1525             int dst = it[1].u.operand;
1526             int enumerator = it[2].u.operand;
1527             int index = it[3].u.operand;
1528             printLocationAndOp(out, exec, location, it, "op_enumerator_generic_pname");
1529             out.printf("%s, %s, %s", registerName(dst).data(), registerName(enumerator).data(), registerName(index).data());
1530             it += OPCODE_LENGTH(op_enumerator_generic_pname) - 1;
1531             break;
1532         }
1533         case op_to_index_string: {
1534             int dst = it[1].u.operand;
1535             int index = it[2].u.operand;
1536             printLocationAndOp(out, exec, location, it, "op_to_index_string");
1537             out.printf("%s, %s", registerName(dst).data(), registerName(index).data());
1538             it += OPCODE_LENGTH(op_to_index_string) - 1;
1539             break;
1540         }
1541         case op_push_with_scope: {
1542             int dst = (++it)->u.operand;
1543             int newScope = (++it)->u.operand;
1544             int currentScope = (++it)->u.operand;
1545             printLocationAndOp(out, exec, location, it, "push_with_scope");
1546             out.printf("%s, %s, %s", registerName(dst).data(), registerName(newScope).data(), registerName(currentScope).data());
1547             break;
1548         }
1549         case op_get_parent_scope: {
1550             int dst = (++it)->u.operand;
1551             int parentScope = (++it)->u.operand;
1552             printLocationAndOp(out, exec, location, it, "get_parent_scope");
1553             out.printf("%s, %s", registerName(dst).data(), registerName(parentScope).data());
1554             break;
1555         }
1556         case op_create_lexical_environment: {
1557             int dst = (++it)->u.operand;
1558             int scope = (++it)->u.operand;
1559             int symbolTable = (++it)->u.operand;
1560             int initialValue = (++it)->u.operand;
1561             printLocationAndOp(out, exec, location, it, "create_lexical_environment");
1562             out.printf("%s, %s, %s, %s", 
1563                 registerName(dst).data(), registerName(scope).data(), registerName(symbolTable).data(), registerName(initialValue).data());
1564             break;
1565         }
1566         case op_catch: {
1567             int r0 = (++it)->u.operand;
1568             int r1 = (++it)->u.operand;
1569             printLocationAndOp(out, exec, location, it, "catch");
1570             out.printf("%s, %s", registerName(r0).data(), registerName(r1).data());
1571             break;
1572         }
1573         case op_throw: {
1574             int r0 = (++it)->u.operand;
1575             printLocationOpAndRegisterOperand(out, exec, location, it, "throw", r0);
1576             break;
1577         }
1578         case op_throw_static_error: {
1579             int k0 = (++it)->u.operand;
1580             int k1 = (++it)->u.operand;
1581             printLocationAndOp(out, exec, location, it, "throw_static_error");
1582             out.printf("%s, %s", constantName(k0).data(), k1 ? "true" : "false");
1583             break;
1584         }
1585         case op_debug: {
1586             int debugHookID = (++it)->u.operand;
1587             int hasBreakpointFlag = (++it)->u.operand;
1588             printLocationAndOp(out, exec, location, it, "debug");
1589             out.printf("%s, %d", debugHookName(debugHookID), hasBreakpointFlag);
1590             break;
1591         }
1592         case op_save: {
1593             int generator = (++it)->u.operand;
1594             unsigned liveCalleeLocalsIndex = (++it)->u.unsignedValue;
1595             int offset = (++it)->u.operand;
1596             const FastBitVector& liveness = m_rareData->m_liveCalleeLocalsAtYield[liveCalleeLocalsIndex];
1597             printLocationAndOp(out, exec, location, it, "save");
1598             out.printf("%s, ", registerName(generator).data());
1599             liveness.dump(out);
1600             out.printf("(@live%1u), %d(->%d)", liveCalleeLocalsIndex, offset, location + offset);
1601             break;
1602         }
1603         case op_resume: {
1604             int generator = (++it)->u.operand;
1605             unsigned liveCalleeLocalsIndex = (++it)->u.unsignedValue;
1606             const FastBitVector& liveness = m_rareData->m_liveCalleeLocalsAtYield[liveCalleeLocalsIndex];
1607             printLocationAndOp(out, exec, location, it, "resume");
1608             out.printf("%s, ", registerName(generator).data());
1609             liveness.dump(out);
1610             out.printf("(@live%1u)", liveCalleeLocalsIndex);
1611             break;
1612         }
1613         case op_assert: {
1614             int condition = (++it)->u.operand;
1615             int line = (++it)->u.operand;
1616             printLocationAndOp(out, exec, location, it, "assert");
1617             out.printf("%s, %d", registerName(condition).data(), line);
1618             break;
1619         }
1620         case op_profile_will_call: {
1621             int function = (++it)->u.operand;
1622             printLocationOpAndRegisterOperand(out, exec, location, it, "profile_will_call", function);
1623             break;
1624         }
1625         case op_profile_did_call: {
1626             int function = (++it)->u.operand;
1627             printLocationOpAndRegisterOperand(out, exec, location, it, "profile_did_call", function);
1628             break;
1629         }
1630         case op_end: {
1631             int r0 = (++it)->u.operand;
1632             printLocationOpAndRegisterOperand(out, exec, location, it, "end", r0);
1633             break;
1634         }
1635         case op_resolve_scope: {
1636             int r0 = (++it)->u.operand;
1637             int scope = (++it)->u.operand;
1638             int id0 = (++it)->u.operand;
1639             ResolveType resolveType = static_cast<ResolveType>((++it)->u.operand);
1640             int depth = (++it)->u.operand;
1641             void* pointer = (++it)->u.pointer;
1642             printLocationAndOp(out, exec, location, it, "resolve_scope");
1643             out.printf("%s, %s, %s, <%s>, %d, %p", registerName(r0).data(), registerName(scope).data(), idName(id0, identifier(id0)).data(), resolveTypeName(resolveType), depth, pointer);
1644             break;
1645         }
1646         case op_get_from_scope: {
1647             int r0 = (++it)->u.operand;
1648             int r1 = (++it)->u.operand;
1649             int id0 = (++it)->u.operand;
1650             GetPutInfo getPutInfo = GetPutInfo((++it)->u.operand);
1651             ++it; // Structure
1652             int operand = (++it)->u.operand; // Operand
1653             printLocationAndOp(out, exec, location, it, "get_from_scope");
1654             out.print(registerName(r0), ", ", registerName(r1));
1655             if (static_cast<unsigned>(id0) == UINT_MAX)
1656                 out.print(", anonymous");
1657             else
1658                 out.print(", ", idName(id0, identifier(id0)));
1659             out.print(", ", getPutInfo.operand(), "<", resolveModeName(getPutInfo.resolveMode()), "|", resolveTypeName(getPutInfo.resolveType()), "|", initializationModeName(getPutInfo.initializationMode()), ">, ", operand);
1660             dumpValueProfiling(out, it, hasPrintedProfiling);
1661             break;
1662         }
1663         case op_put_to_scope: {
1664             int r0 = (++it)->u.operand;
1665             int id0 = (++it)->u.operand;
1666             int r1 = (++it)->u.operand;
1667             GetPutInfo getPutInfo = GetPutInfo((++it)->u.operand);
1668             ++it; // Structure
1669             int operand = (++it)->u.operand; // Operand
1670             printLocationAndOp(out, exec, location, it, "put_to_scope");
1671             out.print(registerName(r0));
1672             if (static_cast<unsigned>(id0) == UINT_MAX)
1673                 out.print(", anonymous");
1674             else
1675                 out.print(", ", idName(id0, identifier(id0)));
1676             out.print(", ", registerName(r1), ", ", getPutInfo.operand(), "<", resolveModeName(getPutInfo.resolveMode()), "|", resolveTypeName(getPutInfo.resolveType()), "|", initializationModeName(getPutInfo.initializationMode()), ">, <structure>, ", operand);
1677             break;
1678         }
1679         case op_get_from_arguments: {
1680             int r0 = (++it)->u.operand;
1681             int r1 = (++it)->u.operand;
1682             int offset = (++it)->u.operand;
1683             printLocationAndOp(out, exec, location, it, "get_from_arguments");
1684             out.printf("%s, %s, %d", registerName(r0).data(), registerName(r1).data(), offset);
1685             dumpValueProfiling(out, it, hasPrintedProfiling);
1686             break;
1687         }
1688         case op_put_to_arguments: {
1689             int r0 = (++it)->u.operand;
1690             int offset = (++it)->u.operand;
1691             int r1 = (++it)->u.operand;
1692             printLocationAndOp(out, exec, location, it, "put_to_arguments");
1693             out.printf("%s, %d, %s", registerName(r0).data(), offset, registerName(r1).data());
1694             break;
1695         }
1696         default:
1697             RELEASE_ASSERT_NOT_REACHED();
1698     }
1699
1700     dumpRareCaseProfile(out, "rare case: ", rareCaseProfileForBytecodeOffset(location), hasPrintedProfiling);
1701     dumpResultProfile(out, resultProfileForBytecodeOffset(location), hasPrintedProfiling);
1702     
1703 #if ENABLE(DFG_JIT)
1704     Vector<DFG::FrequentExitSite> exitSites = exitProfile().exitSitesFor(location);
1705     if (!exitSites.isEmpty()) {
1706         out.print(" !! frequent exits: ");
1707         CommaPrinter comma;
1708         for (unsigned i = 0; i < exitSites.size(); ++i)
1709             out.print(comma, exitSites[i].kind(), " ", exitSites[i].jitType());
1710     }
1711 #else // ENABLE(DFG_JIT)
1712     UNUSED_PARAM(location);
1713 #endif // ENABLE(DFG_JIT)
1714     out.print("\n");
1715 }
1716
1717 void CodeBlock::dumpBytecode(
1718     PrintStream& out, unsigned bytecodeOffset,
1719     const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos)
1720 {
1721     ExecState* exec = m_globalObject->globalExec();
1722     const Instruction* it = instructions().begin() + bytecodeOffset;
1723     dumpBytecode(out, exec, instructions().begin(), it, stubInfos, callLinkInfos);
1724 }
1725
1726 #define FOR_EACH_MEMBER_VECTOR(macro) \
1727     macro(instructions) \
1728     macro(callLinkInfos) \
1729     macro(linkedCallerList) \
1730     macro(identifiers) \
1731     macro(functionExpressions) \
1732     macro(constantRegisters)
1733
1734 #define FOR_EACH_MEMBER_VECTOR_RARE_DATA(macro) \
1735     macro(regexps) \
1736     macro(functions) \
1737     macro(exceptionHandlers) \
1738     macro(switchJumpTables) \
1739     macro(stringSwitchJumpTables) \
1740     macro(evalCodeCache) \
1741     macro(expressionInfo) \
1742     macro(lineInfo) \
1743     macro(callReturnIndexVector)
1744
1745 template<typename T>
1746 static size_t sizeInBytes(const Vector<T>& vector)
1747 {
1748     return vector.capacity() * sizeof(T);
1749 }
1750
1751 namespace {
1752
1753 class PutToScopeFireDetail : public FireDetail {
1754 public:
1755     PutToScopeFireDetail(CodeBlock* codeBlock, const Identifier& ident)
1756         : m_codeBlock(codeBlock)
1757         , m_ident(ident)
1758     {
1759     }
1760     
1761     void dump(PrintStream& out) const override
1762     {
1763         out.print("Linking put_to_scope in ", FunctionExecutableDump(jsCast<FunctionExecutable*>(m_codeBlock->ownerExecutable())), " for ", m_ident);
1764     }
1765     
1766 private:
1767     CodeBlock* m_codeBlock;
1768     const Identifier& m_ident;
1769 };
1770
1771 } // anonymous namespace
1772
1773 CodeBlock::CodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, CodeBlock& other)
1774     : JSCell(*vm, structure)
1775     , m_globalObject(other.m_globalObject)
1776     , m_numCalleeLocals(other.m_numCalleeLocals)
1777     , m_numVars(other.m_numVars)
1778     , m_shouldAlwaysBeInlined(true)
1779 #if ENABLE(JIT)
1780     , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
1781 #endif
1782     , m_didFailFTLCompilation(false)
1783     , m_hasBeenCompiledWithFTL(false)
1784     , m_isConstructor(other.m_isConstructor)
1785     , m_isStrictMode(other.m_isStrictMode)
1786     , m_codeType(other.m_codeType)
1787     , m_unlinkedCode(*other.m_vm, this, other.m_unlinkedCode.get())
1788     , m_hasDebuggerStatement(false)
1789     , m_steppingMode(SteppingModeDisabled)
1790     , m_numBreakpoints(0)
1791     , m_ownerExecutable(*other.m_vm, this, other.m_ownerExecutable.get())
1792     , m_vm(other.m_vm)
1793     , m_instructions(other.m_instructions)
1794     , m_thisRegister(other.m_thisRegister)
1795     , m_scopeRegister(other.m_scopeRegister)
1796     , m_hash(other.m_hash)
1797     , m_source(other.m_source)
1798     , m_sourceOffset(other.m_sourceOffset)
1799     , m_firstLineColumnOffset(other.m_firstLineColumnOffset)
1800     , m_constantRegisters(other.m_constantRegisters)
1801     , m_constantsSourceCodeRepresentation(other.m_constantsSourceCodeRepresentation)
1802     , m_functionDecls(other.m_functionDecls)
1803     , m_functionExprs(other.m_functionExprs)
1804     , m_osrExitCounter(0)
1805     , m_optimizationDelayCounter(0)
1806     , m_reoptimizationRetryCounter(0)
1807     , m_creationTime(std::chrono::steady_clock::now())
1808 {
1809     m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed);
1810
1811     ASSERT(heap()->isDeferred());
1812     ASSERT(m_scopeRegister.isLocal());
1813
1814     setNumParameters(other.numParameters());
1815 }
1816
1817 void CodeBlock::finishCreation(VM& vm, CopyParsedBlockTag, CodeBlock& other)
1818 {
1819     Base::finishCreation(vm);
1820
1821     optimizeAfterWarmUp();
1822     jitAfterWarmUp();
1823
1824     if (other.m_rareData) {
1825         createRareDataIfNecessary();
1826         
1827         m_rareData->m_exceptionHandlers = other.m_rareData->m_exceptionHandlers;
1828         m_rareData->m_constantBuffers = other.m_rareData->m_constantBuffers;
1829         m_rareData->m_switchJumpTables = other.m_rareData->m_switchJumpTables;
1830         m_rareData->m_stringSwitchJumpTables = other.m_rareData->m_stringSwitchJumpTables;
1831         m_rareData->m_liveCalleeLocalsAtYield = other.m_rareData->m_liveCalleeLocalsAtYield;
1832     }
1833     
1834     heap()->m_codeBlocks.add(this);
1835 }
1836
1837 CodeBlock::CodeBlock(VM* vm, Structure* structure, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock,
1838     JSScope* scope, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset)
1839     : JSCell(*vm, structure)
1840     , m_globalObject(scope->globalObject()->vm(), this, scope->globalObject())
1841     , m_numCalleeLocals(unlinkedCodeBlock->m_numCalleeLocals)
1842     , m_numVars(unlinkedCodeBlock->m_numVars)
1843     , m_shouldAlwaysBeInlined(true)
1844 #if ENABLE(JIT)
1845     , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
1846 #endif
1847     , m_didFailFTLCompilation(false)
1848     , m_hasBeenCompiledWithFTL(false)
1849     , m_isConstructor(unlinkedCodeBlock->isConstructor())
1850     , m_isStrictMode(unlinkedCodeBlock->isStrictMode())
1851     , m_codeType(unlinkedCodeBlock->codeType())
1852     , m_unlinkedCode(m_globalObject->vm(), this, unlinkedCodeBlock)
1853     , m_hasDebuggerStatement(false)
1854     , m_steppingMode(SteppingModeDisabled)
1855     , m_numBreakpoints(0)
1856     , m_ownerExecutable(m_globalObject->vm(), this, ownerExecutable)
1857     , m_vm(unlinkedCodeBlock->vm())
1858     , m_thisRegister(unlinkedCodeBlock->thisRegister())
1859     , m_scopeRegister(unlinkedCodeBlock->scopeRegister())
1860     , m_source(sourceProvider)
1861     , m_sourceOffset(sourceOffset)
1862     , m_firstLineColumnOffset(firstLineColumnOffset)
1863     , m_osrExitCounter(0)
1864     , m_optimizationDelayCounter(0)
1865     , m_reoptimizationRetryCounter(0)
1866     , m_creationTime(std::chrono::steady_clock::now())
1867 {
1868     m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed);
1869
1870     ASSERT(heap()->isDeferred());
1871     ASSERT(m_scopeRegister.isLocal());
1872
1873     ASSERT(m_source);
1874     setNumParameters(unlinkedCodeBlock->numParameters());
1875 }
1876
1877 void CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock,
1878     JSScope* scope)
1879 {
1880     Base::finishCreation(vm);
1881
1882     if (vm.typeProfiler() || vm.controlFlowProfiler())
1883         vm.functionHasExecutedCache()->removeUnexecutedRange(ownerExecutable->sourceID(), ownerExecutable->typeProfilingStartOffset(), ownerExecutable->typeProfilingEndOffset());
1884
1885     setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation());
1886     if (unlinkedCodeBlock->usesGlobalObject())
1887         m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(*m_vm, this, m_globalObject.get());
1888
1889     for (unsigned i = 0; i < LinkTimeConstantCount; i++) {
1890         LinkTimeConstant type = static_cast<LinkTimeConstant>(i);
1891         if (unsigned registerIndex = unlinkedCodeBlock->registerIndexForLinkTimeConstant(type))
1892             m_constantRegisters[registerIndex].set(*m_vm, this, m_globalObject->jsCellForLinkTimeConstant(type));
1893     }
1894
1895     // We already have the cloned symbol table for the module environment since we need to instantiate
1896     // the module environments before linking the code block. We replace the stored symbol table with the already cloned one.
1897     if (UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock = jsDynamicCast<UnlinkedModuleProgramCodeBlock*>(unlinkedCodeBlock)) {
1898         SymbolTable* clonedSymbolTable = jsCast<ModuleProgramExecutable*>(ownerExecutable)->moduleEnvironmentSymbolTable();
1899         if (m_vm->typeProfiler()) {
1900             ConcurrentJITLocker locker(clonedSymbolTable->m_lock);
1901             clonedSymbolTable->prepareForTypeProfiling(locker);
1902         }
1903         replaceConstant(unlinkedModuleProgramCodeBlock->moduleEnvironmentSymbolTableConstantRegisterOffset(), clonedSymbolTable);
1904     }
1905
1906     bool shouldUpdateFunctionHasExecutedCache = vm.typeProfiler() || vm.controlFlowProfiler();
1907     m_functionDecls = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionDecls());
1908     for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) {
1909         UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
1910         if (shouldUpdateFunctionHasExecutedCache)
1911             vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
1912         m_functionDecls[i].set(*m_vm, this, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
1913     }
1914
1915     m_functionExprs = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionExprs());
1916     for (size_t count = unlinkedCodeBlock->numberOfFunctionExprs(), i = 0; i < count; ++i) {
1917         UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i);
1918         if (shouldUpdateFunctionHasExecutedCache)
1919             vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->typeProfilingStartOffset(), unlinkedExecutable->typeProfilingEndOffset());
1920         m_functionExprs[i].set(*m_vm, this, unlinkedExecutable->link(*m_vm, ownerExecutable->source()));
1921     }
1922
1923     if (unlinkedCodeBlock->hasRareData()) {
1924         createRareDataIfNecessary();
1925         if (size_t count = unlinkedCodeBlock->constantBufferCount()) {
1926             m_rareData->m_constantBuffers.grow(count);
1927             for (size_t i = 0; i < count; i++) {
1928                 const UnlinkedCodeBlock::ConstantBuffer& buffer = unlinkedCodeBlock->constantBuffer(i);
1929                 m_rareData->m_constantBuffers[i] = buffer;
1930             }
1931         }
1932         if (size_t count = unlinkedCodeBlock->numberOfExceptionHandlers()) {
1933             m_rareData->m_exceptionHandlers.resizeToFit(count);
1934             for (size_t i = 0; i < count; i++) {
1935                 const UnlinkedHandlerInfo& unlinkedHandler = unlinkedCodeBlock->exceptionHandler(i);
1936                 HandlerInfo& handler = m_rareData->m_exceptionHandlers[i];
1937 #if ENABLE(JIT)
1938                 handler.initialize(unlinkedHandler, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(op_catch))));
1939 #else
1940                 handler.initialize(unlinkedHandler);
1941 #endif
1942             }
1943         }
1944
1945         if (size_t count = unlinkedCodeBlock->numberOfStringSwitchJumpTables()) {
1946             m_rareData->m_stringSwitchJumpTables.grow(count);
1947             for (size_t i = 0; i < count; i++) {
1948                 UnlinkedStringJumpTable::StringOffsetTable::iterator ptr = unlinkedCodeBlock->stringSwitchJumpTable(i).offsetTable.begin();
1949                 UnlinkedStringJumpTable::StringOffsetTable::iterator end = unlinkedCodeBlock->stringSwitchJumpTable(i).offsetTable.end();
1950                 for (; ptr != end; ++ptr) {
1951                     OffsetLocation offset;
1952                     offset.branchOffset = ptr->value;
1953                     m_rareData->m_stringSwitchJumpTables[i].offsetTable.add(ptr->key, offset);
1954                 }
1955             }
1956         }
1957
1958         if (size_t count = unlinkedCodeBlock->numberOfSwitchJumpTables()) {
1959             m_rareData->m_switchJumpTables.grow(count);
1960             for (size_t i = 0; i < count; i++) {
1961                 UnlinkedSimpleJumpTable& sourceTable = unlinkedCodeBlock->switchJumpTable(i);
1962                 SimpleJumpTable& destTable = m_rareData->m_switchJumpTables[i];
1963                 destTable.branchOffsets = sourceTable.branchOffsets;
1964                 destTable.min = sourceTable.min;
1965             }
1966         }
1967     }
1968
1969     // Allocate metadata buffers for the bytecode
1970     if (size_t size = unlinkedCodeBlock->numberOfLLintCallLinkInfos())
1971         m_llintCallLinkInfos = RefCountedArray<LLIntCallLinkInfo>(size);
1972     if (size_t size = unlinkedCodeBlock->numberOfArrayProfiles())
1973         m_arrayProfiles.grow(size);
1974     if (size_t size = unlinkedCodeBlock->numberOfArrayAllocationProfiles())
1975         m_arrayAllocationProfiles = RefCountedArray<ArrayAllocationProfile>(size);
1976     if (size_t size = unlinkedCodeBlock->numberOfValueProfiles())
1977         m_valueProfiles = RefCountedArray<ValueProfile>(size);
1978     if (size_t size = unlinkedCodeBlock->numberOfObjectAllocationProfiles())
1979         m_objectAllocationProfiles = RefCountedArray<ObjectAllocationProfile>(size);
1980
1981 #if ENABLE(JIT)
1982     setCalleeSaveRegisters(RegisterSet::llintBaselineCalleeSaveRegisters());
1983 #endif
1984
1985     // Copy and translate the UnlinkedInstructions
1986     unsigned instructionCount = unlinkedCodeBlock->instructions().count();
1987     UnlinkedInstructionStream::Reader instructionReader(unlinkedCodeBlock->instructions());
1988
1989     // Bookkeep the strongly referenced module environments.
1990     HashSet<JSModuleEnvironment*> stronglyReferencedModuleEnvironments;
1991
1992     // Bookkeep the merge point bytecode offsets.
1993     Vector<size_t> mergePointBytecodeOffsets;
1994
1995     RefCountedArray<Instruction> instructions(instructionCount);
1996
1997     for (unsigned i = 0; !instructionReader.atEnd(); ) {
1998         const UnlinkedInstruction* pc = instructionReader.next();
1999
2000         unsigned opLength = opcodeLength(pc[0].u.opcode);
2001
2002         instructions[i] = vm.interpreter->getOpcode(pc[0].u.opcode);
2003         for (size_t j = 1; j < opLength; ++j) {
2004             if (sizeof(int32_t) != sizeof(intptr_t))
2005                 instructions[i + j].u.pointer = 0;
2006             instructions[i + j].u.operand = pc[j].u.operand;
2007         }
2008         switch (pc[0].u.opcode) {
2009         case op_has_indexed_property: {
2010             int arrayProfileIndex = pc[opLength - 1].u.operand;
2011             m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
2012
2013             instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex];
2014             break;
2015         }
2016         case op_call_varargs:
2017         case op_tail_call_varargs:
2018         case op_construct_varargs:
2019         case op_get_by_val: {
2020             int arrayProfileIndex = pc[opLength - 2].u.operand;
2021             m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
2022
2023             instructions[i + opLength - 2] = &m_arrayProfiles[arrayProfileIndex];
2024             FALLTHROUGH;
2025         }
2026         case op_get_direct_pname:
2027         case op_get_by_id:
2028         case op_get_from_arguments: {
2029             ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
2030             ASSERT(profile->m_bytecodeOffset == -1);
2031             profile->m_bytecodeOffset = i;
2032             instructions[i + opLength - 1] = profile;
2033             break;
2034         }
2035         case op_put_by_val: {
2036             int arrayProfileIndex = pc[opLength - 1].u.operand;
2037             m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
2038             instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex];
2039             break;
2040         }
2041         case op_put_by_val_direct: {
2042             int arrayProfileIndex = pc[opLength - 1].u.operand;
2043             m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
2044             instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex];
2045             break;
2046         }
2047
2048         case op_new_array:
2049         case op_new_array_buffer:
2050         case op_new_array_with_size: {
2051             int arrayAllocationProfileIndex = pc[opLength - 1].u.operand;
2052             instructions[i + opLength - 1] = &m_arrayAllocationProfiles[arrayAllocationProfileIndex];
2053             break;
2054         }
2055         case op_new_object: {
2056             int objectAllocationProfileIndex = pc[opLength - 1].u.operand;
2057             ObjectAllocationProfile* objectAllocationProfile = &m_objectAllocationProfiles[objectAllocationProfileIndex];
2058             int inferredInlineCapacity = pc[opLength - 2].u.operand;
2059
2060             instructions[i + opLength - 1] = objectAllocationProfile;
2061             objectAllocationProfile->initialize(vm,
2062                 this, m_globalObject->objectPrototype(), inferredInlineCapacity);
2063             break;
2064         }
2065
2066         case op_call:
2067         case op_tail_call:
2068         case op_call_eval: {
2069             ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
2070             ASSERT(profile->m_bytecodeOffset == -1);
2071             profile->m_bytecodeOffset = i;
2072             instructions[i + opLength - 1] = profile;
2073             int arrayProfileIndex = pc[opLength - 2].u.operand;
2074             m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
2075             instructions[i + opLength - 2] = &m_arrayProfiles[arrayProfileIndex];
2076             instructions[i + 5] = &m_llintCallLinkInfos[pc[5].u.operand];
2077             break;
2078         }
2079         case op_construct: {
2080             instructions[i + 5] = &m_llintCallLinkInfos[pc[5].u.operand];
2081             ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
2082             ASSERT(profile->m_bytecodeOffset == -1);
2083             profile->m_bytecodeOffset = i;
2084             instructions[i + opLength - 1] = profile;
2085             break;
2086         }
2087         case op_get_array_length:
2088             CRASH();
2089
2090         case op_resolve_scope: {
2091             const Identifier& ident = identifier(pc[3].u.operand);
2092             ResolveType type = static_cast<ResolveType>(pc[4].u.operand);
2093             RELEASE_ASSERT(type != LocalClosureVar);
2094             int localScopeDepth = pc[5].u.operand;
2095
2096             ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, type, InitializationMode::NotInitialization);
2097             instructions[i + 4].u.operand = op.type;
2098             instructions[i + 5].u.operand = op.depth;
2099             if (op.lexicalEnvironment) {
2100                 if (op.type == ModuleVar) {
2101                     // Keep the linked module environment strongly referenced.
2102                     if (stronglyReferencedModuleEnvironments.add(jsCast<JSModuleEnvironment*>(op.lexicalEnvironment)).isNewEntry)
2103                         addConstant(op.lexicalEnvironment);
2104                     instructions[i + 6].u.jsCell.set(vm, this, op.lexicalEnvironment);
2105                 } else
2106                     instructions[i + 6].u.symbolTable.set(vm, this, op.lexicalEnvironment->symbolTable());
2107             } else if (JSScope* constantScope = JSScope::constantScopeForCodeBlock(op.type, this))
2108                 instructions[i + 6].u.jsCell.set(vm, this, constantScope);
2109             else
2110                 instructions[i + 6].u.pointer = nullptr;
2111             break;
2112         }
2113
2114         case op_get_from_scope: {
2115             ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
2116             ASSERT(profile->m_bytecodeOffset == -1);
2117             profile->m_bytecodeOffset = i;
2118             instructions[i + opLength - 1] = profile;
2119
2120             // get_from_scope dst, scope, id, GetPutInfo, Structure, Operand
2121
2122             int localScopeDepth = pc[5].u.operand;
2123             instructions[i + 5].u.pointer = nullptr;
2124
2125             GetPutInfo getPutInfo = GetPutInfo(pc[4].u.operand);
2126             ASSERT(!isInitialization(getPutInfo.initializationMode()));
2127             if (getPutInfo.resolveType() == LocalClosureVar) {
2128                 instructions[i + 4] = GetPutInfo(getPutInfo.resolveMode(), ClosureVar, getPutInfo.initializationMode()).operand();
2129                 break;
2130             }
2131
2132             const Identifier& ident = identifier(pc[3].u.operand);
2133             ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, getPutInfo.resolveType(), InitializationMode::NotInitialization);
2134
2135             instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), op.type, getPutInfo.initializationMode()).operand();
2136             if (op.type == ModuleVar)
2137                 instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), ClosureVar, getPutInfo.initializationMode()).operand();
2138             if (op.type == GlobalVar || op.type == GlobalVarWithVarInjectionChecks || op.type == GlobalLexicalVar || op.type == GlobalLexicalVarWithVarInjectionChecks)
2139                 instructions[i + 5].u.watchpointSet = op.watchpointSet;
2140             else if (op.structure)
2141                 instructions[i + 5].u.structure.set(vm, this, op.structure);
2142             instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand);
2143             break;
2144         }
2145
2146         case op_put_to_scope: {
2147             // put_to_scope scope, id, value, GetPutInfo, Structure, Operand
2148             GetPutInfo getPutInfo = GetPutInfo(pc[4].u.operand);
2149             if (getPutInfo.resolveType() == LocalClosureVar) {
2150                 // Only do watching if the property we're putting to is not anonymous.
2151                 if (static_cast<unsigned>(pc[2].u.operand) != UINT_MAX) {
2152                     int symbolTableIndex = pc[5].u.operand;
2153                     SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex));
2154                     const Identifier& ident = identifier(pc[2].u.operand);
2155                     ConcurrentJITLocker locker(symbolTable->m_lock);
2156                     auto iter = symbolTable->find(locker, ident.impl());
2157                     ASSERT(iter != symbolTable->end(locker));
2158                     iter->value.prepareToWatch();
2159                     instructions[i + 5].u.watchpointSet = iter->value.watchpointSet();
2160                 } else
2161                     instructions[i + 5].u.watchpointSet = nullptr;
2162                 break;
2163             }
2164
2165             const Identifier& ident = identifier(pc[2].u.operand);
2166             int localScopeDepth = pc[5].u.operand;
2167             instructions[i + 5].u.pointer = nullptr;
2168             ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Put, getPutInfo.resolveType(), getPutInfo.initializationMode());
2169
2170             instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), op.type, getPutInfo.initializationMode()).operand();
2171             if (op.type == GlobalVar || op.type == GlobalVarWithVarInjectionChecks || op.type == GlobalLexicalVar || op.type == GlobalLexicalVarWithVarInjectionChecks)
2172                 instructions[i + 5].u.watchpointSet = op.watchpointSet;
2173             else if (op.type == ClosureVar || op.type == ClosureVarWithVarInjectionChecks) {
2174                 if (op.watchpointSet)
2175                     op.watchpointSet->invalidate(PutToScopeFireDetail(this, ident));
2176             } else if (op.structure)
2177                 instructions[i + 5].u.structure.set(vm, this, op.structure);
2178             instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand);
2179
2180             break;
2181         }
2182
2183         case op_profile_type: {
2184             RELEASE_ASSERT(vm.typeProfiler());
2185             // The format of this instruction is: op_profile_type regToProfile, TypeLocation*, flag, identifier?, resolveType?
2186             size_t instructionOffset = i + opLength - 1;
2187             unsigned divotStart, divotEnd;
2188             GlobalVariableID globalVariableID = 0;
2189             RefPtr<TypeSet> globalTypeSet;
2190             bool shouldAnalyze = m_unlinkedCode->typeProfilerExpressionInfoForBytecodeOffset(instructionOffset, divotStart, divotEnd);
2191             VirtualRegister profileRegister(pc[1].u.operand);
2192             ProfileTypeBytecodeFlag flag = static_cast<ProfileTypeBytecodeFlag>(pc[3].u.operand);
2193             SymbolTable* symbolTable = nullptr;
2194
2195             switch (flag) {
2196             case ProfileTypeBytecodeClosureVar: {
2197                 const Identifier& ident = identifier(pc[4].u.operand);
2198                 int localScopeDepth = pc[2].u.operand;
2199                 ResolveType type = static_cast<ResolveType>(pc[5].u.operand);
2200                 // Even though type profiling may be profiling either a Get or a Put, we can always claim a Get because
2201                 // we're abstractly "read"ing from a JSScope.
2202                 ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, type, InitializationMode::NotInitialization);
2203
2204                 if (op.type == ClosureVar || op.type == ModuleVar)
2205                     symbolTable = op.lexicalEnvironment->symbolTable();
2206                 else if (op.type == GlobalVar)
2207                     symbolTable = m_globalObject.get()->symbolTable();
2208
2209                 UniquedStringImpl* impl = (op.type == ModuleVar) ? op.importedName.get() : ident.impl();
2210                 if (symbolTable) {
2211                     ConcurrentJITLocker locker(symbolTable->m_lock);
2212                     // If our parent scope was created while profiling was disabled, it will not have prepared for profiling yet.
2213                     symbolTable->prepareForTypeProfiling(locker);
2214                     globalVariableID = symbolTable->uniqueIDForVariable(locker, impl, vm);
2215                     globalTypeSet = symbolTable->globalTypeSetForVariable(locker, impl, vm);
2216                 } else
2217                     globalVariableID = TypeProfilerNoGlobalIDExists;
2218
2219                 break;
2220             }
2221             case ProfileTypeBytecodeLocallyResolved: {
2222                 int symbolTableIndex = pc[2].u.operand;
2223                 SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex));
2224                 const Identifier& ident = identifier(pc[4].u.operand);
2225                 ConcurrentJITLocker locker(symbolTable->m_lock);
2226                 // If our parent scope was created while profiling was disabled, it will not have prepared for profiling yet.
2227                 globalVariableID = symbolTable->uniqueIDForVariable(locker, ident.impl(), vm);
2228                 globalTypeSet = symbolTable->globalTypeSetForVariable(locker, ident.impl(), vm);
2229
2230                 break;
2231             }
2232             case ProfileTypeBytecodeDoesNotHaveGlobalID: 
2233             case ProfileTypeBytecodeFunctionArgument: {
2234                 globalVariableID = TypeProfilerNoGlobalIDExists;
2235                 break;
2236             }
2237             case ProfileTypeBytecodeFunctionReturnStatement: {
2238                 RELEASE_ASSERT(ownerExecutable->isFunctionExecutable());
2239                 globalTypeSet = jsCast<FunctionExecutable*>(ownerExecutable)->returnStatementTypeSet();
2240                 globalVariableID = TypeProfilerReturnStatement;
2241                 if (!shouldAnalyze) {
2242                     // Because a return statement can be added implicitly to return undefined at the end of a function,
2243                     // and these nodes don't emit expression ranges because they aren't in the actual source text of
2244                     // the user's program, give the type profiler some range to identify these return statements.
2245                     // Currently, the text offset that is used as identification is "f" in the function keyword
2246                     // and is stored on TypeLocation's m_divotForFunctionOffsetIfReturnStatement member variable.
2247                     divotStart = divotEnd = ownerExecutable->typeProfilingStartOffset();
2248                     shouldAnalyze = true;
2249                 }
2250                 break;
2251             }
2252             }
2253
2254             std::pair<TypeLocation*, bool> locationPair = vm.typeProfiler()->typeLocationCache()->getTypeLocation(globalVariableID,
2255                 ownerExecutable->sourceID(), divotStart, divotEnd, globalTypeSet, &vm);
2256             TypeLocation* location = locationPair.first;
2257             bool isNewLocation = locationPair.second;
2258
2259             if (flag == ProfileTypeBytecodeFunctionReturnStatement)
2260                 location->m_divotForFunctionOffsetIfReturnStatement = ownerExecutable->typeProfilingStartOffset();
2261
2262             if (shouldAnalyze && isNewLocation)
2263                 vm.typeProfiler()->insertNewLocation(location);
2264
2265             instructions[i + 2].u.location = location;
2266             break;
2267         }
2268
2269         case op_debug: {
2270             if (pc[1].u.index == DidReachBreakpoint)
2271                 m_hasDebuggerStatement = true;
2272             break;
2273         }
2274
2275         case op_save: {
2276             unsigned liveCalleeLocalsIndex = pc[2].u.index;
2277             int offset = pc[3].u.operand;
2278             if (liveCalleeLocalsIndex >= mergePointBytecodeOffsets.size())
2279                 mergePointBytecodeOffsets.resize(liveCalleeLocalsIndex + 1);
2280             mergePointBytecodeOffsets[liveCalleeLocalsIndex] = i + offset;
2281             break;
2282         }
2283
2284         default:
2285             break;
2286         }
2287         i += opLength;
2288     }
2289
2290     if (vm.controlFlowProfiler())
2291         insertBasicBlockBoundariesForControlFlowProfiler(instructions);
2292
2293     m_instructions = WTFMove(instructions);
2294
2295     // Perform bytecode liveness analysis to determine which locals are live and should be resumed when executing op_resume.
2296     if (unlinkedCodeBlock->parseMode() == SourceParseMode::GeneratorBodyMode) {
2297         if (size_t count = mergePointBytecodeOffsets.size()) {
2298             createRareDataIfNecessary();
2299             BytecodeLivenessAnalysis liveness(this);
2300             m_rareData->m_liveCalleeLocalsAtYield.grow(count);
2301             size_t liveCalleeLocalsIndex = 0;
2302             for (size_t bytecodeOffset : mergePointBytecodeOffsets) {
2303                 m_rareData->m_liveCalleeLocalsAtYield[liveCalleeLocalsIndex] = liveness.getLivenessInfoAtBytecodeOffset(bytecodeOffset);
2304                 ++liveCalleeLocalsIndex;
2305             }
2306         }
2307     }
2308
2309     // Set optimization thresholds only after m_instructions is initialized, since these
2310     // rely on the instruction count (and are in theory permitted to also inspect the
2311     // instruction stream to more accurate assess the cost of tier-up).
2312     optimizeAfterWarmUp();
2313     jitAfterWarmUp();
2314
2315     // If the concurrent thread will want the code block's hash, then compute it here
2316     // synchronously.
2317     if (Options::alwaysComputeHash())
2318         hash();
2319
2320     if (Options::dumpGeneratedBytecodes())
2321         dumpBytecode();
2322     
2323     heap()->m_codeBlocks.add(this);
2324     heap()->reportExtraMemoryAllocated(m_instructions.size() * sizeof(Instruction));
2325 }
2326
2327 #if ENABLE(WEBASSEMBLY)
2328 CodeBlock::CodeBlock(VM* vm, Structure* structure, WebAssemblyExecutable* ownerExecutable, JSGlobalObject* globalObject)
2329     : JSCell(*vm, structure)
2330     , m_globalObject(globalObject->vm(), this, globalObject)
2331     , m_numCalleeLocals(0)
2332     , m_numVars(0)
2333     , m_shouldAlwaysBeInlined(false)
2334 #if ENABLE(JIT)
2335     , m_capabilityLevelState(DFG::CannotCompile)
2336 #endif
2337     , m_didFailFTLCompilation(false)
2338     , m_hasBeenCompiledWithFTL(false)
2339     , m_isConstructor(false)
2340     , m_isStrictMode(false)
2341     , m_codeType(FunctionCode)
2342     , m_hasDebuggerStatement(false)
2343     , m_steppingMode(SteppingModeDisabled)
2344     , m_numBreakpoints(0)
2345     , m_ownerExecutable(m_globalObject->vm(), this, ownerExecutable)
2346     , m_vm(vm)
2347     , m_osrExitCounter(0)
2348     , m_optimizationDelayCounter(0)
2349     , m_reoptimizationRetryCounter(0)
2350     , m_creationTime(std::chrono::steady_clock::now())
2351 {
2352     ASSERT(heap()->isDeferred());
2353 }
2354
2355 void CodeBlock::finishCreation(VM& vm, WebAssemblyExecutable*, JSGlobalObject*)
2356 {
2357     Base::finishCreation(vm);
2358
2359     heap()->m_codeBlocks.add(this);
2360 }
2361 #endif
2362
2363 CodeBlock::~CodeBlock()
2364 {
2365     if (m_vm->m_perBytecodeProfiler)
2366         m_vm->m_perBytecodeProfiler->notifyDestruction(this);
2367     
2368 #if ENABLE(VERBOSE_VALUE_PROFILE)
2369     dumpValueProfiles();
2370 #endif
2371
2372     // We may be destroyed before any CodeBlocks that refer to us are destroyed.
2373     // Consider that two CodeBlocks become unreachable at the same time. There
2374     // is no guarantee about the order in which the CodeBlocks are destroyed.
2375     // So, if we don't remove incoming calls, and get destroyed before the
2376     // CodeBlock(s) that have calls into us, then the CallLinkInfo vector's
2377     // destructor will try to remove nodes from our (no longer valid) linked list.
2378     unlinkIncomingCalls();
2379     
2380     // Note that our outgoing calls will be removed from other CodeBlocks'
2381     // m_incomingCalls linked lists through the execution of the ~CallLinkInfo
2382     // destructors.
2383
2384 #if ENABLE(JIT)
2385     for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter) {
2386         StructureStubInfo* stub = *iter;
2387         stub->aboutToDie();
2388         stub->deref();
2389     }
2390 #endif // ENABLE(JIT)
2391 }
2392
2393 void CodeBlock::setConstantRegisters(const Vector<WriteBarrier<Unknown>>& constants, const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation)
2394 {
2395     ASSERT(constants.size() == constantsSourceCodeRepresentation.size());
2396     size_t count = constants.size();
2397     m_constantRegisters.resizeToFit(count);
2398     bool hasTypeProfiler = !!m_vm->typeProfiler();
2399     for (size_t i = 0; i < count; i++) {
2400         JSValue constant = constants[i].get();
2401
2402         if (!constant.isEmpty()) {
2403             if (SymbolTable* symbolTable = jsDynamicCast<SymbolTable*>(constant)) {
2404                 if (hasTypeProfiler) {
2405                     ConcurrentJITLocker locker(symbolTable->m_lock);
2406                     symbolTable->prepareForTypeProfiling(locker);
2407                 }
2408                 constant = symbolTable->cloneScopePart(*m_vm);
2409             }
2410         }
2411
2412         m_constantRegisters[i].set(*m_vm, this, constant);
2413     }
2414
2415     m_constantsSourceCodeRepresentation = constantsSourceCodeRepresentation;
2416 }
2417
2418 void CodeBlock::setAlternative(VM& vm, CodeBlock* alternative)
2419 {
2420     m_alternative.set(vm, this, alternative);
2421 }
2422
2423 void CodeBlock::setNumParameters(int newValue)
2424 {
2425     m_numParameters = newValue;
2426
2427     m_argumentValueProfiles = RefCountedArray<ValueProfile>(newValue);
2428 }
2429
2430 void EvalCodeCache::visitAggregate(SlotVisitor& visitor)
2431 {
2432     EvalCacheMap::iterator end = m_cacheMap.end();
2433     for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr)
2434         visitor.append(&ptr->value);
2435 }
2436
2437 CodeBlock* CodeBlock::specialOSREntryBlockOrNull()
2438 {
2439 #if ENABLE(FTL_JIT)
2440     if (jitType() != JITCode::DFGJIT)
2441         return 0;
2442     DFG::JITCode* jitCode = m_jitCode->dfg();
2443     return jitCode->osrEntryBlock();
2444 #else // ENABLE(FTL_JIT)
2445     return 0;
2446 #endif // ENABLE(FTL_JIT)
2447 }
2448
2449 void CodeBlock::visitWeakly(SlotVisitor& visitor)
2450 {
2451     bool setByMe = m_visitWeaklyHasBeenCalled.compareExchangeStrong(false, true);
2452     if (!setByMe)
2453         return;
2454
2455     if (Heap::isMarked(this))
2456         return;
2457
2458     if (shouldVisitStrongly()) {
2459         visitor.appendUnbarrieredReadOnlyPointer(this);
2460         return;
2461     }
2462
2463     // There are two things that may use unconditional finalizers: inline cache clearing
2464     // and jettisoning. The probability of us wanting to do at least one of those things
2465     // is probably quite close to 1. So we add one no matter what and when it runs, it
2466     // figures out whether it has any work to do.
2467     visitor.addUnconditionalFinalizer(&m_unconditionalFinalizer);
2468
2469     if (!JITCode::isOptimizingJIT(jitType()))
2470         return;
2471
2472     // If we jettison ourselves we'll install our alternative, so make sure that it
2473     // survives GC even if we don't.
2474     visitor.append(&m_alternative);
2475     
2476     // There are two things that we use weak reference harvesters for: DFG fixpoint for
2477     // jettisoning, and trying to find structures that would be live based on some
2478     // inline cache. So it makes sense to register them regardless.
2479     visitor.addWeakReferenceHarvester(&m_weakReferenceHarvester);
2480
2481 #if ENABLE(DFG_JIT)
2482     // We get here if we're live in the sense that our owner executable is live,
2483     // but we're not yet live for sure in another sense: we may yet decide that this
2484     // code block should be jettisoned based on its outgoing weak references being
2485     // stale. Set a flag to indicate that we're still assuming that we're dead, and
2486     // perform one round of determining if we're live. The GC may determine, based on
2487     // either us marking additional objects, or by other objects being marked for
2488     // other reasons, that this iteration should run again; it will notify us of this
2489     // decision by calling harvestWeakReferences().
2490
2491     m_allTransitionsHaveBeenMarked = false;
2492     propagateTransitions(visitor);
2493
2494     m_jitCode->dfgCommon()->livenessHasBeenProved = false;
2495     determineLiveness(visitor);
2496 #endif // ENABLE(DFG_JIT)
2497 }
2498
2499 size_t CodeBlock::estimatedSize(JSCell* cell)
2500 {
2501     CodeBlock* thisObject = jsCast<CodeBlock*>(cell);
2502     size_t extraMemoryAllocated = thisObject->m_instructions.size() * sizeof(Instruction);
2503     if (thisObject->m_jitCode)
2504         extraMemoryAllocated += thisObject->m_jitCode->size();
2505     return Base::estimatedSize(cell) + extraMemoryAllocated;
2506 }
2507
2508 void CodeBlock::visitChildren(JSCell* cell, SlotVisitor& visitor)
2509 {
2510     CodeBlock* thisObject = jsCast<CodeBlock*>(cell);
2511     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
2512     JSCell::visitChildren(thisObject, visitor);
2513     thisObject->visitChildren(visitor);
2514 }
2515
2516 void CodeBlock::visitChildren(SlotVisitor& visitor)
2517 {
2518     // There are two things that may use unconditional finalizers: inline cache clearing
2519     // and jettisoning. The probability of us wanting to do at least one of those things
2520     // is probably quite close to 1. So we add one no matter what and when it runs, it
2521     // figures out whether it has any work to do.
2522     visitor.addUnconditionalFinalizer(&m_unconditionalFinalizer);
2523
2524     if (CodeBlock* otherBlock = specialOSREntryBlockOrNull())
2525         visitor.appendUnbarrieredReadOnlyPointer(otherBlock);
2526
2527     if (m_jitCode)
2528         visitor.reportExtraMemoryVisited(m_jitCode->size());
2529     if (m_instructions.size())
2530         visitor.reportExtraMemoryVisited(m_instructions.size() * sizeof(Instruction) / m_instructions.refCount());
2531
2532     stronglyVisitStrongReferences(visitor);
2533     stronglyVisitWeakReferences(visitor);
2534
2535     m_allTransitionsHaveBeenMarked = false;
2536     propagateTransitions(visitor);
2537 }
2538
2539 bool CodeBlock::shouldVisitStrongly()
2540 {
2541     if (Options::forceCodeBlockLiveness())
2542         return true;
2543
2544     if (shouldJettisonDueToOldAge())
2545         return false;
2546
2547     // Interpreter and Baseline JIT CodeBlocks don't need to be jettisoned when
2548     // their weak references go stale. So if a basline JIT CodeBlock gets
2549     // scanned, we can assume that this means that it's live.
2550     if (!JITCode::isOptimizingJIT(jitType()))
2551         return true;
2552
2553     return false;
2554 }
2555
2556 bool CodeBlock::shouldJettisonDueToWeakReference()
2557 {
2558     if (!JITCode::isOptimizingJIT(jitType()))
2559         return false;
2560     return !Heap::isMarked(this);
2561 }
2562
2563 bool CodeBlock::shouldJettisonDueToOldAge()
2564 {
2565     return false;
2566 }
2567
2568 #if ENABLE(DFG_JIT)
2569 static bool shouldMarkTransition(DFG::WeakReferenceTransition& transition)
2570 {
2571     if (transition.m_codeOrigin && !Heap::isMarked(transition.m_codeOrigin.get()))
2572         return false;
2573     
2574     if (!Heap::isMarked(transition.m_from.get()))
2575         return false;
2576     
2577     return true;
2578 }
2579 #endif // ENABLE(DFG_JIT)
2580
2581 void CodeBlock::propagateTransitions(SlotVisitor& visitor)
2582 {
2583     UNUSED_PARAM(visitor);
2584
2585     if (m_allTransitionsHaveBeenMarked)
2586         return;
2587
2588     bool allAreMarkedSoFar = true;
2589         
2590     Interpreter* interpreter = m_vm->interpreter;
2591     if (jitType() == JITCode::InterpreterThunk) {
2592         const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
2593         for (size_t i = 0; i < propertyAccessInstructions.size(); ++i) {
2594             Instruction* instruction = &instructions()[propertyAccessInstructions[i]];
2595             switch (interpreter->getOpcodeID(instruction[0].u.opcode)) {
2596             case op_put_by_id: {
2597                 StructureID oldStructureID = instruction[4].u.structureID;
2598                 StructureID newStructureID = instruction[6].u.structureID;
2599                 if (!oldStructureID || !newStructureID)
2600                     break;
2601                 Structure* oldStructure =
2602                     m_vm->heap.structureIDTable().get(oldStructureID);
2603                 Structure* newStructure =
2604                     m_vm->heap.structureIDTable().get(newStructureID);
2605                 if (Heap::isMarked(oldStructure))
2606                     visitor.appendUnbarrieredReadOnlyPointer(newStructure);
2607                 else
2608                     allAreMarkedSoFar = false;
2609                 break;
2610             }
2611             default:
2612                 break;
2613             }
2614         }
2615     }
2616
2617 #if ENABLE(JIT)
2618     if (JITCode::isJIT(jitType())) {
2619         for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter)
2620             allAreMarkedSoFar &= (*iter)->propagateTransitions(visitor);
2621     }
2622 #endif // ENABLE(JIT)
2623     
2624 #if ENABLE(DFG_JIT)
2625     if (JITCode::isOptimizingJIT(jitType())) {
2626         DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
2627         for (auto& weakReference : dfgCommon->weakStructureReferences)
2628             allAreMarkedSoFar &= weakReference->markIfCheap(visitor);
2629         
2630         for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) {
2631             if (shouldMarkTransition(dfgCommon->transitions[i])) {
2632                 // If the following three things are live, then the target of the
2633                 // transition is also live:
2634                 //
2635                 // - This code block. We know it's live already because otherwise
2636                 //   we wouldn't be scanning ourselves.
2637                 //
2638                 // - The code origin of the transition. Transitions may arise from
2639                 //   code that was inlined. They are not relevant if the user's
2640                 //   object that is required for the inlinee to run is no longer
2641                 //   live.
2642                 //
2643                 // - The source of the transition. The transition checks if some
2644                 //   heap location holds the source, and if so, stores the target.
2645                 //   Hence the source must be live for the transition to be live.
2646                 //
2647                 // We also short-circuit the liveness if the structure is harmless
2648                 // to mark (i.e. its global object and prototype are both already
2649                 // live).
2650                 
2651                 visitor.append(&dfgCommon->transitions[i].m_to);
2652             } else
2653                 allAreMarkedSoFar = false;
2654         }
2655     }
2656 #endif // ENABLE(DFG_JIT)
2657     
2658     if (allAreMarkedSoFar)
2659         m_allTransitionsHaveBeenMarked = true;
2660 }
2661
2662 void CodeBlock::determineLiveness(SlotVisitor& visitor)
2663 {
2664     UNUSED_PARAM(visitor);
2665     
2666 #if ENABLE(DFG_JIT)
2667     // Check if we have any remaining work to do.
2668     DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
2669     if (dfgCommon->livenessHasBeenProved)
2670         return;
2671     
2672     // Now check all of our weak references. If all of them are live, then we
2673     // have proved liveness and so we scan our strong references. If at end of
2674     // GC we still have not proved liveness, then this code block is toast.
2675     bool allAreLiveSoFar = true;
2676     for (unsigned i = 0; i < dfgCommon->weakReferences.size(); ++i) {
2677         if (!Heap::isMarked(dfgCommon->weakReferences[i].get())) {
2678             allAreLiveSoFar = false;
2679             break;
2680         }
2681     }
2682     if (allAreLiveSoFar) {
2683         for (unsigned i = 0; i < dfgCommon->weakStructureReferences.size(); ++i) {
2684             if (!Heap::isMarked(dfgCommon->weakStructureReferences[i].get())) {
2685                 allAreLiveSoFar = false;
2686                 break;
2687             }
2688         }
2689     }
2690     
2691     // If some weak references are dead, then this fixpoint iteration was
2692     // unsuccessful.
2693     if (!allAreLiveSoFar)
2694         return;
2695     
2696     // All weak references are live. Record this information so we don't
2697     // come back here again, and scan the strong references.
2698     dfgCommon->livenessHasBeenProved = true;
2699     visitor.appendUnbarrieredReadOnlyPointer(this);
2700 #endif // ENABLE(DFG_JIT)
2701 }
2702
2703 void CodeBlock::WeakReferenceHarvester::visitWeakReferences(SlotVisitor& visitor)
2704 {
2705     CodeBlock* codeBlock =
2706         bitwise_cast<CodeBlock*>(
2707             bitwise_cast<char*>(this) - OBJECT_OFFSETOF(CodeBlock, m_weakReferenceHarvester));
2708
2709     codeBlock->propagateTransitions(visitor);
2710     codeBlock->determineLiveness(visitor);
2711 }
2712
2713 void CodeBlock::finalizeLLIntInlineCaches()
2714 {
2715 #if ENABLE(WEBASSEMBLY)
2716     if (m_ownerExecutable->isWebAssemblyExecutable())
2717         return;
2718 #endif
2719
2720     Interpreter* interpreter = m_vm->interpreter;
2721     const Vector<unsigned>& propertyAccessInstructions = m_unlinkedCode->propertyAccessInstructions();
2722     for (size_t size = propertyAccessInstructions.size(), i = 0; i < size; ++i) {
2723         Instruction* curInstruction = &instructions()[propertyAccessInstructions[i]];
2724         switch (interpreter->getOpcodeID(curInstruction[0].u.opcode)) {
2725         case op_get_by_id: {
2726             StructureID oldStructureID = curInstruction[4].u.structureID;
2727             if (!oldStructureID || Heap::isMarked(m_vm->heap.structureIDTable().get(oldStructureID)))
2728                 break;
2729             if (Options::verboseOSR())
2730                 dataLogF("Clearing LLInt property access.\n");
2731             curInstruction[4].u.structureID = 0;
2732             curInstruction[5].u.operand = 0;
2733             break;
2734         }
2735         case op_put_by_id: {
2736             StructureID oldStructureID = curInstruction[4].u.structureID;
2737             StructureID newStructureID = curInstruction[6].u.structureID;
2738             StructureChain* chain = curInstruction[7].u.structureChain.get();
2739             if ((!oldStructureID || Heap::isMarked(m_vm->heap.structureIDTable().get(oldStructureID))) &&
2740                 (!newStructureID || Heap::isMarked(m_vm->heap.structureIDTable().get(newStructureID))) &&
2741                 (!chain || Heap::isMarked(chain)))
2742                 break;
2743             if (Options::verboseOSR())
2744                 dataLogF("Clearing LLInt put transition.\n");
2745             curInstruction[4].u.structureID = 0;
2746             curInstruction[5].u.operand = 0;
2747             curInstruction[6].u.structureID = 0;
2748             curInstruction[7].u.structureChain.clear();
2749             break;
2750         }
2751         case op_get_array_length:
2752             break;
2753         case op_to_this:
2754             if (!curInstruction[2].u.structure || Heap::isMarked(curInstruction[2].u.structure.get()))
2755                 break;
2756             if (Options::verboseOSR())
2757                 dataLogF("Clearing LLInt to_this with structure %p.\n", curInstruction[2].u.structure.get());
2758             curInstruction[2].u.structure.clear();
2759             curInstruction[3].u.toThisStatus = merge(
2760                 curInstruction[3].u.toThisStatus, ToThisClearedByGC);
2761             break;
2762         case op_create_this: {
2763             auto& cacheWriteBarrier = curInstruction[4].u.jsCell;
2764             if (!cacheWriteBarrier || cacheWriteBarrier.unvalidatedGet() == JSCell::seenMultipleCalleeObjects())
2765                 break;
2766             JSCell* cachedFunction = cacheWriteBarrier.get();
2767             if (Heap::isMarked(cachedFunction))
2768                 break;
2769             if (Options::verboseOSR())
2770                 dataLogF("Clearing LLInt create_this with cached callee %p.\n", cachedFunction);
2771             cacheWriteBarrier.clear();
2772             break;
2773         }
2774         case op_resolve_scope: {
2775             // Right now this isn't strictly necessary. Any symbol tables that this will refer to
2776             // are for outer functions, and we refer to those functions strongly, and they refer
2777             // to the symbol table strongly. But it's nice to be on the safe side.
2778             WriteBarrierBase<SymbolTable>& symbolTable = curInstruction[6].u.symbolTable;
2779             if (!symbolTable || Heap::isMarked(symbolTable.get()))
2780                 break;
2781             if (Options::verboseOSR())
2782                 dataLogF("Clearing dead symbolTable %p.\n", symbolTable.get());
2783             symbolTable.clear();
2784             break;
2785         }
2786         case op_get_from_scope:
2787         case op_put_to_scope: {
2788             GetPutInfo getPutInfo = GetPutInfo(curInstruction[4].u.operand);
2789             if (getPutInfo.resolveType() == GlobalVar || getPutInfo.resolveType() == GlobalVarWithVarInjectionChecks 
2790                 || getPutInfo.resolveType() == LocalClosureVar || getPutInfo.resolveType() == GlobalLexicalVar || getPutInfo.resolveType() == GlobalLexicalVarWithVarInjectionChecks)
2791                 continue;
2792             WriteBarrierBase<Structure>& structure = curInstruction[5].u.structure;
2793             if (!structure || Heap::isMarked(structure.get()))
2794                 break;
2795             if (Options::verboseOSR())
2796                 dataLogF("Clearing scope access with structure %p.\n", structure.get());
2797             structure.clear();
2798             break;
2799         }
2800         default:
2801             OpcodeID opcodeID = interpreter->getOpcodeID(curInstruction[0].u.opcode);
2802             ASSERT_WITH_MESSAGE_UNUSED(opcodeID, false, "Unhandled opcode in CodeBlock::finalizeUnconditionally, %s(%d) at bc %u", opcodeNames[opcodeID], opcodeID, propertyAccessInstructions[i]);
2803         }
2804     }
2805
2806     for (unsigned i = 0; i < m_llintCallLinkInfos.size(); ++i) {
2807         if (m_llintCallLinkInfos[i].isLinked() && !Heap::isMarked(m_llintCallLinkInfos[i].callee.get())) {
2808             if (Options::verboseOSR())
2809                 dataLog("Clearing LLInt call from ", *this, "\n");
2810             m_llintCallLinkInfos[i].unlink();
2811         }
2812         if (!!m_llintCallLinkInfos[i].lastSeenCallee && !Heap::isMarked(m_llintCallLinkInfos[i].lastSeenCallee.get()))
2813             m_llintCallLinkInfos[i].lastSeenCallee.clear();
2814     }
2815 }
2816
2817 void CodeBlock::finalizeBaselineJITInlineCaches()
2818 {
2819 #if ENABLE(JIT)
2820     for (auto iter = callLinkInfosBegin(); !!iter; ++iter)
2821         (*iter)->visitWeak(*vm());
2822
2823     for (Bag<StructureStubInfo>::iterator iter = m_stubInfos.begin(); !!iter; ++iter) {
2824         StructureStubInfo& stubInfo = **iter;
2825         stubInfo.visitWeakReferences(this);
2826     }
2827 #endif
2828 }
2829
2830 void CodeBlock::UnconditionalFinalizer::finalizeUnconditionally()
2831 {
2832     CodeBlock* codeBlock = bitwise_cast<CodeBlock*>(
2833         bitwise_cast<char*>(this) - OBJECT_OFFSETOF(CodeBlock, m_unconditionalFinalizer));
2834
2835 #if ENABLE(DFG_JIT)
2836     if (codeBlock->shouldJettisonDueToWeakReference()) {
2837         codeBlock->jettison(Profiler::JettisonDueToWeakReference);
2838         return;
2839     }
2840 #endif // ENABLE(DFG_JIT)
2841
2842     if (codeBlock->shouldJettisonDueToOldAge()) {
2843         codeBlock->jettison(Profiler::JettisonDueToOldAge);
2844         return;
2845     }
2846
2847     if (JITCode::couldBeInterpreted(codeBlock->jitType()))
2848         codeBlock->finalizeLLIntInlineCaches();
2849
2850 #if ENABLE(JIT)
2851     if (!!codeBlock->jitCode())
2852         codeBlock->finalizeBaselineJITInlineCaches();
2853 #endif
2854 }
2855
2856 void CodeBlock::getStubInfoMap(const ConcurrentJITLocker&, StubInfoMap& result)
2857 {
2858 #if ENABLE(JIT)
2859     toHashMap(m_stubInfos, getStructureStubInfoCodeOrigin, result);
2860 #else
2861     UNUSED_PARAM(result);
2862 #endif
2863 }
2864
2865 void CodeBlock::getStubInfoMap(StubInfoMap& result)
2866 {
2867     ConcurrentJITLocker locker(m_lock);
2868     getStubInfoMap(locker, result);
2869 }
2870
2871 void CodeBlock::getCallLinkInfoMap(const ConcurrentJITLocker&, CallLinkInfoMap& result)
2872 {
2873 #if ENABLE(JIT)
2874     toHashMap(m_callLinkInfos, getCallLinkInfoCodeOrigin, result);
2875 #else
2876     UNUSED_PARAM(result);
2877 #endif
2878 }
2879
2880 void CodeBlock::getCallLinkInfoMap(CallLinkInfoMap& result)
2881 {
2882     ConcurrentJITLocker locker(m_lock);
2883     getCallLinkInfoMap(locker, result);
2884 }
2885
2886 void CodeBlock::getByValInfoMap(const ConcurrentJITLocker&, ByValInfoMap& result)
2887 {
2888 #if ENABLE(JIT)
2889     for (auto* byValInfo : m_byValInfos)
2890         result.add(CodeOrigin(byValInfo->bytecodeIndex), byValInfo);
2891 #else
2892     UNUSED_PARAM(result);
2893 #endif
2894 }
2895
2896 void CodeBlock::getByValInfoMap(ByValInfoMap& result)
2897 {
2898     ConcurrentJITLocker locker(m_lock);
2899     getByValInfoMap(locker, result);
2900 }
2901
2902 #if ENABLE(JIT)
2903 StructureStubInfo* CodeBlock::addStubInfo(AccessType accessType)
2904 {
2905     ConcurrentJITLocker locker(m_lock);
2906     return m_stubInfos.add(accessType);
2907 }
2908
2909 StructureStubInfo* CodeBlock::findStubInfo(CodeOrigin codeOrigin)
2910 {
2911     for (StructureStubInfo* stubInfo : m_stubInfos) {
2912         if (stubInfo->codeOrigin == codeOrigin)
2913             return stubInfo;
2914     }
2915     return nullptr;
2916 }
2917
2918 ByValInfo* CodeBlock::addByValInfo()
2919 {
2920     ConcurrentJITLocker locker(m_lock);
2921     return m_byValInfos.add();
2922 }
2923
2924 CallLinkInfo* CodeBlock::addCallLinkInfo()
2925 {
2926     ConcurrentJITLocker locker(m_lock);
2927     return m_callLinkInfos.add();
2928 }
2929
2930 CallLinkInfo* CodeBlock::getCallLinkInfoForBytecodeIndex(unsigned index)
2931 {
2932     for (auto iter = m_callLinkInfos.begin(); !!iter; ++iter) {
2933         if ((*iter)->codeOrigin() == CodeOrigin(index))
2934             return *iter;
2935     }
2936     return nullptr;
2937 }
2938 #endif
2939
2940 void CodeBlock::visitOSRExitTargets(SlotVisitor& visitor)
2941 {
2942     // We strongly visit OSR exits targets because we don't want to deal with
2943     // the complexity of generating an exit target CodeBlock on demand and
2944     // guaranteeing that it matches the details of the CodeBlock we compiled
2945     // the OSR exit against.
2946
2947     visitor.append(&m_alternative);
2948
2949 #if ENABLE(DFG_JIT)
2950     DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
2951     if (dfgCommon->inlineCallFrames) {
2952         for (auto* inlineCallFrame : *dfgCommon->inlineCallFrames) {
2953             ASSERT(inlineCallFrame->baselineCodeBlock);
2954             visitor.append(&inlineCallFrame->baselineCodeBlock);
2955         }
2956     }
2957 #endif
2958 }
2959
2960 void CodeBlock::stronglyVisitStrongReferences(SlotVisitor& visitor)
2961 {
2962     visitor.append(&m_globalObject);
2963     visitor.append(&m_ownerExecutable);
2964     visitor.append(&m_unlinkedCode);
2965     if (m_rareData)
2966         m_rareData->m_evalCodeCache.visitAggregate(visitor);
2967     visitor.appendValues(m_constantRegisters.data(), m_constantRegisters.size());
2968     for (size_t i = 0; i < m_functionExprs.size(); ++i)
2969         visitor.append(&m_functionExprs[i]);
2970     for (size_t i = 0; i < m_functionDecls.size(); ++i)
2971         visitor.append(&m_functionDecls[i]);
2972     for (unsigned i = 0; i < m_objectAllocationProfiles.size(); ++i)
2973         m_objectAllocationProfiles[i].visitAggregate(visitor);
2974
2975 #if ENABLE(DFG_JIT)
2976     if (JITCode::isOptimizingJIT(jitType()))
2977         visitOSRExitTargets(visitor);
2978 #endif
2979
2980     updateAllPredictions();
2981 }
2982
2983 void CodeBlock::stronglyVisitWeakReferences(SlotVisitor& visitor)
2984 {
2985     UNUSED_PARAM(visitor);
2986
2987 #if ENABLE(DFG_JIT)
2988     if (!JITCode::isOptimizingJIT(jitType()))
2989         return;
2990     
2991     DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
2992
2993     for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) {
2994         if (!!dfgCommon->transitions[i].m_codeOrigin)
2995             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.
2996         visitor.append(&dfgCommon->transitions[i].m_from);
2997         visitor.append(&dfgCommon->transitions[i].m_to);
2998     }
2999     
3000     for (unsigned i = 0; i < dfgCommon->weakReferences.size(); ++i)
3001         visitor.append(&dfgCommon->weakReferences[i]);
3002
3003     for (unsigned i = 0; i < dfgCommon->weakStructureReferences.size(); ++i)
3004         visitor.append(&dfgCommon->weakStructureReferences[i]);
3005
3006     dfgCommon->livenessHasBeenProved = true;
3007 #endif    
3008 }
3009
3010 CodeBlock* CodeBlock::baselineAlternative()
3011 {
3012 #if ENABLE(JIT)
3013     CodeBlock* result = this;
3014     while (result->alternative())
3015         result = result->alternative();
3016     RELEASE_ASSERT(result);
3017     RELEASE_ASSERT(JITCode::isBaselineCode(result->jitType()) || result->jitType() == JITCode::None);
3018     return result;
3019 #else
3020     return this;
3021 #endif
3022 }
3023
3024 CodeBlock* CodeBlock::baselineVersion()
3025 {
3026 #if ENABLE(JIT)
3027     if (JITCode::isBaselineCode(jitType()))
3028         return this;
3029     CodeBlock* result = replacement();
3030     if (!result) {
3031         // This can happen if we're creating the original CodeBlock for an executable.
3032         // Assume that we're the baseline CodeBlock.
3033         RELEASE_ASSERT(jitType() == JITCode::None);
3034         return this;
3035     }
3036     result = result->baselineAlternative();
3037     return result;
3038 #else
3039     return this;
3040 #endif
3041 }
3042
3043 #if ENABLE(JIT)
3044 bool CodeBlock::hasOptimizedReplacement(JITCode::JITType typeToReplace)
3045 {
3046     return JITCode::isHigherTier(replacement()->jitType(), typeToReplace);
3047 }
3048
3049 bool CodeBlock::hasOptimizedReplacement()
3050 {
3051     return hasOptimizedReplacement(jitType());
3052 }
3053 #endif
3054
3055 HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset, RequiredHandler requiredHandler)
3056 {
3057     RELEASE_ASSERT(bytecodeOffset < instructions().size());
3058     return handlerForIndex(bytecodeOffset, requiredHandler);
3059 }
3060
3061 HandlerInfo* CodeBlock::handlerForIndex(unsigned index, RequiredHandler requiredHandler)
3062 {
3063     if (!m_rareData)
3064         return 0;
3065     
3066     Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers;
3067     for (size_t i = 0; i < exceptionHandlers.size(); ++i) {
3068         HandlerInfo& handler = exceptionHandlers[i];
3069         if ((requiredHandler == RequiredHandler::CatchHandler) && !handler.isCatchHandler())
3070             continue;
3071
3072         // Handlers are ordered innermost first, so the first handler we encounter
3073         // that contains the source address is the correct handler to use.
3074         // This index used is either the BytecodeOffset or a CallSiteIndex.
3075         if (handler.start <= index && handler.end > index)
3076             return &handler;
3077     }
3078
3079     return 0;
3080 }
3081
3082 CallSiteIndex CodeBlock::newExceptionHandlingCallSiteIndex(CallSiteIndex originalCallSite)
3083 {
3084 #if ENABLE(DFG_JIT)
3085     RELEASE_ASSERT(JITCode::isOptimizingJIT(jitType()));
3086     RELEASE_ASSERT(canGetCodeOrigin(originalCallSite));
3087     ASSERT(!!handlerForIndex(originalCallSite.bits()));
3088     CodeOrigin originalOrigin = codeOrigin(originalCallSite);
3089     return m_jitCode->dfgCommon()->addUniqueCallSiteIndex(originalOrigin);
3090 #else
3091     // We never create new on-the-fly exception handling
3092     // call sites outside the DFG/FTL inline caches.
3093     UNUSED_PARAM(originalCallSite);
3094     RELEASE_ASSERT_NOT_REACHED();
3095     return CallSiteIndex(0u);
3096 #endif
3097 }
3098
3099 void CodeBlock::removeExceptionHandlerForCallSite(CallSiteIndex callSiteIndex)
3100 {
3101     RELEASE_ASSERT(m_rareData);
3102     Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers;
3103     unsigned index = callSiteIndex.bits();
3104     for (size_t i = 0; i < exceptionHandlers.size(); ++i) {
3105         HandlerInfo& handler = exceptionHandlers[i];
3106         if (handler.start <= index && handler.end > index) {
3107             exceptionHandlers.remove(i);
3108             return;
3109         }
3110     }
3111
3112     RELEASE_ASSERT_NOT_REACHED();
3113 }
3114
3115 unsigned CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
3116 {
3117     RELEASE_ASSERT(bytecodeOffset < instructions().size());
3118     return ownerScriptExecutable()->firstLine() + m_unlinkedCode->lineNumberForBytecodeOffset(bytecodeOffset);
3119 }
3120
3121 unsigned CodeBlock::columnNumberForBytecodeOffset(unsigned bytecodeOffset)
3122 {
3123     int divot;
3124     int startOffset;
3125     int endOffset;
3126     unsigned line;
3127     unsigned column;
3128     expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column);
3129     return column;
3130 }
3131
3132 void CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)
3133 {
3134     m_unlinkedCode->expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column);
3135     divot += m_sourceOffset;
3136     column += line ? 1 : firstLineColumnOffset();
3137     line += ownerScriptExecutable()->firstLine();
3138 }
3139
3140 bool CodeBlock::hasOpDebugForLineAndColumn(unsigned line, unsigned column)
3141 {
3142     Interpreter* interpreter = vm()->interpreter;
3143     const Instruction* begin = instructions().begin();
3144     const Instruction* end = instructions().end();
3145     for (const Instruction* it = begin; it != end;) {
3146         OpcodeID opcodeID = interpreter->getOpcodeID(it->u.opcode);
3147         if (opcodeID == op_debug) {
3148             unsigned bytecodeOffset = it - begin;
3149             int unused;
3150             unsigned opDebugLine;
3151             unsigned opDebugColumn;
3152             expressionRangeForBytecodeOffset(bytecodeOffset, unused, unused, unused, opDebugLine, opDebugColumn);
3153             if (line == opDebugLine && (column == Breakpoint::unspecifiedColumn || column == opDebugColumn))
3154                 return true;
3155         }
3156         it += opcodeLengths[opcodeID];
3157     }
3158     return false;
3159 }
3160
3161 void CodeBlock::shrinkToFit(ShrinkMode shrinkMode)
3162 {
3163     m_rareCaseProfiles.shrinkToFit();
3164     m_resultProfiles.shrinkToFit();
3165     
3166     if (shrinkMode == EarlyShrink) {
3167         m_constantRegisters.shrinkToFit();
3168         m_constantsSourceCodeRepresentation.shrinkToFit();
3169         
3170         if (m_rareData) {
3171             m_rareData->m_switchJumpTables.shrinkToFit();
3172             m_rareData->m_stringSwitchJumpTables.shrinkToFit();
3173             m_rareData->m_liveCalleeLocalsAtYield.shrinkToFit();
3174         }
3175     } // else don't shrink these, because we would have already pointed pointers into these tables.
3176 }
3177
3178 #if ENABLE(JIT)
3179 void CodeBlock::linkIncomingCall(ExecState* callerFrame, CallLinkInfo* incoming)
3180 {
3181     noticeIncomingCall(callerFrame);
3182     m_incomingCalls.push(incoming);
3183 }
3184
3185 void CodeBlock::linkIncomingPolymorphicCall(ExecState* callerFrame, PolymorphicCallNode* incoming)
3186 {
3187     noticeIncomingCall(callerFrame);
3188     m_incomingPolymorphicCalls.push(incoming);
3189 }
3190 #endif // ENABLE(JIT)
3191
3192 void CodeBlock::unlinkIncomingCalls()
3193 {
3194     while (m_incomingLLIntCalls.begin() != m_incomingLLIntCalls.end())
3195         m_incomingLLIntCalls.begin()->unlink();
3196 #if ENABLE(JIT)
3197     while (m_incomingCalls.begin() != m_incomingCalls.end())
3198         m_incomingCalls.begin()->unlink(*vm());
3199     while (m_incomingPolymorphicCalls.begin() != m_incomingPolymorphicCalls.end())
3200         m_incomingPolymorphicCalls.begin()->unlink(*vm());
3201 #endif // ENABLE(JIT)
3202 }
3203
3204 void CodeBlock::linkIncomingCall(ExecState* callerFrame, LLIntCallLinkInfo* incoming)
3205 {
3206     noticeIncomingCall(callerFrame);
3207     m_incomingLLIntCalls.push(incoming);
3208 }
3209
3210 CodeBlock* CodeBlock::newReplacement()
3211 {
3212     return ownerScriptExecutable()->newReplacementCodeBlockFor(specializationKind());
3213 }
3214
3215 #if ENABLE(JIT)
3216 CodeBlock* CodeBlock::replacement()
3217 {
3218     const ClassInfo* classInfo = this->classInfo();
3219
3220     if (classInfo == FunctionCodeBlock::info())
3221         return jsCast<FunctionExecutable*>(ownerExecutable())->codeBlockFor(m_isConstructor ? CodeForConstruct : CodeForCall);
3222
3223     if (classInfo == EvalCodeBlock::info())
3224         return jsCast<EvalExecutable*>(ownerExecutable())->codeBlock();
3225
3226     if (classInfo == ProgramCodeBlock::info())
3227         return jsCast<ProgramExecutable*>(ownerExecutable())->codeBlock();
3228
3229     if (classInfo == ModuleProgramCodeBlock::info())
3230         return jsCast<ModuleProgramExecutable*>(ownerExecutable())->codeBlock();
3231
3232 #if ENABLE(WEBASSEMBLY)
3233     if (classInfo == WebAssemblyCodeBlock::info())
3234         return nullptr;
3235 #endif
3236
3237     RELEASE_ASSERT_NOT_REACHED();
3238     return nullptr;
3239 }
3240
3241 DFG::CapabilityLevel CodeBlock::computeCapabilityLevel()
3242 {
3243     const ClassInfo* classInfo = this->classInfo();
3244
3245     if (classInfo == FunctionCodeBlock::info()) {
3246         if (m_isConstructor)
3247             return DFG::functionForConstructCapabilityLevel(this);
3248         return DFG::functionForCallCapabilityLevel(this);
3249     }
3250
3251     if (classInfo == EvalCodeBlock::info())
3252         return DFG::evalCapabilityLevel(this);
3253
3254     if (classInfo == ProgramCodeBlock::info())
3255         return DFG::programCapabilityLevel(this);
3256
3257     if (classInfo == ModuleProgramCodeBlock::info())
3258         return DFG::programCapabilityLevel(this);
3259
3260 #if ENABLE(WEBASSEMBLY)
3261     if (classInfo == WebAssemblyCodeBlock::info())
3262         return DFG::CannotCompile;
3263 #endif
3264
3265     RELEASE_ASSERT_NOT_REACHED();
3266     return DFG::CannotCompile;
3267 }
3268
3269 #endif // ENABLE(JIT)
3270
3271 void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mode, const FireDetail* detail)
3272 {
3273 #if !ENABLE(DFG_JIT)
3274     UNUSED_PARAM(mode);
3275     UNUSED_PARAM(detail);
3276 #endif
3277
3278     RELEASE_ASSERT(reason != Profiler::NotJettisoned);
3279     
3280 #if ENABLE(DFG_JIT)
3281     if (DFG::shouldDumpDisassembly()) {
3282         dataLog("Jettisoning ", *this);
3283         if (mode == CountReoptimization)
3284             dataLog(" and counting reoptimization");
3285         dataLog(" due to ", reason);
3286         if (detail)
3287             dataLog(", ", *detail);
3288         dataLog(".\n");
3289     }
3290     
3291     if (reason == Profiler::JettisonDueToWeakReference) {
3292         if (DFG::shouldDumpDisassembly()) {
3293             dataLog(*this, " will be jettisoned because of the following dead references:\n");
3294             DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
3295             for (unsigned i = 0; i < dfgCommon->transitions.size(); ++i) {
3296                 DFG::WeakReferenceTransition& transition = dfgCommon->transitions[i];
3297                 JSCell* origin = transition.m_codeOrigin.get();
3298                 JSCell* from = transition.m_from.get();
3299                 JSCell* to = transition.m_to.get();
3300                 if ((!origin || Heap::isMarked(origin)) && Heap::isMarked(from))
3301                     continue;