Commit 0aaf82a4 authored by weinig@apple.com's avatar weinig@apple.com

2008-12-11 Sam Weinig <sam@webkit.org>

        Reviewed by Geoffrey Garen.

        Remove dependancy on having the Instruction buffer in order to
        deref Structures used for property access and global resolves.
        Instead, we put references to the necessary Structures in axillary
        data structures on the CodeBlock. This is not an ideal solution,
        as we still pay for having the Structures in two places and we
        would like to eventually just hold on to offsets into the machine
        code buffer.

        - Also removes CodeBlock bloat in non-JIT by #ifdefing the JIT
          only data structures.

        * GNUmakefile.am:
        * JavaScriptCore.pri:
        * JavaScriptCore.scons:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * JavaScriptCoreSources.bkl:
        * bytecode/CodeBlock.cpp:
        (JSC::isGlobalResolve):
        (JSC::isPropertyAccess):
        (JSC::instructionOffsetForNth):
        (JSC::printGlobalResolveInfo):
        (JSC::printStructureStubInfo):
        (JSC::CodeBlock::printStructures):
        (JSC::CodeBlock::dump):
        (JSC::CodeBlock::~CodeBlock):
        (JSC::CodeBlock::shrinkToFit):
        * bytecode/CodeBlock.h:
        (JSC::GlobalResolveInfo::GlobalResolveInfo):
        (JSC::getNativePC):
        (JSC::CodeBlock::instructions):
        (JSC::CodeBlock::getStubInfo):
        (JSC::CodeBlock::getBytecodeIndex):
        (JSC::CodeBlock::addPropertyAccessInstruction):
        (JSC::CodeBlock::addGlobalResolveInstruction):
        (JSC::CodeBlock::numberOfStructureStubInfos):
        (JSC::CodeBlock::addStructureStubInfo):
        (JSC::CodeBlock::structureStubInfo):
        (JSC::CodeBlock::addGlobalResolveInfo):
        (JSC::CodeBlock::globalResolveInfo):
        (JSC::CodeBlock::numberOfCallLinkInfos):
        (JSC::CodeBlock::addCallLinkInfo):
        (JSC::CodeBlock::callLinkInfo):
        * bytecode/Instruction.h:
        (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
        (JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
        * bytecode/Opcode.h:
        (JSC::):
        * bytecode/StructureStubInfo.cpp: Copied from bytecode/CodeBlock.cpp.
        (JSC::StructureStubInfo::deref):
        * bytecode/StructureStubInfo.h: Copied from bytecode/CodeBlock.h.
        (JSC::StructureStubInfo::StructureStubInfo):
        (JSC::StructureStubInfo::initGetByIdSelf):
        (JSC::StructureStubInfo::initGetByIdProto):
        (JSC::StructureStubInfo::initGetByIdChain):
        (JSC::StructureStubInfo::initGetByIdSelfList):
        (JSC::StructureStubInfo::initGetByIdProtoList):
        (JSC::StructureStubInfo::initPutByIdTransition):
        (JSC::StructureStubInfo::initPutByIdReplace):
        (JSC::StructureStubInfo::):
        * bytecompiler/BytecodeGenerator.cpp:
        (JSC::BytecodeGenerator::emitResolve):
        (JSC::BytecodeGenerator::emitGetById):
        (JSC::BytecodeGenerator::emitPutById):
        (JSC::BytecodeGenerator::emitCall):
        (JSC::BytecodeGenerator::emitConstruct):
        (JSC::BytecodeGenerator::emitCatch):
        * interpreter/Interpreter.cpp:
        (JSC::Interpreter::tryCTICachePutByID):
        (JSC::Interpreter::tryCTICacheGetByID):
        (JSC::Interpreter::cti_op_get_by_id_self_fail):
        (JSC::getPolymorphicAccessStructureListSlot):
        (JSC::Interpreter::cti_op_get_by_id_proto_list):
        (JSC::Interpreter::cti_op_resolve_global):
        * jit/JIT.cpp:
        (JSC::JIT::JIT):
        (JSC::JIT::privateCompileMainPass):
        (JSC::JIT::privateCompileSlowCases):
        (JSC::JIT::privateCompile):
        * jit/JITPropertyAccess.cpp:
        (JSC::JIT::compileGetByIdHotPath):
        (JSC::JIT::compilePutByIdHotPath):
        (JSC::JIT::compileGetByIdSlowCase):
        (JSC::JIT::compilePutByIdSlowCase):
        (JSC::JIT::privateCompileGetByIdSelfList):
        (JSC::JIT::privateCompileGetByIdProtoList):
        (JSC::JIT::privateCompileGetByIdChainList):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39229 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a7ce2734
2008-12-11 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
Remove dependancy on having the Instruction buffer in order to
deref Structures used for property access and global resolves.
Instead, we put references to the necessary Structures in axillary
data structures on the CodeBlock. This is not an ideal solution,
as we still pay for having the Structures in two places and we
would like to eventually just hold on to offsets into the machine
code buffer.
- Also removes CodeBlock bloat in non-JIT by #ifdefing the JIT
only data structures.
* GNUmakefile.am:
* JavaScriptCore.pri:
* JavaScriptCore.scons:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* bytecode/CodeBlock.cpp:
(JSC::isGlobalResolve):
(JSC::isPropertyAccess):
(JSC::instructionOffsetForNth):
(JSC::printGlobalResolveInfo):
(JSC::printStructureStubInfo):
(JSC::CodeBlock::printStructures):
(JSC::CodeBlock::dump):
(JSC::CodeBlock::~CodeBlock):
(JSC::CodeBlock::shrinkToFit):
* bytecode/CodeBlock.h:
(JSC::GlobalResolveInfo::GlobalResolveInfo):
(JSC::getNativePC):
(JSC::CodeBlock::instructions):
(JSC::CodeBlock::getStubInfo):
(JSC::CodeBlock::getBytecodeIndex):
(JSC::CodeBlock::addPropertyAccessInstruction):
(JSC::CodeBlock::addGlobalResolveInstruction):
(JSC::CodeBlock::numberOfStructureStubInfos):
(JSC::CodeBlock::addStructureStubInfo):
(JSC::CodeBlock::structureStubInfo):
(JSC::CodeBlock::addGlobalResolveInfo):
(JSC::CodeBlock::globalResolveInfo):
(JSC::CodeBlock::numberOfCallLinkInfos):
(JSC::CodeBlock::addCallLinkInfo):
(JSC::CodeBlock::callLinkInfo):
* bytecode/Instruction.h:
(JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
(JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
* bytecode/Opcode.h:
(JSC::):
* bytecode/StructureStubInfo.cpp: Copied from bytecode/CodeBlock.cpp.
(JSC::StructureStubInfo::deref):
* bytecode/StructureStubInfo.h: Copied from bytecode/CodeBlock.h.
(JSC::StructureStubInfo::StructureStubInfo):
(JSC::StructureStubInfo::initGetByIdSelf):
(JSC::StructureStubInfo::initGetByIdProto):
(JSC::StructureStubInfo::initGetByIdChain):
(JSC::StructureStubInfo::initGetByIdSelfList):
(JSC::StructureStubInfo::initGetByIdProtoList):
(JSC::StructureStubInfo::initPutByIdTransition):
(JSC::StructureStubInfo::initPutByIdReplace):
(JSC::StructureStubInfo::):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitResolve):
(JSC::BytecodeGenerator::emitGetById):
(JSC::BytecodeGenerator::emitPutById):
(JSC::BytecodeGenerator::emitCall):
(JSC::BytecodeGenerator::emitConstruct):
(JSC::BytecodeGenerator::emitCatch):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::tryCTICachePutByID):
(JSC::Interpreter::tryCTICacheGetByID):
(JSC::Interpreter::cti_op_get_by_id_self_fail):
(JSC::getPolymorphicAccessStructureListSlot):
(JSC::Interpreter::cti_op_get_by_id_proto_list):
(JSC::Interpreter::cti_op_resolve_global):
* jit/JIT.cpp:
(JSC::JIT::JIT):
(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):
(JSC::JIT::privateCompile):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::compileGetByIdHotPath):
(JSC::JIT::compilePutByIdHotPath):
(JSC::JIT::compileGetByIdSlowCase):
(JSC::JIT::compilePutByIdSlowCase):
(JSC::JIT::privateCompileGetByIdSelfList):
(JSC::JIT::privateCompileGetByIdProtoList):
(JSC::JIT::privateCompileGetByIdChainList):
2008-12-11 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -81,6 +81,8 @@ javascriptcore_sources += \
JavaScriptCore/jit/ExecutableAllocatorPosix.cpp \
JavaScriptCore/jit/JIT.h \
JavaScriptCore/jit/JITInlineMethods.h \
JavaScriptCore/bytecode/StructureStubInfo.cpp \
JavaScriptCore/bytecode/StructureStubInfo.h \
JavaScriptCore/bytecode/CodeBlock.cpp \
JavaScriptCore/bytecode/CodeBlock.h \
JavaScriptCore/bytecode/JumpTable.cpp \
......
......@@ -69,6 +69,7 @@ SOURCES += \
runtime/JSActivation.cpp \
runtime/JSNotAnObject.cpp \
bytecode/CodeBlock.cpp \
bytecode/StructureStubInfo.cpp \
bytecode/JumpTable.cpp \
jit/JIT.cpp \
jit/JITCall.cpp \
......
......@@ -116,6 +116,7 @@ sources['runtime'] = [
]
sources['bytecode'] = [
'bytecode/CodeBlock.cpp',
'bytecode/StructureStubInfo.cpp',
'bytecode/JumpTable.cpp',
'bytecode/Opcode.cpp',
'bytecode/SamplingTool.cpp',
......
......@@ -1233,6 +1233,14 @@
<Filter
Name="bytecode"
>
<File
RelativePath="..\..\bytecode\StructureStubInfo.cpp"
>
</File>
<File
RelativePath="..\..\bytecode\StructureStubInfo.h"
>
</File>
<File
RelativePath="..\..\bytecode\CodeBlock.cpp"
>
......
......@@ -306,6 +306,8 @@
BC7F8FB90E19D1C3008632C0 /* JSNumberCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F8FB80E19D1C3008632C0 /* JSNumberCell.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC9041480EB9250900FE26FA /* StructureTransitionTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9041470EB9250900FE26FA /* StructureTransitionTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC95437D0EBA70FD0072B6D3 /* PropertyMapHashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BC95437C0EBA70FD0072B6D3 /* PropertyMapHashTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCCF0D080EF0AAB900413C8F /* StructureStubInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BCCF0D070EF0AAB900413C8F /* StructureStubInfo.h */; };
BCCF0D0C0EF0B8A500413C8F /* StructureStubInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCCF0D0B0EF0B8A500413C8F /* StructureStubInfo.cpp */; };
BCD202C20E1706A7002C7E82 /* RegExpConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202BE0E1706A7002C7E82 /* RegExpConstructor.h */; };
BCD202C40E1706A7002C7E82 /* RegExpPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */; };
BCD202D60E170708002C7E82 /* RegExpConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202D50E170708002C7E82 /* RegExpConstructor.lut.h */; };
......@@ -711,6 +713,8 @@
BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalFunction.cpp; sourceTree = "<group>"; };
BCA62DFE0E2826230004F30D /* CallData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CallData.cpp; sourceTree = "<group>"; };
BCA62DFF0E2826310004F30D /* ConstructData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstructData.cpp; sourceTree = "<group>"; };
BCCF0D070EF0AAB900413C8F /* StructureStubInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureStubInfo.h; sourceTree = "<group>"; };
BCCF0D0B0EF0B8A500413C8F /* StructureStubInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructureStubInfo.cpp; sourceTree = "<group>"; };
BCD202BD0E1706A7002C7E82 /* RegExpConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpConstructor.cpp; sourceTree = "<group>"; };
BCD202BE0E1706A7002C7E82 /* RegExpConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpConstructor.h; sourceTree = "<group>"; };
BCD202BF0E1706A7002C7E82 /* RegExpPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpPrototype.cpp; sourceTree = "<group>"; };
......@@ -1402,6 +1406,8 @@
969A07950ED1D3AE00F1F681 /* Opcode.h */,
1429D8830ED21C3D00B89619 /* SamplingTool.cpp */,
1429D8840ED21C3D00B89619 /* SamplingTool.h */,
BCCF0D0B0EF0B8A500413C8F /* StructureStubInfo.cpp */,
BCCF0D070EF0AAB900413C8F /* StructureStubInfo.h */,
);
path = bytecode;
sourceTree = "<group>";
......@@ -1654,6 +1660,7 @@
BC18C44D0E16F5CD00B34460 /* pcre.h in Headers */,
BC18C44E0E16F5CD00B34460 /* pcre_internal.h in Headers */,
BC18C4720E16F5CD00B34460 /* ucpinternal.h in Headers */,
BCCF0D080EF0AAB900413C8F /* StructureStubInfo.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1999,6 +2006,7 @@
930754D008B0F74600AB3056 /* pcre_tables.cpp in Sources */,
937013480CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp in Sources */,
93E26BD408B1514100F85226 /* pcre_xclass.cpp in Sources */,
BCCF0D0C0EF0B8A500413C8F /* StructureStubInfo.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -147,6 +147,7 @@ Source files for JSCore.
</set>
<set append="1" var="JSCORE_VM_SOURCES">
bytecode/CodeBlock.cpp
bytecode/StructureStubInfo.cpp
bytecode/JumpTable.cpp
runtime/ExceptionHelpers.cpp
interpreter/Interpreter.cpp
......
This diff is collapsed.
......@@ -40,6 +40,10 @@
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#if ENABLE(JIT)
#include "StructureStubInfo.h"
#endif
namespace JSC {
class ExecState;
......@@ -53,7 +57,9 @@ namespace JSC {
uint32_t end;
uint32_t target;
uint32_t scopeDepth;
#if ENABLE(JIT)
void* nativeCode;
#endif
};
struct ExpressionRangeInfo {
......@@ -72,21 +78,7 @@ namespace JSC {
int32_t lineNumber;
};
struct StructureStubInfo {
StructureStubInfo(unsigned bytecodeIndex)
: bytecodeIndex(bytecodeIndex)
, stubRoutine(0)
, callReturnLocation(0)
, hotPathBegin(0)
{
}
unsigned bytecodeIndex;
void* stubRoutine;
void* callReturnLocation;
void* hotPathBegin;
};
#if ENABLE(JIT)
struct CallLinkInfo {
CallLinkInfo()
: callReturnLocation(0)
......@@ -109,7 +101,17 @@ namespace JSC {
bool isLinked() { return callee; }
};
#if ENABLE(JIT)
struct GlobalResolveInfo {
GlobalResolveInfo()
: structure(0)
, offset(0)
{
}
Structure* structure;
unsigned offset;
};
struct PC {
PC(void* nativePC, unsigned bytecodeIndex)
: nativePC(nativePC)
......@@ -120,7 +122,6 @@ namespace JSC {
void* nativePC;
unsigned bytecodeIndex;
};
#endif
// valueAtPosition helpers for the binaryChop algorithm below.
......@@ -134,12 +135,10 @@ namespace JSC {
return callLinkInfo->callReturnLocation;
}
#if ENABLE(JIT)
inline void* getNativePC(PC* pc)
{
return pc->nativePC;
}
#endif
// Binary chop algorithm, calls valueAtPosition on pre-sorted elements in array,
// compares result with key (KeyTypes should be comparable with '--', '<', '>').
......@@ -176,6 +175,7 @@ namespace JSC {
ASSERT(key == valueAtPosition(&array[0]));
return &array[0];
}
#endif
class CodeBlock {
friend class JIT;
......@@ -183,30 +183,20 @@ namespace JSC {
CodeBlock(ScopeNode* ownerNode, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);
~CodeBlock();
static void dumpStatistics();
#if ENABLE(JIT)
void mark();
void refStructures(Instruction* vPC) const;
void derefStructures(Instruction* vPC) const;
#if ENABLE(JIT)
void unlinkCallers();
#endif
void addCaller(CallLinkInfo* caller)
{
caller->callee = this;
caller->position = m_linkedCallerList.size();
m_linkedCallerList.append(caller);
}
void removeCaller(CallLinkInfo* caller)
{
unsigned pos = caller->position;
unsigned lastPos = m_linkedCallerList.size() - 1;
static void dumpStatistics();
if (pos != lastPos) {
m_linkedCallerList[pos] = m_linkedCallerList[lastPos];
m_linkedCallerList[pos]->position = pos;
}
m_linkedCallerList.shrink(lastPos);
}
#if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING
void dump(ExecState*) const;
void printStructures(const Instruction*) const;
void printStructure(const char* name, const Instruction*, int operand) const;
#endif
inline bool isKnownNotImmediate(int index)
{
......@@ -234,22 +224,33 @@ namespace JSC {
return index >= m_numVars + m_numConstants;
}
#if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING
void dump(ExecState*) const;
void printStructures(const Instruction*) const;
void printStructure(const char* name, const Instruction*, int operand) const;
#endif
int expressionRangeForVPC(const Instruction*, int& divot, int& startOffset, int& endOffset);
int lineNumberForVPC(const Instruction* vPC);
HandlerInfo* handlerForVPC(const Instruction* vPC);
void mark();
void refStructures(Instruction* vPC) const;
void derefStructures(Instruction* vPC) const;
#if ENABLE(JIT)
void addCaller(CallLinkInfo* caller)
{
caller->callee = this;
caller->position = m_linkedCallerList.size();
m_linkedCallerList.append(caller);
}
void removeCaller(CallLinkInfo* caller)
{
unsigned pos = caller->position;
unsigned lastPos = m_linkedCallerList.size() - 1;
if (pos != lastPos) {
m_linkedCallerList[pos] = m_linkedCallerList[lastPos];
m_linkedCallerList[pos]->position = pos;
}
m_linkedCallerList.shrink(lastPos);
}
StructureStubInfo& getStubInfo(void* returnAddress)
{
return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_propertyAccessInstructions.begin(), m_propertyAccessInstructions.size(), returnAddress));
return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_structureStubInfos.begin(), m_structureStubInfos.size(), returnAddress));
}
CallLinkInfo& getCallLinkInfo(void* returnAddress)
......@@ -257,7 +258,6 @@ namespace JSC {
return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(m_callLinkInfos.begin(), m_callLinkInfos.size(), returnAddress));
}
#if ENABLE(JIT)
unsigned getBytecodeIndex(void* nativePC)
{
return binaryChop<PC, void*, getNativePC>(m_pcVector.begin(), m_pcVector.size(), nativePC)->bytecodeIndex;
......@@ -265,6 +265,7 @@ namespace JSC {
#endif
Vector<Instruction>& instructions() { return m_instructions; }
#if ENABLE(JIT)
void setJITCode(void* jitCode) { m_jitCode = jitCode; }
void* jitCode() { return m_jitCode; }
......@@ -291,16 +292,6 @@ namespace JSC {
SourceProvider* source() const { return m_source.get(); }
unsigned sourceOffset() const { return m_sourceOffset; }
void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
size_t numberOfPropertyAccessInstructions() const { return m_propertyAccessInstructions.size(); }
void addPropertyAccessInstruction(unsigned propertyAccessInstructions) { m_propertyAccessInstructions.append(StructureStubInfo(propertyAccessInstructions)); }
StructureStubInfo& propertyAccessInstruction(int index) { return m_propertyAccessInstructions[index]; }
size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); }
CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; }
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]; }
......@@ -316,7 +307,21 @@ namespace JSC {
void addLineInfo(const LineInfo& lineInfo) { return m_lineInfo.append(lineInfo); }
LineInfo& lastLineInfo() { return m_lineInfo.last(); }
#if ENABLE(JIT)
#if !ENABLE(JIT)
void addPropertyAccessInstruction(unsigned propertyAccessInstruction) { m_propertyAccessInstructions.append(propertyAccessInstruction); }
void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); }
#else
size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); }
void addStructureStubInfo(const StructureStubInfo& stubInfo) { m_structureStubInfos.append(stubInfo); }
StructureStubInfo& structureStubInfo(int index) { return m_structureStubInfos[index]; }
void addGlobalResolveInfo() { m_globalResolveInfos.append(GlobalResolveInfo()); }
GlobalResolveInfo& globalResolveInfo(int index) { return m_globalResolveInfos[index]; }
size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); }
void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); }
CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; }
Vector<PC>& pcVector() { return m_pcVector; }
#endif
......@@ -407,10 +412,15 @@ namespace JSC {
RefPtr<SourceProvider> m_source;
unsigned m_sourceOffset;
#if !ENABLE(JIT)
Vector<unsigned> m_propertyAccessInstructions;
Vector<unsigned> m_globalResolveInstructions;
Vector<StructureStubInfo> m_propertyAccessInstructions;
#else
Vector<StructureStubInfo> m_structureStubInfos;
Vector<GlobalResolveInfo> m_globalResolveInfos;
Vector<CallLinkInfo> m_callLinkInfos;
Vector<CallLinkInfo*> m_linkedCallerList;
#endif
Vector<unsigned> m_jumpTargets;
......
......@@ -30,6 +30,7 @@
#define Instruction_h
#include "Opcode.h"
#include "Structure.h"
#include <wtf/VectorTraits.h>
#define POLYMORPHIC_LIST_CACHE_SIZE 4
......@@ -40,11 +41,10 @@ namespace JSC {
class Structure;
class StructureChain;
// Structure used by op_get_by_id_proto_list instruction to hold data off the main opcode stream.
// Structure used by op_get_by_id_self_list and op_get_by_id_proto_list instruction to hold data off the main opcode stream.
struct PolymorphicAccessStructureList {
struct PolymorphicStubInfo {
unsigned cachedOffset : 31;
unsigned isChain : 1;
bool isChain;
void* stubRoutine;
Structure* base;
union {
......@@ -52,27 +52,24 @@ namespace JSC {
StructureChain* chain;
} u;
void set(int _cachedOffset, void* _stubRoutine, Structure* _base)
void set(void* _stubRoutine, Structure* _base)
{
cachedOffset = _cachedOffset;
stubRoutine = _stubRoutine;
base = _base;
u.proto = 0;
isChain = false;
}
void set(int _cachedOffset, void* _stubRoutine, Structure* _base, Structure* _proto)
void set(void* _stubRoutine, Structure* _base, Structure* _proto)
{
cachedOffset = _cachedOffset;
stubRoutine = _stubRoutine;
base = _base;
u.proto = _proto;
isChain = false;
}
void set(int _cachedOffset, void* _stubRoutine, Structure* _base, StructureChain* _chain)
void set(void* _stubRoutine, Structure* _base, StructureChain* _chain)
{
cachedOffset = _cachedOffset;
stubRoutine = _stubRoutine;
base = _base;
u.chain = _chain;
......@@ -80,19 +77,19 @@ namespace JSC {
}
} list[POLYMORPHIC_LIST_CACHE_SIZE];
PolymorphicAccessStructureList(int cachedOffset, void* stubRoutine, Structure* firstBase)
PolymorphicAccessStructureList(void* stubRoutine, Structure* firstBase)
{
list[0].set(cachedOffset, stubRoutine, firstBase);
list[0].set(stubRoutine, firstBase);
}
PolymorphicAccessStructureList(int cachedOffset, void* stubRoutine, Structure* firstBase, Structure* firstProto)
PolymorphicAccessStructureList(void* stubRoutine, Structure* firstBase, Structure* firstProto)
{
list[0].set(cachedOffset, stubRoutine, firstBase, firstProto);
list[0].set(stubRoutine, firstBase, firstProto);
}
PolymorphicAccessStructureList(int cachedOffset, void* stubRoutine, Structure* firstBase, StructureChain* firstChain)
PolymorphicAccessStructureList(void* stubRoutine, Structure* firstBase, StructureChain* firstChain)
{
list[0].set(cachedOffset, stubRoutine, firstBase, firstChain);
list[0].set(stubRoutine, firstBase, firstChain);
}
void derefStructures(int count)
......
......@@ -178,6 +178,10 @@ namespace JSC {
#define OPCODE_LENGTH(opcode) opcode##_length
#define OPCODE_ID_LENGTH_MAP(opcode, length) length,
const int opcodeLengths[numOpcodeIDs] = { FOR_EACH_OPCODE_ID(OPCODE_ID_LENGTH_MAP) };
#undef OPCODE_ID_LENGTH_MAP
#define VERIFY_OPCODE_ID(id, size) COMPILE_ASSERT(id <= op_end, ASSERT_THAT_JS_OPCODE_IDS_ARE_VALID);
FOR_EACH_OPCODE_ID(VERIFY_OPCODE_ID);
#undef VERIFY_OPCODE_ID
......
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "StructureStubInfo.h"
namespace JSC {
#if ENABLE(JIT)
void StructureStubInfo::deref()
{
switch (opcodeID) {
case op_get_by_id_self:
u.getByIdSelf.baseObjectStructure->deref();
return;
case op_get_by_id_proto:
u.getByIdProto.baseObjectStructure->deref();
u.getByIdProto.prototypeStructure->deref();
return;
case op_get_by_id_chain:
u.getByIdChain.baseObjectStructure->deref();
u.getByIdChain.chain->deref();
return;
case op_get_by_id_self_list: {
PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
polymorphicStructures->derefStructures(u.getByIdSelfList.listSize);
delete polymorphicStructures;
return;
}
case op_get_by_id_proto_list: {
PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList;
polymorphicStructures->derefStructures(u.getByIdProtoList.listSize);
delete polymorphicStructures;
return;
}
case op_put_by_id_transition:
u.putByIdTransition.previousStructure->deref();
u.putByIdTransition.structure->deref();
u.putByIdTransition.chain->deref();
return;
case op_put_by_id_replace:
u.putByIdReplace.baseObjectStructure->deref();
return;
case op_get_by_id:
case op_put_by_id:
case op_get_by_id_generic:
case op_put_by_id_generic:
case op_get_array_length:
case op_get_string_length:
// These instructions don't ref their Structures.
return;
default:
ASSERT_NOT_REACHED();
}
}
#endif
} // namespace JSC
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef StructureStubInfo_h
#define StructureStubInfo_h
#include "Instruction.h"
#include "Opcode.h"
#include "Structure.h"
namespace JSC {
#if ENABLE(JIT)
struct StructureStubInfo {
StructureStubInfo(OpcodeID opcodeID)
: opcodeID(opcodeID)
, stubRoutine(0)
, callReturnLocation(0)
, hotPathBegin(0)
{
}
void initGetByIdSelf(Structure* baseObjectStructure)
{
opcodeID = op_get_by_id_self;
u.getByIdSelf.baseObjectStructure = baseObjectStructure;
baseObjectStructure->ref();
}
void initGetByIdProto(Structure* baseObjectStructure, Structure* prototypeStructure)
{
opcodeID = op_get_by_id_proto;
u.getByIdProto.baseObjectStructure = baseObjectStructure;
baseObjectStructure->ref();
u.getByIdProto.prototypeStructure = prototypeStructure;
prototypeStructure->ref();
}