Title: [112039] trunk/Source/_javascript_Core
Revision
112039
Author
[email protected]
Date
2012-03-25 16:35:07 -0700 (Sun, 25 Mar 2012)

Log Message

DFGOperands should be moved out of the DFG and into bytecode
https://bugs.webkit.org/show_bug.cgi?id=82151

Reviewed by Dan Bernstein.

* GNUmakefile.list.am:
* _javascript_Core.xcodeproj/project.pbxproj:
* bytecode/Operands.h: Copied from Source/_javascript_Core/dfg/DFGOperands.h.
* dfg/DFGBasicBlock.h:
* dfg/DFGNode.h:
* dfg/DFGOSREntry.h:
* dfg/DFGOSRExit.h:
* dfg/DFGOperands.h: Removed.
* dfg/DFGVariableAccessData.h:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (112038 => 112039)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-25 23:35:07 UTC (rev 112039)
@@ -1,3 +1,20 @@
+2012-03-25  Filip Pizlo  <[email protected]>
+
+        DFGOperands should be moved out of the DFG and into bytecode
+        https://bugs.webkit.org/show_bug.cgi?id=82151
+
+        Reviewed by Dan Bernstein.
+
+        * GNUmakefile.list.am:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * bytecode/Operands.h: Copied from Source/_javascript_Core/dfg/DFGOperands.h.
+        * dfg/DFGBasicBlock.h:
+        * dfg/DFGNode.h:
+        * dfg/DFGOSREntry.h:
+        * dfg/DFGOSRExit.h:
+        * dfg/DFGOperands.h: Removed.
+        * dfg/DFGVariableAccessData.h:
+
 2012-03-24  Filip Pizlo  <[email protected]>
 
         DFG 64-bit Branch implementation should not be creating a JSValueOperand that

Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (112038 => 112039)


--- trunk/Source/_javascript_Core/GNUmakefile.list.am	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am	2012-03-25 23:35:07 UTC (rev 112039)
@@ -117,6 +117,7 @@
 	Source/_javascript_Core/bytecode/MethodOfGettingAValueProfile.h \
 	Source/_javascript_Core/bytecode/Opcode.cpp \
 	Source/_javascript_Core/bytecode/Opcode.h \
+	Source/_javascript_Core/bytecode/Operands.h \
 	Source/_javascript_Core/bytecode/PolymorphicPutByIdList.cpp \
 	Source/_javascript_Core/bytecode/PolymorphicPutByIdList.h \
 	Source/_javascript_Core/bytecode/PredictedType.cpp \
@@ -175,7 +176,6 @@
 	Source/_javascript_Core/dfg/DFGAdjacencyList.h \
 	Source/_javascript_Core/dfg/DFGNodeType.h \
 	Source/_javascript_Core/dfg/DFGEdge.h \
-	Source/_javascript_Core/dfg/DFGOperands.h \
 	Source/_javascript_Core/dfg/DFGOperations.cpp \
 	Source/_javascript_Core/dfg/DFGOperations.h \
 	Source/_javascript_Core/dfg/DFGOSREntry.cpp \

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (112038 => 112039)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2012-03-25 23:35:07 UTC (rev 112039)
@@ -74,6 +74,7 @@
 		0F242DA713F3B1E8007ADD4C /* WeakReferenceHarvester.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F2BDC15151C5D4D00CD8910 /* DFGFixupPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2BDC12151C5D4A00CD8910 /* DFGFixupPhase.cpp */; };
 		0F2BDC16151C5D4F00CD8910 /* DFGFixupPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2BDC13151C5D4A00CD8910 /* DFGFixupPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		0F2BDC2C151FDE9100CD8910 /* Operands.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2BDC2B151FDE8B00CD8910 /* Operands.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F2C556F14738F3100121E4F /* DFGCodeBlocks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2C556E14738F2E00121E4F /* DFGCodeBlocks.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F2C557014738F3500121E4F /* DFGCodeBlocks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2C556D14738F2E00121E4F /* DFGCodeBlocks.cpp */; };
 		0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A451460CBAB00131F8F /* ValueRecovery.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -100,7 +101,6 @@
 		0F56A1D515001CF4002992B1 /* ExecutionCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F56A1D415001CF2002992B1 /* ExecutionCounter.cpp */; };
 		0F5F08CF146C7633000472A9 /* UnconditionalFinalizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5F08CE146C762F000472A9 /* UnconditionalFinalizer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F620174143FCD330068B77C /* DFGVariableAccessData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F620172143FCD2F0068B77C /* DFGVariableAccessData.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		0F620175143FCD370068B77C /* DFGOperands.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F620171143FCD2F0068B77C /* DFGOperands.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F620176143FCD3B0068B77C /* DFGBasicBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F620170143FCD2F0068B77C /* DFGBasicBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F620177143FCD3F0068B77C /* DFGAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F62016F143FCD2F0068B77C /* DFGAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F620178143FCD440068B77C /* DFGAbstractState.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F62016E143FCD2F0068B77C /* DFGAbstractState.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -724,6 +724,7 @@
 		0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakReferenceHarvester.h; sourceTree = "<group>"; };
 		0F2BDC12151C5D4A00CD8910 /* DFGFixupPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGFixupPhase.cpp; path = dfg/DFGFixupPhase.cpp; sourceTree = "<group>"; };
 		0F2BDC13151C5D4A00CD8910 /* DFGFixupPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGFixupPhase.h; path = dfg/DFGFixupPhase.h; sourceTree = "<group>"; };
+		0F2BDC2B151FDE8B00CD8910 /* Operands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Operands.h; sourceTree = "<group>"; };
 		0F2C556D14738F2E00121E4F /* DFGCodeBlocks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFGCodeBlocks.cpp; sourceTree = "<group>"; };
 		0F2C556E14738F2E00121E4F /* DFGCodeBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFGCodeBlocks.h; sourceTree = "<group>"; };
 		0F426A451460CBAB00131F8F /* ValueRecovery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueRecovery.h; sourceTree = "<group>"; };
@@ -755,7 +756,6 @@
 		0F62016E143FCD2F0068B77C /* DFGAbstractState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAbstractState.h; path = dfg/DFGAbstractState.h; sourceTree = "<group>"; };
 		0F62016F143FCD2F0068B77C /* DFGAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAbstractValue.h; path = dfg/DFGAbstractValue.h; sourceTree = "<group>"; };
 		0F620170143FCD2F0068B77C /* DFGBasicBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBasicBlock.h; path = dfg/DFGBasicBlock.h; sourceTree = "<group>"; };
-		0F620171143FCD2F0068B77C /* DFGOperands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOperands.h; path = dfg/DFGOperands.h; sourceTree = "<group>"; };
 		0F620172143FCD2F0068B77C /* DFGVariableAccessData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGVariableAccessData.h; path = dfg/DFGVariableAccessData.h; sourceTree = "<group>"; };
 		0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAdjacencyList.h; path = dfg/DFGAdjacencyList.h; sourceTree = "<group>"; };
 		0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGEdge.h; path = dfg/DFGEdge.h; sourceTree = "<group>"; };
@@ -2002,7 +2002,6 @@
 				0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */,
 				0FA581B9150E952A00B9A2D9 /* DFGNodeType.h */,
 				0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */,
-				0F620171143FCD2F0068B77C /* DFGOperands.h */,
 				86EC9DBF1328DF82002B2AD7 /* DFGOperations.cpp */,
 				86EC9DC01328DF82002B2AD7 /* DFGOperations.h */,
 				0FD82E52141DAEDE00179C94 /* DFGOSREntry.cpp */,
@@ -2105,6 +2104,7 @@
 				0FB5467614F59AD1002C2989 /* LazyOperandValueProfile.h */,
 				0F21C27E14BEAA8000ADC64B /* BytecodeConventions.h */,
 				0F0FC45814BD15F100B81154 /* LLIntCallLinkInfo.h */,
+				0F2BDC2B151FDE8B00CD8910 /* Operands.h */,
 				0F9FC8BF14E1B5FB00D52AE0 /* PolymorphicPutByIdList.cpp */,
 				0F9FC8C014E1B5FB00D52AE0 /* PolymorphicPutByIdList.h */,
 				0F9FC8C114E1B5FB00D52AE0 /* PutKind.h */,
@@ -2235,7 +2235,6 @@
 				86EC9DC81328DF82002B2AD7 /* DFGGraph.h in Headers */,
 				86EC9DCC1328DF82002B2AD7 /* DFGJITCompiler.h in Headers */,
 				86ECA3EA132DEF1C002B2AD7 /* DFGNode.h in Headers */,
-				0F620175143FCD370068B77C /* DFGOperands.h in Headers */,
 				86EC9DD01328DF82002B2AD7 /* DFGOperations.h in Headers */,
 				0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */,
 				0FC0976A1468A6F700CF2442 /* DFGOSRExit.h in Headers */,
@@ -2501,6 +2500,7 @@
 				0FA581BB150E953000B9A2D9 /* DFGNodeFlags.h in Headers */,
 				0FA581BC150E953000B9A2D9 /* DFGNodeType.h in Headers */,
 				0F2BDC16151C5D4F00CD8910 /* DFGFixupPhase.h in Headers */,
+				0F2BDC2C151FDE9100CD8910 /* Operands.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Copied: trunk/Source/_javascript_Core/bytecode/Operands.h (from rev 112024, trunk/Source/_javascript_Core/dfg/DFGOperands.h) (0 => 112039)


--- trunk/Source/_javascript_Core/bytecode/Operands.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/bytecode/Operands.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2011, 2012 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 Operands_h
+#define Operands_h
+
+#include "CallFrame.h"
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+// argument 0 is 'this'.
+inline bool operandIsArgument(int operand) { return operand < 0; }
+inline int operandToArgument(int operand) { return -operand + CallFrame::thisArgumentOffset(); }
+inline int argumentToOperand(int argument) { return -argument + CallFrame::thisArgumentOffset(); }
+
+template<typename T> struct OperandValueTraits;
+
+template<typename T>
+struct OperandValueTraits {
+    static T defaultValue() { return T(); }
+    static void dump(const T& value, FILE* out) { value.dump(out); }
+};
+
+template<typename T, typename Traits = OperandValueTraits<T> >
+class Operands {
+public:
+    Operands() { }
+    
+    explicit Operands(size_t numArguments, size_t numLocals)
+    {
+        m_arguments.fill(Traits::defaultValue(), numArguments);
+        m_locals.fill(Traits::defaultValue(), numLocals);
+    }
+    
+    size_t numberOfArguments() const { return m_arguments.size(); }
+    size_t numberOfLocals() const { return m_locals.size(); }
+    
+    T& argument(size_t idx) { return m_arguments[idx]; }
+    const T& argument(size_t idx) const { return m_arguments[idx]; }
+    
+    T& local(size_t idx) { return m_locals[idx]; }
+    const T& local(size_t idx) const { return m_locals[idx]; }
+    
+    void ensureLocals(size_t size)
+    {
+        if (size <= m_locals.size())
+            return;
+
+        size_t oldSize = m_locals.size();
+        m_locals.resize(size);
+        for (size_t i = oldSize; i < m_locals.size(); ++i)
+            m_locals[i] = Traits::defaultValue();
+    }
+    
+    void setLocal(size_t idx, const T& value)
+    {
+        ensureLocals(idx + 1);
+        
+        m_locals[idx] = value;
+    }
+    
+    T getLocal(size_t idx)
+    {
+        if (idx >= m_locals.size())
+            return Traits::defaultValue();
+        return m_locals[idx];
+    }
+    
+    void setArgumentFirstTime(size_t idx, const T& value)
+    {
+        ASSERT(m_arguments[idx] == Traits::defaultValue());
+        argument(idx) = value;
+    }
+    
+    void setLocalFirstTime(size_t idx, const T& value)
+    {
+        ASSERT(idx >= m_locals.size() || m_locals[idx] == Traits::defaultValue());
+        setLocal(idx, value);
+    }
+    
+    T& operand(int operand)
+    {
+        if (operandIsArgument(operand)) {
+            int argument = operandToArgument(operand);
+            return m_arguments[argument];
+        }
+        
+        return m_locals[operand];
+    }
+    
+    const T& operand(int operand) const { return const_cast<const T&>(const_cast<Operands*>(this)->operand(operand)); }
+    
+    void setOperand(int operand, const T& value)
+    {
+        if (operandIsArgument(operand)) {
+            int argument = operandToArgument(operand);
+            m_arguments[argument] = value;
+            return;
+        }
+        
+        setLocal(operand, value);
+    }
+    
+    void clear()
+    {
+        for (size_t i = 0; i < m_arguments.size(); ++i)
+            m_arguments[i] = Traits::defaultValue();
+        for (size_t i = 0; i < m_locals.size(); ++i)
+            m_locals[i] = Traits::defaultValue();
+    }
+    
+private:
+    Vector<T, 8> m_arguments;
+    Vector<T, 16> m_locals;
+};
+
+template<typename T, typename Traits>
+void dumpOperands(Operands<T, Traits>& operands, FILE* out)
+{
+    for (size_t argument = 0; argument < operands.numberOfArguments(); ++argument) {
+        if (argument)
+            fprintf(out, " ");
+        Traits::dump(operands.argument(argument), out);
+    }
+    fprintf(out, " : ");
+    for (size_t local = 0; local < operands.numberOfLocals(); ++local) {
+        if (local)
+            fprintf(out, " ");
+        Traits::dump(operands.local(local), out);
+    }
+}
+
+} // namespace JSC
+
+#endif // Operands_h
+

Modified: trunk/Source/_javascript_Core/dfg/DFGBasicBlock.h (112038 => 112039)


--- trunk/Source/_javascript_Core/dfg/DFGBasicBlock.h	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/dfg/DFGBasicBlock.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -30,7 +30,7 @@
 
 #include "DFGAbstractValue.h"
 #include "DFGNode.h"
-#include "DFGOperands.h"
+#include "Operands.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/Vector.h>
 

Modified: trunk/Source/_javascript_Core/dfg/DFGNode.h (112038 => 112039)


--- trunk/Source/_javascript_Core/dfg/DFGNode.h	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/dfg/DFGNode.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -36,9 +36,9 @@
 #include "DFGCommon.h"
 #include "DFGNodeFlags.h"
 #include "DFGNodeType.h"
-#include "DFGOperands.h"
 #include "DFGVariableAccessData.h"
 #include "JSValue.h"
+#include "Operands.h"
 #include "PredictedType.h"
 #include "ValueProfile.h"
 

Modified: trunk/Source/_javascript_Core/dfg/DFGOSREntry.h (112038 => 112039)


--- trunk/Source/_javascript_Core/dfg/DFGOSREntry.h	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/dfg/DFGOSREntry.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -27,7 +27,7 @@
 #define DFGOSREntry_h
 
 #include "DFGAbstractValue.h"
-#include "DFGOperands.h"
+#include "Operands.h"
 #include <wtf/BitVector.h>
 
 namespace JSC {

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExit.h (112038 => 112039)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExit.h	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExit.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -35,9 +35,9 @@
 #include "DFGCorrectableJumpPoint.h"
 #include "DFGExitProfile.h"
 #include "DFGGPRInfo.h"
-#include "DFGOperands.h"
 #include "MacroAssembler.h"
 #include "MethodOfGettingAValueProfile.h"
+#include "Operands.h"
 #include "ValueProfile.h"
 #include "ValueRecovery.h"
 #include <wtf/Vector.h>

Deleted: trunk/Source/_javascript_Core/dfg/DFGOperands.h (112038 => 112039)


--- trunk/Source/_javascript_Core/dfg/DFGOperands.h	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/dfg/DFGOperands.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2011 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 DFGOperands_h
-#define DFGOperands_h
-
-#include <wtf/Platform.h>
-
-#if ENABLE(DFG_JIT)
-
-#include "CallFrame.h"
-#include <wtf/Vector.h>
-
-namespace JSC { namespace DFG {
-
-// argument 0 is 'this'.
-inline bool operandIsArgument(int operand) { return operand < 0; }
-inline int operandToArgument(int operand) { return -operand + CallFrame::thisArgumentOffset(); }
-inline int argumentToOperand(int argument) { return -argument + CallFrame::thisArgumentOffset(); }
-
-template<typename T> struct OperandValueTraits;
-
-template<typename T>
-struct OperandValueTraits {
-    static T defaultValue() { return T(); }
-    static void dump(const T& value, FILE* out) { value.dump(out); }
-};
-
-template<typename T, typename Traits = OperandValueTraits<T> >
-class Operands {
-public:
-    Operands() { }
-    
-    explicit Operands(size_t numArguments, size_t numLocals)
-    {
-        m_arguments.fill(Traits::defaultValue(), numArguments);
-        m_locals.fill(Traits::defaultValue(), numLocals);
-    }
-    
-    size_t numberOfArguments() const { return m_arguments.size(); }
-    size_t numberOfLocals() const { return m_locals.size(); }
-    
-    T& argument(size_t idx) { return m_arguments[idx]; }
-    const T& argument(size_t idx) const { return m_arguments[idx]; }
-    
-    T& local(size_t idx) { return m_locals[idx]; }
-    const T& local(size_t idx) const { return m_locals[idx]; }
-    
-    void ensureLocals(size_t size)
-    {
-        if (size <= m_locals.size())
-            return;
-
-        size_t oldSize = m_locals.size();
-        m_locals.resize(size);
-        for (size_t i = oldSize; i < m_locals.size(); ++i)
-            m_locals[i] = Traits::defaultValue();
-    }
-    
-    void setLocal(size_t idx, const T& value)
-    {
-        ensureLocals(idx + 1);
-        
-        m_locals[idx] = value;
-    }
-    
-    T getLocal(size_t idx)
-    {
-        if (idx >= m_locals.size())
-            return Traits::defaultValue();
-        return m_locals[idx];
-    }
-    
-    void setArgumentFirstTime(size_t idx, const T& value)
-    {
-        ASSERT(m_arguments[idx] == Traits::defaultValue());
-        argument(idx) = value;
-    }
-    
-    void setLocalFirstTime(size_t idx, const T& value)
-    {
-        ASSERT(idx >= m_locals.size() || m_locals[idx] == Traits::defaultValue());
-        setLocal(idx, value);
-    }
-    
-    T& operand(int operand)
-    {
-        if (operandIsArgument(operand)) {
-            int argument = operandToArgument(operand);
-            return m_arguments[argument];
-        }
-        
-        return m_locals[operand];
-    }
-    
-    const T& operand(int operand) const { return const_cast<const T&>(const_cast<Operands*>(this)->operand(operand)); }
-    
-    void setOperand(int operand, const T& value)
-    {
-        if (operandIsArgument(operand)) {
-            int argument = operandToArgument(operand);
-            m_arguments[argument] = value;
-            return;
-        }
-        
-        setLocal(operand, value);
-    }
-    
-    void clear()
-    {
-        for (size_t i = 0; i < m_arguments.size(); ++i)
-            m_arguments[i] = Traits::defaultValue();
-        for (size_t i = 0; i < m_locals.size(); ++i)
-            m_locals[i] = Traits::defaultValue();
-    }
-    
-private:
-    Vector<T, 8> m_arguments;
-    Vector<T, 16> m_locals;
-};
-
-template<typename T, typename Traits>
-void dumpOperands(Operands<T, Traits>& operands, FILE* out)
-{
-    for (size_t argument = 0; argument < operands.numberOfArguments(); ++argument) {
-        if (argument)
-            fprintf(out, " ");
-        Traits::dump(operands.argument(argument), out);
-    }
-    fprintf(out, " : ");
-    for (size_t local = 0; local < operands.numberOfLocals(); ++local) {
-        if (local)
-            fprintf(out, " ");
-        Traits::dump(operands.local(local), out);
-    }
-}
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
-#endif // DFGOperands_h
-

Modified: trunk/Source/_javascript_Core/dfg/DFGVariableAccessData.h (112038 => 112039)


--- trunk/Source/_javascript_Core/dfg/DFGVariableAccessData.h	2012-03-25 21:47:17 UTC (rev 112038)
+++ trunk/Source/_javascript_Core/dfg/DFGVariableAccessData.h	2012-03-25 23:35:07 UTC (rev 112039)
@@ -27,7 +27,7 @@
 #define DFGVariableAccessData_h
 
 #include "DFGNodeFlags.h"
-#include "DFGOperands.h"
+#include "Operands.h"
 #include "PredictedType.h"
 #include "VirtualRegister.h"
 #include <wtf/Platform.h>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to