jitcraft/ObjectVisitor.h
changeset 54 8e22792a3921
parent 53 13bd3a8df334
child 59 b7d61ddb3c8d
     1.1 --- a/jitcraft/ObjectVisitor.h	Sat Jul 07 17:11:31 2012 -0700
     1.2 +++ b/jitcraft/ObjectVisitor.h	Sat Jul 07 20:28:29 2012 -0700
     1.3 @@ -27,6 +27,7 @@
     1.4  #include "Modules.h"
     1.5  #include "Functions.h"
     1.6  #include "Array.h"
     1.7 +#include "Strings.h"
     1.8  
     1.9  namespace jc {
    1.10  
    1.11 @@ -45,6 +46,7 @@
    1.12          visitField(obj, Type::offsetOfContained());
    1.13          visitField(obj, Type::offsetOfReturnType());
    1.14          visitField(obj, Type::offsetOfParameters());
    1.15 +        visitField(obj, Type::offsetOfTag());
    1.16          return sizeof(Type);
    1.17      }
    1.18  
    1.19 @@ -86,6 +88,10 @@
    1.20          return sizeof(Function);
    1.21      }
    1.22  
    1.23 +    size_t iterateString(Object *obj) {
    1.24 +        return String::SizeFor(String::cast(obj)->length());
    1.25 +    }
    1.26 +
    1.27      size_t iterateArray(Array *array, ArrayMap *map) {
    1.28          if (map->type()->isArray()) {
    1.29              unsigned length = array->nelements();
    1.30 @@ -117,7 +123,7 @@
    1.31              return iterateFixedArray(FixedArray::cast(obj));
    1.32  
    1.33            case MapKind_ByteArray:
    1.34 -            return Align(iterateByteArray(ByteArray::cast(obj)), kObjectAlignment);
    1.35 +            return iterateByteArray(ByteArray::cast(obj));
    1.36  
    1.37            case MapKind_Code:
    1.38              return iterateCode(obj);
    1.39 @@ -131,6 +137,9 @@
    1.40            case MapKind_Function:
    1.41              return iterateFunction(obj);
    1.42  
    1.43 +          case MapKind_String:
    1.44 +            return iterateString(obj);
    1.45 +
    1.46            case MapKind_Array:
    1.47              return Align(iterateArray(Array::cast(obj), ArrayMap::cast(map)), kObjectAlignment);
    1.48  
    1.49 @@ -155,7 +164,7 @@
    1.50          return FixedArray::SizeFor(FixedArray::cast(obj)->length());
    1.51  
    1.52        case MapKind_ByteArray:
    1.53 -        return Align(ByteArray::SizeFor(ByteArray::cast(obj)->length()), kObjectAlignment);
    1.54 +        return ByteArray::SizeFor(ByteArray::cast(obj)->length());
    1.55  
    1.56        case MapKind_Code:
    1.57          return sizeof(Code);
    1.58 @@ -169,6 +178,9 @@
    1.59        case MapKind_Function:
    1.60          return sizeof(Function);
    1.61  
    1.62 +      case MapKind_String:
    1.63 +        return String::SizeFor(String::cast(obj)->length());
    1.64 +
    1.65        case MapKind_Array:
    1.66          return Align(Array::SizeOf(Array::cast(obj)), kObjectAlignment);
    1.67