src/share/vm/shark/sharkCodeBuffer.hpp

Wed, 11 Aug 2010 05:51:21 -0700

author
twisti
date
Wed, 11 Aug 2010 05:51:21 -0700
changeset 2047
d2ede61b7a12
child 2314
f95d63e2154a
permissions
-rw-r--r--

6976186: integrate Shark HotSpot changes
Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure.
Reviewed-by: kvn, twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

twisti@2047 1 /*
twisti@2047 2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
twisti@2047 3 * Copyright 2009 Red Hat, Inc.
twisti@2047 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@2047 5 *
twisti@2047 6 * This code is free software; you can redistribute it and/or modify it
twisti@2047 7 * under the terms of the GNU General Public License version 2 only, as
twisti@2047 8 * published by the Free Software Foundation.
twisti@2047 9 *
twisti@2047 10 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@2047 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@2047 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@2047 13 * version 2 for more details (a copy is included in the LICENSE file that
twisti@2047 14 * accompanied this code).
twisti@2047 15 *
twisti@2047 16 * You should have received a copy of the GNU General Public License version
twisti@2047 17 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@2047 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@2047 19 *
twisti@2047 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
twisti@2047 21 * or visit www.oracle.com if you need additional information or have any
twisti@2047 22 * questions.
twisti@2047 23 *
twisti@2047 24 */
twisti@2047 25
twisti@2047 26 class SharkCodeBuffer : public StackObj {
twisti@2047 27 public:
twisti@2047 28 SharkCodeBuffer(MacroAssembler* masm)
twisti@2047 29 : _masm(masm), _base_pc(NULL) {}
twisti@2047 30
twisti@2047 31 private:
twisti@2047 32 MacroAssembler* _masm;
twisti@2047 33 llvm::Value* _base_pc;
twisti@2047 34
twisti@2047 35 private:
twisti@2047 36 MacroAssembler* masm() const {
twisti@2047 37 return _masm;
twisti@2047 38 }
twisti@2047 39
twisti@2047 40 public:
twisti@2047 41 llvm::Value* base_pc() const {
twisti@2047 42 return _base_pc;
twisti@2047 43 }
twisti@2047 44 void set_base_pc(llvm::Value* base_pc) {
twisti@2047 45 assert(_base_pc == NULL, "only do this once");
twisti@2047 46 _base_pc = base_pc;
twisti@2047 47 }
twisti@2047 48
twisti@2047 49 // Allocate some space in the buffer and return its address.
twisti@2047 50 // This buffer will have been relocated by the time the method
twisti@2047 51 // is installed, so you can't inline the result in code.
twisti@2047 52 public:
twisti@2047 53 void* malloc(size_t size) const {
twisti@2047 54 masm()->align(BytesPerWord);
twisti@2047 55 void *result = masm()->pc();
twisti@2047 56 masm()->advance(size);
twisti@2047 57 return result;
twisti@2047 58 }
twisti@2047 59
twisti@2047 60 // Create a unique offset in the buffer.
twisti@2047 61 public:
twisti@2047 62 int create_unique_offset() const {
twisti@2047 63 int offset = masm()->offset();
twisti@2047 64 masm()->advance(1);
twisti@2047 65 return offset;
twisti@2047 66 }
twisti@2047 67
twisti@2047 68 // Inline an oop into the buffer and return its offset.
twisti@2047 69 public:
twisti@2047 70 int inline_oop(jobject object) const {
twisti@2047 71 masm()->align(BytesPerWord);
twisti@2047 72 int offset = masm()->offset();
twisti@2047 73 masm()->store_oop(object);
twisti@2047 74 return offset;
twisti@2047 75 }
twisti@2047 76
twisti@2047 77 // Inline a block of non-oop data into the buffer and return its offset.
twisti@2047 78 public:
twisti@2047 79 int inline_data(void *src, size_t size) const {
twisti@2047 80 masm()->align(BytesPerWord);
twisti@2047 81 int offset = masm()->offset();
twisti@2047 82 void *dst = masm()->pc();
twisti@2047 83 masm()->advance(size);
twisti@2047 84 memcpy(dst, src, size);
twisti@2047 85 return offset;
twisti@2047 86 }
twisti@2047 87 };

mercurial