]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/code_blocks.cpp
audio.engine.test: cleanup using
[factor.git] / vm / code_blocks.cpp
index 6b4ef18bc695094011260b7b99e93c6929d3d014..d9d774f9f961e1bca3a093d48a2f43c054e0bf11 100644 (file)
@@ -3,28 +3,23 @@
 namespace factor {
 
 static cell code_block_owner(code_block* compiled) {
-  tagged<object> owner(compiled->owner);
+  cell owner = compiled->owner;
 
   // Cold generic word call sites point to quotations that call the
   // inline-cache-miss and inline-cache-miss-tail primitives.
-  if (owner.type() == QUOTATION_TYPE) {
-    tagged<quotation> quot(owner.as<quotation>());
-    tagged<array> elements(quot->array);
-
-    FACTOR_ASSERT(array_capacity(elements.untagged()) == 5);
-    FACTOR_ASSERT(array_nth(elements.untagged(), 4) ==
-                  special_objects[PIC_MISS_WORD] ||
-                  array_nth(elements.untagged(), 4) ==
-                  special_objects[PIC_MISS_TAIL_WORD]);
-
-    tagged<wrapper> word_wrapper(array_nth(elements.untagged(), 0));
-    return word_wrapper->object;
-  }
-  return compiled->owner;
+  if (TAG(owner) != QUOTATION_TYPE)
+    return owner;
+
+  quotation* quot = untag<quotation>(owner);
+  array* elements = untag<array>(quot->array);
+
+  FACTOR_ASSERT(array_capacity(elements) == 5);
+  wrapper* wrap = untag<wrapper>(array_nth(elements, 0));
+  return wrap->object;
 }
 
 static cell compute_entry_point_address(cell obj) {
-  switch (tagged<object>(obj).type()) {
+  switch (TAG(obj)) {
     case WORD_TYPE:
       return untag<word>(obj)->entry_point;
     case QUOTATION_TYPE:
@@ -43,10 +38,9 @@ static cell compute_here_address(cell arg, cell offset, code_block* compiled) {
 }
 
 cell code_block::owner_quot() const {
-  tagged<object> executing(owner);
-  if (type() != CODE_BLOCK_OPTIMIZED && executing->type() == WORD_TYPE)
-    executing = executing.as<word>()->def;
-  return executing.value();
+  if (type() != CODE_BLOCK_OPTIMIZED && TAG(owner) == WORD_TYPE)
+    return untag<word>(owner)->def;
+  return owner;
 }
 
 // If the code block is an unoptimized quotation, we can calculate the
@@ -57,13 +51,13 @@ cell code_block::scan(factor_vm* vm, cell addr) const {
     return tag_fixnum(-1);
   }
 
-  tagged<object> obj(owner);
-  if (obj.type() == WORD_TYPE)
-    obj = obj.as<word>()->def;
-  if (obj.type() != QUOTATION_TYPE)
+  cell ptr = owner;
+  if (TAG(ptr) == WORD_TYPE)
+    ptr = untag<word>(ptr)->def;
+  if (TAG(ptr) != QUOTATION_TYPE)
     return tag_fixnum(-1);
   cell ofs = offset(addr);
-  return tag_fixnum(vm->quot_code_offset_to_scan(obj.value(), ofs));
+  return tag_fixnum(vm->quot_code_offset_to_scan(ptr, ofs));
 }
 
 cell factor_vm::compute_entry_point_pic_address(word* w, cell tagged_quot) {