--- a/src/hotspot/share/asm/codeBuffer.hpp Tue Jun 12 13:07:47 2018 -0400
+++ b/src/hotspot/share/asm/codeBuffer.hpp Mon Jun 11 15:32:43 2018 +0100
@@ -337,6 +337,7 @@
class CodeBuffer: public StackObj {
friend class CodeSection;
+ friend class StubCodeGenerator;
private:
// CodeBuffers must be allocated on the stack except for a single
--- a/src/hotspot/share/compiler/disassembler.cpp Tue Jun 12 13:07:47 2018 -0400
+++ b/src/hotspot/share/compiler/disassembler.cpp Mon Jun 11 15:32:43 2018 +0100
@@ -155,6 +155,7 @@
CodeStrings _strings;
outputStream* _output;
address _start, _end;
+ ptrdiff_t _offset;
char _option_buf[512];
char _print_raw;
@@ -191,7 +192,8 @@
void print_address(address value);
public:
- decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings());
+ decode_env(CodeBlob* code, outputStream* output,
+ CodeStrings c = CodeStrings(), ptrdiff_t offset = 0);
address decode_instructions(address start, address end);
@@ -221,13 +223,15 @@
const char* options() { return _option_buf; }
};
-decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
+decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c,
+ ptrdiff_t offset) {
memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields.
_output = output ? output : tty;
_code = code;
if (code != NULL && code->is_nmethod())
_nm = (nmethod*) code;
_strings.copy(c);
+ _offset = offset;
// by default, output pc but not bytes:
_print_pc = true;
@@ -354,7 +358,7 @@
if (cb != NULL) {
cb->print_block_comment(st, p);
}
- _strings.print_block_comment(st, (intptr_t)(p - _start));
+ _strings.print_block_comment(st, (intptr_t)(p - _start + _offset));
if (_print_pc) {
st->print(" " PTR_FORMAT ": ", p2i(p));
}
@@ -507,10 +511,11 @@
env.decode_instructions(cb->code_begin(), cb->code_end());
}
-void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
+void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c,
+ ptrdiff_t offset) {
ttyLocker ttyl;
if (!load_library()) return;
- decode_env env(CodeCache::find_blob_unsafe(start), st, c);
+ decode_env env(CodeCache::find_blob_unsafe(start), st, c, offset);
env.decode_instructions(start, end);
}
--- a/src/hotspot/share/compiler/disassembler.hpp Tue Jun 12 13:07:47 2018 -0400
+++ b/src/hotspot/share/compiler/disassembler.hpp Mon Jun 11 15:32:43 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,8 @@
}
static void decode(CodeBlob *cb, outputStream* st = NULL);
static void decode(nmethod* nm, outputStream* st = NULL);
- static void decode(address begin, address end, outputStream* st = NULL, CodeStrings c = CodeStrings());
+ static void decode(address begin, address end, outputStream* st = NULL,
+ CodeStrings c = CodeStrings(), ptrdiff_t offset = 0);
};
#endif // SHARE_VM_COMPILER_DISASSEMBLER_HPP
--- a/src/hotspot/share/runtime/stubCodeGenerator.cpp Tue Jun 12 13:07:47 2018 -0400
+++ b/src/hotspot/share/runtime/stubCodeGenerator.cpp Mon Jun 11 15:32:43 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
}
StubCodeGenerator::~StubCodeGenerator() {
- if (_print_code) {
+ if (PRODUCT_ONLY(_print_code) NOT_PRODUCT(true)) {
CodeBuffer* cbuf = _masm->code();
CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
if (blob != NULL) {
@@ -86,9 +86,19 @@
void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) {
if (_print_code) {
+ CodeStrings cs;
+ ptrdiff_t offset = 0;
+#ifndef PRODUCT
+ // Find the code strings in the outer CodeBuffer.
+ CodeBuffer *outer_cbuf = _masm->code_section()->outer();
+ cs = outer_cbuf->strings();
+ // The offset from the start of the outer CodeBuffer to the start
+ // of this stub.
+ offset = cdesc->begin() - outer_cbuf->insts()->start();
+#endif
cdesc->print();
tty->cr();
- Disassembler::decode(cdesc->begin(), cdesc->end());
+ Disassembler::decode(cdesc->begin(), cdesc->end(), NULL, cs, offset);
tty->cr();
}
}