Title: [110651] trunk/Source/_javascript_Core
Revision
110651
Author
[email protected]
Date
2012-03-13 17:46:03 -0700 (Tue, 13 Mar 2012)

Log Message

Functions with C linkage should return POD types
https://bugs.webkit.org/show_bug.cgi?id=81061

Reviewed by Mark Rowe.

* dfg/DFGOperations.h:
* llint/LLIntSlowPaths.h:
(LLInt):
(SlowPathReturnType):
(JSC::LLInt::encodeResult):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (110650 => 110651)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-14 00:36:34 UTC (rev 110650)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-14 00:46:03 UTC (rev 110651)
@@ -1,5 +1,18 @@
 2012-03-13  Filip Pizlo  <[email protected]>
 
+        Functions with C linkage should return POD types
+        https://bugs.webkit.org/show_bug.cgi?id=81061
+
+        Reviewed by Mark Rowe.
+
+        * dfg/DFGOperations.h:
+        * llint/LLIntSlowPaths.h:
+        (LLInt):
+        (SlowPathReturnType):
+        (JSC::LLInt::encodeResult):
+
+2012-03-13  Filip Pizlo  <[email protected]>
+
         Loads from UInt32Arrays should not result in a double up-convert if it isn't necessary
         https://bugs.webkit.org/show_bug.cgi?id=80979
         <rdar://problem/11036848>

Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.h (110650 => 110651)


--- trunk/Source/_javascript_Core/dfg/DFGOperations.h	2012-03-14 00:36:34 UTC (rev 110650)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.h	2012-03-14 00:46:03 UTC (rev 110651)
@@ -154,21 +154,11 @@
 
 // This method is used to lookup an exception hander, keyed by faultLocation, which is
 // the return location from one of the calls out to one of the helper operations above.
+
+// According to C++ rules, a type used for the return signature of function with C linkage (i.e.
+// 'extern "C"') needs to be POD; hence putting any constructors into it could cause either compiler
+// warnings, or worse, a change in the ABI used to return these types.
 struct DFGHandler {
-    DFGHandler(ExecState* exec, void* handler)
-    {
-        u.s.exec = exec;
-        u.s.handler = handler;
-    }
-
-#if !CPU(X86_64)
-    uint64_t encoded()
-    {
-        COMPILE_ASSERT(sizeof(Union) == sizeof(uint64_t), DFGHandler_Union_is_64bit);
-        return u.encoded;
-    }
-#endif
-
     union Union {
         struct Struct {
             ExecState* exec;
@@ -177,17 +167,28 @@
         uint64_t encoded;
     } u;
 };
+COMPILE_ASSERT(std::is_pod<DFGHandler>::value, DFGHandler_is_POD);
+
+inline DFGHandler createDFGHandler(ExecState* exec, void* handler)
+{
+    DFGHandler result;
+    result.u.s.exec = exec;
+    result.u.s.handler = handler;
+    return result;
+}
+
 #if CPU(X86_64)
 typedef DFGHandler DFGHandlerEncoded;
 inline DFGHandlerEncoded dfgHandlerEncoded(ExecState* exec, void* handler)
 {
-    return DFGHandler(exec, handler);
+    return createDFGHandler(exec, handler);
 }
 #else
 typedef uint64_t DFGHandlerEncoded;
 inline DFGHandlerEncoded dfgHandlerEncoded(ExecState* exec, void* handler)
 {
-    return DFGHandler(exec, handler).encoded();
+    COMPILE_ASSERT(sizeof(DFGHandler::Union) == sizeof(uint64_t), DFGHandler_Union_is_64bit);
+    return createDFGHandler(exec, handler).u.encoded;
 }
 #endif
 DFGHandlerEncoded DFG_OPERATION lookupExceptionHandler(ExecState*, uint32_t);

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h (110650 => 110651)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h	2012-03-14 00:36:34 UTC (rev 110650)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h	2012-03-14 00:46:03 UTC (rev 110651)
@@ -39,20 +39,21 @@
 namespace LLInt {
 
 #if USE(JSVALUE64)
+// According to C++ rules, a type used for the return signature of function with C linkage (i.e.
+// 'extern "C"') needs to be POD; hence putting any constructors into it could cause either compiler
+// warnings, or worse, a change in the ABI used to return these types.
 struct SlowPathReturnType {
     void* a;
     void* b;
-    
-    SlowPathReturnType(void* a, void* b)
-        : a(a)
-        , b(b)
-    {
-    }
 };
+COMPILE_ASSERT(std::is_pod<SlowPathReturnType>::value, SlowPathReturnType_is_POD);
 
 inline SlowPathReturnType encodeResult(void* a, void* b)
 {
-    return SlowPathReturnType(a, b);
+    SlowPathReturnType result;
+    result.a = a;
+    result.b = b;
+    return result;
 }
 #else
 typedef int64_t SlowPathReturnType;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to