Skip to content

Commit 17a1eed

Browse files
committed
Merge branch 'master' of https://github.com/perl6/nqp
2 parents a065e99 + ea1349b commit 17a1eed

File tree

8 files changed

+56
-16
lines changed

8 files changed

+56
-16
lines changed

README.pod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ used. On Mavericks use 10.9 (like above), on Yosemite use 10.10.
9494

9595
The L<examples directory|https://github.com/perl6/nqp/tree/master/examples> is a good place to start, with the
9696
L<loops|https://github.com/perl6/nqp/blob/master/examples/loops.nqp> and other files. Opcodes are listed in
97-
L<the docs directory|https://github.com/perl6/nqp/blob/master/docs/ops.markdown>. You can use NQP from this
97+
L<the docs directory|https://github.com/perl6/nqp/blob/master/docs/ops.markdown>. NQP also has built-in routines
98+
listed in L<the docs directory|https://github.com/perl6/nqp/blob/master/docs/built-ins.md>. You can use NQP from this
9899
release, it will be already installed if you have built Perl6 from
99100
scratch.
100101

102+
Developers and module authors should note that significant run-time speed-ups are sometimes possible by using NQP
103+
inside Perl 6 code.
104+
101105
=head2 JavaScript backend
102106

103107
The best thing before playing with it/hacking on it is to contact pmurias via IRC at #perl6 on irc.freenode.org.

docs/built-ins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Open file `$filename`. Options:
3737
Close the file attached to file handle `$fh`.
3838

3939
## slurp
40-
* `slurp ($filename --> str)`
40+
* `slurp($filename --> str)`
4141

4242
Returns the contents of `$filename` as a single string.
4343

docs/ops.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ Return 1 if this filehandle is at the end of the file, otherwise 0.
15611561

15621562
## filenofh
15631563
* `filenofh(Handle $fh --> int)`
1564-
Returns the filehandle number.
1564+
Returns the filehandle number. Not usable on the JVM (always returns -1).
15651565

15661566
## flushfh
15671567
* `flushfh(Handle $fh)`

examples/fib.nqp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ my $t0 := nqp::time_n();
1010
my $z := fib($N);
1111
my $t1 := nqp::time_n();
1212

13-
nqp::say("fib($N) = " ~ fib($N));
14-
nqp::say("time = " ~ ($t1-$t0));
13+
say("fib($N) = " ~ fib($N));
14+
say("time = " ~ ($t1-$t0));

examples/loops.nqp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33

44
my $i := 0;
55
while $i < 10 {
6-
say("i=$i");
7-
$i++;
6+
say("i={$i++}");
87
}

src/vm/jvm/runtime/org/perl6/nqp/io/StandardReadHandle.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public byte[] read(ThreadContext tc, int bytes) {
4141
byte[] array = new byte[bytes];
4242
int read = 0;
4343
int offset = 0;
44-
while ((read = is.read(array, offset, bytes - offset)) != -1) {
44+
while (offset < bytes) {
45+
if ((read = is.read(array, offset, bytes - offset)) == -1) {
46+
eof = true;
47+
break;
48+
}
4549
offset += read;
4650
}
4751
byte[] compact = new byte[offset];

src/vm/moar/HLL/Backend.nqp

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,37 @@ class HLL::Backend::MoarVM {
291291
my int $node_id := 0;
292292
#my %profile := nqp::hash();
293293
my $mapping := nqp::shift($obj);
294+
my $pieces := nqp::list_s();
295+
my $empty-array := nqp::list_s();
294296
for $mapping -> $k {
295297
my $v := $mapping{$k};
296298
if nqp::ishash($v) {
297-
$profile_fh.say("INSERT INTO routines VALUES ('" ~ nqp::join("','", nqp::list(nqp::iterkey_s($k), literal_subst(~$v<name>, "'", "''"), ~$v<line>, ~$v<file>)) ~ "');");
299+
nqp::push_s($pieces, "INSERT INTO routines VALUES ('");
300+
nqp::push_s($pieces,
301+
nqp::join("','",
302+
nqp::list(
303+
nqp::iterkey_s($k),
304+
literal_subst(~$v<name>, "'", "''"),
305+
~$v<line>,
306+
~$v<file>))
307+
~ "');\n");
298308
}
299309
else {
300-
$profile_fh.say("INSERT INTO types VALUES ('" ~ nqp::join("','", nqp::list(nqp::iterkey_s($k), literal_subst(~$v, "'", "''"))) ~ "');");
310+
nqp::push_s($pieces, "INSERT INTO types VALUES ('");
311+
nqp::push_s($pieces,
312+
nqp::join("','",
313+
nqp::list(
314+
nqp::iterkey_s($k),
315+
literal_subst(~$v, "'", "''")))
316+
~ "');\n");
317+
}
318+
if nqp::elems($pieces) > 500 {
319+
$profile_fh.say(nqp::join("", $pieces));
320+
nqp::splice($pieces, $empty-array, 0, nqp::elems($pieces));
301321
}
302322
}
303323
for $obj -> $thread {
304324
my $thisprof := nqp::list;
305-
note($thread<thread>);
306325
$thisprof[3] := "NULL";
307326
for $thread -> $k {
308327
my $v := $thread{$k};
@@ -322,7 +341,8 @@ class HLL::Backend::MoarVM {
322341
nqp::push_s(@g, ~($gc{$f} // '0'));
323342
}
324343
nqp::push_s(@g, ~$thread<thread>);
325-
$profile_fh.say('INSERT INTO gcs VALUES (' ~ nqp::join(',', @g) ~ ');');
344+
nqp::push_s($pieces, 'INSERT INTO gcs VALUES (');
345+
nqp::push_s($pieces, nqp::join(',', @g) ~ ");\n");
326346
}
327347
}
328348
elsif $k eq 'call_graph' {
@@ -338,14 +358,16 @@ class HLL::Backend::MoarVM {
338358
my str $routine_id := ~%call_graph<id>;
339359
%call_rec_depth{$routine_id} := 0 unless %call_rec_depth{$routine_id};
340360
nqp::push_s(@call, ~%call_rec_depth{$routine_id});
341-
$profile_fh.say('INSERT INTO calls VALUES (' ~ nqp::join(',', @call) ~ ');');
361+
nqp::push_s($pieces, 'INSERT INTO calls VALUES (');
362+
nqp::push_s($pieces, nqp::join(',', @call) ~ ");\n");
342363
if %call_graph<allocations> {
343364
for %call_graph<allocations> -> $a {
344365
my @a := nqp::list_s($call_id);
345366
for <id spesh jit count> -> $f {
346367
nqp::push_s(@a, ~($a{$f} // '0'));
347368
}
348-
$profile_fh.say('INSERT INTO allocations VALUES (' ~ nqp::join(',', @a) ~ ');');
369+
nqp::push_s($pieces, 'INSERT INTO allocations VALUES (');
370+
nqp::push_s($pieces, nqp::join(',', @a) ~ ");\n");
349371
}
350372
}
351373
if %call_graph<callees> {
@@ -355,12 +377,23 @@ class HLL::Backend::MoarVM {
355377
}
356378
%call_rec_depth{$routine_id}--;
357379
}
380+
if nqp::elems($pieces) > 500 {
381+
$profile_fh.say(nqp::join("", $pieces));
382+
nqp::splice($pieces, $empty-array, 0, nqp::elems($pieces));
383+
}
358384
}
359385
collect_calls(~$node_id, $v);
360386
}
361387
}
362-
$profile_fh.say('INSERT INTO profile VALUES (' ~ nqp::join(',', $thisprof) ~ ');');
388+
nqp::push_s($pieces, 'INSERT INTO profile VALUES (');
389+
nqp::push_s($pieces, nqp::join(',', $thisprof) ~ ");\n");
390+
if nqp::elems($pieces) > 500 {
391+
$profile_fh.say(nqp::join("", $pieces));
392+
nqp::splice($pieces, $empty-array, 0, nqp::elems($pieces));
393+
}
363394
}
395+
$profile_fh.say(nqp::join("", $pieces));
396+
nqp::splice($pieces, $empty-array, 0, nqp::elems($pieces));
364397
}
365398

366399
# Post-process the call data, turning objects into flat data.

tools/build/MOAR_REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2018.02-21-gc6543e21f
1+
2018.02-31-g408555456

0 commit comments

Comments
 (0)