From b027285b48d849d55a22fc9d88dedae9e031a35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sun, 29 May 2016 03:03:07 +0200 Subject: [PATCH] VM: makes some factor_vm methods to free functions --- vm/dispatch.cpp | 14 +++++--------- vm/vm.hpp | 4 ---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/vm/dispatch.cpp b/vm/dispatch.cpp index 615edde4eb..f1a4dd8acd 100644 --- a/vm/dispatch.cpp +++ b/vm/dispatch.cpp @@ -2,20 +2,16 @@ namespace factor { -cell factor_vm::search_lookup_alist(cell table, cell klass) { +static cell search_lookup_alist(cell table, cell klass) { array* elements = untag(table); - fixnum index = array_capacity(elements) - 2; - while (index >= 0) { + for (fixnum index = array_capacity(elements) - 2; index >= 0; index -= 2) { if (array_nth(elements, index) == klass) return array_nth(elements, index + 1); - else - index -= 2; } - return false_object; } -cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode) { +static cell search_lookup_hash(cell table, cell klass, cell hashcode) { array* buckets = untag(table); cell bucket = array_nth(buckets, hashcode & (array_capacity(buckets) - 1)); if (TAG(bucket) == ARRAY_TYPE) @@ -23,12 +19,12 @@ cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode) { return bucket; } -cell factor_vm::nth_superclass(tuple_layout* layout, fixnum echelon) { +static cell nth_superclass(tuple_layout* layout, fixnum echelon) { cell* ptr = (cell*)(layout + 1); return ptr[echelon * 2]; } -cell factor_vm::nth_hashcode(tuple_layout* layout, fixnum echelon) { +static cell nth_hashcode(tuple_layout* layout, fixnum echelon) { cell* ptr = (cell*)(layout + 1); return ptr[echelon * 2 + 1]; } diff --git a/vm/vm.hpp b/vm/vm.hpp index f737fcd763..1f186ff6b3 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -660,10 +660,6 @@ struct factor_vm { void primitive_quotation_compiled_p(); // dispatch - cell search_lookup_alist(cell table, cell klass); - cell search_lookup_hash(cell table, cell klass, cell hashcode); - cell nth_superclass(tuple_layout* layout, fixnum echelon); - cell nth_hashcode(tuple_layout* layout, fixnum echelon); cell lookup_tuple_method(cell obj, cell methods); cell lookup_method(cell obj, cell methods); void primitive_lookup_method();