jitcraft/Zone.cpp
changeset 12 75e385f68b7e
parent 11 a350c2cc736a
child 14 0784ac5cc347
     1.1 --- a/jitcraft/Zone.cpp	Fri Jun 29 19:35:17 2012 -0700
     1.2 +++ b/jitcraft/Zone.cpp	Sat Jun 30 19:38:53 2012 -0700
     1.3 @@ -33,13 +33,19 @@
     1.4  {
     1.5      if (!stack_.initialize())
     1.6          return false;
     1.7 -    if (!unsafeStack_.initialize())
     1.8 -        return false;
     1.9      if (!heap_.initialize())
    1.10          return false;
    1.11  
    1.12      maps_[MapKind_Meta] = heap_.metaMap();
    1.13 -    if ((maps_[MapKind_Type] = heap_.allocateMap(MapKind_Type, sizeof(Map))) == NULL)
    1.14 +    if ((maps_[MapKind_Type] = allocateMap(MapKind_Type, sizeof(Map))) == NULL)
    1.15 +        return false;
    1.16 +    if ((maps_[MapKind_FixedArray] = allocateMap(MapKind_FixedArray, sizeof(Map))) == NULL)
    1.17 +        return false;
    1.18 +    if ((maps_[MapKind_ByteArray] = allocateMap(MapKind_ByteArray, sizeof(Map))) == NULL)
    1.19 +        return false;
    1.20 +    if ((maps_[MapKind_Code] = allocateMap(MapKind_Code, sizeof(Map))) == NULL)
    1.21 +        return false;
    1.22 +    if ((maps_[MapKind_MetaArray] = allocateMap(MapKind_MetaArray, sizeof(Map))) == NULL)
    1.23          return false;
    1.24  
    1.25      types_ = new TypeManager(this);
    1.26 @@ -48,3 +54,14 @@
    1.27  
    1.28      return true;
    1.29  }
    1.30 +
    1.31 +Map *
    1.32 +Zone::allocateMap(MapKind kind, size_t bytes, MapKind parent)
    1.33 +{
    1.34 +    assert(maps_[parent]);
    1.35 +    Map *map = heap_.allocateMap(kind, bytes);
    1.36 +    if (!map)
    1.37 +        return NULL;
    1.38 +    map->init(maps_[parent]);
    1.39 +    return map;
    1.40 +}