Title: [295680] trunk/Source
Revision
295680
Author
[email protected]
Date
2022-06-20 23:37:29 -0700 (Mon, 20 Jun 2022)

Log Message

Enhance RawPointer to take function pointers as well.
https://bugs.webkit.org/show_bug.cgi?id=241773

Reviewed by Yusuke Suzuki.

Also add PageBlock::end and PageReservation::end methods to make code a little
more readable (motivated by a RawPointer use).

* Source/_javascript_Core/API/JSMarkingConstraintPrivate.cpp:
(JSContextGroupAddMarkingConstraint):
* Source/_javascript_Core/heap/HeapFinalizerCallback.cpp:
(JSC::HeapFinalizerCallback::dump const):
* Source/_javascript_Core/jit/ExecutableAllocator.cpp:
(JSC::initializeJITPageReservation):
* Source/WTF/wtf/PageBlock.h:
(WTF::PageBlock::end const):
* Source/WTF/wtf/PageReservation.h:
* Source/WTF/wtf/RawPointer.h:
(WTF::RawPointer::RawPointer):

Canonical link: https://commits.webkit.org/251685@main

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSMarkingConstraintPrivate.cpp (295679 => 295680)


--- trunk/Source/_javascript_Core/API/JSMarkingConstraintPrivate.cpp	2022-06-21 03:54:18 UTC (rev 295679)
+++ trunk/Source/_javascript_Core/API/JSMarkingConstraintPrivate.cpp	2022-06-21 06:37:29 UTC (rev 295680)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2021 Apple Inc.  All rights reserved.
+ * Copyright (C) 2017-2022 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -71,8 +71,8 @@
     ConstraintVolatility volatility = ConstraintVolatility::GreyedByMarking;
     
     auto constraint = makeUnique<SimpleMarkingConstraint>(
-        toCString("Amc", constraintIndex, "(", RawPointer(bitwise_cast<void*>(constraintCallback)), ")"),
-        toCString("API Marking Constraint #", constraintIndex, " (", RawPointer(bitwise_cast<void*>(constraintCallback)), ", ", RawPointer(userData), ")"),
+        toCString("Amc", constraintIndex, "(", RawPointer(constraintCallback), ")"),
+        toCString("API Marking Constraint #", constraintIndex, " (", RawPointer(constraintCallback), ", ", RawPointer(userData), ")"),
         MAKE_MARKING_CONSTRAINT_EXECUTOR_PAIR(([constraintCallback, userData] (AbstractSlotVisitor& visitor) {
             Marker marker;
             marker.IsMarked = isMarked;

Modified: trunk/Source/_javascript_Core/heap/HeapFinalizerCallback.cpp (295679 => 295680)


--- trunk/Source/_javascript_Core/heap/HeapFinalizerCallback.cpp	2022-06-21 03:54:18 UTC (rev 295679)
+++ trunk/Source/_javascript_Core/heap/HeapFinalizerCallback.cpp	2022-06-21 06:37:29 UTC (rev 295680)
@@ -33,7 +33,7 @@
 
 void HeapFinalizerCallback::dump(PrintStream& out) const
 {
-    out.print(RawPointer(bitwise_cast<void*>(m_finalizer)), ":", RawPointer(m_userData));
+    out.print(RawPointer(m_finalizer), ":", RawPointer(m_userData));
 }
 
 void HeapFinalizerCallback::run(VM& vm) const

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp (295679 => 295680)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2022-06-21 03:54:18 UTC (rev 295679)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2022-06-21 06:37:29 UTC (rev 295680)
@@ -386,7 +386,7 @@
     reservation.pageReservation = tryCreatePageReservation(reservation.size);
 
     if (Options::verboseExecutablePoolAllocation())
-        dataLog(getpid(), ": Got executable pool reservation at ", RawPointer(reservation.pageReservation.base()), "...", RawPointer(bitwise_cast<char*>(reservation.pageReservation.base()) + reservation.pageReservation.size()), ", while I'm at ", RawPointer(bitwise_cast<void*>(initializeJITPageReservation)), "\n");
+        dataLog(getpid(), ": Got executable pool reservation at ", RawPointer(reservation.pageReservation.base()), "...", RawPointer(reservation.pageReservation.end()), ", while I'm at ", RawPointer(bitwise_cast<void*>(initializeJITPageReservation)), "\n");
     
     if (reservation.pageReservation) {
         ASSERT(reservation.pageReservation.size() == reservation.size);

Modified: trunk/Source/WTF/wtf/PageBlock.h (295679 => 295680)


--- trunk/Source/WTF/wtf/PageBlock.h	2022-06-21 03:54:18 UTC (rev 295679)
+++ trunk/Source/WTF/wtf/PageBlock.h	2022-06-21 06:37:29 UTC (rev 295680)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -69,6 +69,7 @@
     PageBlock(void*, size_t, bool hasGuardPages);
     
     void* base() const { return m_base; }
+    void* end() const { return reinterpret_cast<uint8_t*>(m_base) + size(); }
     size_t size() const { return m_size; }
 
     operator bool() const { return !!m_realBase; }

Modified: trunk/Source/WTF/wtf/PageReservation.h (295679 => 295680)


--- trunk/Source/WTF/wtf/PageReservation.h	2022-06-21 03:54:18 UTC (rev 295679)
+++ trunk/Source/WTF/wtf/PageReservation.h	2022-06-21 06:37:29 UTC (rev 295680)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -58,6 +58,7 @@
     PageReservation() = default;
 
     using PageBlock::base;
+    using PageBlock::end;
     using PageBlock::size;
     using PageBlock::operator bool;
 

Modified: trunk/Source/WTF/wtf/RawPointer.h (295679 => 295680)


--- trunk/Source/WTF/wtf/RawPointer.h	2022-06-21 03:54:18 UTC (rev 295679)
+++ trunk/Source/WTF/wtf/RawPointer.h	2022-06-21 06:37:29 UTC (rev 295680)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,7 +43,13 @@
         : m_value(value)
     {
     }
-    
+
+    template<typename T, typename = std::enable_if_t<std::is_function_v<T>, T>>
+    explicit RawPointer(T* value)
+        : m_value(reinterpret_cast<const void*>(value))
+    {
+    }
+
     const void* value() const { return m_value; }
     
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to