Commit f0c01b8e authored by oliver@apple.com's avatar oliver@apple.com

Reduce parser overhead in JSC

https://bugs.webkit.org/show_bug.cgi?id=101127

Reviewed by Filip Pizlo.

An exciting journey into the world of architecture in which our hero
adds yet another layer to JSC codegeneration.

This patch adds a marginally more compact form of bytecode that is
free from any data specific to a given execution context, and that
does store any data structures necessary for execution.  To actually
execute this UnlinkedBytecode we still need to instantiate a real
CodeBlock, but this is a much faster linear time operation than any
of the earlier parsing or code generation passes.

As the unlinked code is context free we can then simply use a cache
from source to unlinked code mapping to completely avoid all of the
old parser overhead.  The cache is currently very simple and memory
heavy, using the complete source text as a key (rather than SourceCode
or equivalent), and a random eviction policy.

This seems to produce a substantial win when loading identical content
in different contexts.

* API/tests/testapi.c:
(main):
* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.cpp:
* bytecode/CodeBlock.h:
    Moved a number of fields, and a bunch of logic to UnlinkedCodeBlock.h/cpp
* bytecode/Opcode.h:
    Added a global const init no op instruction needed to get correct
    behaviour without any associated semantics.
* bytecode/UnlinkedCodeBlock.cpp: Added.
* bytecode/UnlinkedCodeBlock.h: Added.
    A fairly shallow, GC allocated version of the old CodeBlock
    classes with a 32bit instruction size, and just metadata
    size tracking.
* bytecompiler/BytecodeGenerator.cpp:
* bytecompiler/BytecodeGenerator.h:
    Replace direct access to m_symbolTable with access through
    symbolTable().  ProgramCode no longer has a symbol table at
    all so some previously unconditional (and pointless) uses
    of symbolTable get null checks.
    A few other changes to deal with type changes due to us generating
    unlinked code (eg. pointer free, so profile indices rather than
    pointers).
* dfg/DFGByteCodeParser.cpp:
* dfg/DFGCapabilities.h:
    Support global_init_nop
* interpreter/Interpreter.cpp:
    Now get the ProgramExecutable to initialise new global properties
    before starting execution.
* jit/JIT.cpp:
* jit/JITDriver.h:
* jit/JITStubs.cpp:
* llint/LLIntData.cpp:
* llint/LLIntSlowPaths.cpp:
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
    Adding init_global_const_nop everywhere else
* parser/Parser.h:
* parser/ParserModes.h: Added.
* parser/ParserTokens.h:
    Parser no longer needs a global object or callframe to function
* runtime/CodeCache.cpp: Added.
* runtime/CodeCache.h: Added.
    A simple, random eviction, Source->UnlinkedCode cache
* runtime/Executable.cpp:
* runtime/Executable.h:
    Executables now reference their unlinked counterparts, and
    request code specifically for the target global object.
* runtime/JSGlobalData.cpp:
* runtime/JSGlobalData.h:
    GlobalData now owns a CodeCache and a set of new structures
    for the unlinked code types.
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
    Utility functions used by executables to perform compilation

* runtime/JSType.h:
  Add new JSTypes for unlinked code

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133688 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 376cae42
......@@ -59,6 +59,7 @@ SET(JavaScriptCore_SOURCES
bytecode/SpecialPointer.cpp
bytecode/StructureStubClearingWatchpoint.cpp
bytecode/StructureStubInfo.cpp
bytecode/UnlinkedCodeBlock.cpp
bytecode/Watchpoint.cpp
bytecompiler/BytecodeGenerator.cpp
......@@ -174,6 +175,7 @@ SET(JavaScriptCore_SOURCES
runtime/BooleanObject.cpp
runtime/BooleanPrototype.cpp
runtime/CallData.cpp
runtime/CodeCache.cpp
runtime/CommonIdentifiers.cpp
runtime/Completion.cpp
runtime/ConstructData.cpp
......
2012-11-06 Oliver Hunt <oliver@apple.com>
Reduce parser overhead in JSC
https://bugs.webkit.org/show_bug.cgi?id=101127
Reviewed by Filip Pizlo.
An exciting journey into the world of architecture in which our hero
adds yet another layer to JSC codegeneration.
This patch adds a marginally more compact form of bytecode that is
free from any data specific to a given execution context, and that
does store any data structures necessary for execution. To actually
execute this UnlinkedBytecode we still need to instantiate a real
CodeBlock, but this is a much faster linear time operation than any
of the earlier parsing or code generation passes.
As the unlinked code is context free we can then simply use a cache
from source to unlinked code mapping to completely avoid all of the
old parser overhead. The cache is currently very simple and memory
heavy, using the complete source text as a key (rather than SourceCode
or equivalent), and a random eviction policy.
This seems to produce a substantial win when loading identical content
in different contexts.
* API/tests/testapi.c:
(main):
* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.cpp:
* bytecode/CodeBlock.h:
Moved a number of fields, and a bunch of logic to UnlinkedCodeBlock.h/cpp
* bytecode/Opcode.h:
Added a global const init no op instruction needed to get correct
behaviour without any associated semantics.
* bytecode/UnlinkedCodeBlock.cpp: Added.
* bytecode/UnlinkedCodeBlock.h: Added.
A fairly shallow, GC allocated version of the old CodeBlock
classes with a 32bit instruction size, and just metadata
size tracking.
* bytecompiler/BytecodeGenerator.cpp:
* bytecompiler/BytecodeGenerator.h:
Replace direct access to m_symbolTable with access through
symbolTable(). ProgramCode no longer has a symbol table at
all so some previously unconditional (and pointless) uses
of symbolTable get null checks.
A few other changes to deal with type changes due to us generating
unlinked code (eg. pointer free, so profile indices rather than
pointers).
* dfg/DFGByteCodeParser.cpp:
* dfg/DFGCapabilities.h:
Support global_init_nop
* interpreter/Interpreter.cpp:
Now get the ProgramExecutable to initialise new global properties
before starting execution.
* jit/JIT.cpp:
* jit/JITDriver.h:
* jit/JITStubs.cpp:
* llint/LLIntData.cpp:
* llint/LLIntSlowPaths.cpp:
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
Adding init_global_const_nop everywhere else
* parser/Parser.h:
* parser/ParserModes.h: Added.
* parser/ParserTokens.h:
Parser no longer needs a global object or callframe to function
* runtime/CodeCache.cpp: Added.
* runtime/CodeCache.h: Added.
A simple, random eviction, Source->UnlinkedCode cache
* runtime/Executable.cpp:
* runtime/Executable.h:
Executables now reference their unlinked counterparts, and
request code specifically for the target global object.
* runtime/JSGlobalData.cpp:
* runtime/JSGlobalData.h:
GlobalData now owns a CodeCache and a set of new structures
for the unlinked code types.
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
Utility functions used by executables to perform compilation
* runtime/JSType.h:
Add new JSTypes for unlinked code
2012-11-06 Michael Saboff <msaboff@apple.com>
JSStringCreateWithCFString() Should create an 8 bit String if possible
......@@ -2017,7 +2106,7 @@
(JSC::JIT::emit_op_next_pname):
(JSC::JIT::compileOpStrictEq):
(JSC::JIT::emit_op_catch):
(JSC::JIT::emit_op_throw_reference_error):
(JSC::JIT::emit_op_throw_static_error):
(JSC::JIT::emit_op_eq_null):
(JSC::JIT::emit_op_neq_null):
(JSC::JIT::emit_op_create_activation):
......
......@@ -138,6 +138,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/bytecode/StructureStubInfo.h \
Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.cpp \
Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h \
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp \
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h \
Source/JavaScriptCore/bytecode/ValueProfile.h \
Source/JavaScriptCore/bytecode/ValueRecovery.h \
Source/JavaScriptCore/bytecode/VirtualRegister.h \
......@@ -444,6 +446,7 @@ javascriptcore_sources += \
Source/JavaScriptCore/parser/ParserTokens.h \
Source/JavaScriptCore/parser/Parser.cpp \
Source/JavaScriptCore/parser/Parser.h \
Source/JavaScriptCore/parser/ParserModes.h \
Source/JavaScriptCore/parser/ResultType.h \
Source/JavaScriptCore/parser/SourceCode.h \
Source/JavaScriptCore/parser/SourceProvider.h \
......@@ -484,6 +487,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/CallData.cpp \
Source/JavaScriptCore/runtime/CallData.h \
Source/JavaScriptCore/runtime/ClassInfo.h \
Source/JavaScriptCore/runtime/CodeCache.cpp \
Source/JavaScriptCore/runtime/CodeCache.h \
Source/JavaScriptCore/runtime/CodeSpecializationKind.h \
Source/JavaScriptCore/runtime/CommonIdentifiers.cpp \
Source/JavaScriptCore/runtime/CommonIdentifiers.h \
......
......@@ -637,6 +637,14 @@
RelativePath="..\..\runtime\ClassInfo.h"
>
</File>
<File
RelativePath="..\..\runtime\CodeCache.cpp"
>
</File>
<File
RelativePath="..\..\runtime\CodeCache.h"
>
</File>
<File
RelativePath="..\..\runtime\CommonIdentifiers.cpp"
>
......@@ -1745,6 +1753,14 @@
RelativePath="..\..\bytecode\StructureStubInfo.h"
>
</File>
<File
RelativePath="..\..\bytecode\UnlinkedCodeBlock.cpp"
>
</File>
<File
RelativePath="..\..\bytecode\UnlinkedCodeBlock.h"
>
</File>
<File
RelativePath="..\..\bytecode\ValueProfile.h"
>
......@@ -2229,6 +2245,10 @@
RelativePath="..\..\parser\Parser.h"
>
</File>
<File
RelativePath="..\..\parser\ParserModes.h"
>
</File>
<File
RelativePath="..\..\parser\ParserArena.cpp"
>
......
......@@ -580,12 +580,17 @@
A75706DE118A2BCF0057F88F /* JITArithmetic32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */; };
A766B44F0EE8DCD1009518CA /* ExecutableAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
A76C51761182748D00715B05 /* JSInterfaceJIT.h in Headers */ = {isa = PBXBuildFile; fileRef = A76C51741182748D00715B05 /* JSInterfaceJIT.h */; settings = {ATTRIBUTES = (Private, ); }; };
A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A79E781E15EECBA80047C855 /* UnlinkedCodeBlock.cpp */; };
A76F54A313B28AAB00EF2BCE /* JITWriteBarrier.h in Headers */ = {isa = PBXBuildFile; fileRef = A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */; };
A77F1821164088B200640A47 /* CodeCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A77F181F164088B200640A47 /* CodeCache.cpp */; };
A77F1822164088B200640A47 /* CodeCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A77F1820164088B200640A47 /* CodeCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
A77F1825164192C700640A47 /* ParserModes.h in Headers */ = {isa = PBXBuildFile; fileRef = A77F18241641925400640A47 /* ParserModes.h */; settings = {ATTRIBUTES = (Private, ); }; };
A784A26111D16622005776AC /* ASTBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A7EE7411B98B8D0065A14F /* ASTBuilder.h */; };
A784A26411D16622005776AC /* SyntaxChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A7EE7711B98B8D0065A14F /* SyntaxChecker.h */; };
A7AFC17915F7EFE30048F57B /* ResolveOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = A7AFC17715F7EFE30048F57B /* ResolveOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */; };
A7B4ACAF1484C9CE00B38A36 /* JSExportMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B4ACAE1484C9CE00B38A36 /* JSExportMacros.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = A79E781F15EECBA80047C855 /* UnlinkedCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7C1E8E4112E72EF00A37F98 /* JITPropertyAccess32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C1E8C8112E701C00A37F98 /* JITPropertyAccess32_64.cpp */; };
A7DCB97312E5193F00911940 /* WriteBarrier.h in Headers */ = {isa = PBXBuildFile; fileRef = A7DCB77912E3D90500911940 /* WriteBarrier.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7E2EA6B0FB460CF00601F06 /* LiteralParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A7E2EA690FB460CF00601F06 /* LiteralParser.h */; };
......@@ -1378,6 +1383,11 @@
A767FF9F14F4502900789059 /* JSCTypedArrayStubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCTypedArrayStubs.h; sourceTree = "<group>"; };
A76C51741182748D00715B05 /* JSInterfaceJIT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInterfaceJIT.h; sourceTree = "<group>"; };
A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITWriteBarrier.h; sourceTree = "<group>"; };
A77F181F164088B200640A47 /* CodeCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeCache.cpp; sourceTree = "<group>"; };
A77F1820164088B200640A47 /* CodeCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeCache.h; sourceTree = "<group>"; };
A77F18241641925400640A47 /* ParserModes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ParserModes.h; sourceTree = "<group>"; };
A79E781E15EECBA80047C855 /* UnlinkedCodeBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkedCodeBlock.cpp; sourceTree = "<group>"; };
A79E781F15EECBA80047C855 /* UnlinkedCodeBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedCodeBlock.h; sourceTree = "<group>"; };
A79EDB0811531CD60019E912 /* JSObjectRefPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectRefPrivate.h; sourceTree = "<group>"; };
A7A7EE7411B98B8D0065A14F /* ASTBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTBuilder.h; sourceTree = "<group>"; };
A7A7EE7711B98B8D0065A14F /* SyntaxChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxChecker.h; sourceTree = "<group>"; };
......@@ -2063,6 +2073,7 @@
E49DC15112EF272200184A1F /* SourceProviderCache.h */,
E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */,
A7A7EE7711B98B8D0065A14F /* SyntaxChecker.h */,
A77F18241641925400640A47 /* ParserModes.h */,
);
path = parser;
sourceTree = "<group>";
......@@ -2297,6 +2308,8 @@
1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */,
A7DCB77912E3D90500911940 /* WriteBarrier.h */,
C2D58C3315912FEE0021A844 /* GCActivityCallback.cpp */,
A77F181F164088B200640A47 /* CodeCache.cpp */,
A77F1820164088B200640A47 /* CodeCache.h */,
);
path = runtime;
sourceTree = "<group>";
......@@ -2567,6 +2580,8 @@
0F93329914CA7DC10085F3C6 /* PutByIdStatus.cpp */,
0F93329A14CA7DC10085F3C6 /* PutByIdStatus.h */,
0F93329B14CA7DC10085F3C6 /* StructureSet.h */,
A79E781E15EECBA80047C855 /* UnlinkedCodeBlock.cpp */,
A79E781F15EECBA80047C855 /* UnlinkedCodeBlock.h */,
);
path = bytecode;
sourceTree = "<group>";
......@@ -2993,6 +3008,9 @@
0FEB3ECD16237F4D00AB67AD /* TypedArrayDescriptor.h in Headers */,
0F256C361627B0AD007F2783 /* DFGCallArrayAllocatorSlowPathGenerator.h in Headers */,
C2239D1B16262BDD005AC5FD /* GCThread.h in Headers */,
A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */,
A77F1822164088B200640A47 /* CodeCache.h in Headers */,
A77F1825164192C700640A47 /* ParserModes.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -3569,6 +3587,8 @@
C24D31E2161CD695002AA4DB /* HeapStatistics.cpp in Sources */,
C2239D1716262BDD005AC5FD /* CopyVisitor.cpp in Sources */,
C2239D1A16262BDD005AC5FD /* GCThread.cpp in Sources */,
A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */,
A77F1821164088B200640A47 /* CodeCache.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -69,6 +69,7 @@ SOURCES += \
bytecode/SpeculatedType.cpp \
bytecode/StructureStubClearingWatchpoint.cpp \
bytecode/StructureStubInfo.cpp \
bytecode/UnlinkedCodeBlock.cpp \
bytecode/Watchpoint.cpp \
bytecompiler/BytecodeGenerator.cpp \
bytecompiler/NodesCodegen.cpp \
......@@ -184,6 +185,7 @@ SOURCES += \
runtime/BooleanObject.cpp \
runtime/BooleanPrototype.cpp \
runtime/CallData.cpp \
runtime/CodeCache.cpp \
runtime/CommonIdentifiers.cpp \
runtime/Completion.cpp \
runtime/ConstructData.cpp \
......
......@@ -120,7 +120,7 @@ namespace JSC {
protected:
CodeBlock(CopyParsedBlockTag, CodeBlock& other);
CodeBlock(ScriptExecutable* ownerExecutable, CodeType, JSGlobalObject*, PassRefPtr<SourceProvider>, unsigned sourceOffset, bool isConstructor, PassOwnPtr<CodeBlock> alternative);
CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock*, JSGlobalObject*, unsigned baseScopeDepth, PassRefPtr<SourceProvider>, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative);
WriteBarrier<JSGlobalObject> m_globalObject;
Heap* m_heap;
......@@ -130,7 +130,6 @@ namespace JSC {
int numParameters() const { return m_numParameters; }
void setNumParameters(int newValue);
void addParameter();
int* addressOfNumParameters() { return &m_numParameters; }
static ptrdiff_t offsetOfNumParameters() { return OBJECT_OFFSETOF(CodeBlock, m_numParameters); }
......@@ -434,8 +433,7 @@ namespace JSC {
return static_cast<Instruction*>(returnAddress) - instructions().begin();
}
void setIsNumericCompareFunction(bool isNumericCompareFunction) { m_isNumericCompareFunction = isNumericCompareFunction; }
bool isNumericCompareFunction() { return m_isNumericCompareFunction; }
bool isNumericCompareFunction() { return m_unlinkedCode->isNumericCompareFunction(); }
unsigned numberOfInstructions() const { return m_instructions.size(); }
RefCountedArray<Instruction>& instructions() { return m_instructions; }
......@@ -524,10 +522,8 @@ namespace JSC {
void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; }
int thisRegister() const { return m_thisRegister; }
void setNeedsFullScopeChain(bool needsFullScopeChain) { m_needsFullScopeChain = needsFullScopeChain; }
bool needsFullScopeChain() const { return m_needsFullScopeChain; }
void setUsesEval(bool usesEval) { m_usesEval = usesEval; }
bool usesEval() const { return m_usesEval; }
bool needsFullScopeChain() const { return m_unlinkedCode->needsFullScopeChain(); }
bool usesEval() const { return m_unlinkedCode->usesEval(); }
void setArgumentsRegister(int argumentsRegister)
{
......@@ -589,37 +585,28 @@ namespace JSC {
if (usesArguments() && operand == unmodifiedArgumentsRegister(argumentsRegister()))
return true;
// We're in global code so there are no locals to capture
if (!symbolTable())
return false;
return operand >= symbolTable()->captureStart()
&& operand < symbolTable()->captureEnd();
}
CodeType codeType() const { return m_codeType; }
CodeType codeType() const { return m_unlinkedCode->codeType(); }
SourceProvider* source() const { return m_source.get(); }
unsigned sourceOffset() const { return m_sourceOffset; }
size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); }
unsigned jumpTarget(int index) const { return m_jumpTargets[index]; }
unsigned lastJumpTarget() const { return m_jumpTargets.last(); }
size_t numberOfJumpTargets() const { return m_unlinkedCode->numberOfJumpTargets(); }
unsigned jumpTarget(int index) const { return m_unlinkedCode->jumpTarget(index); }
void createActivation(CallFrame*);
void clearEvalCache();
String nameForRegister(int registerNumber);
void addPropertyAccessInstruction(unsigned propertyAccessInstruction)
{
m_propertyAccessInstructions.append(propertyAccessInstruction);
}
#if ENABLE(LLINT)
LLIntCallLinkInfo* addLLIntCallLinkInfo()
{
m_llintCallLinkInfos.append(LLIntCallLinkInfo());
return &m_llintCallLinkInfos.last();
}
#endif
#if ENABLE(JIT)
void setNumberOfStructureStubInfos(size_t size) { m_structureStubInfos.grow(size); }
size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); }
......@@ -647,14 +634,7 @@ namespace JSC {
ASSERT(result->m_bytecodeOffset == -1);
return result;
}
ValueProfile* addValueProfile(int bytecodeOffset)
{
ASSERT(bytecodeOffset != -1);
ASSERT(m_valueProfiles.isEmpty() || m_valueProfiles.last().m_bytecodeOffset < bytecodeOffset);
m_valueProfiles.append(ValueProfile(bytecodeOffset));
return &m_valueProfiles.last();
}
unsigned numberOfValueProfiles() { return m_valueProfiles.size(); }
ValueProfile* valueProfile(int index)
{
......@@ -780,25 +760,24 @@ namespace JSC {
// Exception handling support
size_t numberOfExceptionHandlers() const { return m_rareData ? m_rareData->m_exceptionHandlers.size() : 0; }
void addExceptionHandler(const HandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); }
HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
void addExpressionInfo(const ExpressionRangeInfo& expressionInfo)
void allocateHandlers(const Vector<UnlinkedHandlerInfo>& unlinkedHandlers)
{
size_t count = unlinkedHandlers.size();
if (!count)
return;
createRareDataIfNecessary();
m_rareData->m_expressionInfo.append(expressionInfo);
}
void addLineInfo(unsigned bytecodeOffset, int lineNo)
{
Vector<LineInfo>& lineInfo = m_lineInfo;
if (!lineInfo.size() || lineInfo.last().lineNumber != lineNo) {
LineInfo info = { bytecodeOffset, lineNo };
lineInfo.append(info);
m_rareData->m_exceptionHandlers.resize(count);
for (size_t i = 0; i < count; ++i) {
m_rareData->m_exceptionHandlers[i].start = unlinkedHandlers[i].start;
m_rareData->m_exceptionHandlers[i].end = unlinkedHandlers[i].end;
m_rareData->m_exceptionHandlers[i].target = unlinkedHandlers[i].target;
m_rareData->m_exceptionHandlers[i].scopeDepth = unlinkedHandlers[i].scopeDepth;
}
}
HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
bool hasExpressionInfo() { return m_rareData && m_rareData->m_expressionInfo.size(); }
bool hasExpressionInfo() { return m_unlinkedCode->hasExpressionInfo(); }
#if ENABLE(JIT)
Vector<CallReturnOffsetToBytecodeOffset>& callReturnIndexVector()
......@@ -873,6 +852,8 @@ namespace JSC {
m_constantRegisters.last().set(m_globalObject->globalData(), m_ownerExecutable.get(), v);
return result;
}
unsigned addOrFindConstant(JSValue);
WriteBarrier<Unknown>& constantRegister(int index) { return m_constantRegisters[index - FirstConstantRegisterIndex]; }
ALWAYS_INLINE bool isConstantRegisterIndex(int index) const { return index >= FirstConstantRegisterIndex; }
......@@ -896,20 +877,7 @@ namespace JSC {
}
FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); }
unsigned addRegExp(RegExp* r)
{
createRareDataIfNecessary();
unsigned size = m_rareData->m_regexps.size();
m_rareData->m_regexps.append(WriteBarrier<RegExp>(*m_globalData, ownerExecutable(), r));
return size;
}
unsigned numberOfRegExps() const
{
if (!m_rareData)
return 0;
return m_rareData->m_regexps.size();
}
RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); }
RegExp* regexp(int index) const { return m_unlinkedCode->regexp(index); }
unsigned numberOfConstantBuffers() const
{
......@@ -924,10 +892,6 @@ namespace JSC {
m_rareData->m_constantBuffers.append(buffer);
return size;
}
unsigned addConstantBuffer(unsigned length)
{
return addConstantBuffer(Vector<JSValue>(length));
}
Vector<JSValue>& constantBufferAsVector(unsigned index)
{
......@@ -964,7 +928,7 @@ namespace JSC {
StringJumpTable& stringSwitchJumpTable(int tableIndex) { ASSERT(m_rareData); return m_rareData->m_stringSwitchJumpTables[tableIndex]; }
SharedSymbolTable* symbolTable() const { return m_symbolTable.get(); }
SharedSymbolTable* symbolTable() const { return m_unlinkedCode->symbolTable(); }
EvalCodeCache& evalCodeCache() { createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; }
......@@ -1208,6 +1172,8 @@ namespace JSC {
virtual void visitWeakReferences(SlotVisitor&);
virtual void finalizeUnconditionally();
UnlinkedCodeBlock* unlinkedCodeBlock() const { return m_unlinkedCode.get(); }
private:
friend class DFGCodeBlocks;
......@@ -1219,7 +1185,21 @@ namespace JSC {
#if ENABLE(VALUE_PROFILER)
void updateAllPredictionsAndCountLiveness(OperationInProgress, unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles);
#endif
void setIdentifiers(const Vector<Identifier>& identifiers)
{
ASSERT(m_identifiers.isEmpty());
m_identifiers.appendVector(identifiers);
}
void setConstantRegisters(const Vector<WriteBarrier<Unknown> >& constants)
{
size_t count = constants.size();
m_constantRegisters.resize(count);
for (size_t i = 0; i < count; i++)
m_constantRegisters[i].set(*m_globalData, ownerExecutable(), constants[i].get());
}
void dump(ExecState*, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator&);
CString registerName(ExecState*, int r) const;
......@@ -1269,29 +1249,21 @@ namespace JSC {
#if ENABLE(JIT)
void resetStubInternal(RepatchBuffer&, StructureStubInfo&);
#endif
WriteBarrier<UnlinkedCodeBlock> m_unlinkedCode;
int m_numParameters;
WriteBarrier<ScriptExecutable> m_ownerExecutable;
JSGlobalData* m_globalData;
RefCountedArray<Instruction> m_instructions;
int m_thisRegister;
int m_argumentsRegister;
int m_activationRegister;
bool m_needsFullScopeChain;
bool m_usesEval;
bool m_isNumericCompareFunction;
bool m_isStrictMode;
CodeType m_codeType;
RefPtr<SourceProvider> m_source;
unsigned m_sourceOffset;
Vector<unsigned> m_propertyAccessInstructions;
#if ENABLE(LLINT)
SegmentedVector<LLIntCallLinkInfo, 8> m_llintCallLinkInfos;
SentinelLinkedList<LLIntCallLinkInfo, BasicRawSentinelNode<LLIntCallLinkInfo> > m_incomingLLIntCalls;
......@@ -1362,18 +1334,15 @@ namespace JSC {
unsigned m_executionEntryCount;
#endif
Vector<unsigned> m_jumpTargets;
Vector<unsigned> m_loopTargets;
// Constant Pool
Vector<Identifier> m_identifiers;
COMPILE_ASSERT(sizeof(Register) == sizeof(WriteBarrier<Unknown>), Register_must_be_same_size_as_WriteBarrier_Unknown);
// TODO: This could just be a pointer to m_unlinkedCodeBlock's data, but the DFG mutates
// it, so we're stuck with it for now.
Vector<WriteBarrier<Unknown> > m_constantRegisters;
Vector<WriteBarrier<FunctionExecutable> > m_functionDecls;
Vector<WriteBarrier<FunctionExecutable> > m_functionExprs;
WriteBarrier<SharedSymbolTable> m_symbolTable;
OwnPtr<CodeBlock> m_alternative;
ExecutionCounter m_llintExecuteCounter;
......@@ -1384,11 +1353,6 @@ namespace JSC {
uint16_t m_optimizationDelayCounter;
uint16_t m_reoptimizationRetryCounter;
Vector<LineInfo> m_lineInfo;
#if ENABLE(BYTECODE_COMMENTS)
Vector<Comment> m_bytecodeComments;
size_t m_bytecodeCommentIterator;
#endif
Vector<ResolveOperations> m_resolveOperations;
Vector<PutToBaseOperation, 1> m_putToBaseOperations;
......@@ -1397,9 +1361,6 @@ namespace JSC {
public:
Vector<HandlerInfo> m_exceptionHandlers;
// Rare Constants
Vector<WriteBarrier<RegExp> > m_regexps;
// Buffers used for large array literals
Vector<Vector<JSValue> > m_constantBuffers;
......@@ -1410,9 +1371,6 @@ namespace JSC {
EvalCodeCache m_evalCodeCache;
// Expression info - present if debugging.
Vector<ExpressionRangeInfo> m_expressionInfo;
// Line info - present if profiling or debugging.
#if ENABLE(JIT)
Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector;
#endif
......@@ -1440,8 +1398,8 @@ namespace JSC {
{
}
GlobalCodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative)
: CodeBlock(ownerExecutable, codeType, globalObject, sourceProvider, sourceOffset, false, alternative)
GlobalCodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, unsigned baseScopeDepth, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, PassOwnPtr<CodeBlock> alternative)
: CodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, baseScopeDepth, sourceProvider, sourceOffset, alternative)
{
}
};
......@@ -1453,11 +1411,11 @@ namespace JSC {
{
}
ProgramCodeBlock(ProgramExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, PassOwnPtr<CodeBlock> alternative)
: GlobalCodeBlock(ownerExecutable, codeType, globalObject, sourceProvider, 0, alternative)
ProgramCodeBlock(ProgramExecutable* ownerExecutable, UnlinkedProgramCodeBlock* unlinkedCodeBlock, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, PassOwnPtr<CodeBlock> alternative)
: GlobalCodeBlock(ownerExecutable, unlinkedCodeBlock, globalObject, 0, sourceProvider, 0, alternative)
{
}