summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/VirtualRegister.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/bytecode/VirtualRegister.h')
-rw-r--r--Source/JavaScriptCore/bytecode/VirtualRegister.h60
1 files changed, 40 insertions, 20 deletions
diff --git a/Source/JavaScriptCore/bytecode/VirtualRegister.h b/Source/JavaScriptCore/bytecode/VirtualRegister.h
index c63aee85f..f32e8d24f 100644
--- a/Source/JavaScriptCore/bytecode/VirtualRegister.h
+++ b/Source/JavaScriptCore/bytecode/VirtualRegister.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,12 +23,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef VirtualRegister_h
-#define VirtualRegister_h
+#pragma once
+#include "BytecodeConventions.h"
#include "CallFrame.h"
-
-#include <wtf/Platform.h>
#include <wtf/PrintStream.h>
namespace JSC {
@@ -60,18 +58,51 @@ public:
bool isValid() const { return (m_virtualRegister != s_invalidVirtualRegister); }
bool isLocal() const { return operandIsLocal(m_virtualRegister); }
bool isArgument() const { return operandIsArgument(m_virtualRegister); }
+ bool isHeader() const { return m_virtualRegister >= 0 && m_virtualRegister < CallFrameSlot::thisArgument; }
bool isConstant() const { return m_virtualRegister >= s_firstConstantRegisterIndex; }
int toLocal() const { ASSERT(isLocal()); return operandToLocal(m_virtualRegister); }
int toArgument() const { ASSERT(isArgument()); return operandToArgument(m_virtualRegister); }
int toConstantIndex() const { ASSERT(isConstant()); return m_virtualRegister - s_firstConstantRegisterIndex; }
int offset() const { return m_virtualRegister; }
-
- bool operator==(const VirtualRegister other) const { return m_virtualRegister == other.m_virtualRegister; }
- bool operator!=(const VirtualRegister other) const { return m_virtualRegister != other.m_virtualRegister; }
+ int offsetInBytes() const { return m_virtualRegister * sizeof(Register); }
+
+ bool operator==(VirtualRegister other) const { return m_virtualRegister == other.m_virtualRegister; }
+ bool operator!=(VirtualRegister other) const { return m_virtualRegister != other.m_virtualRegister; }
+ bool operator<(VirtualRegister other) const { return m_virtualRegister < other.m_virtualRegister; }
+ bool operator>(VirtualRegister other) const { return m_virtualRegister > other.m_virtualRegister; }
+ bool operator<=(VirtualRegister other) const { return m_virtualRegister <= other.m_virtualRegister; }
+ bool operator>=(VirtualRegister other) const { return m_virtualRegister >= other.m_virtualRegister; }
+
+ VirtualRegister operator+(int value) const
+ {
+ return VirtualRegister(offset() + value);
+ }
+ VirtualRegister operator-(int value) const
+ {
+ return VirtualRegister(offset() - value);
+ }
+ VirtualRegister operator+(VirtualRegister value) const
+ {
+ return VirtualRegister(offset() + value.offset());
+ }
+ VirtualRegister operator-(VirtualRegister value) const
+ {
+ return VirtualRegister(offset() - value.offset());
+ }
+ VirtualRegister& operator+=(int value)
+ {
+ return *this = *this + value;
+ }
+ VirtualRegister& operator-=(int value)
+ {
+ return *this = *this - value;
+ }
+
+ void dump(PrintStream& out) const;
private:
static const int s_invalidVirtualRegister = 0x3fffffff;
- static const int s_firstConstantRegisterIndex = 0x40000000;
+ static const int s_firstConstantRegisterIndex = FirstConstantRegisterIndex;
static int localToOperand(int local) { return -1 - local; }
static int operandToLocal(int operand) { return -1 - operand; }
@@ -94,14 +125,3 @@ inline VirtualRegister virtualRegisterForArgument(int argument, int offset = 0)
}
} // namespace JSC
-
-namespace WTF {
-
-inline void printInternal(PrintStream& out, JSC::VirtualRegister value)
-{
- out.print(value.offset());
-}
-
-} // namespace WTF
-
-#endif // VirtualRegister_h