Title: [104415] trunk/Source/_javascript_Core
Revision
104415
Author
[email protected]
Date
2012-01-08 15:46:12 -0800 (Sun, 08 Jan 2012)

Log Message

The JIT's protocol for exception handling should be available to other parts of the system
https://bugs.webkit.org/show_bug.cgi?id=75808
<rdar://problem/10661025>

Reviewed by Oliver Hunt.

* CMakeLists.txt:
* GNUmakefile.list.am:
* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj:
* _javascript_Core.xcodeproj/project.pbxproj:
* Target.pri:
* jit/JITExceptions.cpp: Added.
(JSC::genericThrow):
(JSC::jitThrow):
* jit/JITExceptions.h: Added.
* jit/JITStubs.cpp:
* runtime/JSGlobalData.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (104414 => 104415)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2012-01-08 23:46:12 UTC (rev 104415)
@@ -92,6 +92,7 @@
     jit/JITCall32_64.cpp
     jit/JITCall.cpp
     jit/JIT.cpp
+    jit/JITExceptions.cpp
     jit/JITOpcodes32_64.cpp
     jit/JITOpcodes.cpp
     jit/JITPropertyAccess32_64.cpp

Modified: trunk/Source/_javascript_Core/ChangeLog (104414 => 104415)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-08 23:46:12 UTC (rev 104415)
@@ -1,3 +1,23 @@
+2012-01-08  Filip Pizlo  <[email protected]>
+
+        The JIT's protocol for exception handling should be available to other parts of the system
+        https://bugs.webkit.org/show_bug.cgi?id=75808
+        <rdar://problem/10661025>
+
+        Reviewed by Oliver Hunt.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * Target.pri:
+        * jit/JITExceptions.cpp: Added.
+        (JSC::genericThrow):
+        (JSC::jitThrow):
+        * jit/JITExceptions.h: Added.
+        * jit/JITStubs.cpp:
+        * runtime/JSGlobalData.h:
+
 2012-01-06  Hajime Morrita  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=75296

Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (104414 => 104415)


--- trunk/Source/_javascript_Core/GNUmakefile.list.am	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am	2012-01-08 23:46:12 UTC (rev 104415)
@@ -260,6 +260,8 @@
 	Source/_javascript_Core/jit/JITCode.h \
 	Source/_javascript_Core/jit/JIT.cpp \
 	Source/_javascript_Core/jit/JIT.h \
+	Source/_javascript_Core/jit/JITExceptions.cpp \
+	Source/_javascript_Core/jit/JITExceptions.h \
 	Source/_javascript_Core/jit/JITInlineMethods.h \
 	Source/_javascript_Core/jit/JITOpcodes32_64.cpp \
 	Source/_javascript_Core/jit/JITOpcodes.cpp \

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj (104414 => 104415)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj	2012-01-08 23:46:12 UTC (rev 104415)
@@ -1710,6 +1710,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\jit\JITExceptions.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\jit\JITExceptions.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\jit\JITStubs.cpp"
 				>
 			</File>

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (104414 => 104415)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2012-01-08 23:46:12 UTC (rev 104415)
@@ -58,6 +58,8 @@
 		0F426A491460CBB700131F8F /* VirtualRegister.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A461460CBAB00131F8F /* VirtualRegister.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F426A4B1460CD6E00131F8F /* DataFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A4A1460CD6B00131F8F /* DataFormat.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F431738146BAC69007E3890 /* ListableHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F431736146BAC65007E3890 /* ListableHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F46808014BA572700BFE272 /* JITExceptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		0F46808314BA573100BFE272 /* JITExceptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F46807F14BA572700BFE272 /* JITExceptions.cpp */; };
 		0F5F08CF146C7633000472A9 /* UnconditionalFinalizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5F08CE146C762F000472A9 /* UnconditionalFinalizer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F620174143FCD330068B77C /* DFGVariableAccessData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F620172143FCD2F0068B77C /* DFGVariableAccessData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0F620175143FCD370068B77C /* DFGOperands.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F620171143FCD2F0068B77C /* DFGOperands.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -841,6 +843,8 @@
 		0F426A461460CBAB00131F8F /* VirtualRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualRegister.h; sourceTree = "<group>"; };
 		0F426A4A1460CD6B00131F8F /* DataFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataFormat.h; sourceTree = "<group>"; };
 		0F431736146BAC65007E3890 /* ListableHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListableHandler.h; sourceTree = "<group>"; };
+		0F46807F14BA572700BFE272 /* JITExceptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITExceptions.cpp; sourceTree = "<group>"; };
+		0F46808014BA572700BFE272 /* JITExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITExceptions.h; sourceTree = "<group>"; };
 		0F5F08CC146BE602000472A9 /* DFGByteCodeCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGByteCodeCache.h; path = dfg/DFGByteCodeCache.h; sourceTree = "<group>"; };
 		0F5F08CE146C762F000472A9 /* UnconditionalFinalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnconditionalFinalizer.h; sourceTree = "<group>"; };
 		0F62016D143FCD2F0068B77C /* DFGAbstractState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAbstractState.cpp; path = dfg/DFGAbstractState.cpp; sourceTree = "<group>"; };
@@ -1698,6 +1702,8 @@
 		1429D92C0ED22D7000B89619 /* jit */ = {
 			isa = PBXGroup;
 			children = (
+				0F46807F14BA572700BFE272 /* JITExceptions.cpp */,
+				0F46808014BA572700BFE272 /* JITExceptions.h */,
 				0FD82E37141AB14200179C94 /* CompactJITCodeMap.h */,
 				A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */,
 				A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */,
@@ -3004,6 +3010,7 @@
 				86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */,
 				86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
 				0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */,
+				0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -3542,6 +3549,7 @@
 				86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
 				86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
 				86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
+				0F46808314BA573100BFE272 /* JITExceptions.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/_javascript_Core/Target.pri (104414 => 104415)


--- trunk/Source/_javascript_Core/Target.pri	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/Target.pri	2012-01-08 23:46:12 UTC (rev 104415)
@@ -104,6 +104,7 @@
     jit/JITCall.cpp \
     jit/JITCall32_64.cpp \
     jit/JIT.cpp \
+    jit/JITExceptions.cpp \
     jit/JITOpcodes.cpp \
     jit/JITOpcodes32_64.cpp \
     jit/JITPropertyAccess.cpp \

Added: trunk/Source/_javascript_Core/jit/JITExceptions.cpp (0 => 104415)


--- trunk/Source/_javascript_Core/jit/JITExceptions.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/jit/JITExceptions.cpp	2012-01-08 23:46:12 UTC (rev 104415)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 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 "JITExceptions.h"
+
+#include "CallFrame.h"
+#include "CodeBlock.h"
+#include "Interpreter.h"
+#include "JSGlobalData.h"
+#include "JSValue.h"
+
+namespace JSC {
+
+ExceptionHandler genericThrow(JSGlobalData* globalData, ExecState* callFrame, JSValue exceptionValue, unsigned vPCIndex)
+{
+    ASSERT(exceptionValue);
+
+    globalData->exception = JSValue();
+    HandlerInfo* handler = globalData->interpreter->throwException(callFrame, exceptionValue, vPCIndex); // This may update callFrame & exceptionValue!
+    globalData->exception = exceptionValue;
+
+    void* catchRoutine;
+    Instruction* catchPCForInterpreter = 0;
+    if (handler) {
+        catchRoutine = handler->nativeCode.executableAddress();
+        if (callFrame->codeBlock()->hasInstructions())
+            catchPCForInterpreter = &callFrame->codeBlock()->instructions()[handler->target];
+    } else
+        catchRoutine = FunctionPtr(ctiOpThrowNotCaught).value();
+    
+    globalData->callFrameForThrow = callFrame;
+    globalData->targetMachinePCForThrow = catchRoutine;
+    globalData->targetInterpreterPCForThrow = catchPCForInterpreter;
+    
+    ASSERT(catchRoutine);
+    ExceptionHandler exceptionHandler = { catchRoutine, callFrame };
+    return exceptionHandler;
+}
+
+ExceptionHandler jitThrow(JSGlobalData* globalData, ExecState* callFrame, JSValue exceptionValue, ReturnAddressPtr faultLocation)
+{
+    return genericThrow(globalData, callFrame, exceptionValue, callFrame->codeBlock()->bytecodeOffset(faultLocation));
+}
+
+}
+

Added: trunk/Source/_javascript_Core/jit/JITExceptions.h (0 => 104415)


--- trunk/Source/_javascript_Core/jit/JITExceptions.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/jit/JITExceptions.h	2012-01-08 23:46:12 UTC (rev 104415)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 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 JITExceptions_h
+#define JITExceptions_h
+
+#include "JSValue.h"
+#include "MacroAssemblerCodeRef.h"
+
+namespace JSC {
+
+class ExecState;
+class JSGlobalData;
+
+// This header gives other parts of the system access to the JIT's prototocol
+// for the throwing and handling exceptions.
+
+struct ExceptionHandler {
+    void* catchRoutine;
+    ExecState* callFrame;
+};
+
+ExceptionHandler genericThrow(JSGlobalData*, ExecState*, JSValue exceptionValue, unsigned vPCIndex);
+
+ExceptionHandler jitThrow(JSGlobalData*, ExecState*, JSValue exceptionValue, ReturnAddressPtr faultLocation);
+
+} // namespace JSC
+
+#endif // JITExceptions_h
+

Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (104414 => 104415)


--- trunk/Source/_javascript_Core/jit/JITStubs.cpp	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp	2012-01-08 23:46:12 UTC (rev 104415)
@@ -44,6 +44,7 @@
 #include "Heap.h"
 #include "InlineASM.h"
 #include "JIT.h"
+#include "JITExceptions.h"
 #include "JSActivation.h"
 #include "JSArray.h"
 #include "JSByteArray.h"
@@ -1033,26 +1034,6 @@
         } \
     } while (0)
 
-struct ExceptionHandler {
-    void* catchRoutine;
-    CallFrame* callFrame;
-};
-
-static ExceptionHandler jitThrow(JSGlobalData* globalData, CallFrame* callFrame, JSValue exceptionValue, ReturnAddressPtr faultLocation)
-{
-    ASSERT(exceptionValue);
-
-    unsigned vPCIndex = callFrame->codeBlock()->bytecodeOffset(faultLocation);
-    globalData->exception = JSValue();
-    HandlerInfo* handler = globalData->interpreter->throwException(callFrame, exceptionValue, vPCIndex); // This may update callFrame & exceptionValue!
-    globalData->exception = exceptionValue;
-
-    void* catchRoutine = handler ? handler->nativeCode.executableAddress() : FunctionPtr(ctiOpThrowNotCaught).value();
-    ASSERT(catchRoutine);
-    ExceptionHandler exceptionHandler = { catchRoutine, callFrame };
-    return exceptionHandler;
-}
-
 // Helper function for JIT stubs that may throw an exception in the middle of
 // processing a function call. This function rolls back the register file to
 // our caller, so exception processing can proceed from a valid state.

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.h (104414 => 104415)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2012-01-08 23:44:40 UTC (rev 104414)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2012-01-08 23:46:12 UTC (rev 104415)
@@ -251,6 +251,9 @@
 #if ENABLE(JIT)
         ReturnAddressPtr exceptionLocation;
         JSValue hostCallReturnValue;
+        CallFrame* callFrameForThrow;
+        void* targetMachinePCForThrow;
+        Instruction* targetInterpreterPCForThrow;
 #if ENABLE(DFG_JIT)
         uint32_t osrExitIndex;
         void* osrExitJumpDestination;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to