Commit ec6f626b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #692 from toshok/fewer-mallocs2

Fewer mallocs
parents 78493220 3501184a
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
Assembler(uint8_t* start, int size) : start_addr(start), end_addr(start + size), addr(start_addr), failed(false) {} Assembler(uint8_t* start, int size) : start_addr(start), end_addr(start + size), addr(start_addr), failed(false) {}
#ifndef NDEBUG #ifndef NDEBUG
inline void comment(std::string msg) { inline void comment(const llvm::Twine& msg) {
if (ASSEMBLY_LOGGING) { if (ASSEMBLY_LOGGING) {
logger.log_comment(msg, addr - start_addr); logger.log_comment(msg, addr - start_addr);
} }
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
} }
} }
#else #else
inline void comment(std::string msg) {} inline void comment(const llvm::Twine& msg) {}
inline std::string dump() { return ""; } inline std::string dump() { return ""; }
#endif #endif
......
...@@ -59,8 +59,8 @@ void disassemblyInitialize() { ...@@ -59,8 +59,8 @@ void disassemblyInitialize() {
llvm::InitializeNativeTargetAsmParser(); llvm::InitializeNativeTargetAsmParser();
} }
void AssemblyLogger::log_comment(const std::string& comment, size_t offset) { void AssemblyLogger::log_comment(const llvm::Twine& comment, size_t offset) {
comments[offset].push_back(comment); comments[offset].push_back(comment.str());
} }
void AssemblyLogger::append_comments(llvm::raw_string_ostream& stream, size_t pos) const { void AssemblyLogger::append_comments(llvm::raw_string_ostream& stream, size_t pos) const {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <unordered_map> #include <unordered_map>
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
namespace pyston { namespace pyston {
...@@ -31,7 +32,7 @@ private: ...@@ -31,7 +32,7 @@ private:
void append_comments(llvm::raw_string_ostream&, size_t pos) const; void append_comments(llvm::raw_string_ostream&, size_t pos) const;
public: public:
void log_comment(const std::string&, size_t offset); void log_comment(const llvm::Twine&, size_t offset);
std::string finalize_log(uint8_t const* start_addr, uint8_t const* end_addr) const; std::string finalize_log(uint8_t const* start_addr, uint8_t const* end_addr) const;
}; };
} }
......
...@@ -232,7 +232,7 @@ private: ...@@ -232,7 +232,7 @@ private:
// Here "done" means that it would be okay to release all of the var's locations and // Here "done" means that it would be okay to release all of the var's locations and
// thus allocate new variables in that same location. To be safe, you can always just // thus allocate new variables in that same location. To be safe, you can always just
// only call bumpUse at the end, but in some cases it may be possible earlier. // only call bumpUse at the end, but in some cases it may be possible earlier.
std::vector<int> uses; llvm::SmallVector<int, 32> uses;
int next_use; int next_use;
void bumpUse(); void bumpUse();
void releaseIfNoUses(); void releaseIfNoUses();
...@@ -348,7 +348,7 @@ protected: ...@@ -348,7 +348,7 @@ protected:
Rewriter(std::unique_ptr<ICSlotRewrite> rewrite, int num_args, const std::vector<int>& live_outs); Rewriter(std::unique_ptr<ICSlotRewrite> rewrite, int num_args, const std::vector<int>& live_outs);
std::vector<RewriterAction> actions; llvm::SmallVector<RewriterAction, 32> actions;
void addAction(std::function<void()> action, std::vector<RewriterVar*> const& vars, ActionType type) { void addAction(std::function<void()> action, std::vector<RewriterVar*> const& vars, ActionType type) {
assertPhaseCollecting(); assertPhaseCollecting();
for (RewriterVar* var : vars) { for (RewriterVar* var : vars) {
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
class ASTInterpreter { class ASTInterpreter {
public: public:
typedef ContiguousMap<InternedString, Box*> SymMap; typedef ContiguousMap<InternedString, Box*, llvm::SmallDenseMap<InternedString, int, 16>> SymMap;
ASTInterpreter(CLFunction* clfunc); ASTInterpreter(CLFunction* clfunc);
~ASTInterpreter(); ~ASTInterpreter();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment