Added GC descriptors (lol, these are not descriptors).
authorDavid Anderson <dvander@alliedmods.net>
Tue Jul 03 08:30:09 2012 -0700 (2012-07-03)
changeset 44c920f9328716
parent 43 f6b1a68e7ebb
child 45 25b995bc75a0
Added GC descriptors (lol, these are not descriptors).
jitcraft/Array.h
jitcraft/Code.h
jitcraft/Functions.h
jitcraft/Makefile.in
jitcraft/Modules.h
jitcraft/Reference.h
jitcraft/Types.h
     1.1 --- a/jitcraft/Array.h	Tue Jul 03 01:25:23 2012 -0700
     1.2 +++ b/jitcraft/Array.h	Tue Jul 03 08:30:09 2012 -0700
     1.3 @@ -86,6 +86,10 @@
     1.4          write(zone, &objVec()[index], ptr);
     1.5      }
     1.6  
     1.7 +    static inline size_t SizeOf(Array *array) {
     1.8 +        return sizeof(Array) + array->nelements() * array->elementSize();
     1.9 +    }
    1.10 +
    1.11      static Array *cast(Object *obj) {
    1.12          assert(!obj || obj->is(MapKind_Array));
    1.13          return reinterpret_cast<Array *>(obj);
    1.14 @@ -106,6 +110,15 @@
    1.15      ArrayMap *contained() {
    1.16          return contained_;
    1.17      }
    1.18 +
    1.19 +    // GC Descriptor.
    1.20 +    static inline size_t offsetOfType() {
    1.21 +        return offsetof(ArrayMap, type_);
    1.22 +    }
    1.23 +    static inline size_t offsetOfContained() {
    1.24 +        return offsetof(ArrayMap, contained_);
    1.25 +    }
    1.26 +    // End GC Descriptor.
    1.27      
    1.28      static ArrayMap *cast(Object *obj) {
    1.29          assert(!obj || obj->is(MapKind_MetaArray));
     2.1 --- a/jitcraft/Code.h	Tue Jul 03 01:25:23 2012 -0700
     2.2 +++ b/jitcraft/Code.h	Tue Jul 03 08:30:09 2012 -0700
     2.3 @@ -69,6 +69,21 @@
     2.4          return objects_->at(index);
     2.5      }
     2.6  
     2.7 +    // GC Descriptor.
     2.8 +    static inline size_t offsetOfModule() {
     2.9 +        return offsetof(Code, module_);
    2.10 +    }
    2.11 +    static inline size_t offsetOfBytecode() {
    2.12 +        return offsetof(Code, bytecode_);
    2.13 +    }
    2.14 +    static inline size_t offsetOfLocals() {
    2.15 +        return offsetof(Code, locals_);
    2.16 +    }
    2.17 +    static inline size_t offsetOfObjects() {
    2.18 +        return offsetof(Code, objects_);
    2.19 +    }
    2.20 +    // End GC Descriptor.
    2.21 +
    2.22      static Code *cast(Object *obj) {
    2.23          assert(!obj || obj->is(MapKind_Code));
    2.24          return reinterpret_cast<Code *>(obj);
     3.1 --- a/jitcraft/Functions.h	Tue Jul 03 01:25:23 2012 -0700
     3.2 +++ b/jitcraft/Functions.h	Tue Jul 03 08:30:09 2012 -0700
     3.3 @@ -56,6 +56,18 @@
     3.4          return type()->parameterAt(index);
     3.5      }
     3.6  
     3.7 +    // Begin GC Descriptor.
     3.8 +    static inline size_t offsetOfModule() {
     3.9 +        return offsetof(Function, module_);
    3.10 +    }
    3.11 +    static inline size_t offsetOfCode() {
    3.12 +        return offsetof(Function, code_);
    3.13 +    }
    3.14 +    static inline size_t offsetOfType() {
    3.15 +        return offsetof(Function, type_);
    3.16 +    }
    3.17 +    // End GC Descriptor.
    3.18 +
    3.19      static inline Function *cast(Object *obj) {
    3.20          assert(!obj || obj->is(MapKind_Function));
    3.21          return reinterpret_cast<Function *>(obj);
     4.1 --- a/jitcraft/Makefile.in	Tue Jul 03 01:25:23 2012 -0700
     4.2 +++ b/jitcraft/Makefile.in	Tue Jul 03 08:30:09 2012 -0700
     4.3 @@ -11,7 +11,7 @@
     4.4  
     4.5  INCLUDES += -I${srcdir}
     4.6  CXXFLAGS += $(INCLUDES)
     4.7 -BASECXXFLAGS = -Wall -Werror -Wno-null-arithmetic
     4.8 +BASECXXFLAGS = -Wall -Werror -Wno-null-arithmetic -Wno-invalid-offsetof
     4.9  
    4.10  CPPSRCS = \
    4.11  	Array.cpp                  \
     5.1 --- a/jitcraft/Modules.h	Tue Jul 03 01:25:23 2012 -0700
     5.2 +++ b/jitcraft/Modules.h	Tue Jul 03 08:30:09 2012 -0700
     5.3 @@ -40,6 +40,12 @@
     5.4          functions_->set(zone, i, fun);
     5.5      }
     5.6  
     5.7 +    // Begin GC Descriptor.
     5.8 +    static inline size_t offsetOfFunctions() {
     5.9 +        return offsetof(Module, functions_);
    5.10 +    }
    5.11 +    // End GC Descriptor.
    5.12 +
    5.13      static inline Module *cast(Object *obj) {
    5.14          assert(!obj || obj->is(MapKind_Module));
    5.15          return reinterpret_cast<Module *>(obj);
     6.1 --- a/jitcraft/Reference.h	Tue Jul 03 01:25:23 2012 -0700
     6.2 +++ b/jitcraft/Reference.h	Tue Jul 03 08:30:09 2012 -0700
     6.3 @@ -51,6 +51,12 @@
     6.4          *reinterpret_cast<float *>(location_) = f;
     6.5      }
     6.6  
     6.7 +    // Begin GC Descriptor.
     6.8 +    static inline size_t offsetOfBase() {
     6.9 +        return offsetof(Reference, base_);
    6.10 +    }
    6.11 +    // End GC Descriptor.
    6.12 +
    6.13      static inline Reference *cast(Object *obj) {
    6.14          assert(!obj || obj->is(MapKind_Reference));
    6.15          return reinterpret_cast<Reference *>(obj);
     7.1 --- a/jitcraft/Types.h	Tue Jul 03 01:25:23 2012 -0700
     7.2 +++ b/jitcraft/Types.h	Tue Jul 03 08:30:09 2012 -0700
     7.3 @@ -1,4 +1,5 @@
     7.4 -/*
     7.5 +/* vim: set ts=4 sw=4 tw=99 et:
     7.6 + *
     7.7   * Copyright (C) 2012 David Anderson
     7.8   *
     7.9   * This file is part of JITCraft.
    7.10 @@ -129,6 +130,18 @@
    7.11          return Type::cast(parameters()->at(i));
    7.12      }
    7.13  
    7.14 +    // GC Descriptor.
    7.15 +    static inline size_t offsetOfContained() {
    7.16 +        return offsetof(Type, contained_);
    7.17 +    }
    7.18 +    static inline size_t offsetOfReturnType() {
    7.19 +        return offsetof(Type, returnType_);
    7.20 +    }
    7.21 +    static inline size_t offsetOfParameters() {
    7.22 +        return offsetof(Type, parameters_);
    7.23 +    }
    7.24 +    // End GC Descriptor.
    7.25 +
    7.26    private:
    7.27      Kind kind_;
    7.28      PrimitiveType primitive_;