From b202371d620a3439aeb7560bb76833634625fdf7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 31 Oct 2009 02:58:00 -0500 Subject: [PATCH] vm: faster tuple allocation primitives --- vm/tuples.cpp | 26 +++++++++++--------------- vm/vm.hpp | 1 - 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/vm/tuples.cpp b/vm/tuples.cpp index 8a6e2d053b..8c759b4884 100755 --- a/vm/tuples.cpp +++ b/vm/tuples.cpp @@ -3,33 +3,29 @@ namespace factor { -/* push a new tuple on the stack */ -tuple *factor_vm::allot_tuple(cell layout_) -{ - gc_root layout(layout_,this); - gc_root t(allot(tuple_size(layout.untagged())),this); - t->layout = layout.value(); - return t.untagged(); -} - /* push a new tuple on the stack, filling its slots with f */ void factor_vm::primitive_tuple() { gc_root layout(dpop(),this); - tuple *t = allot_tuple(layout.value()); - cell size = (tuple_size(layout.untagged()) - 1) * sizeof(cell); - memset_cell(t->data(),false_object,size); - dpush(tag(t)); + tagged t(allot(tuple_size(layout.untagged()))); + t->layout = layout.value(); + + memset_cell(t->data(),false_object,tuple_size(layout.untagged()) - sizeof(cell)); + + dpush(t.value()); } /* push a new tuple on the stack, filling its slots from the stack */ void factor_vm::primitive_tuple_boa() { gc_root layout(dpop(),this); - gc_root t(allot_tuple(layout.value()),this); + tagged t(allot(tuple_size(layout.untagged()))); + t->layout = layout.value(); + cell size = untag_fixnum(layout.untagged()->size) * sizeof(cell); - memcpy(t->data(),(cell *)(ds - (size - sizeof(cell))),size); + memcpy(t->data(),(cell *)(ds - size + sizeof(cell)),size); ds -= size; + dpush(t.value()); } diff --git a/vm/vm.hpp b/vm/vm.hpp index e4a2ffc753..d3686c743e 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -363,7 +363,6 @@ struct factor_vm void primitive_resize_byte_array(); //tuples - tuple *allot_tuple(cell layout_); void primitive_tuple(); void primitive_tuple_boa();