Skip to content

Instantly share code, notes, and snippets.

Elizabeth Mattijsen lizmat

Block or report user

Report or block lizmat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lizmat
lizmat / gist:90974d3d89f7f64d02122362ff39c6cc
Last active Sep 26, 2019
alternate Proxy implementation
View gist:90974d3d89f7f64d02122362ff39c6cc
class Proxy {
has Mu &.FETCH;
has Mu &.STORE;
my constant $FETCH = method FETCH(\SELF:) {
my $self := nqp::create(Scalar);
nqp::bindattr($self, Scalar, '$!value', SELF);
nqp::decont(&!FETCH($self))
}
my constant $STORE = method STORE(\SELF: \value) {
@lizmat
lizmat / gist:71c32456b5de3cab33a5a833f3a8ea6a
Created Sep 26, 2019
Why do we need to create a Scalar for the Proxy object for each access / change ???
View gist:71c32456b5de3cab33a5a833f3a8ea6a
diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
index 963db37eb..ffef42e48 100644
--- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
+++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
@@ -1739,14 +1739,10 @@ BEGIN {
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!FETCH>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!STORE>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_method(Proxy, 'FETCH', ($PROXY_FETCH := nqp::getstaticcode(sub ($cont) {
- my $var := nqp::create(Scalar);
- nqp::bindattr($var, Scalar, '$!value', $cont);
@lizmat
lizmat / gist:8c0476706a473405f5b48793eff69f72
Last active Sep 25, 2019
proof of concept for "is tracked" variable trait
View gist:8c0476706a473405f5b48793eff69f72
class History is Proxy {
has @.history;
method history() { @.history.skip.map: *<> }
method push(\value --> Nil) { @!history.push(value) }
method reset(--> Nil) { @!history = () }
}
sub historized-container() is raw {
my $value;
my $historized-container := History.new(
View gist:6b1fd58385a522886253ecb095edc323
$ git diff
diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
index a26697224..17b8dc3e7 100644
--- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
+++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
@@ -1749,7 +1749,7 @@ BEGIN {
nqp::getattr($cont, Proxy, '&!STORE')($var, $val)
})));
Proxy.HOW.add_method(Proxy, 'new', nqp::getstaticcode(sub ($type, :$FETCH!, :$STORE!) {
- my $cont := nqp::create(Proxy);
View gist:098de1bf9d93e280414b7db69bec06a2
$ git checkout newer-sprintf
Switched to branch 'newer-sprintf'
Your branch and 'origin/newer-sprintf' have diverged,
and have 16 and 6 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
LizyPro:rakudo.moar liz$ git rebase master
Current branch newer-sprintf is up to date.
View gist:351d306c87fe14c327f1d5b1b7e1c91b
$ perl6 --ll-exception t/spec/S32-io/socket-recv-vs-read.t
1..13
No such method 'recv' for invocant of type 'Any'
at SETTING::src/core/Exception.pm6:62 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/CORE.setting.moarvm:throw)
from SETTING::src/core/Exception.pm6:2797 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/CORE.setting.moarvm:)
from gen/moar/BOOTSTRAP.nqp:3814 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/BOOTSTRAP.moarvm:)
from t/spec/S32-io/socket-recv-vs-read.t:27 (<ephemeral file>:<unit>)
from t/spec/S32-io/socket-recv-vs-read.t:1 (<ephemeral file>:<unit-outer>)
from gen/moar/stage2/NQPHLL.nqp:1835 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/NQPHLL.moarvm:eval)
from gen/moar/stage2/NQPHLL.nqp:2039 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/NQPHLL.moarvm:evalfiles)
View gist:83476091b86901b90fb0a005bab53986
$ 6l 'use Inline::Perl5'
Cannot unbox a type object (int64) to int.
at gen/moar/stage2/QASTNode.nqp:387 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/QASTNode.moarvm:new)
from src/Perl6/World.nqp:3053 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/World.moarvm:add_constant_folded_result)
from gen/moar/Perl6-Actions.nqp:5163 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/Actions.moarvm:type_declarator:sym<constant>)
from gen/moar/stage2/QRegex.nqp:1545 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/QRegex.moarvm:!cursor_pass)
from gen/moar/Perl6-Grammar.nqp:2937 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/Grammar.moarvm:type_declarator:sym<constant>)
from gen/moar/stage2/QRegex.nqp:1644 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/QRegex.moarvm:!protoregex)
from <unknown>:1 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/Grammar.moarvm:type_declarator)
from gen/moar/Perl6-Grammar.nqp:2187 (/Users/liz/Github/rakudo.
@lizmat
lizmat / gist:2ed4732f8acff8bba03aa371a130b78c
Created Jun 9, 2019
2 profiles of the same code, one before MoarVM bump, one after
View gist:2ed4732f8acff8bba03aa371a130b78c
<!DOCTYPE html>
<html lang="en" ng-app="moarProfApp" ng-controller="NavigationController">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MoarVM Profiler Results</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<style>
View gist:0102c94fb8c7ddff333cbec854a0465f
$ 6 'use Data::Dump::Tree; use nqp; ddt nqp::backendconfig'
{153} @0
├ ar => ar.Str
├ arflags => rcs.Str
├ arout => .Str
├ as => as.Str
├ asm => .s.Str
├ asmout => -o .Str
├ asmswitch => -S.Str
├ auxclean => @:.Str
View gist:99c0246aff5ee0abf0579e8905e91106
$ 6mp 'sub a() { my $a = 42 }; .say for profile( { a for ^10000 } ).my_callees'
Unnamed callee was called 1 time
at -e line 1
from thread #1.
Was jitted and had an On-Stack-Replacement.
Called at 0 microsecs and ran for 5649 microsecs.
Did 12455 allocations (of which 1 (0.01%) was done here).
Unnamed callee was called 10000 times
at -e line 1
You can’t perform that action at this time.