Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
o- committed Dec 12, 2018
1 parent 4c10d31 commit fa85136
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/mandelbrot_mini.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mandelbrot_mini <- function() {

f <- rir.compile(function() mandelbrot_mini())

# Run twice to get realistic type feedback
f()
f()
pir.compile(mandelbrot_mini, debugFlags=pir.debugFlags(PrintPirAfterOpt=TRUE, ShowWarnings=TRUE))
1 change: 1 addition & 0 deletions examples/tree_mini.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test <- function() {

f <- rir.compile(function() test())

# Run twice to get realistic type feedback
f()
f()
pir.compile(test, debugFlags=pir.debugFlags(PrintPirAfterOpt=TRUE, ShowWarnings=TRUE))
23 changes: 19 additions & 4 deletions rir/src/compiler/opt/inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class TheInliner {
Closure* function;
explicit TheInliner(Closure* function) : function(function) {}

static constexpr size_t MAX_SIZE = 10000;
static constexpr size_t MAX_INLINEE_SIZE = 200;
static constexpr size_t MAX_FUEL = 5;
static const size_t MAX_SIZE;
static const size_t MAX_INLINEE_SIZE;
static const size_t INITIAL_FUEL;

void operator()() {
size_t fuel = MAX_FUEL;
size_t fuel = INITIAL_FUEL;

if (function->size() > MAX_SIZE)
return;
Expand Down Expand Up @@ -228,6 +228,21 @@ class TheInliner {
});
}
};

// TODO: maybe implement something more resonable to pass in those constants.
// For now it seems a simple env variable is just fine.
const size_t TheInliner::MAX_SIZE = getenv("PIR_INLINER_MAX_SIZE")
? atoi(getenv("PIR_INLINER_MAX_SIZE"))
: 10000;
const size_t TheInliner::MAX_INLINEE_SIZE =
getenv("PIR_INLINER_MAX_INLINEE_SIZE")
? atoi(getenv("PIR_INLINER_MAX_INLINEE_SIZE"))
: 200;
const size_t TheInliner::INITIAL_FUEL =
getenv("PIR_INLINER_INITIAL_FUEL")
? atoi(getenv("PIR_INLINER_INITIAL_FUEL"))
: 5;

} // namespace

namespace rir {
Expand Down

0 comments on commit fa85136

Please sign in to comment.