Commit 466a745c authored by weinig@apple.com's avatar weinig@apple.com

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

        Reviewed by Cameron Zwarich.

        Split JumpTable code into its own file.

        * GNUmakefile.am:
        * JavaScriptCore.pri:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * JavaScriptCoreSources.bkl:
        * bytecode/CodeBlock.cpp:
        * bytecode/CodeBlock.h:
        * bytecode/JumpTable.cpp: Copied from bytecode/CodeBlock.cpp.
        * bytecode/JumpTable.h: Copied from bytecode/CodeBlock.h.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39071 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cb26d81f
2008-12-06 Sam Weinig <sam@webkit.org>
Reviewed by Cameron Zwarich.
Split JumpTable code into its own file.
* GNUmakefile.am:
* JavaScriptCore.pri:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* bytecode/CodeBlock.cpp:
* bytecode/CodeBlock.h:
* bytecode/JumpTable.cpp: Copied from bytecode/CodeBlock.cpp.
* bytecode/JumpTable.h: Copied from bytecode/CodeBlock.h.
2008-12-05 Sam Weinig <sam@webkit.org>
Reviewed by Cameron Zwarich.
......
......@@ -81,6 +81,8 @@ javascriptcore_sources += \
JavaScriptCore/jit/JITInlineMethods.h \
JavaScriptCore/bytecode/CodeBlock.cpp \
JavaScriptCore/bytecode/CodeBlock.h \
JavaScriptCore/bytecode/JumpTable.cpp \
JavaScriptCore/bytecode/JumpTable.h \
JavaScriptCore/bytecode/EvalCodeCache.h \
JavaScriptCore/runtime/ExceptionHelpers.cpp \
JavaScriptCore/runtime/ExceptionHelpers.h \
......
......@@ -69,6 +69,7 @@ SOURCES += \
runtime/JSActivation.cpp \
runtime/JSNotAnObject.cpp \
bytecode/CodeBlock.cpp \
bytecode/JumpTable.cpp \
jit/JIT.cpp \
jit/JITCall.cpp \
jit/JITArithmetic.cpp \
......
......@@ -1241,6 +1241,14 @@
RelativePath="..\..\bytecode\CodeBlock.h"
>
</File>
<File
RelativePath="..\..\bytecode\JumpTable.cpp"
>
</File>
<File
RelativePath="..\..\bytecode\JumpTable.h"
>
</File>
<File
RelativePath="..\..\jit\JIT.cpp"
>
......
......@@ -312,6 +312,8 @@
BCDE3AB80E6C82F5001453A7 /* Structure.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDE3AB10E6C82CF001453A7 /* Structure.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCDE3B430E6C832D001453A7 /* Structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCDE3AB00E6C82CF001453A7 /* Structure.cpp */; };
BCF605140E203EF800B9A64D /* ArgList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF605120E203EF800B9A64D /* ArgList.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCFD8C920EEB2EE700283848 /* JumpTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCFD8C900EEB2EE700283848 /* JumpTable.cpp */; };
BCFD8C930EEB2EE700283848 /* JumpTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFD8C910EEB2EE700283848 /* JumpTable.h */; };
C0A272630E50A06300E96E15 /* NotFound.h in Headers */ = {isa = PBXBuildFile; fileRef = C0A2723F0E509F1E00E96E15 /* NotFound.h */; settings = {ATTRIBUTES = (Private, ); }; };
E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */ = {isa = PBXBuildFile; fileRef = E124A8F50E555775003091F1 /* OpaqueJSString.h */; settings = {ATTRIBUTES = (Private, ); }; };
E124A8F80E555775003091F1 /* OpaqueJSString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E124A8F60E555775003091F1 /* OpaqueJSString.cpp */; };
......@@ -718,6 +720,8 @@
BCF605110E203EF800B9A64D /* ArgList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArgList.cpp; sourceTree = "<group>"; };
BCF605120E203EF800B9A64D /* ArgList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgList.h; sourceTree = "<group>"; };
BCF6553B0A2048DE0038A194 /* MathExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MathExtras.h; sourceTree = "<group>"; };
BCFD8C900EEB2EE700283848 /* JumpTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JumpTable.cpp; sourceTree = "<group>"; };
BCFD8C910EEB2EE700283848 /* JumpTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JumpTable.h; sourceTree = "<group>"; };
C0A2723F0E509F1E00E96E15 /* NotFound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotFound.h; sourceTree = "<group>"; };
D21202280AD4310C00ED79B6 /* DateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DateMath.cpp; sourceTree = "<group>"; };
D21202290AD4310C00ED79B6 /* DateMath.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DateMath.h; sourceTree = "<group>"; };
......@@ -1383,6 +1387,8 @@
969A07910ED1D3AE00F1F681 /* CodeBlock.h */,
969A07920ED1D3AE00F1F681 /* EvalCodeCache.h */,
969A07930ED1D3AE00F1F681 /* Instruction.h */,
BCFD8C900EEB2EE700283848 /* JumpTable.cpp */,
BCFD8C910EEB2EE700283848 /* JumpTable.h */,
969A07940ED1D3AE00F1F681 /* Opcode.cpp */,
969A07950ED1D3AE00F1F681 /* Opcode.h */,
1429D8830ED21C3D00B89619 /* SamplingTool.cpp */,
......@@ -1637,6 +1643,7 @@
96A746410EDDF70600904779 /* Escapes.h in Headers */,
86C36EEA0EE1289D00B3DF59 /* MacroAssembler.h in Headers */,
86CC85A10EE79A4700288682 /* JITInlineMethods.h in Headers */,
BCFD8C930EEB2EE700283848 /* JumpTable.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1979,6 +1986,7 @@
86CC85A30EE79B7400288682 /* JITCall.cpp in Sources */,
86CC85C40EE7A89400288682 /* JITPropertyAccess.cpp in Sources */,
86A90ED00EE7D51F00AB350D /* JITArithmetic.cpp in Sources */,
BCFD8C920EEB2EE700283848 /* JumpTable.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/JumpTable.cpp
runtime/ExceptionHelpers.cpp
interpreter/Interpreter.cpp
bytecode/Opcode.cpp
......
......@@ -1205,14 +1205,4 @@ void CodeBlock::shrinkToFit()
m_stringSwitchJumpTables.shrinkToFit();
}
int32_t SimpleJumpTable::offsetForValue(int32_t value, int32_t defaultOffset)
{
if (value >= min && static_cast<uint32_t>(value - min) < branchOffsets.size()) {
int32_t offset = branchOffsets[value - min];
if (offset)
return offset;
}
return defaultOffset;
}
} // namespace JSC
......@@ -33,6 +33,7 @@
#include "EvalCodeCache.h"
#include "Instruction.h"
#include "JSGlobalObject.h"
#include "JumpTable.h"
#include "Nodes.h"
#include "RegExp.h"
#include "UString.h"
......@@ -71,13 +72,6 @@ namespace JSC {
int32_t lineNumber;
};
struct OffsetLocation {
int32_t branchOffset;
#if ENABLE(JIT)
void* ctiOffset;
#endif
};
struct StructureStubInfo {
StructureStubInfo(unsigned bytecodeIndex)
: bytecodeIndex(bytecodeIndex)
......@@ -161,60 +155,6 @@ namespace JSC {
return &array[0];
}
struct StringJumpTable {
typedef HashMap<RefPtr<UString::Rep>, OffsetLocation> StringOffsetTable;
StringOffsetTable offsetTable;
#if ENABLE(JIT)
void* ctiDefault; // FIXME: it should not be necessary to store this.
#endif
inline int32_t offsetForValue(UString::Rep* value, int32_t defaultOffset)
{
StringOffsetTable::const_iterator end = offsetTable.end();
StringOffsetTable::const_iterator loc = offsetTable.find(value);
if (loc == end)
return defaultOffset;
return loc->second.branchOffset;
}
#if ENABLE(JIT)
inline void* ctiForValue(UString::Rep* value)
{
StringOffsetTable::const_iterator end = offsetTable.end();
StringOffsetTable::const_iterator loc = offsetTable.find(value);
if (loc == end)
return ctiDefault;
return loc->second.ctiOffset;
}
#endif
};
struct SimpleJumpTable {
// FIXME: The two Vectors can be combind into one Vector<OffsetLocation>
Vector<int32_t> branchOffsets;
int32_t min;
#if ENABLE(JIT)
Vector<void*> ctiOffsets;
void* ctiDefault;
#endif
int32_t offsetForValue(int32_t value, int32_t defaultOffset);
void add(int32_t key, int32_t offset)
{
if (!branchOffsets[key])
branchOffsets[key] = offset;
}
#if ENABLE(JIT)
inline void* ctiForValue(int32_t value)
{
if (value >= min && static_cast<uint32_t>(value - min) < ctiOffsets.size())
return ctiOffsets[value - min];
return ctiDefault;
}
#endif
};
class CodeBlock {
friend class JIT;
public:
......
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
*
* 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 "JumpTable.h"
namespace JSC {
int32_t SimpleJumpTable::offsetForValue(int32_t value, int32_t defaultOffset)
{
if (value >= min && static_cast<uint32_t>(value - min) < branchOffsets.size()) {
int32_t offset = branchOffsets[value - min];
if (offset)
return offset;
}
return defaultOffset;
}
} // namespace JSC
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
*
* 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 JumpTable_h
#define JumpTable_h
#include "UString.h"
#include <wtf/HashMap.h>
#include <wtf/Vector.h>
namespace JSC {
struct OffsetLocation {
int32_t branchOffset;
#if ENABLE(JIT)
void* ctiOffset;
#endif
};
struct StringJumpTable {
typedef HashMap<RefPtr<UString::Rep>, OffsetLocation> StringOffsetTable;
StringOffsetTable offsetTable;
#if ENABLE(JIT)
void* ctiDefault; // FIXME: it should not be necessary to store this.
#endif
inline int32_t offsetForValue(UString::Rep* value, int32_t defaultOffset)
{
StringOffsetTable::const_iterator end = offsetTable.end();
StringOffsetTable::const_iterator loc = offsetTable.find(value);
if (loc == end)
return defaultOffset;
return loc->second.branchOffset;
}
#if ENABLE(JIT)
inline void* ctiForValue(UString::Rep* value)
{
StringOffsetTable::const_iterator end = offsetTable.end();
StringOffsetTable::const_iterator loc = offsetTable.find(value);
if (loc == end)
return ctiDefault;
return loc->second.ctiOffset;
}
#endif
};
struct SimpleJumpTable {
// FIXME: The two Vectors can be combind into one Vector<OffsetLocation>
Vector<int32_t> branchOffsets;
int32_t min;
#if ENABLE(JIT)
Vector<void*> ctiOffsets;
void* ctiDefault;
#endif
int32_t offsetForValue(int32_t value, int32_t defaultOffset);
void add(int32_t key, int32_t offset)
{
if (!branchOffsets[key])
branchOffsets[key] = offset;
}
#if ENABLE(JIT)
inline void* ctiForValue(int32_t value)
{
if (value >= min && static_cast<uint32_t>(value - min) < ctiOffsets.size())
return ctiOffsets[value - min];
return ctiDefault;
}
#endif
};
} // namespace JSC
#endif // JumpTable_h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment