- AP.SwitchToTextSection(TAI.getTextSection());
- EmitCamlGlobal(getModule(), OS, AP, TAI, "code_end");
-
- AP.SwitchToDataSection(TAI.getDataSection());
- EmitCamlGlobal(getModule(), OS, AP, TAI, "data_end");
-
- OS << AddressDirective << 0; // FIXME: Why does ocaml emit this??
- AP.EOL();
-
- AP.SwitchToDataSection(TAI.getDataSection());
- EmitCamlGlobal(getModule(), OS, AP, TAI, "frametable");
-
- for (iterator FI = begin(), FE = end(); FI != FE; ++FI) {
- CollectorMetadata &MD = **FI;
-
- OS << "\t" << TAI.getCommentString() << " live roots for "
- << MD.getFunction().getNameStart() << "\n";
-
- for (CollectorMetadata::iterator PI = MD.begin(),
- PE = MD.end(); PI != PE; ++PI) {
-
- uint64_t FrameSize = MD.getFrameSize();
- if (FrameSize >= 1<<16) {
- cerr << "Function '" << MD.getFunction().getNameStart()
- << "' is too large for the ocaml collector! "
- << "Frame size " << FrameSize << " >= 65536.\n";
- abort(); // Very rude!
- }
-
- size_t LiveCount = MD.live_size(PI);
+ if (NumDescriptors >= 1<<16) {
+ // Very rude!
+ report_fatal_error(" Too much descriptor for ocaml GC");
+ }
+ AP.EmitInt16(NumDescriptors);
+ AP.EmitAlignment(IntPtrSize == 4 ? 2 : 3);
+
+ for (iterator I = begin(), IE = end(); I != IE; ++I) {
+ GCFunctionInfo &FI = **I;
+
+ uint64_t FrameSize = FI.getFrameSize();
+ if (FrameSize >= 1<<16) {
+ // Very rude!
+ report_fatal_error("Function '" + FI.getFunction().getName() +
+ "' is too large for the ocaml GC! "
+ "Frame size " + Twine(FrameSize) + ">= 65536.\n"
+ "(" + Twine(uintptr_t(&FI)) + ")");
+ }
+
+ AP.OutStreamer.AddComment("live roots for " +
+ Twine(FI.getFunction().getName()));
+ AP.OutStreamer.AddBlankLine();
+
+ for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) {
+ size_t LiveCount = FI.live_size(J);