Title: [191994] trunk/Source/_javascript_Core
Revision
191994
Author
fpi...@apple.com
Date
2015-11-03 16:28:23 -0800 (Tue, 03 Nov 2015)

Log Message

B3::Values that have effects should allow specification of custom HeapRanges
https://bugs.webkit.org/show_bug.cgi?id=150535

Reviewed by Benjamin Poulain.

Add a Effects field to calls and patchpoints. Add a HeapRange to MemoryValues.

In the process, I created a class for the CCall opcode, so that it has somewhere to put
the Effects field.

While doing this, I realized that we didn't have a good way of ensuring that an opcode
that requires a specific subclass was actually created with that subclass. So, I added
assertions for this.

* CMakeLists.txt:
* _javascript_Core.xcodeproj/project.pbxproj:
* b3/B3ArgumentRegValue.h:
* b3/B3CCallValue.cpp: Added.
* b3/B3CCallValue.h: Added.
* b3/B3CheckValue.h:
* b3/B3Const32Value.h:
* b3/B3Const64Value.h:
* b3/B3ConstDoubleValue.h:
(JSC::B3::ConstDoubleValue::ConstDoubleValue):
* b3/B3ControlValue.h:
* b3/B3Effects.h:
(JSC::B3::Effects::forCall):
(JSC::B3::Effects::mustExecute):
* b3/B3MemoryValue.h:
* b3/B3PatchpointValue.h:
* b3/B3StackSlotValue.h:
* b3/B3UpsilonValue.h:
* b3/B3Value.cpp:
(JSC::B3::Value::effects):
(JSC::B3::Value::dumpMeta):
(JSC::B3::Value::checkOpcode):
(JSC::B3::Value::typeFor):
* b3/B3Value.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (191993 => 191994)


--- trunk/Source/_javascript_Core/ChangeLog	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-11-04 00:28:23 UTC (rev 191994)
@@ -1,5 +1,46 @@
 2015-11-03  Filip Pizlo  <fpi...@apple.com>
 
+        B3::Values that have effects should allow specification of custom HeapRanges
+        https://bugs.webkit.org/show_bug.cgi?id=150535
+
+        Reviewed by Benjamin Poulain.
+
+        Add a Effects field to calls and patchpoints. Add a HeapRange to MemoryValues.
+
+        In the process, I created a class for the CCall opcode, so that it has somewhere to put
+        the Effects field.
+
+        While doing this, I realized that we didn't have a good way of ensuring that an opcode
+        that requires a specific subclass was actually created with that subclass. So, I added
+        assertions for this.
+
+        * CMakeLists.txt:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * b3/B3ArgumentRegValue.h:
+        * b3/B3CCallValue.cpp: Added.
+        * b3/B3CCallValue.h: Added.
+        * b3/B3CheckValue.h:
+        * b3/B3Const32Value.h:
+        * b3/B3Const64Value.h:
+        * b3/B3ConstDoubleValue.h:
+        (JSC::B3::ConstDoubleValue::ConstDoubleValue):
+        * b3/B3ControlValue.h:
+        * b3/B3Effects.h:
+        (JSC::B3::Effects::forCall):
+        (JSC::B3::Effects::mustExecute):
+        * b3/B3MemoryValue.h:
+        * b3/B3PatchpointValue.h:
+        * b3/B3StackSlotValue.h:
+        * b3/B3UpsilonValue.h:
+        * b3/B3Value.cpp:
+        (JSC::B3::Value::effects):
+        (JSC::B3::Value::dumpMeta):
+        (JSC::B3::Value::checkOpcode):
+        (JSC::B3::Value::typeFor):
+        * b3/B3Value.h:
+
+2015-11-03  Filip Pizlo  <fpi...@apple.com>
+
         B3::Stackmap should be a superclass of B3::PatchpointValue and B3::CheckValue rather than being one of their members
         https://bugs.webkit.org/show_bug.cgi?id=150831
 

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (191993 => 191994)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2015-11-04 00:28:23 UTC (rev 191994)
@@ -280,6 +280,8 @@
 		0F300B7C18AB1B1400A6D72E /* DFGIntegerCheckCombiningPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F300B7A18AB1B1400A6D72E /* DFGIntegerCheckCombiningPhase.h */; };
 		0F32BD101BB34F190093A57F /* HeapHelperPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F32BD0E1BB34F190093A57F /* HeapHelperPool.cpp */; };
 		0F32BD111BB34F190093A57F /* HeapHelperPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F32BD0F1BB34F190093A57F /* HeapHelperPool.h */; };
+		0F338DF91BE96AA80013C88F /* B3CCallValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338DF71BE96AA80013C88F /* B3CCallValue.cpp */; };
+		0F338DFA1BE96AA80013C88F /* B3CCallValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338DF81BE96AA80013C88F /* B3CCallValue.h */; };
 		0F338DF11BE93AD10013C88F /* B3StackmapValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338DEF1BE93AD10013C88F /* B3StackmapValue.cpp */; };
 		0F338DF21BE93AD10013C88F /* B3StackmapValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338DF01BE93AD10013C88F /* B3StackmapValue.h */; };
 		0F338DF51BE93D550013C88F /* B3ConstrainedValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338DF31BE93D550013C88F /* B3ConstrainedValue.cpp */; };
@@ -2301,6 +2303,8 @@
 		0F300B7A18AB1B1400A6D72E /* DFGIntegerCheckCombiningPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGIntegerCheckCombiningPhase.h; path = dfg/DFGIntegerCheckCombiningPhase.h; sourceTree = "<group>"; };
 		0F32BD0E1BB34F190093A57F /* HeapHelperPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapHelperPool.cpp; sourceTree = "<group>"; };
 		0F32BD0F1BB34F190093A57F /* HeapHelperPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapHelperPool.h; sourceTree = "<group>"; };
+		0F338DF71BE96AA80013C88F /* B3CCallValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3CCallValue.cpp; path = b3/B3CCallValue.cpp; sourceTree = "<group>"; };
+		0F338DF81BE96AA80013C88F /* B3CCallValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3CCallValue.h; path = b3/B3CCallValue.h; sourceTree = "<group>"; };
 		0F338DEF1BE93AD10013C88F /* B3StackmapValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3StackmapValue.cpp; path = b3/B3StackmapValue.cpp; sourceTree = "<group>"; };
 		0F338DF01BE93AD10013C88F /* B3StackmapValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3StackmapValue.h; path = b3/B3StackmapValue.h; sourceTree = "<group>"; };
 		0F338DF31BE93D550013C88F /* B3ConstrainedValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3ConstrainedValue.cpp; path = b3/B3ConstrainedValue.cpp; sourceTree = "<group>"; };
@@ -4397,6 +4401,8 @@
 				0FEC84B81BDACDAC0080FF74 /* B3BasicBlockInlines.h */,
 				0FEC84B91BDACDAC0080FF74 /* B3BasicBlockUtils.h */,
 				0FEC84BA1BDACDAC0080FF74 /* B3BlockWorklist.h */,
+				0F338DF71BE96AA80013C88F /* B3CCallValue.cpp */,
+				0F338DF81BE96AA80013C88F /* B3CCallValue.h */,
 				0FEC84BB1BDACDAC0080FF74 /* B3CheckSpecial.cpp */,
 				0FEC84BC1BDACDAC0080FF74 /* B3CheckSpecial.h */,
 				0FEC84BD1BDACDAC0080FF74 /* B3CheckValue.cpp */,
@@ -6521,6 +6527,7 @@
 				0FEC856E1BDACDC70080FF74 /* AirAllocateStack.h in Headers */,
 				0FEC85701BDACDC70080FF74 /* AirArg.h in Headers */,
 				0FEC85721BDACDC70080FF74 /* AirBasicBlock.h in Headers */,
+				0F338DFA1BE96AA80013C88F /* B3CCallValue.h in Headers */,
 				0FEC85741BDACDC70080FF74 /* AirCCallSpecial.h in Headers */,
 				0FEC85761BDACDC70080FF74 /* AirCode.h in Headers */,
 				0F4570391BE44C910062A629 /* AirEliminateDeadCode.h in Headers */,
@@ -8836,6 +8843,7 @@
 				14E84F9E14EE1ACC00D6D5D4 /* WeakBlock.cpp in Sources */,
 				14F7256514EE265E00B1652B /* WeakHandleOwner.cpp in Sources */,
 				A7CA3AE317DA41AE006538AF /* WeakMapConstructor.cpp in Sources */,
+				0F338DF91BE96AA80013C88F /* B3CCallValue.cpp in Sources */,
 				A7CA3AEB17DA5168006538AF /* WeakMapData.cpp in Sources */,
 				A7CA3AE517DA41AE006538AF /* WeakMapPrototype.cpp in Sources */,
 				14E84FA014EE1ACC00D6D5D4 /* WeakSet.cpp in Sources */,

Modified: trunk/Source/_javascript_Core/b3/B3ArgumentRegValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3ArgumentRegValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3ArgumentRegValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -48,7 +48,7 @@
     friend class Procedure;
 
     ArgumentRegValue(unsigned index, Origin origin, Reg reg)
-        : Value(index, ArgumentReg, reg.isGPR() ? pointerType() : Double, origin)
+        : Value(index, CheckedOpcode, ArgumentReg, reg.isGPR() ? pointerType() : Double, origin)
         , m_reg(reg)
     {
         ASSERT(reg.isSet());

Added: trunk/Source/_javascript_Core/b3/B3CCallValue.cpp (0 => 191994)


--- trunk/Source/_javascript_Core/b3/B3CCallValue.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/b3/B3CCallValue.cpp	2015-11-04 00:28:23 UTC (rev 191994)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 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 "B3CCallValue.h"
+
+#if ENABLE(B3_JIT)
+
+namespace JSC { namespace B3 {
+
+CCallValue::~CCallValue()
+{
+}
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
+

Added: trunk/Source/_javascript_Core/b3/B3CCallValue.h (0 => 191994)


--- trunk/Source/_javascript_Core/b3/B3CCallValue.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/b3/B3CCallValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2015 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 B3CCallValue_h
+#define B3CCallValue_h
+
+#if ENABLE(B3_JIT)
+
+#include "B3Effects.h"
+#include "B3Value.h"
+
+namespace JSC { namespace B3 {
+
+class JS_EXPORT_PRIVATE CCallValue : public Value {
+public:
+    static bool accepts(Opcode opcode) { return opcode == CCall; }
+
+    ~CCallValue();
+
+    Effects effects;
+
+private:
+    friend class Procedure;
+
+    template<typename... Arguments>
+    CCallValue(unsigned index, Type type, Origin origin, Arguments... arguments)
+        : Value(index, CheckedOpcode, CCall, type, origin, arguments...)
+        , effects(Effects::forCall())
+    {
+    }
+};
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
+
+#endif // B3CCallValue_h
+

Modified: trunk/Source/_javascript_Core/b3/B3CheckValue.cpp (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3CheckValue.cpp	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3CheckValue.cpp	2015-11-04 00:28:23 UTC (rev 191994)
@@ -36,7 +36,7 @@
 
 // Use this form for CheckAdd, CheckSub, and CheckMul.
 CheckValue::CheckValue(unsigned index, Opcode opcode, Origin origin, Value* left, Value* right)
-    : StackmapValue(index, opcode, left->type(), origin)
+    : StackmapValue(index, CheckedOpcode, opcode, left->type(), origin)
 {
     ASSERT(B3::isInt(type()));
     ASSERT(left->type() == right->type());
@@ -47,7 +47,7 @@
 
 // Use this form for Check.
 CheckValue::CheckValue(unsigned index, Opcode opcode, Origin origin, Value* predicate)
-    : StackmapValue(index, opcode, Void, origin)
+    : StackmapValue(index, CheckedOpcode, opcode, Void, origin)
 {
     ASSERT(opcode == Check);
     append(predicate);

Modified: trunk/Source/_javascript_Core/b3/B3Const32Value.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3Const32Value.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3Const32Value.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -55,7 +55,7 @@
     friend class Procedure;
 
     Const32Value(unsigned index, Origin origin, int32_t value)
-        : Value(index, Const32, Int32, origin)
+        : Value(index, CheckedOpcode, Const32, Int32, origin)
         , m_value(value)
     {
     }

Modified: trunk/Source/_javascript_Core/b3/B3Const64Value.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3Const64Value.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3Const64Value.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -55,7 +55,7 @@
     friend class Procedure;
 
     Const64Value(unsigned index, Origin origin, int64_t value)
-        : Value(index, Const64, Int64, origin)
+        : Value(index, CheckedOpcode, Const64, Int64, origin)
         , m_value(value)
     {
     }

Modified: trunk/Source/_javascript_Core/b3/B3ConstDoubleValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3ConstDoubleValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3ConstDoubleValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -54,7 +54,7 @@
     friend class Procedure;
 
     ConstDoubleValue(unsigned index, Origin origin, double value)
-        : Value(index, ConstDouble, Double, origin)
+        : Value(index, CheckedOpcode, ConstDouble, Double, origin)
         , m_value(value)
     {
     }

Modified: trunk/Source/_javascript_Core/b3/B3ControlValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3ControlValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3ControlValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -95,6 +95,7 @@
     ControlValue(unsigned index, Opcode opcode, Type type, Origin origin, Arguments... arguments)
         : Value(index, opcode, type, origin, arguments...)
     {
+        ASSERT(accepts(opcode));
     }
 
     // Subclasses will populate this.
@@ -105,21 +106,21 @@
 
     // Use this for Oops.
     ControlValue(unsigned index, Opcode opcode, Origin origin)
-        : Value(index, opcode, Void, origin)
+        : Value(index, CheckedOpcode, opcode, Void, origin)
     {
         ASSERT(opcode == Oops);
     }
 
     // Use this for Return.
     ControlValue(unsigned index, Opcode opcode, Origin origin, Value* result)
-        : Value(index, opcode, Void, origin, result)
+        : Value(index, CheckedOpcode, opcode, Void, origin, result)
     {
         ASSERT(opcode == Return);
     }
 
     // Use this for Jump.
     ControlValue(unsigned index, Opcode opcode, Origin origin, const FrequentedBlock& target)
-        : Value(index, opcode, Void, origin)
+        : Value(index, CheckedOpcode, opcode, Void, origin)
     {
         ASSERT(opcode == Jump);
         m_successors.append(target);
@@ -129,7 +130,7 @@
     ControlValue(
         unsigned index, Opcode opcode, Origin origin, Value* predicate,
         const FrequentedBlock& yes, const FrequentedBlock& no)
-        : Value(index, opcode, Void, origin, predicate)
+        : Value(index, CheckedOpcode, opcode, Void, origin, predicate)
     {
         ASSERT(opcode == Branch);
         m_successors.append(yes);

Modified: trunk/Source/_javascript_Core/b3/B3Effects.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3Effects.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3Effects.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -55,6 +55,16 @@
     HeapRange writes;
     HeapRange reads;
 
+    static Effects forCall()
+    {
+        Effects result;
+        result.exitsSideways = true;
+        result.controlDependent = true;
+        result.writes = HeapRange::top();
+        result.reads = HeapRange::top();
+        return result;
+    }
+
     bool mustExecute() const
     {
         return terminal || exitsSideways || writesSSAState || writes;

Modified: trunk/Source/_javascript_Core/b3/B3MemoryValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3MemoryValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3MemoryValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -28,14 +28,11 @@
 
 #if ENABLE(B3_JIT)
 
+#include "B3HeapRange.h"
 #include "B3Value.h"
 
 namespace JSC { namespace B3 {
 
-// FIXME: Add alias analysis to these by allowing the client to associate an integer range to the
-// value. Two operations may access the same memory if their ranges overlaps.
-// https://bugs.webkit.org/show_bug.cgi?id=150535
-
 class JS_EXPORT_PRIVATE MemoryValue : public Value {
 public:
     static bool accepts(Opcode opcode)
@@ -62,6 +59,9 @@
     int32_t offset() const { return m_offset; }
     void setOffset(int32_t offset) { m_offset = offset; }
 
+    const HeapRange& range() const { return m_range; }
+    void setRange(const HeapRange& range) { m_range = range; }
+
     size_t accessByteSize() const;
 
 protected:
@@ -75,8 +75,9 @@
     MemoryValue(
         unsigned index, Opcode opcode, Type type, Origin origin, Value* pointer,
         int32_t offset = 0)
-        : Value(index, opcode, type, origin, pointer)
+        : Value(index, CheckedOpcode, opcode, type, origin, pointer)
         , m_offset(offset)
+        , m_range(HeapRange::top())
     {
         if (!ASSERT_DISABLED) {
             switch (opcode) {
@@ -113,8 +114,9 @@
     MemoryValue(
         unsigned index, Opcode opcode, Origin origin, Value* value, Value* pointer,
         int32_t offset = 0)
-        : Value(index, opcode, Void, origin, value, pointer)
+        : Value(index, CheckedOpcode, opcode, Void, origin, value, pointer)
         , m_offset(offset)
+        , m_range(HeapRange::top())
     {
         if (!ASSERT_DISABLED) {
             switch (opcode) {
@@ -131,6 +133,7 @@
     }
 
     int32_t m_offset { 0 };
+    HeapRange m_range;
 };
 
 } } // namespace JSC::B3

Modified: trunk/Source/_javascript_Core/b3/B3PatchpointValue.cpp (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3PatchpointValue.cpp	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3PatchpointValue.cpp	2015-11-04 00:28:23 UTC (rev 191994)
@@ -35,7 +35,7 @@
 }
 
 PatchpointValue::PatchpointValue(unsigned index, Type type, Origin origin)
-    : StackmapValue(index, Patchpoint, type, origin)
+    : StackmapValue(index, CheckedOpcode, Patchpoint, type, origin)
 {
 }
 

Modified: trunk/Source/_javascript_Core/b3/B3PatchpointValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3PatchpointValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3PatchpointValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -28,7 +28,9 @@
 
 #if ENABLE(B3_JIT)
 
+#include "B3Effects.h"
 #include "B3StackmapValue.h"
+#include "B3Value.h"
 
 namespace JSC { namespace B3 {
 
@@ -38,6 +40,8 @@
 
     ~PatchpointValue();
 
+    Effects effects;
+
 private:
     friend class Procedure;
 

Modified: trunk/Source/_javascript_Core/b3/B3StackSlotValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3StackSlotValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3StackSlotValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -64,7 +64,7 @@
     friend class Procedure;
 
     StackSlotValue(unsigned index, Origin origin, unsigned byteSize, StackSlotKind kind)
-        : Value(index, StackSlot, pointerType(), origin)
+        : Value(index, CheckedOpcode, StackSlot, pointerType(), origin)
         , m_byteSize(byteSize)
         , m_kind(kind)
         , m_offsetFromFP(0)

Modified: trunk/Source/_javascript_Core/b3/B3StackmapValue.cpp (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3StackmapValue.cpp	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3StackmapValue.cpp	2015-11-04 00:28:23 UTC (rev 191994)
@@ -78,9 +78,10 @@
         ", usedRegisters = ", m_usedRegisters);
 }
 
-StackmapValue::StackmapValue(unsigned index, Opcode opcode, Type type, Origin origin)
-    : Value(index, opcode, type, origin)
+StackmapValue::StackmapValue(unsigned index, CheckedOpcodeTag, Opcode opcode, Type type, Origin origin)
+    : Value(index, CheckedOpcode, opcode, type, origin)
 {
+    ASSERT(accepts(opcode));
 }
 
 } } // namespace JSC::B3

Modified: trunk/Source/_javascript_Core/b3/B3StackmapValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3StackmapValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3StackmapValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -176,7 +176,7 @@
     void dumpChildren(CommaPrinter&, PrintStream&) const override;
     void dumpMeta(CommaPrinter&, PrintStream&) const override;
 
-    StackmapValue(unsigned index, Opcode, Type, Origin);
+    StackmapValue(unsigned index, CheckedOpcodeTag, Opcode, Type, Origin);
 
 private:
     friend class CheckSpecial;

Modified: trunk/Source/_javascript_Core/b3/B3UpsilonValue.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3UpsilonValue.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3UpsilonValue.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -56,7 +56,7 @@
     // the Upsilons without the Phi, then create the Phi, then go back and tell the Upsilons about
     // the Phi. This allows you to emit code in its natural order.
     UpsilonValue(unsigned index, Origin origin, Value* value, Value* phi = nullptr)
-        : Value(index, Upsilon, Void, origin, value)
+        : Value(index, CheckedOpcode, Upsilon, Void, origin, value)
         , m_phi(phi)
     {
         if (phi) {

Modified: trunk/Source/_javascript_Core/b3/B3Value.cpp (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3Value.cpp	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3Value.cpp	2015-11-04 00:28:23 UTC (rev 191994)
@@ -28,6 +28,12 @@
 
 #if ENABLE(B3_JIT)
 
+#include "B3ArgumentRegValue.h"
+#include "B3CCallValue.h"
+#include "B3ControlValue.h"
+#include "B3MemoryValue.h"
+#include "B3StackSlotValue.h"
+#include "B3UpsilonValue.h"
 #include "B3ValueInlines.h"
 #include <wtf/CommaPrinter.h>
 #include <wtf/StringPrintStream.h>
@@ -241,26 +247,21 @@
     case Load16S:
     case LoadFloat:
     case Load:
-        // FIXME: MemoryValue should have a HeapRange.
-        // https://bugs.webkit.org/show_bug.cgi?id=150535
-        result.reads = HeapRange::top();
+        result.reads = as<MemoryValue>()->range();
         result.controlDependent = true;
         break;
     case Store8:
     case Store16:
     case StoreFloat:
     case Store:
-        // FIXME: MemoryValue should have a HeapRange.
-        // https://bugs.webkit.org/show_bug.cgi?id=150535
-        result.writes = HeapRange::top();
+        result.writes = as<MemoryValue>()->range();
         result.controlDependent = true;
         break;
     case CCall:
+        result = as<CCallValue>()->effects;
+        break;
     case Patchpoint:
-        result.reads = HeapRange::top();
-        result.writes = HeapRange::top();
-        result.exitsSideways = true;
-        result.controlDependent = true;
+        result = as<PatchpointValue>()->effects;
         break;
     case CheckAdd:
     case CheckSub:
@@ -297,6 +298,23 @@
 {
 }
 
+#if !ASSERT_DISABLED
+void Value::checkOpcode(Opcode opcode)
+{
+    ASSERT(!ArgumentRegValue::accepts(opcode));
+    ASSERT(!CCallValue::accepts(opcode));
+    ASSERT(!CheckValue::accepts(opcode));
+    ASSERT(!Const32Value::accepts(opcode));
+    ASSERT(!Const64Value::accepts(opcode));
+    ASSERT(!ConstDoubleValue::accepts(opcode));
+    ASSERT(!ControlValue::accepts(opcode));
+    ASSERT(!MemoryValue::accepts(opcode));
+    ASSERT(!PatchpointValue::accepts(opcode));
+    ASSERT(!StackSlotValue::accepts(opcode));
+    ASSERT(!UpsilonValue::accepts(opcode));
+}
+#endif // !ASSERT_DISABLED
+
 Type Value::typeFor(Opcode opcode, Value* firstChild)
 {
     switch (opcode) {

Modified: trunk/Source/_javascript_Core/b3/B3Value.h (191993 => 191994)


--- trunk/Source/_javascript_Core/b3/B3Value.h	2015-11-04 00:13:27 UTC (rev 191993)
+++ trunk/Source/_javascript_Core/b3/B3Value.h	2015-11-04 00:28:23 UTC (rev 191994)
@@ -159,15 +159,24 @@
 protected:
     virtual void dumpChildren(CommaPrinter&, PrintStream&) const;
     virtual void dumpMeta(CommaPrinter&, PrintStream&) const;
-    
+
 private:
     friend class Procedure;
 
+    // Checks that this opcode is valid for use with B3::Value.
+#if ASSERT_DISABLED
+    static void checkOpcode(Opcode) { }
+#else
+    static void checkOpcode(Opcode);
+#endif
+
 protected:
+    enum CheckedOpcodeTag { CheckedOpcode };
+    
     // Instantiate values via Procedure.
     // This form requires specifying the type explicitly:
     template<typename... Arguments>
-    explicit Value(unsigned index, Opcode opcode, Type type, Origin origin, Value* firstChild, Arguments... arguments)
+    explicit Value(unsigned index, CheckedOpcodeTag, Opcode opcode, Type type, Origin origin, Value* firstChild, Arguments... arguments)
         : m_index(index)
         , m_opcode(opcode)
         , m_type(type)
@@ -176,7 +185,7 @@
     {
     }
     // This form is for specifying the type explicitly when the opcode has no children:
-    explicit Value(unsigned index, Opcode opcode, Type type, Origin origin)
+    explicit Value(unsigned index, CheckedOpcodeTag, Opcode opcode, Type type, Origin origin)
         : m_index(index)
         , m_opcode(opcode)
         , m_type(type)
@@ -185,7 +194,7 @@
     }
     // This form is for those opcodes that can infer their type from the opcode and first child:
     template<typename... Arguments>
-    explicit Value(unsigned index, Opcode opcode, Origin origin, Value* firstChild, Arguments... arguments)
+    explicit Value(unsigned index, CheckedOpcodeTag, Opcode opcode, Origin origin, Value* firstChild, Arguments... arguments)
         : m_index(index)
         , m_opcode(opcode)
         , m_type(typeFor(opcode, firstChild))
@@ -195,7 +204,7 @@
     }
     // This form is for those opcodes that can infer their type from the opcode alone, and that don't
     // take any arguments:
-    explicit Value(unsigned index, Opcode opcode, Origin origin)
+    explicit Value(unsigned index, CheckedOpcodeTag, Opcode opcode, Origin origin)
         : m_index(index)
         , m_opcode(opcode)
         , m_type(typeFor(opcode, nullptr))
@@ -203,7 +212,7 @@
     {
     }
     // Use this form for varargs.
-    explicit Value(unsigned index, Opcode opcode, Type type, Origin origin, const AdjacencyList& children)
+    explicit Value(unsigned index, CheckedOpcodeTag, Opcode opcode, Type type, Origin origin, const AdjacencyList& children)
         : m_index(index)
         , m_opcode(opcode)
         , m_type(type)
@@ -211,7 +220,7 @@
         , m_children(children)
     {
     }
-    explicit Value(unsigned index, Opcode opcode, Type type, Origin origin, AdjacencyList&& children)
+    explicit Value(unsigned index, CheckedOpcodeTag, Opcode opcode, Type type, Origin origin, AdjacencyList&& children)
         : m_index(index)
         , m_opcode(opcode)
         , m_type(type)
@@ -220,6 +229,15 @@
     {
     }
 
+    // This is the constructor you end up actually calling, if you're instantiating Value
+    // directly.
+    template<typename... Arguments>
+    explicit Value(unsigned index, Opcode opcode, Arguments&&... arguments)
+        : Value(index, CheckedOpcode, opcode, std::forward<Arguments>(arguments)...)
+    {
+        checkOpcode(opcode);
+    }
+
 private:
     static Type typeFor(Opcode, Value* firstChild);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to