Bring our native stack usage down.
I'd have preferred to have a 512-byte limit, but there are some monsters
in the verifier; 2000-line functions and the like. I'm also not policing
tests (except for one silly one). They can use all the stack they like.
This fixes the IntMath test (the stack overflow test was failing because
we were using more than 4KiB to throw!).
Change-Id: I7e53e2fde2b39fde1910f8ee5b1712e8a66069c7
diff --git a/src/logging.h b/src/logging.h
index a0b290d..2f73599 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -134,6 +134,27 @@
RHS rhs;
};
+// This indirection greatly reduces the stack impact of having
+// lots of checks/logging in a function.
+struct LogMessageData {
+ public:
+ LogMessageData(int line, LogSeverity severity, int error)
+ : file(NULL),
+ line_number(line),
+ severity(severity),
+ error(error) {
+ }
+
+ std::ostringstream buffer;
+ const char* file;
+ int line_number;
+ LogSeverity severity;
+ int error;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LogMessageData);
+};
+
class LogMessage {
public:
LogMessage(const char* file, int line, LogSeverity severity, int error);
@@ -143,11 +164,7 @@
private:
void LogLine(const char*);
- std::stringstream buffer_;
- const char* file_;
- int line_number_;
- LogSeverity severity_;
- int errno_;
+ LogMessageData* data_;
DISALLOW_COPY_AND_ASSIGN(LogMessage);
};