getIndexQuickly should be const
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 13:24:08 +0000 (13:24 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 13:24:08 +0000 (13:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199747

Reviewed by Yusuke Suzuki.

* runtime/Butterfly.h:
(JSC::Butterfly::indexingPayload const):
(JSC::Butterfly::arrayStorage const):
(JSC::Butterfly::contiguousInt32 const):
(JSC::Butterfly::contiguousDouble const):
(JSC::Butterfly::contiguous const):
* runtime/JSObject.h:
(JSC::JSObject::canGetIndexQuickly const):
(JSC::JSObject::getIndexQuickly const):
(JSC::JSObject::tryGetIndexQuickly const):
(JSC::JSObject::canGetIndexQuickly): Deleted.
(JSC::JSObject::getIndexQuickly): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247386 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/Butterfly.h
Source/JavaScriptCore/runtime/JSObject.h

index bf0665c..277420c 100644 (file)
@@ -1,3 +1,23 @@
+2019-07-12  Keith Miller  <keith_miller@apple.com>
+
+        getIndexQuickly should be const
+        https://bugs.webkit.org/show_bug.cgi?id=199747
+
+        Reviewed by Yusuke Suzuki.
+
+        * runtime/Butterfly.h:
+        (JSC::Butterfly::indexingPayload const):
+        (JSC::Butterfly::arrayStorage const):
+        (JSC::Butterfly::contiguousInt32 const):
+        (JSC::Butterfly::contiguousDouble const):
+        (JSC::Butterfly::contiguous const):
+        * runtime/JSObject.h:
+        (JSC::JSObject::canGetIndexQuickly const):
+        (JSC::JSObject::getIndexQuickly const):
+        (JSC::JSObject::tryGetIndexQuickly const):
+        (JSC::JSObject::canGetIndexQuickly): Deleted.
+        (JSC::JSObject::getIndexQuickly): Deleted.
+
 2019-07-11  Justin Michaud  <justin_michaud@apple.com>
 
         Add b3 macro lowering for CheckMul on arm64
index 2eb23bc..c05456a 100644 (file)
@@ -125,8 +125,10 @@ private:
 #endif
 };
 
-typedef ContiguousData<double> ContiguousDoubles;
-typedef ContiguousData<WriteBarrier<Unknown>> ContiguousJSValues;
+using ContiguousDoubles = ContiguousData<double>;
+using ContiguousJSValues = ContiguousData<WriteBarrier<Unknown>>;
+using ConstContiguousDoubles = ContiguousData<const double>;
+using ConstContiguousJSValues = ContiguousData<const WriteBarrier<Unknown>>;
 
 class Butterfly {
     WTF_MAKE_NONCOPYABLE(Butterfly);
@@ -189,6 +191,13 @@ public:
     ContiguousJSValues contiguousInt32() { return ContiguousJSValues(indexingPayload<WriteBarrier<Unknown>>(), vectorLength()); }
     ContiguousDoubles contiguousDouble() { return ContiguousDoubles(indexingPayload<double>(), vectorLength()); }
     ContiguousJSValues contiguous() { return ContiguousJSValues(indexingPayload<WriteBarrier<Unknown>>(), vectorLength()); }
+
+    template<typename T>
+    const T* indexingPayload() const { return reinterpret_cast_ptr<const T*>(this); }
+    const ArrayStorage* arrayStorage() const { return indexingPayload<ArrayStorage>(); }
+    ConstContiguousJSValues contiguousInt32() const { return ConstContiguousJSValues(indexingPayload<WriteBarrier<Unknown>>(), vectorLength()); }
+    ConstContiguousDoubles contiguousDouble() const { return ConstContiguousDoubles(indexingPayload<double>(), vectorLength()); }
+    ConstContiguousJSValues contiguous() const { return ConstContiguousJSValues(indexingPayload<WriteBarrier<Unknown>>(), vectorLength()); }
     
     static Butterfly* fromContiguous(WriteBarrier<Unknown>* contiguous)
     {
index e1b2185..41f51fe 100644 (file)
@@ -256,9 +256,9 @@ public:
         return structure(vm)->hasIndexingHeader(this);
     }
     
-    bool canGetIndexQuickly(unsigned i)
+    bool canGetIndexQuickly(unsigned i) const
     {
-        Butterfly* butterfly = this->butterfly();
+        const Butterfly* butterfly = this->butterfly();
         switch (indexingType()) {
         case ALL_BLANK_INDEXING_TYPES:
         case ALL_UNDECIDED_INDEXING_TYPES:
@@ -282,9 +282,9 @@ public:
         }
     }
         
-    JSValue getIndexQuickly(unsigned i)
+    JSValue getIndexQuickly(unsigned i) const
     {
-        Butterfly* butterfly = this->butterfly();
+        const Butterfly* butterfly = this->butterfly();
         switch (indexingType()) {
         case ALL_INT32_INDEXING_TYPES:
             return jsNumber(butterfly->contiguous().at(this, i).get().asInt32());
@@ -302,7 +302,7 @@ public:
         
     JSValue tryGetIndexQuickly(unsigned i) const
     {
-        Butterfly* butterfly = const_cast<JSObject*>(this)->butterfly();
+        const Butterfly* butterfly = this->butterfly();
         switch (indexingType()) {
         case ALL_BLANK_INDEXING_TYPES:
         case ALL_UNDECIDED_INDEXING_TYPES: