hotspot/src/share/vm/asm/assembler.inline.hpp
author twisti
Fri, 30 Nov 2012 11:44:05 -0800
changeset 14625 b02f361c324e
parent 7433 b418028612ad
child 14626 0cf4eccf130f
permissions -rw-r--r--
8003195: AbstractAssembler should not store code pointers but use the CodeSection directly Reviewed-by: twisti, kvn Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_ASM_ASSEMBLER_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "asm/assembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "asm/codeBuffer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "compiler/disassembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "runtime/threadLocalStorage.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
14625
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    33
inline address AbstractAssembler::addr_at(int pos) const {
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    34
  return code_section()->start() + pos;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
14625
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    37
void AbstractAssembler::emit_int8(int8_t x)     { code_section()->emit_int8 (x); }
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    38
void AbstractAssembler::emit_int16(int16_t x)   { code_section()->emit_int16(x); }
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    39
void AbstractAssembler::emit_int32(int32_t x)   { code_section()->emit_int32(x); }
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    40
void AbstractAssembler::emit_int64(int64_t x)   { code_section()->emit_int64(x); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
14625
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    42
void AbstractAssembler::emit_float(jfloat  x)   { code_section()->emit_float(x); }
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    43
void AbstractAssembler::emit_double(jdouble x)  { code_section()->emit_double(x); }
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    44
void AbstractAssembler::emit_address(address x) { code_section()->emit_address(x); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
inline address AbstractAssembler::inst_mark() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  return code_section()->mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
inline void AbstractAssembler::set_inst_mark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  code_section()->set_mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
inline void AbstractAssembler::clear_inst_mark() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  code_section()->clear_mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
inline void AbstractAssembler::relocate(RelocationHolder const& rspec, int format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  assert(!pd_check_instruction_mark()
14625
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    61
         || inst_mark() == NULL || inst_mark() == code_section()->end(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
         "call relocate() between instructions");
14625
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    63
  code_section()->relocate(code_section()->end(), rspec, format);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
inline CodeBuffer* AbstractAssembler::code() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  return code_section()->outer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
inline int AbstractAssembler::sect() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  return code_section()->index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
14625
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    75
inline address AbstractAssembler::pc() const {
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    76
  return code_section()->end();
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    77
}
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    78
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    79
inline int AbstractAssembler::offset() const {
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    80
  return code_section()->size();
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    81
}
b02f361c324e 8003195: AbstractAssembler should not store code pointers but use the CodeSection directly
twisti
parents: 7433
diff changeset
    82
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
inline int AbstractAssembler::locator() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  return CodeBuffer::locator(offset(), sect());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
inline address AbstractAssembler::target(Label& L) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  return code_section()->target(L, pc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
inline int Label::loc_pos() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  return CodeBuffer::locator_pos(loc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
inline int Label::loc_sect() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  return CodeBuffer::locator_sect(loc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
inline void Label::bind_loc(int pos, int sect) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  bind_loc(CodeBuffer::locator(pos, sect));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   103
#endif // SHARE_VM_ASM_ASSEMBLER_INLINE_HPP