Title: [160981] branches/jsCStack/Source/_javascript_Core
Revision
160981
Author
[email protected]
Date
2013-12-22 14:26:23 -0800 (Sun, 22 Dec 2013)

Log Message

CStack: Fixed some JSStack on C Stack boundary computations.
https://bugs.webkit.org/show_bug.cgi?id=126139.

Not yet reviewed.

1. Implement committedByteCount() for JSStack on the C stack using the
   current stack usage as an estimate of committed stack memory.
2. Implement lowAddress() and highAddress() for JSStack on the C stack
   for containsAddress(). lowAddress() will be the top of the JS stack.
   highAddress() will be 1 past the end of the JS stack.
3. Moved some functions around in preparation for an upcoming patch to
   #if out code which is only used when ENABLE(LLINT_C_LOOP)

* interpreter/JSStack.cpp:
(JSC::JSStack::lowAddress):
(JSC::JSStack::highAddress):
(JSC::JSStack::committedByteCount):
* interpreter/JSStack.h:
(JSC::JSStack::containsAddress):
(JSC::JSStack::lowAddress):

Modified Paths

Diff

Modified: branches/jsCStack/Source/_javascript_Core/ChangeLog (160980 => 160981)


--- branches/jsCStack/Source/_javascript_Core/ChangeLog	2013-12-22 18:42:09 UTC (rev 160980)
+++ branches/jsCStack/Source/_javascript_Core/ChangeLog	2013-12-22 22:26:23 UTC (rev 160981)
@@ -1,3 +1,26 @@
+2013-12-22  Mark Lam  <[email protected]>
+
+        CStack: Fixed some JSStack on C Stack boundary computations.
+        https://bugs.webkit.org/show_bug.cgi?id=126139.
+
+        Not yet reviewed.
+
+        1. Implement committedByteCount() for JSStack on the C stack using the
+           current stack usage as an estimate of committed stack memory.
+        2. Implement lowAddress() and highAddress() for JSStack on the C stack
+           for containsAddress(). lowAddress() will be the top of the JS stack.
+           highAddress() will be 1 past the end of the JS stack.
+        3. Moved some functions around in preparation for an upcoming patch to
+           #if out code which is only used when ENABLE(LLINT_C_LOOP)
+
+        * interpreter/JSStack.cpp:
+        (JSC::JSStack::lowAddress):
+        (JSC::JSStack::highAddress):
+        (JSC::JSStack::committedByteCount):
+        * interpreter/JSStack.h:
+        (JSC::JSStack::containsAddress):
+        (JSC::JSStack::lowAddress):
+
 2013-12-22  Filip Pizlo  <[email protected]>
 
         It should be possible to run the full version of V8v7/crypto with the FTL and call IC's

Modified: branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.cpp (160980 => 160981)


--- branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.cpp	2013-12-22 18:42:09 UTC (rev 160980)
+++ branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.cpp	2013-12-22 22:26:23 UTC (rev 160981)
@@ -142,12 +142,6 @@
     stackStatisticsMutex();
 }
 
-size_t JSStack::committedByteCount()
-{
-    MutexLocker locker(stackStatisticsMutex());
-    return committedBytesCount;
-}
-
 void JSStack::addToCommittedByteCount(long byteCount)
 {
     MutexLocker locker(stackStatisticsMutex());
@@ -176,6 +170,35 @@
     }
 }
 
+#if !ENABLE(LLINT_C_LOOP)
+Register* JSStack::lowAddress() const
+{
+    ASSERT(wtfThreadData().stack().isGrowingDownward());
+    return reinterpret_cast<Register*>(m_vm.jsStackLimit());
+}
+
+Register* JSStack::highAddress() const
+{
+    ASSERT(wtfThreadData().stack().isGrowingDownward());
+    return reinterpret_cast<Register*>(wtfThreadData().stack().origin());
+}
+#endif // !ENABLE(LLINT_C_LOOP)
+
+size_t JSStack::committedByteCount()
+{
+#if ENABLE(LLINT_C_LOOP)
+    MutexLocker locker(stackStatisticsMutex());
+    return committedBytesCount;
+#else
+    // When using the C stack, we don't know how many stack pages are actually
+    // committed. So, we use the current stack usage as an estimate.
+    ASSERT(wtfThreadData().stack().isGrowingDownward());
+    int8_t* current = reinterpret_cast<int8_t*>(&current);
+    int8_t* high = reinterpret_cast<int8_t*>(wtfThreadData().stack().origin());
+    return high - current;
+#endif
+}
+
 void JSStack::updateStackLimit()
 {
 #if ENABLE(LLINT_C_LOOP)

Modified: branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.h (160980 => 160981)


--- branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.h	2013-12-22 18:42:09 UTC (rev 160980)
+++ branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.h	2013-12-22 22:26:23 UTC (rev 160981)
@@ -85,6 +85,9 @@
 
         void updateStackLimit();
 
+        bool containsAddress(Register* address) { return (lowAddress() <= address && address < highAddress()); }
+        static size_t committedByteCount();
+
         void gatherConservativeRoots(ConservativeRoots&);
         void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&);
         void sanitizeStack();
@@ -96,7 +99,6 @@
 
         size_t size() const { return highAddress() - lowAddress(); }
 
-        static size_t committedByteCount();
         static void initializeThreading();
 
         Register* startOfFrameFor(CallFrame*);
@@ -105,8 +107,6 @@
 
         void popFrame(CallFrame*);
 
-        bool containsAddress(Register* address) { return (lowAddress() <= address && address <= highAddress()); }
-
 #if ENABLE(DEBUG_JSSTACK)
         void installFence(CallFrame*, const char *function = "", int lineNo = 0);
         void validateFence(CallFrame*, const char *function = "", int lineNo = 0);
@@ -122,15 +122,20 @@
         inline Register* topOfStack();
         inline Register* topOfStackForCapacityCheck();
 
+#if ENABLE(LLINT_C_LOOP)
         Register* lowAddress() const
         {
-            return m_end;
+            return m_end + 1;
         }
 
         Register* highAddress() const
         {
             return reinterpret_cast_ptr<Register*>(static_cast<char*>(m_reservation.base()) + m_reservation.size());
         }
+#else
+        Register* lowAddress() const;
+        Register* highAddress() const;
+#endif // ENABLE(LLINT_C_LOOP)
 
         Register* reservationEnd() const
         {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to