Commit acf7fea8 authored by barraclough@apple.com's avatar barraclough@apple.com

2009-06-15 Gavin Barraclough <barraclough@apple.com>

        Reviewed by Sam Weinig.

        Having moved most of their functionality into the RepatchBuffer class,
        we can simplify the CodeLocation* classes.

        The CodeLocation* classes are currently a tangle of templatey and friendly
        badness, burried in the middle of AbstractMacroAssembler.  Having moved
        the ability to repatch out into RepatchBufer they are now do-nothing wrappers
        on CodePtr (MacroAssemblerCodePtr), that only exist to provide type-safety.

        Simplify the code, and move them off into their own header.

        * JavaScriptCore.xcodeproj/project.pbxproj:
        * assembler/AbstractMacroAssembler.h:
        (JSC::AbstractMacroAssembler::PatchBuffer::patch):
        * assembler/CodeLocation.h: Copied from assembler/AbstractMacroAssembler.h.
        (JSC::CodeLocationCommon::CodeLocationCommon):
        (JSC::CodeLocationInstruction::CodeLocationInstruction):
        (JSC::CodeLocationLabel::CodeLocationLabel):
        (JSC::CodeLocationJump::CodeLocationJump):
        (JSC::CodeLocationCall::CodeLocationCall):
        (JSC::CodeLocationNearCall::CodeLocationNearCall):
        (JSC::CodeLocationDataLabel32::CodeLocationDataLabel32):
        (JSC::CodeLocationDataLabelPtr::CodeLocationDataLabelPtr):
        (JSC::CodeLocationCommon::instructionAtOffset):
        (JSC::CodeLocationCommon::labelAtOffset):
        (JSC::CodeLocationCommon::jumpAtOffset):
        (JSC::CodeLocationCommon::callAtOffset):
        (JSC::CodeLocationCommon::nearCallAtOffset):
        (JSC::CodeLocationCommon::dataLabelPtrAtOffset):
        (JSC::CodeLocationCommon::dataLabel32AtOffset):
        * assembler/MacroAssemblerCodeRef.h:
        (JSC::MacroAssemblerCodePtr::operator!):
        * bytecode/CodeBlock.h:
        (JSC::getStructureStubInfoReturnLocation):
        (JSC::getCallLinkInfoReturnLocation):
        (JSC::getMethodCallLinkInfoReturnLocation):
        * bytecode/Instruction.h:
        * bytecode/JumpTable.h:
        (JSC::StringJumpTable::ctiForValue):
        (JSC::SimpleJumpTable::ctiForValue):
        * bytecode/StructureStubInfo.h:
        * bytecompiler/BytecodeGenerator.cpp:
        (JSC::BytecodeGenerator::emitCatch):
        * jit/JIT.cpp:
        (JSC::JIT::privateCompile):
        * jit/JITStubs.cpp:
        (JSC::JITStubs::DEFINE_STUB_FUNCTION):
        (JSC::JITStubs::getPolymorphicAccessStructureListSlot):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44711 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 27a703f3
2009-06-15 Gavin Barraclough <barraclough@apple.com>
Reviewed by Sam Weinig.
Having moved most of their functionality into the RepatchBuffer class,
we can simplify the CodeLocation* classes.
The CodeLocation* classes are currently a tangle of templatey and friendly
badness, burried in the middle of AbstractMacroAssembler. Having moved
the ability to repatch out into RepatchBufer they are now do-nothing wrappers
on CodePtr (MacroAssemblerCodePtr), that only exist to provide type-safety.
Simplify the code, and move them off into their own header.
* JavaScriptCore.xcodeproj/project.pbxproj:
* assembler/AbstractMacroAssembler.h:
(JSC::AbstractMacroAssembler::PatchBuffer::patch):
* assembler/CodeLocation.h: Copied from assembler/AbstractMacroAssembler.h.
(JSC::CodeLocationCommon::CodeLocationCommon):
(JSC::CodeLocationInstruction::CodeLocationInstruction):
(JSC::CodeLocationLabel::CodeLocationLabel):
(JSC::CodeLocationJump::CodeLocationJump):
(JSC::CodeLocationCall::CodeLocationCall):
(JSC::CodeLocationNearCall::CodeLocationNearCall):
(JSC::CodeLocationDataLabel32::CodeLocationDataLabel32):
(JSC::CodeLocationDataLabelPtr::CodeLocationDataLabelPtr):
(JSC::CodeLocationCommon::instructionAtOffset):
(JSC::CodeLocationCommon::labelAtOffset):
(JSC::CodeLocationCommon::jumpAtOffset):
(JSC::CodeLocationCommon::callAtOffset):
(JSC::CodeLocationCommon::nearCallAtOffset):
(JSC::CodeLocationCommon::dataLabelPtrAtOffset):
(JSC::CodeLocationCommon::dataLabel32AtOffset):
* assembler/MacroAssemblerCodeRef.h:
(JSC::MacroAssemblerCodePtr::operator!):
* bytecode/CodeBlock.h:
(JSC::getStructureStubInfoReturnLocation):
(JSC::getCallLinkInfoReturnLocation):
(JSC::getMethodCallLinkInfoReturnLocation):
* bytecode/Instruction.h:
* bytecode/JumpTable.h:
(JSC::StringJumpTable::ctiForValue):
(JSC::SimpleJumpTable::ctiForValue):
* bytecode/StructureStubInfo.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitCatch):
* jit/JIT.cpp:
(JSC::JIT::privateCompile):
* jit/JITStubs.cpp:
(JSC::JITStubs::DEFINE_STUB_FUNCTION):
(JSC::JITStubs::getPolymorphicAccessStructureListSlot):
2009-06-15 Gavin Barraclough <barraclough@apple.com>
Reviewed by Sam Weinig.
......@@ -136,6 +136,7 @@
86CC85C40EE7A89400288682 /* JITPropertyAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CC85C30EE7A89400288682 /* JITPropertyAccess.cpp */; };
86CCEFDE0F413F8900FD7F9E /* JITCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CCEFDD0F413F8900FD7F9E /* JITCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
86DB64640F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86DB64630F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp */; };
86E116B10FE75AC800B512BC /* CodeLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E116B00FE75AC800B512BC /* CodeLocation.h */; };
86EAC4950F93E8D1008EC948 /* RegexCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EAC48D0F93E8D1008EC948 /* RegexCompiler.cpp */; };
86EAC4960F93E8D1008EC948 /* RegexCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EAC48E0F93E8D1008EC948 /* RegexCompiler.h */; };
86EAC4970F93E8D1008EC948 /* RegexInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EAC48F0F93E8D1008EC948 /* RegexInterpreter.cpp */; };
......@@ -641,6 +642,7 @@
86CCEFDD0F413F8900FD7F9E /* JITCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITCode.h; sourceTree = "<group>"; };
86DB645F0F954E9100D7D921 /* ExecutableAllocatorWin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorWin.cpp; sourceTree = "<group>"; };
86DB64630F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorFixedVMPool.cpp; sourceTree = "<group>"; };
86E116B00FE75AC800B512BC /* CodeLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeLocation.h; sourceTree = "<group>"; };
86EAC48D0F93E8D1008EC948 /* RegexCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegexCompiler.cpp; path = yarr/RegexCompiler.cpp; sourceTree = "<group>"; };
86EAC48E0F93E8D1008EC948 /* RegexCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegexCompiler.h; path = yarr/RegexCompiler.h; sourceTree = "<group>"; };
86EAC48F0F93E8D1008EC948 /* RegexInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegexInterpreter.cpp; path = yarr/RegexInterpreter.cpp; sourceTree = "<group>"; };
......@@ -1546,6 +1548,7 @@
860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */,
86ADD1430FDDEA980006EEC2 /* ARMv7Assembler.h */,
9688CB130ED12B4E001D649F /* AssemblerBuffer.h */,
86E116B00FE75AC800B512BC /* CodeLocation.h */,
863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */,
86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */,
860161E00F3A83C100F84710 /* MacroAssemblerX86.h */,
......@@ -1859,6 +1862,7 @@
A7F9949B0FD746A300A0B2D0 /* JSONObject.lut.h in Headers */,
86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
86ADD1460FDDEA980006EEC2 /* MacroAssemblerARMv7.h in Headers */,
86E116B10FE75AC800B512BC /* CodeLocation.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -29,6 +29,7 @@
#include <wtf/Platform.h>
#include <MacroAssemblerCodeRef.h>
#include <CodeLocation.h>
#include <wtf/Noncopyable.h>
#include <wtf/UnusedParam.h>
......@@ -50,13 +51,6 @@ public:
class Jump;
class PatchBuffer;
class RepatchBuffer;
class CodeLocationInstruction;
class CodeLocationLabel;
class CodeLocationJump;
class CodeLocationCall;
class CodeLocationNearCall;
class CodeLocationDataLabel32;
class CodeLocationDataLabelPtr;
typedef typename AssemblerType::RegisterID RegisterID;
typedef typename AssemblerType::FPRegisterID FPRegisterID;
......@@ -412,223 +406,7 @@ public:
};
// Section 3: MacroAssembler JIT instruction stream handles.
//
// The MacroAssembler supported facilities to modify a JIT generated
// instruction stream after it has been generated (relinking calls and
// jumps, and repatching data values). The following types are used
// to store handles into the underlying instruction stream, the type
// providing semantic information as to what it is that is in the
// instruction stream at this point, and thus what operations may be
// performed on it.
// CodeLocationCommon:
//
// Base type for other CodeLocation* types. A postion in the JIT genertaed
// instruction stream, without any semantic information.
class CodeLocationCommon {
friend class RepatchBuffer;
public:
CodeLocationCommon()
{
}
// In order to avoid the need to store multiple handles into the
// instructions stream, where the code generation is deterministic
// and the labels will always be a fixed distance apart, these
// methods may be used to recover a handle that has nopw been
// retained, based on a known fixed relative offset from one that has.
CodeLocationInstruction instructionAtOffset(int offset);
CodeLocationLabel labelAtOffset(int offset);
CodeLocationJump jumpAtOffset(int offset);
CodeLocationCall callAtOffset(int offset);
CodeLocationNearCall nearCallAtOffset(int offset);
CodeLocationDataLabelPtr dataLabelPtrAtOffset(int offset);
CodeLocationDataLabel32 dataLabel32AtOffset(int offset);
protected:
explicit CodeLocationCommon(CodePtr location)
: m_location(location)
{
}
void* dataLocation() { return m_location.dataLocation(); }
void* executableAddress() { return m_location.executableAddress(); }
void reset()
{
m_location = CodePtr();
}
private:
CodePtr m_location;
};
// CodeLocationInstruction:
//
// An arbitrary instruction in the JIT code.
class CodeLocationInstruction : public CodeLocationCommon {
public:
CodeLocationInstruction()
{
}
explicit CodeLocationInstruction(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
};
// CodeLocationLabel:
//
// A point in the JIT code maked with a label.
class CodeLocationLabel : public CodeLocationCommon {
friend class CodeLocationCommon;
friend class CodeLocationJump;
friend class CodeLocationCall;
friend class CodeLocationNearCall;
friend class PatchBuffer;
friend class RepatchBuffer;
public:
CodeLocationLabel()
{
}
void* addressForSwitch() { return this->executableAddress(); }
void* addressForExceptionHandler() { return this->executableAddress(); }
void* addressForJSR() { return this->executableAddress(); }
bool operator!()
{
return !this->executableAddress();
}
void reset()
{
CodeLocationCommon::reset();
}
private:
explicit CodeLocationLabel(CodePtr location)
: CodeLocationCommon(location)
{
}
explicit CodeLocationLabel(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
void* getJumpDestination() { return this->executableAddress(); }
};
// CodeLocationJump:
//
// A point in the JIT code at which there is a jump instruction.
class CodeLocationJump : public CodeLocationCommon {
friend class CodeLocationCommon;
friend class PatchBuffer;
public:
CodeLocationJump()
{
}
explicit CodeLocationJump(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
};
// CodeLocationCall:
//
// A point in the JIT code at which there is a call instruction.
class CodeLocationCall : public CodeLocationCommon {
public:
CodeLocationCall()
{
}
explicit CodeLocationCall(CodePtr location)
: CodeLocationCommon(location)
{
}
explicit CodeLocationCall(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
// This methods returns the value that will be set as the return address
// within a function that has been called from this call instruction.
void* calleeReturnAddressValue()
{
return this->executableAddress();
}
};
// CodeLocationNearCall:
//
// A point in the JIT code at which there is a call instruction with near linkage.
class CodeLocationNearCall : public CodeLocationCommon {
public:
CodeLocationNearCall()
{
}
explicit CodeLocationNearCall(CodePtr location)
: CodeLocationCommon(location)
{
}
explicit CodeLocationNearCall(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
// This methods returns the value that will be set as the return address
// within a function that has been called from this call instruction.
void* calleeReturnAddressValue()
{
return this->executableAddress();
}
};
// CodeLocationDataLabel32:
//
// A point in the JIT code at which there is an int32_t immediate that may be repatched.
class CodeLocationDataLabel32 : public CodeLocationCommon {
public:
CodeLocationDataLabel32()
{
}
explicit CodeLocationDataLabel32(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
};
// CodeLocationDataLabelPtr:
//
// A point in the JIT code at which there is a void* immediate that may be repatched.
class CodeLocationDataLabelPtr : public CodeLocationCommon {
public:
CodeLocationDataLabelPtr()
{
}
explicit CodeLocationDataLabelPtr(void* location)
: CodeLocationCommon(CodePtr(location))
{
}
};
// Section 4: PatchBuffer - utility to finalize code generation.
// Section 3: PatchBuffer - utility to finalize code generation.
static CodePtr trampolineAt(CodeRef ref, Label label)
{
......@@ -704,7 +482,7 @@ public:
void patch(DataLabelPtr label, CodeLocationLabel value)
{
AssemblerType::patchPointer(code(), label.m_label, value.getJumpDestination());
AssemblerType::patchPointer(code(), label.m_label, value.executableAddress());
}
// These methods are used to obtain handles to allow the code to be relinked / repatched later.
......@@ -874,7 +652,7 @@ public:
};
// Section 5: Misc admin methods
// Section 4: Misc admin methods
size_t size()
{
......@@ -936,49 +714,6 @@ protected:
AssemblerType m_assembler;
};
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationInstruction AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::instructionAtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationInstruction(reinterpret_cast<char*>(dataLocation()) + offset);
}
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationLabel AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::labelAtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationLabel(reinterpret_cast<char*>(dataLocation()) + offset);
}
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationJump AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::jumpAtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationJump(reinterpret_cast<char*>(dataLocation()) + offset);
}
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationCall AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::callAtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationCall(reinterpret_cast<char*>(dataLocation()) + offset);
}
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationNearCall AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::nearCallAtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationNearCall(reinterpret_cast<char*>(dataLocation()) + offset);
}
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationDataLabelPtr AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::dataLabelPtrAtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationDataLabelPtr(reinterpret_cast<char*>(dataLocation()) + offset);
}
template <class AssemblerType>
typename AbstractMacroAssembler<AssemblerType>::CodeLocationDataLabel32 AbstractMacroAssembler<AssemblerType>::CodeLocationCommon::dataLabel32AtOffset(int offset)
{
return typename AbstractMacroAssembler::CodeLocationDataLabel32(reinterpret_cast<char*>(dataLocation()) + offset);
}
} // namespace JSC
#endif // ENABLE(ASSEMBLER)
......
/*
* Copyright (C) 2009 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 CodeLocation_h
#define CodeLocation_h
#include <wtf/Platform.h>
#include <MacroAssemblerCodeRef.h>
#if ENABLE(ASSEMBLER)
namespace JSC {
class CodeLocationInstruction;
class CodeLocationLabel;
class CodeLocationJump;
class CodeLocationCall;
class CodeLocationNearCall;
class CodeLocationDataLabel32;
class CodeLocationDataLabelPtr;
// The CodeLocation* types are all pretty much do-nothing wrappers around
// CodePtr (or MacroAssemblerCodePtr, to give it its full name). These
// classes only exist to provide type-safety when linking and patching code.
//
// The one new piece of functionallity introduced by these classes is the
// ability to create (or put another way, to re-discover) another CodeLocation
// at an offset from one you already know. When patching code to optimize it
// we often want to patch a number of instructions that are short, fixed
// offsets apart. To reduce memory overhead we will only retain a pointer to
// one of the instructions, and we will use the *AtOffset methods provided by
// CodeLocationCommon to find the other points in the code to modify.
class CodeLocationCommon : public MacroAssemblerCodePtr {
public:
CodeLocationInstruction instructionAtOffset(int offset);
CodeLocationLabel labelAtOffset(int offset);
CodeLocationJump jumpAtOffset(int offset);
CodeLocationCall callAtOffset(int offset);
CodeLocationNearCall nearCallAtOffset(int offset);
CodeLocationDataLabelPtr dataLabelPtrAtOffset(int offset);
CodeLocationDataLabel32 dataLabel32AtOffset(int offset);
protected:
CodeLocationCommon()
{
}
CodeLocationCommon(MacroAssemblerCodePtr location)
: MacroAssemblerCodePtr(location)
{
}
};
class CodeLocationInstruction : public CodeLocationCommon {
public:
CodeLocationInstruction() {}
explicit CodeLocationInstruction(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationInstruction(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
class CodeLocationLabel : public CodeLocationCommon {
public:
CodeLocationLabel() {}
explicit CodeLocationLabel(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationLabel(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
class CodeLocationJump : public CodeLocationCommon {
public:
CodeLocationJump() {}
explicit CodeLocationJump(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationJump(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
class CodeLocationCall : public CodeLocationCommon {
public:
CodeLocationCall() {}
explicit CodeLocationCall(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationCall(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
class CodeLocationNearCall : public CodeLocationCommon {
public:
CodeLocationNearCall() {}
explicit CodeLocationNearCall(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationNearCall(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
class CodeLocationDataLabel32 : public CodeLocationCommon {
public:
CodeLocationDataLabel32() {}
explicit CodeLocationDataLabel32(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationDataLabel32(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
class CodeLocationDataLabelPtr : public CodeLocationCommon {
public:
CodeLocationDataLabelPtr() {}
explicit CodeLocationDataLabelPtr(MacroAssemblerCodePtr location)
: CodeLocationCommon(location) {}
explicit CodeLocationDataLabelPtr(void* location)
: CodeLocationCommon(MacroAssemblerCodePtr(location)) {}
};
inline CodeLocationInstruction CodeLocationCommon::instructionAtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationInstruction(reinterpret_cast<char*>(dataLocation()) + offset);
}
inline CodeLocationLabel CodeLocationCommon::labelAtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationLabel(reinterpret_cast<char*>(dataLocation()) + offset);
}
inline CodeLocationJump CodeLocationCommon::jumpAtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationJump(reinterpret_cast<char*>(dataLocation()) + offset);
}
inline CodeLocationCall CodeLocationCommon::callAtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationCall(reinterpret_cast<char*>(dataLocation()) + offset);
}
inline CodeLocationNearCall CodeLocationCommon::nearCallAtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationNearCall(reinterpret_cast<char*>(dataLocation()) + offset);
}
inline CodeLocationDataLabelPtr CodeLocationCommon::dataLabelPtrAtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationDataLabelPtr(reinterpret_cast<char*>(dataLocation()) + offset);
}
inline CodeLocationDataLabel32 CodeLocationCommon::dataLabel32AtOffset(int offset)
{
ASSERT_VALID_CODE_OFFSET(offset);
return CodeLocationDataLabel32(reinterpret_cast<char*>(dataLocation()) + offset);
}
} // namespace JSC
#endif // ENABLE(ASSEMBLER)
#endif // CodeLocation_h
......@@ -46,9 +46,12 @@
#define ASSERT_VALID_CODE_POINTER(ptr) \
ASSERT(reinterpret_cast<intptr_t>(ptr) & ~1); \
ASSERT(reinterpret_cast<intptr_t>(ptr) & 1)
#define ASSERT_VALID_CODE_OFFSET(offset) \
ASSERT(!(offset & 1)) // Must be multiple of 2.
#else
#define ASSERT_VALID_CODE_POINTER(ptr) \
ASSERT(ptr)
#define ASSERT_VALID_CODE_OFFSET(offset) // Anything goes!
#endif
namespace JSC {
......@@ -145,6 +148,11 @@ public:
void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return m_value; }
#endif
bool operator!()
{
return !m_value;
}
private:
void* m_value;
};
......
......@@ -59,7 +59,7 @@ namespace JSC {
uint32_t target;
uint32_t scopeDepth;
#if ENABLE(JIT)
MacroAssembler::CodeLocationLabel nativeCode;
CodeLocationLabel nativeCode;
#endif
};
......@@ -95,9 +95,9 @@ namespace JSC {
}
unsigned bytecodeIndex;
MacroAssembler::CodeLocationNearCall callReturnLocation;
MacroAssembler</