Skip to content

Commit

Permalink
perf(vm): Add function inlining
Browse files Browse the repository at this point in the history
The main purpose of this is to avoid the overhead of the trivial
operator functions `+, -, *` etc.
  • Loading branch information
Marwes committed Oct 1, 2019
1 parent 8f2e109 commit 5093137
Show file tree
Hide file tree
Showing 9 changed files with 457 additions and 49 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/compiler_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ where

debug!("Translation returned: {}", expr);

core::optimize::optimize(&translator.allocator, expr)
core::optimize::optimize(&translator.allocator, &*env, expr)
};

let source = compiler
Expand Down
1 change: 1 addition & 0 deletions vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ gluon_codegen = { path = "../codegen", version = "0.12.0" } # GLUON
lalrpop = { version = "0.17", optional = true }

[dev-dependencies]
difference = "2"
env_logger = "0.6"
pretty_assertions = "0.6"

Expand Down
8 changes: 2 additions & 6 deletions vm/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::base::{
};

use crate::{
core::{self, CExpr, Expr, Literal, Pattern},
core::{self, is_primitive, CExpr, Expr, Literal, Pattern},
interner::InternedStr,
source_map::{LocalMap, SourceMap},
types::*,
Expand Down Expand Up @@ -759,11 +759,7 @@ impl<'a> Compiler<'a> {
}
Expr::Call(func, args) => {
if let Expr::Ident(ref id, _) = *func {
if id.name.as_ref() == "&&"
|| id.name.as_ref() == "||"
|| (id.name.as_ref().starts_with('#')
&& id.name.declared_name() != "#error")
{
if is_primitive(&id.name) && id.name.declared_name() != "#error" {
self.compile_primitive(&id.name, args, function, tail_position)?;
return Ok(None);
}
Expand Down
3 changes: 2 additions & 1 deletion vm/src/core/grammar.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::base::{
ast::{TypedIdent},
pos::{BytePos, Span},
symbol::{Symbol, Symbols},
types::{Field, Type}};
types::{Field, Type},
};

use crate::core::{Allocator, Alternative, Closure, Expr, LetBinding, Literal, Named, Pattern};

Expand Down
Loading

0 comments on commit 5093137

Please sign in to comment.