mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
YJIT: fold the "asm_comments" feature into "disasm" (#6591)
Previously, enabling only "disasm" didn't actually build. Since these two features are closely related and we don't really use one without the other, let's simplify and merge the two features together.
This commit is contained in:
parent
bc939d2937
commit
5ca23caa20
Notes:
git
2022-10-19 18:03:29 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
7 changed files with 12 additions and 13 deletions
|
@ -3754,12 +3754,12 @@ AS_CASE(["${YJIT_SUPPORT}"],
|
|||
],
|
||||
[dev], [
|
||||
rb_rust_target_subdir=debug
|
||||
CARGO_BUILD_ARGS='--features stats,disasm,asm_comments'
|
||||
CARGO_BUILD_ARGS='--features stats,disasm'
|
||||
AC_DEFINE(RUBY_DEBUG, 1)
|
||||
],
|
||||
[dev_nodebug], [
|
||||
rb_rust_target_subdir=dev_nodebug
|
||||
CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm,asm_comments'
|
||||
CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm'
|
||||
],
|
||||
[stats], [
|
||||
rb_rust_target_subdir=stats
|
||||
|
|
|
@ -22,7 +22,6 @@ capstone = { version = "0.10.0", optional = true }
|
|||
# For debugging, `make V=1` shows exact cargo invocation.
|
||||
disasm = ["capstone"]
|
||||
stats = []
|
||||
asm_comments = []
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 0
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::backend::x86_64::JMP_PTR_BYTES;
|
|||
use crate::backend::arm64::JMP_PTR_BYTES;
|
||||
use crate::virtualmem::WriteError;
|
||||
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::codegen::CodegenGlobals;
|
||||
|
@ -69,7 +69,7 @@ pub struct CodeBlock {
|
|||
label_refs: Vec<LabelRef>,
|
||||
|
||||
// Comments for assembly instructions, if that feature is enabled
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
asm_comments: BTreeMap<usize, Vec<String>>,
|
||||
|
||||
// True for OutlinedCb
|
||||
|
@ -101,7 +101,7 @@ impl CodeBlock {
|
|||
label_addrs: Vec::new(),
|
||||
label_names: Vec::new(),
|
||||
label_refs: Vec::new(),
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
asm_comments: BTreeMap::new(),
|
||||
outlined,
|
||||
dropped_bytes: false,
|
||||
|
@ -239,7 +239,7 @@ impl CodeBlock {
|
|||
|
||||
/// Add an assembly comment if the feature is on.
|
||||
/// If not, this becomes an inline no-op.
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
pub fn add_comment(&mut self, comment: &str) {
|
||||
let cur_ptr = self.get_write_ptr().into_usize();
|
||||
|
||||
|
@ -251,11 +251,11 @@ impl CodeBlock {
|
|||
this_line_comments.push(comment.to_string());
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "asm_comments"))]
|
||||
#[cfg(not(feature = "disasm"))]
|
||||
#[inline]
|
||||
pub fn add_comment(&mut self, _: &str) {}
|
||||
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
pub fn comments_at(&self, pos: usize) -> Option<&Vec<String>> {
|
||||
self.asm_comments.get(&pos)
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ fn basic_capstone_usage() -> std::result::Result<(), capstone::Error> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
fn block_comments() {
|
||||
let mut cb = super::CodeBlock::new_dummy(4096);
|
||||
|
||||
|
|
|
@ -724,7 +724,7 @@ impl Assembler
|
|||
|
||||
match insn {
|
||||
Insn::Comment(text) => {
|
||||
if cfg!(feature = "asm_comments") {
|
||||
if cfg!(feature = "disasm") {
|
||||
cb.add_comment(text);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -388,7 +388,7 @@ impl Assembler
|
|||
|
||||
match insn {
|
||||
Insn::Comment(text) => {
|
||||
if cfg!(feature = "asm_comments") {
|
||||
if cfg!(feature = "disasm") {
|
||||
cb.add_comment(text);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -510,7 +510,7 @@ impl From<VALUE> for u16 {
|
|||
}
|
||||
|
||||
/// Produce a Ruby string from a Rust string slice
|
||||
#[cfg(feature = "asm_comments")]
|
||||
#[cfg(feature = "disasm")]
|
||||
pub fn rust_str_to_ruby(str: &str) -> VALUE {
|
||||
unsafe { rb_utf8_str_new(str.as_ptr() as *const _, str.len() as i64) }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue