Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: lib/Transforms/NaCl/ExceptionInfoWriter.h

Issue 24777002: Add PNaClSjLjEH pass to implement C++ exception handling using setjmp()+longjmp() (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry upload Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/Transforms/NaCl/CMakeLists.txt ('k') | lib/Transforms/NaCl/ExceptionInfoWriter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Transforms/NaCl/ExceptionInfoWriter.h
diff --git a/lib/Transforms/NaCl/ExceptionInfoWriter.h b/lib/Transforms/NaCl/ExceptionInfoWriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..dadaaf76158c5162a0930c434b509fcdbd938f31
--- /dev/null
+++ b/lib/Transforms/NaCl/ExceptionInfoWriter.h
@@ -0,0 +1,71 @@
+//===-- ExceptionInfoWriter.h - Generate C++ exception info------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TRANSFORMS_NACL_EXCEPTIONINFOWRITER_H
+#define TRANSFORMS_NACL_EXCEPTIONINFOWRITER_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Module.h"
+
+namespace llvm {
+
+// The ExceptionInfoWriter class converts the clauses of a
+// "landingpad" instruction into data tables stored in global
+// variables, which are interpreted by PNaCl's C++ runtime library.
+// See ExceptionInfoWriter.cpp for a full description.
+class ExceptionInfoWriter {
+ LLVMContext *Context;
+ StructType *ActionTableEntryTy;
+
+ // Data for populating __pnacl_eh_type_table[], which is an array of
+ // std::type_info* pointers. Each of these pointers represents a
+ // C++ exception type.
+ SmallVector<Constant *, 10> TypeTableData;
+ // Mapping from std::type_info* pointer to type ID (index in
+ // TypeTableData).
+ typedef DenseMap<Constant *, unsigned> TypeTableIDMapType;
+ TypeTableIDMapType TypeTableIDMap;
+
+ // Data for populating __pnacl_eh_action_table[], which is an array
+ // of pairs.
+ SmallVector<Constant *, 10> ActionTableData;
+ // Pair of (clause_id, clause_list_id).
+ typedef std::pair<unsigned, unsigned> ActionTableEntry;
+ // Mapping from (clause_id, clause_list_id) to clause_id (index in
+ // ActionTableData).
+ typedef DenseMap<ActionTableEntry, unsigned> ActionTableIDMapType;
+ ActionTableIDMapType ActionTableIDMap;
+
+ // Data for populating __pnacl_eh_filter_table[], which is an array
+ // of integers.
+ SmallVector<Constant *, 10> FilterTableData;
+
+ // Get the interned ID for an action.
+ unsigned getIDForClauseListNode(unsigned ClauseID, unsigned NextClauseListID);
+
+ // Get the clause ID for a "filter" clause.
+ unsigned getIDForFilterClause(Value *Filter);
+
+public:
+ explicit ExceptionInfoWriter(LLVMContext *Context);
+
+ // Get the interned type ID (a small integer) for a C++ exception type.
+ unsigned getIDForExceptionType(Value *Ty);
+
+ // Get the clause list ID for a landingpad's clause list.
+ unsigned getIDForLandingPadClauseList(LandingPadInst *LP);
+
+ // Add the exception info tables to the module.
+ void defineGlobalVariables(Module *M);
+};
+
+}
+
+#endif
« no previous file with comments | « lib/Transforms/NaCl/CMakeLists.txt ('k') | lib/Transforms/NaCl/ExceptionInfoWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698