1.1 --- a/jitcraft/Zone.cpp Sat Jul 07 17:11:31 2012 -0700
1.2 +++ b/jitcraft/Zone.cpp Sat Jul 07 20:28:29 2012 -0700
1.3 @@ -17,7 +17,9 @@
1.4 * JITCraft. If not, see http://www.gnu.org/licenses/.
1.5 */
1.6 #include "Zone.h"
1.7 +#include "StringPool.h"
1.8 #include "TypeManager.h"
1.9 +#include "AllocatorPolicies.h"
1.10
1.11 using namespace jc;
1.12
1.13 @@ -30,6 +32,12 @@
1.14 {
1.15 }
1.16
1.17 +Zone::~Zone()
1.18 +{
1.19 + delete symbols_;
1.20 + delete types_;
1.21 +}
1.22 +
1.23 bool
1.24 Zone::initialize()
1.25 {
1.26 @@ -38,6 +46,10 @@
1.27 if (!heap_.initialize())
1.28 return false;
1.29
1.30 + symbols_ = new StringPool(this);
1.31 + if (!symbols_ || !symbols_->initialize())
1.32 + return false;
1.33 +
1.34 maps_[MapKind_Meta] = heap_.metaMap();
1.35 if ((maps_[MapKind_Type] = allocateMap(MapKind_Type, sizeof(Map))) == NULL)
1.36 return false;
1.37 @@ -55,6 +67,8 @@
1.38 return false;
1.39 if ((maps_[MapKind_Function] = allocateMap(MapKind_Function, sizeof(Map))) == NULL)
1.40 return false;
1.41 + if ((maps_[MapKind_String] = allocateMap(MapKind_String, sizeof(Map))) == NULL)
1.42 + return false;
1.43 if ((maps_[MapKind_FreeRegion] = allocateMap(MapKind_FreeRegion, sizeof(Map))) == NULL)
1.44 return false;
1.45
1.46 @@ -94,3 +108,28 @@
1.47 stack_.accept(visitor);
1.48 }
1.49
1.50 +String *
1.51 +Zone::makeSymbol(const char *str, size_t length)
1.52 +{
1.53 + return symbols_->add(str, length);
1.54 +}
1.55 +
1.56 +String *
1.57 +Zone::makeSymbol(const char *str)
1.58 +{
1.59 + return makeSymbol(str, strlen(str));
1.60 +}
1.61 +
1.62 +void
1.63 +ZoneAllocatorPolicy::reportOutOfMemory()
1.64 +{
1.65 + // :TODO: report
1.66 + assert(false);
1.67 +}
1.68 +
1.69 +void
1.70 +ZoneAllocatorPolicy::reportAllocationOverflow()
1.71 +{
1.72 + // :TODO: report
1.73 + assert(false);
1.74 +}