1.1 --- a/src/share/vm/asm/assembler.hpp Tue Mar 03 18:25:57 2009 -0800 1.2 +++ b/src/share/vm/asm/assembler.hpp Wed Mar 04 09:58:39 2009 -0800 1.3 @@ -140,6 +140,28 @@ 1.4 } 1.5 }; 1.6 1.7 +// A union type for code which has to assemble both constant and 1.8 +// non-constant operands, when the distinction cannot be made 1.9 +// statically. 1.10 +class RegisterConstant VALUE_OBJ_CLASS_SPEC { 1.11 + private: 1.12 + Register _r; 1.13 + intptr_t _c; 1.14 + 1.15 + public: 1.16 + RegisterConstant(): _r(noreg), _c(0) {} 1.17 + RegisterConstant(Register r): _r(r), _c(0) {} 1.18 + RegisterConstant(intptr_t c): _r(noreg), _c(c) {} 1.19 + 1.20 + Register as_register() const { assert(is_register(),""); return _r; } 1.21 + intptr_t as_constant() const { assert(is_constant(),""); return _c; } 1.22 + 1.23 + Register register_or_noreg() const { return _r; } 1.24 + intptr_t constant_or_zero() const { return _c; } 1.25 + 1.26 + bool is_register() const { return _r != noreg; } 1.27 + bool is_constant() const { return _r == noreg; } 1.28 +}; 1.29 1.30 // The Abstract Assembler: Pure assembler doing NO optimizations on the 1.31 // instruction level; i.e., what you write is what you get. 1.32 @@ -280,6 +302,26 @@ 1.33 inline address address_constant(Label& L); 1.34 inline address address_table_constant(GrowableArray<Label*> label); 1.35 1.36 + // Bootstrapping aid to cope with delayed determination of constants. 1.37 + // Returns a static address which will eventually contain the constant. 1.38 + // The value zero (NULL) stands instead of a constant which is still uncomputed. 1.39 + // Thus, the eventual value of the constant must not be zero. 1.40 + // This is fine, since this is designed for embedding object field 1.41 + // offsets in code which must be generated before the object class is loaded. 1.42 + // Field offsets are never zero, since an object's header (mark word) 1.43 + // is located at offset zero. 1.44 + RegisterConstant delayed_value(int(*value_fn)(), Register tmp, int offset = 0) { 1.45 + return delayed_value(delayed_value_addr(value_fn), tmp, offset); 1.46 + } 1.47 + RegisterConstant delayed_value(address(*value_fn)(), Register tmp, int offset = 0) { 1.48 + return delayed_value(delayed_value_addr(value_fn), tmp, offset); 1.49 + } 1.50 + virtual RegisterConstant delayed_value(intptr_t* delayed_value_addr, Register tmp, int offset) = 0; 1.51 + // Last overloading is platform-dependent; look in assembler_<arch>.cpp. 1.52 + static intptr_t* delayed_value_addr(int(*constant_fn)()); 1.53 + static intptr_t* delayed_value_addr(address(*constant_fn)()); 1.54 + static void update_delayed_values(); 1.55 + 1.56 // Bang stack to trigger StackOverflowError at a safe location 1.57 // implementation delegates to machine-specific bang_stack_with_offset 1.58 void generate_stack_overflow_check( int frame_size_in_bytes );