X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Flinker.cpp;h=4cede0109c4a7c2c99e9bbeb9114e892f04ee48b;hb=e60e2e7532c2ce0657b23f0ba1338ea433529d2c;hp=a29ffaa86bdaa1704985bbba61c339c41c2a11dd;hpb=4a653a918f49c4322acb009b881c60aa03797ca8;p=cacao.git diff --git a/src/vm/linker.cpp b/src/vm/linker.cpp index a29ffaa86..4cede0109 100644 --- a/src/vm/linker.cpp +++ b/src/vm/linker.cpp @@ -1,6 +1,6 @@ -/* src/vm/linker.c - class linker functions +/* src/vm/linker.cpp - class linker functions - Copyright (C) 1996-2005, 2006, 2007, 2008 + Copyright (C) 1996-2005, 2006, 2007, 2008, 2010 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -30,14 +30,14 @@ #include "vm/types.h" -#include "mm/memory.h" +#include "mm/memory.hpp" #include "native/native.hpp" #include "threads/lock.hpp" #include "threads/mutex.hpp" -#include "toolbox/logging.h" +#include "toolbox/logging.hpp" #include "vm/access.hpp" #include "vm/array.hpp" @@ -45,6 +45,7 @@ #include "vm/classcache.hpp" #include "vm/exceptions.hpp" #include "vm/globals.hpp" +#include "vm/hook.hpp" #include "vm/loader.hpp" #include "vm/options.h" #include "vm/primitive.hpp" @@ -55,6 +56,9 @@ #include "vm/jit/asmpart.h" #include "vm/jit/stubs.hpp" +#include +#include + /* debugging macros ***********************************************************/ @@ -112,6 +116,9 @@ static bool linker_addinterface(classinfo *c, classinfo *ic); static s4 class_highestinterface(classinfo *c); +typedef std::vector > deferred_strings_vec_t; +static deferred_strings_vec_t deferred_strings; + /* linker_init ***************************************************************** Initializes the linker subsystem and links classes required for the @@ -425,6 +432,9 @@ classinfo *link_class(classinfo *c) RT_TIMING_TIME_DIFF(time_start,time_end,RT_TIMING_LINK_TOTAL); + // Hook point just after a class was linked. + Hook::class_linked(r); + return r; } @@ -531,7 +541,7 @@ static bool linker_overwrite_method(methodinfo *mg, *******************************************************************************/ -static void build_display(classinfo *c) +static classinfo *build_display(classinfo *c) { int depth, i; int depth_fixed; @@ -558,7 +568,8 @@ static void build_display(classinfo *c) super = c->super; } while (false); if (super) { - build_display(super); + if (!link_class(super)) + return NULL; depth = super->vftbl->subtype_depth + 1; } else /* java.lang.Object doesn't have a super class. */ @@ -586,6 +597,8 @@ static void build_display(classinfo *c) c->vftbl->subtype_display[i] = NULL; c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[0]) + sizeof(vftbl_t*) * depth_fixed; c->vftbl->subtype_depth = depth; + + return c; } #endif @@ -995,7 +1008,8 @@ static classinfo *link_class_intern(classinfo *c) RT_TIMING_GET_TIME(time_subclasses); #if USES_NEW_SUBTYPE - build_display(c); + if (!build_display(c)) + return NULL; #endif /* revert the linking state and class is linked */ @@ -1104,8 +1118,8 @@ static arraydescriptor *link_array(classinfo *c) desc->elementvftbl = compvftbl->arraydesc->elementvftbl; if (compvftbl->arraydesc->dimension >= 255) { - log_text("Creating array of dimension >255"); - assert(0); + exceptions_throw_illegalargumentexception(); + return NULL; } desc->dimension = compvftbl->arraydesc->dimension + 1; @@ -1182,6 +1196,24 @@ static arraydescriptor *link_array(classinfo *c) return desc; } +/* linker_create_string_later ************************************************** + + A hack so we can initialize java.lang.String objects during initialization. + +*******************************************************************************/ +void linker_create_string_later(java_object_t **a, utf *u) +{ + deferred_strings.push_back(std::make_pair(a, u)); +} + +void linker_initialize_deferred_strings() +{ + deferred_strings_vec_t::const_iterator it = deferred_strings.begin(); + for (; it != deferred_strings.end(); ++it) + *it->first = literalstring_new(it->second); + deferred_strings.clear(); +} + /* linker_compute_subclasses *************************************************** @@ -1399,7 +1431,7 @@ static s4 class_highestinterface(classinfo *c) * Emacs will automagically detect them. * --------------------------------------------------------------------- * Local variables: - * mode: c + * mode: c++ * indent-tabs-mode: t * c-basic-offset: 4 * tab-width: 4