/* * Copyright (c) 2021, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
staticconstchar* replace_addr_expr(constchar* str)
{ // Remove any address expression "0x0123456789abcdef" found in order to // aid string comparison. Also remove any trailing printout from a padded // buffer (too brittle?).
staticconstchar* delete_header_line(constchar* str)
{ // Remove (second) header line in output, e.g.: // Decoding CodeBlob, name: CodeStringTest, at [<addr>, <addr>] 8 bytes\n
std::basic_string<char> red = std::regex_replace(str, std::regex("Decoding.+bytes\\n"), "");
return os::strdup(red.c_str());
}
staticvoid asm_remarks_check(const AsmRemarks &rem1, const AsmRemarks &rem2)
{
ASSERT_EQ(rem1.ref(), rem2.ref()) << "Should share the same collection.";
}
staticvoid dbg_strings_check(const DbgStrings &dbg1, const DbgStrings &dbg2)
{
ASSERT_EQ(dbg1.ref(), dbg2.ref()) << "Should share the same collection.";
}
staticvoid disasm_string_check(CodeBuffer* cbuf, CodeBlob* blob)
{ if (Disassembler::is_abstract())
{ return; // No disassembler available (no comments will be used).
}
stringStream out1, out2;
// 1. Check Assembly Remarks are shared by buffer and blob.
asm_remarks_check(cbuf->asm_remarks(), blob->asm_remarks());
// 2. Check Debug Strings are shared by buffer and blob.
dbg_strings_check(cbuf->dbg_strings(), blob->dbg_strings());
// 3. Check that the disassembly output matches.
disasm_string_check(cbuf, blob);
BufferBlob::free(blob);
ASSERT_EQ(remarks_empty, cbuf->asm_remarks().is_empty())
<< "Expecting property to be unchanged.";
ASSERT_EQ(strings_empty, cbuf->dbg_strings().is_empty())
<< "Expecting property to be unchanged.";
}
staticvoid code_buffer_test()
{
constexpr int BUF_SZ = 256;
// 2. Generate additional entries without causing the buffer to expand. for (unsigned i = 0; i < unsigned(n)/2; i++)
{
ASSERT_FALSE(cbuf.insts()->maybe_expand_to_ensure_remaining(sz));
ASSERT_TRUE(cbuf.insts_remaining()/sz >= n/2);
// The x86-64 version of 'stop' will use relocation info. that will result // in tainting the location start and limit if no location info. buffer is // present. static uint8_t s_loc_buf[BUF_SZ]; // Raw memory buffer used for relocInfo.
cbuf.insts()->initialize_shared_locs((relocInfo*)&s_loc_buf[0], BUF_SZ);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.