src/cpu/x86/vm/c1_MacroAssembler_x86.hpp

Wed, 07 May 2008 08:06:46 -0700

author
rasbold
date
Wed, 07 May 2008 08:06:46 -0700
changeset 580
f3de1255b035
parent 435
a61af66fc99e
child 739
dc7f315e41f7
permissions
-rw-r--r--

6603011: RFE: Optimize long division
Summary: Transform long division by constant into multiply
Reviewed-by: never, kvn

duke@435 1 /*
duke@435 2 * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // C1_MacroAssembler contains high-level macros for C1
duke@435 26
duke@435 27 private:
duke@435 28 int _rsp_offset; // track rsp changes
duke@435 29 // initialization
duke@435 30 void pd_init() { _rsp_offset = 0; }
duke@435 31
duke@435 32 public:
duke@435 33 void try_allocate(
duke@435 34 Register obj, // result: pointer to object after successful allocation
duke@435 35 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
duke@435 36 int con_size_in_bytes, // object size in bytes if known at compile time
duke@435 37 Register t1, // temp register
duke@435 38 Register t2, // temp register
duke@435 39 Label& slow_case // continuation point if fast allocation fails
duke@435 40 );
duke@435 41
duke@435 42 void initialize_header(Register obj, Register klass, Register len, Register t1, Register t2);
duke@435 43 void initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1);
duke@435 44
duke@435 45 // locking
duke@435 46 // hdr : must be rax, contents destroyed
duke@435 47 // obj : must point to the object to lock, contents preserved
duke@435 48 // disp_hdr: must point to the displaced header location, contents preserved
duke@435 49 // scratch : scratch register, contents destroyed
duke@435 50 // returns code offset at which to add null check debug information
duke@435 51 int lock_object (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case);
duke@435 52
duke@435 53 // unlocking
duke@435 54 // hdr : contents destroyed
duke@435 55 // obj : must point to the object to lock, contents preserved
duke@435 56 // disp_hdr: must be eax & must point to the displaced header location, contents destroyed
duke@435 57 void unlock_object(Register swap, Register obj, Register lock, Label& slow_case);
duke@435 58
duke@435 59 void initialize_object(
duke@435 60 Register obj, // result: pointer to object after successful allocation
duke@435 61 Register klass, // object klass
duke@435 62 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
duke@435 63 int con_size_in_bytes, // object size in bytes if known at compile time
duke@435 64 Register t1, // temp register
duke@435 65 Register t2 // temp register
duke@435 66 );
duke@435 67
duke@435 68 // allocation of fixed-size objects
duke@435 69 // (can also be used to allocate fixed-size arrays, by setting
duke@435 70 // hdr_size correctly and storing the array length afterwards)
duke@435 71 // obj : must be rax, will contain pointer to allocated object
duke@435 72 // t1, t2 : scratch registers - contents destroyed
duke@435 73 // header_size: size of object header in words
duke@435 74 // object_size: total size of object in words
duke@435 75 // slow_case : exit to slow case implementation if fast allocation fails
duke@435 76 void allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case);
duke@435 77
duke@435 78 enum {
duke@435 79 max_array_allocation_length = 0x00FFFFFF
duke@435 80 };
duke@435 81
duke@435 82 // allocation of arrays
duke@435 83 // obj : must be rax, will contain pointer to allocated object
duke@435 84 // len : array length in number of elements
duke@435 85 // t : scratch register - contents destroyed
duke@435 86 // header_size: size of object header in words
duke@435 87 // f : element scale factor
duke@435 88 // slow_case : exit to slow case implementation if fast allocation fails
duke@435 89 void allocate_array(Register obj, Register len, Register t, Register t2, int header_size, Address::ScaleFactor f, Register klass, Label& slow_case);
duke@435 90
duke@435 91 int rsp_offset() const { return _rsp_offset; }
duke@435 92 void set_rsp_offset(int n) { _rsp_offset = n; }
duke@435 93
duke@435 94 // Note: NEVER push values directly, but only through following push_xxx functions;
duke@435 95 // This helps us to track the rsp changes compared to the entry rsp (->_rsp_offset)
duke@435 96
duke@435 97 void push_jint (jint i) { _rsp_offset++; pushl(i); }
duke@435 98 void push_oop (jobject o) { _rsp_offset++; pushoop(o); }
duke@435 99 void push_addr (Address a) { _rsp_offset++; pushl(a); }
duke@435 100 void push_reg (Register r) { _rsp_offset++; pushl(r); }
duke@435 101 void pop (Register r) { _rsp_offset--; popl (r); assert(_rsp_offset >= 0, "stack offset underflow"); }
duke@435 102
duke@435 103 void dec_stack (int nof_words) {
duke@435 104 _rsp_offset -= nof_words;
duke@435 105 assert(_rsp_offset >= 0, "stack offset underflow");
duke@435 106 addl(rsp, wordSize * nof_words);
duke@435 107 }
duke@435 108
duke@435 109 void dec_stack_after_call (int nof_words) {
duke@435 110 _rsp_offset -= nof_words;
duke@435 111 assert(_rsp_offset >= 0, "stack offset underflow");
duke@435 112 }
duke@435 113
duke@435 114 void invalidate_registers(bool inv_rax, bool inv_rbx, bool inv_rcx, bool inv_rdx, bool inv_rsi, bool inv_rdi) PRODUCT_RETURN;

mercurial