tario / fastruby Goto Github PK
View Code? Open in Web Editor NEWFastruby, fast execution of ruby code (please, killme)
License: GNU General Public License v3.0
Fastruby, fast execution of ruby code (please, killme)
License: GNU General Public License v3.0
Tip: use global functions for method wrapping and doble indirection when make fastruby calls
example:
def foo(a,b,c=$x)
a+b+c
end
$x = 99
foo(1,2) # 102
foo(1,2,3) # 6
to_c_defn must define a new method instead of calling fastruby
tip: save and restore stack in a buffer to allow continuation
example:
def foo(a,b,c,&block)
block.call
end
foo(1,2,3) do
print "hello world\n"
end
Inline implementations of translations will consume less real C frames allowing the use of local goto's in more scenarios to increase performance
Inline implementations of translations will consume less real C frames allowing the use of local goto's in more scenarios to increase performance
Tip: emulate proc using a singleton method
Tip2: use C API to define the proc
Support for case when else
fastruby '
def foo
print "hello world\n"
end
'
foo
Expected hello world
Obtained: Segmentation fault
class X
def foo
yield(2)
end
def bar
foo(&:to_s)
end
end
Since each single method serves as template to generate multiple static versions, this precompiled versions must be associated with their corresponding method
Example
def bar
yield
end
myproc = proc do
print "hello world\n"
end
bar(&myproc)
Avoid using rb_funcall
= Specs with generated class names
spec/variable_spec.rb
spec/exception_spec.rb
non-local goto is more expensive that a simple return, use normal return when possible to improve the performance a many cases
This code will generate three objects for X#foo instead of expected (two)
code = "
class X
def foo
6
end
end
"
fastruby code
X.new.foo.should be == 6
fastruby "class ::JU4
def foo
9
end
end
"
X.new.foo.should be == 9
fastruby code
X.new.foo.should be == 6
class << x
def foo
end
end
may use conditional compiling to maintain compatibility with ruby1.8
Tip1: change fastruby convention to handle variable number of arguments
Tip2: wrap fastruby convention of specific number of arguments
class X
def foo
yield(5)
end
def bar
foo do |n|
p n
n = n - 1
redo if n > 0
end
end
end
X.new.bar
expected; 5 4 3 2 1
received: 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
tip1: registry a marker object for the "entire stack"which will mark all of the locals
tip2: registry all the local addresses using the RubyC API
only when run under ruby1.8
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.