• Save
Noboxing plugin
Upcoming SlideShare
Loading in...5
×
 

Noboxing plugin

on

  • 2,969 views

 

Statistics

Views

Total Views
2,969
Views on SlideShare
2,924
Embed Views
45

Actions

Likes
1
Downloads
0
Comments
0

2 Embeds 45

http://skillsmatter.com 44
http://smash 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Noboxing plugin Noboxing plugin Presentation Transcript

    • No boxing here! A Scala compiler plugin walk-through Iulian Dragos Scala Solutions 1 Thursday, October 7, 2010
    • def mult(m: Matrix[Int], n: Matrix[Int]) = { val p = new Matrix[Int](m.rows, n.cols) for (i <- 0 until m.rows) for (j <- 0 until n.cols) { var sum = 0 for (k <- 0 until n.rows) sum += m(i, k) * n(k, j) p(i, j) = sum } p } 2 Thursday, October 7, 2010
    • How does this code perform? Boxing Implicit conversions Specialization 3 Thursday, October 7, 2010
    • Run the code in the profiler Instrument scala.runtime.BoxesRuntime 4 Thursday, October 7, 2010
    • Why not have the compiler tell us? 5 Thursday, October 7, 2010
    • Parser Type Checker Erasure Code Gen 6 Thursday, October 7, 2010
    • Parser Create the AST Type Checker Erasure Code Gen 6 Thursday, October 7, 2010
    • Parser Create the AST Type Checker Add symbols and types Erasure Code Gen 6 Thursday, October 7, 2010
    • Parser Create the AST Type Checker Add symbols and types Erasure Remove generics and add boxing Code Gen 6 Thursday, October 7, 2010
    • Parser Create the AST Type Checker Add symbols and types Erasure Remove generics and add boxing @noboxing Issue warnings no box/unbox Code Gen 6 Thursday, October 7, 2010
    • Plugins Implement a Plugin interface name, description runsAfter distributed as jar files enabled by -Xplugin 7 Thursday, October 7, 2010
    • Live coding 8 Thursday, October 7, 2010
    • Scala AST Definitions PackageDef, ValDef, DefDef, ClassDef, TypeDef Terms New, If, Match, Return, Ident, This, Apply Boxing is just a method call (Int.box) 9 Thursday, October 7, 2010
    • Traverser/Transformer library classes for AST inspection/modifcation override the default traverse/transform(tree) 10 Thursday, October 7, 2010
    • Symbols & Types Each definition has a unique Symbol references involve symbols (never names or trees) Each Symbol has a Type Each Tree has a Type Some Trees have Symbols 11 Thursday, October 7, 2010
    • Definitions definitions. getClass returns the symbol of a fully-qualified name getMember - member of a class/object/package isBox/isUnbox - checks if a symbol is a boxing op common symbols (PredefModule, ArrayClass, etc) 12 Thursday, October 7, 2010
    • More info Scala-lang.org http://www.scala-lang.org/node/140 (writing compiler plugins) http://www.scala-lang.org/node/598 (compiler internals videos) Source code on github http://github.com/dragos/noboxing-plugin 13 Thursday, October 7, 2010