Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Renames BuiltIn => Builtin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed May 24, 2023
1 parent 8a1615c commit 0b37d9f
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 90 deletions.
6 changes: 3 additions & 3 deletions benches/elf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ use solana_rbpf::{
elf::Executable,
syscalls::bpf_syscall_u64,
verifier::TautologyVerifier,
vm::{BuiltInProgram, Config, TestContextObject},
vm::{BuiltinProgram, Config, TestContextObject},
};
use std::{fs::File, io::Read, sync::Arc};
use test::Bencher;

fn loader() -> Arc<BuiltInProgram<TestContextObject>> {
let mut loader = BuiltInProgram::new_loader(Config::default());
fn loader() -> Arc<BuiltinProgram<TestContextObject>> {
let mut loader = BuiltinProgram::new_loader(Config::default());
loader
.register_function(b"log_64", bpf_syscall_u64)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions benches/jit_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate test;
use solana_rbpf::{
elf::Executable,
verifier::{RequisiteVerifier, TautologyVerifier},
vm::{BuiltInProgram, Config, TestContextObject},
vm::{BuiltinProgram, Config, TestContextObject},
};
use std::{fs::File, io::Read, sync::Arc};
use test::Bencher;
Expand All @@ -25,7 +25,7 @@ fn bench_init_vm(bencher: &mut Bencher) {
file.read_to_end(&mut elf).unwrap();
let executable = Executable::<TautologyVerifier, TestContextObject>::from_elf(
&elf,
Arc::new(BuiltInProgram::new_loader(Config::default())),
Arc::new(BuiltinProgram::new_loader(Config::default())),
)
.unwrap();
let verified_executable =
Expand All @@ -52,7 +52,7 @@ fn bench_jit_compile(bencher: &mut Bencher) {
file.read_to_end(&mut elf).unwrap();
let executable = Executable::<TautologyVerifier, TestContextObject>::from_elf(
&elf,
Arc::new(BuiltInProgram::new_loader(Config::default())),
Arc::new(BuiltinProgram::new_loader(Config::default())),
)
.unwrap();
let mut verified_executable =
Expand Down
8 changes: 4 additions & 4 deletions benches/vm_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use solana_rbpf::{
elf::Executable,
memory_region::MemoryRegion,
verifier::{RequisiteVerifier, TautologyVerifier},
vm::{BuiltInProgram, Config, TestContextObject},
vm::{BuiltinProgram, Config, TestContextObject},
};
use std::{fs::File, io::Read, sync::Arc};
use test::Bencher;
Expand All @@ -27,7 +27,7 @@ fn bench_init_interpreter_execution(bencher: &mut Bencher) {
file.read_to_end(&mut elf).unwrap();
let executable = Executable::<TautologyVerifier, TestContextObject>::from_elf(
&elf,
Arc::new(BuiltInProgram::new_loader(Config::default())),
Arc::new(BuiltinProgram::new_loader(Config::default())),
)
.unwrap();
let verified_executable =
Expand Down Expand Up @@ -56,7 +56,7 @@ fn bench_init_jit_execution(bencher: &mut Bencher) {
file.read_to_end(&mut elf).unwrap();
let executable = Executable::<TautologyVerifier, TestContextObject>::from_elf(
&elf,
Arc::new(BuiltInProgram::new_loader(Config::default())),
Arc::new(BuiltinProgram::new_loader(Config::default())),
)
.unwrap();
let mut verified_executable =
Expand Down Expand Up @@ -88,7 +88,7 @@ fn bench_jit_vs_interpreter(
) {
let executable = solana_rbpf::assembler::assemble::<TestContextObject>(
assembly,
Arc::new(BuiltInProgram::new_loader(config)),
Arc::new(BuiltinProgram::new_loader(config)),
)
.unwrap();
let mut verified_executable =
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use solana_rbpf::{
memory_region::{MemoryMapping, MemoryRegion},
static_analysis::Analysis,
verifier::{RequisiteVerifier, TautologyVerifier},
vm::{BuiltInProgram, Config, DynamicAnalysis, EbpfVm, TestContextObject},
vm::{BuiltinProgram, Config, DynamicAnalysis, EbpfVm, TestContextObject},
};
use std::{fs::File, io::Read, path::Path, sync::Arc};

Expand Down Expand Up @@ -92,7 +92,7 @@ fn main() {
)
.get_matches();

let loader = Arc::new(BuiltInProgram::new_loader(Config {
let loader = Arc::new(BuiltinProgram::new_loader(Config {
enable_instruction_tracing: matches.is_present("trace") || matches.is_present("profile"),
enable_symbol_and_section_labels: true,
..Config::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/disassemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use solana_rbpf::{
elf::Executable,
static_analysis::Analysis,
verifier::TautologyVerifier,
vm::{BuiltInProgram, FunctionRegistry, TestContextObject},
vm::{BuiltinProgram, FunctionRegistry, TestContextObject},
};
use std::sync::Arc;

Expand All @@ -31,7 +31,7 @@ fn main() {
0x00, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
];
let loader = Arc::new(BuiltInProgram::default());
let loader = Arc::new(BuiltinProgram::default());
let executable = Executable::<TautologyVerifier, TestContextObject>::from_text_bytes(
program,
loader,
Expand Down
4 changes: 2 additions & 2 deletions examples/to_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use solana_rbpf::{
elf::Executable,
static_analysis::Analysis,
verifier::TautologyVerifier,
vm::{BuiltInProgram, FunctionRegistry, TestContextObject},
vm::{BuiltinProgram, FunctionRegistry, TestContextObject},
};
use std::sync::Arc;
// Turn a program into a JSON string.
Expand All @@ -30,7 +30,7 @@ use std::sync::Arc;
fn to_json(program: &[u8]) -> String {
let executable = Executable::<TautologyVerifier, TestContextObject>::from_text_bytes(
program,
Arc::new(BuiltInProgram::default()),
Arc::new(BuiltinProgram::default()),
FunctionRegistry::default(),
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/dumb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use solana_rbpf::{
elf::Executable,
memory_region::MemoryRegion,
verifier::{RequisiteVerifier, TautologyVerifier, Verifier},
vm::{BuiltInProgram, FunctionRegistry, TestContextObject},
vm::{BuiltinProgram, FunctionRegistry, TestContextObject},
};
use test_utils::create_vm;

Expand All @@ -35,7 +35,7 @@ fuzz_target!(|data: DumbFuzzData| {
let mut mem = data.mem;
let executable = Executable::<TautologyVerifier, TestContextObject>::from_text_bytes(
&prog,
std::sync::Arc::new(BuiltInProgram::new_loader(config)),
std::sync::Arc::new(BuiltinProgram::new_loader(config)),
function_registry,
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/smart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use solana_rbpf::{
insn_builder::{Arch, IntoBytes},
memory_region::MemoryRegion,
verifier::{RequisiteVerifier, TautologyVerifier, Verifier},
vm::{BuiltInProgram, FunctionRegistry, TestContextObject},
vm::{BuiltinProgram, FunctionRegistry, TestContextObject},
};
use test_utils::create_vm;

Expand Down Expand Up @@ -39,7 +39,7 @@ fuzz_target!(|data: FuzzData| {
let mut mem = data.mem;
let executable = Executable::<TautologyVerifier, TestContextObject>::from_text_bytes(
prog.into_bytes(),
std::sync::Arc::new(BuiltInProgram::new_loader(config)),
std::sync::Arc::new(BuiltinProgram::new_loader(config)),
function_registry,
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/smart_jit_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use solana_rbpf::{
insn_builder::{Arch, Instruction, IntoBytes},
memory_region::MemoryRegion,
verifier::{RequisiteVerifier, TautologyVerifier, Verifier},
vm::{BuiltInProgram, FunctionRegistry, TestContextObject},
vm::{BuiltinProgram, FunctionRegistry, TestContextObject},
};
use test_utils::create_vm;

Expand Down Expand Up @@ -47,7 +47,7 @@ fuzz_target!(|data: FuzzData| {
let mut jit_mem = data.mem;
let mut executable = Executable::<TautologyVerifier, TestContextObject>::from_text_bytes(
prog.into_bytes(),
std::sync::Arc::new(BuiltInProgram::new_loader(config)),
std::sync::Arc::new(BuiltinProgram::new_loader(config)),
function_registry,
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/smarter_jit_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use solana_rbpf::{
static_analysis::Analysis,
verifier::{RequisiteVerifier, TautologyVerifier, Verifier},
vm::{
BuiltInProgram, ContextObject, FunctionRegistry, TestContextObject,
BuiltinProgram, ContextObject, FunctionRegistry, TestContextObject,
},
};
use test_utils::create_vm;
Expand Down Expand Up @@ -46,7 +46,7 @@ fuzz_target!(|data: FuzzData| {
let mut jit_mem = data.mem;
let mut executable = Executable::<TautologyVerifier, TestContextObject>::from_text_bytes(
prog.into_bytes(),
std::sync::Arc::new(BuiltInProgram::new_loader(config)),
std::sync::Arc::new(BuiltinProgram::new_loader(config)),
function_registry,
)
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
ebpf::{self, Insn},
elf::{register_internal_function, Executable},
verifier::TautologyVerifier,
vm::{BuiltInProgram, ContextObject, FunctionRegistry},
vm::{BuiltinProgram, ContextObject, FunctionRegistry},
};
use std::{collections::HashMap, sync::Arc};

Expand Down Expand Up @@ -183,15 +183,15 @@ fn insn(opc: u8, dst: i64, src: i64, off: i64, imm: i64) -> Result<Insn, String>
/// # Examples
///
/// ```
/// use solana_rbpf::{assembler::assemble, vm::{Config, TestContextObject, BuiltInProgram}};
/// use solana_rbpf::{assembler::assemble, vm::{Config, TestContextObject, BuiltinProgram}};
/// let executable = assemble::<TestContextObject>(
/// "add64 r1, 0x605
/// mov64 r2, 0x32
/// mov64 r1, r0
/// be16 r0
/// neg64 r2
/// exit",
/// std::sync::Arc::new(BuiltInProgram::new_loader(Config::default())),
/// std::sync::Arc::new(BuiltinProgram::new_loader(Config::default())),
/// ).unwrap();
/// let program = executable.get_text_bytes().1;
/// println!("{:?}", program);
Expand All @@ -216,7 +216,7 @@ fn insn(opc: u8, dst: i64, src: i64, off: i64, imm: i64) -> Result<Insn, String>
/// ```
pub fn assemble<C: ContextObject>(
src: &str,
loader: Arc<BuiltInProgram<C>>,
loader: Arc<BuiltinProgram<C>>,
) -> Result<Executable<TautologyVerifier, C>, String> {
fn resolve_label(
insn_ptr: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::ebpf;
use crate::static_analysis::CfgNode;
use crate::vm::{BuiltInProgram, ContextObject, FunctionRegistry};
use crate::vm::{BuiltinProgram, ContextObject, FunctionRegistry};
use std::collections::BTreeMap;

fn resolve_label(cfg_nodes: &BTreeMap<usize, CfgNode>, pc: usize) -> &str {
Expand Down Expand Up @@ -121,7 +121,7 @@ pub fn disassemble_instruction<C: ContextObject>(
insn: &ebpf::Insn,
cfg_nodes: &BTreeMap<usize, CfgNode>,
function_registry: &FunctionRegistry,
loader: &BuiltInProgram<C>,
loader: &BuiltinProgram<C>,
) -> String {
let name;
let desc;
Expand Down
28 changes: 14 additions & 14 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
error::EbpfError,
memory_region::MemoryRegion,
verifier::{TautologyVerifier, Verifier},
vm::{BuiltInProgram, Config, ContextObject, FunctionRegistry},
vm::{BuiltinProgram, Config, ContextObject, FunctionRegistry},
};

#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn register_internal_function<
T: AsRef<str> + ToString + std::cmp::PartialEq<&'static str>,
>(
function_registry: &mut FunctionRegistry,
loader: &BuiltInProgram<C>,
loader: &BuiltinProgram<C>,
pc: usize,
name: T,
) -> Result<u32, ElfError> {
Expand Down Expand Up @@ -279,7 +279,7 @@ pub struct Executable<V: Verifier, C: ContextObject> {
/// Call resolution map (hash, pc, name)
function_registry: FunctionRegistry,
/// Loader built-in program
loader: Arc<BuiltInProgram<C>>,
loader: Arc<BuiltinProgram<C>>,
/// Compiled program and argument
#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
compiled_program: Option<JitProgram>,
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
}

/// Get the loader built-in program
pub fn get_loader(&self) -> &BuiltInProgram<C> {
pub fn get_loader(&self) -> &BuiltinProgram<C> {
&self.loader
}

Expand Down Expand Up @@ -381,7 +381,7 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
/// Create from raw text section bytes (list of instructions)
pub fn new_from_text_bytes(
text_bytes: &[u8],
loader: Arc<BuiltInProgram<C>>,
loader: Arc<BuiltinProgram<C>>,
mut function_registry: FunctionRegistry,
) -> Result<Self, ElfError> {
let elf_bytes = AlignedMemory::from_slice(text_bytes);
Expand Down Expand Up @@ -418,7 +418,7 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
}

/// Fully loads an ELF, including validation and relocation
pub fn load(bytes: &[u8], loader: Arc<BuiltInProgram<C>>) -> Result<Self, ElfError> {
pub fn load(bytes: &[u8], loader: Arc<BuiltinProgram<C>>) -> Result<Self, ElfError> {
if loader.get_config().new_elf_parser {
// The new parser creates references from the input byte slice, so
// it must be properly aligned. We assume that HOST_ALIGN is a
Expand All @@ -439,7 +439,7 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
fn load_with_parser<'a, P: ElfParser<'a>>(
elf: &'a P,
bytes: &[u8],
loader: Arc<BuiltInProgram<C>>,
loader: Arc<BuiltinProgram<C>>,
) -> Result<Self, ElfError> {
let mut elf_bytes = AlignedMemory::from_slice(bytes);
let config = loader.get_config();
Expand Down Expand Up @@ -564,7 +564,7 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
/// Fix-ups relative calls
pub fn fixup_relative_calls(
function_registry: &mut FunctionRegistry,
loader: &BuiltInProgram<C>,
loader: &BuiltinProgram<C>,
elf_bytes: &mut [u8],
) -> Result<(), ElfError> {
let config = loader.get_config();
Expand Down Expand Up @@ -886,7 +886,7 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
/// Relocates the ELF in-place
fn relocate<'a, P: ElfParser<'a>>(
function_registry: &mut FunctionRegistry,
loader: &BuiltInProgram<C>,
loader: &BuiltinProgram<C>,
elf: &'a P,
elf_bytes: &mut [u8],
) -> Result<(), ElfError> {
Expand Down Expand Up @@ -1232,8 +1232,8 @@ mod test {
use test_utils::assert_error;
type ElfExecutable = Executable<TautologyVerifier, TestContextObject>;

fn loader() -> Arc<BuiltInProgram<TestContextObject>> {
let mut loader = BuiltInProgram::new_loader(Config::default());
fn loader() -> Arc<BuiltinProgram<TestContextObject>> {
let mut loader = BuiltinProgram::new_loader(Config::default());
loader
.register_function(b"log", syscalls::bpf_syscall_string)
.unwrap();
Expand Down Expand Up @@ -1399,7 +1399,7 @@ mod test {
#[test]
fn test_fixup_relative_calls_back() {
let mut function_registry = FunctionRegistry::default();
let loader = BuiltInProgram::new_loader(Config {
let loader = BuiltinProgram::new_loader(Config {
static_syscalls: false,
enable_symbol_and_section_labels: true,
..Config::default()
Expand Down Expand Up @@ -1448,7 +1448,7 @@ mod test {
#[test]
fn test_fixup_relative_calls_forward() {
let mut function_registry = FunctionRegistry::default();
let loader = BuiltInProgram::new_loader(Config {
let loader = BuiltinProgram::new_loader(Config {
static_syscalls: false,
enable_symbol_and_section_labels: true,
..Config::default()
Expand Down Expand Up @@ -2117,7 +2117,7 @@ mod test {
#[test]
#[should_panic(expected = r#"validation failed: RelativeJumpOutOfBounds(29)"#)]
fn test_static_syscall_disabled() {
let loader = BuiltInProgram::new_loader(Config {
let loader = BuiltinProgram::new_loader(Config {
static_syscalls: false,
..Config::default()
});
Expand Down
4 changes: 2 additions & 2 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ mod tests {
use crate::{
syscalls,
verifier::TautologyVerifier,
vm::{BuiltInProgram, FunctionRegistry, TestContextObject},
vm::{BuiltinProgram, FunctionRegistry, TestContextObject},
};
use byteorder::{ByteOrder, LittleEndian};
use std::sync::Arc;
Expand Down Expand Up @@ -1601,7 +1601,7 @@ mod tests {
fn create_mockup_executable(
program: &[u8],
) -> Executable<TautologyVerifier, TestContextObject> {
let mut loader = BuiltInProgram::new_loader(Config {
let mut loader = BuiltinProgram::new_loader(Config {
noop_instruction_rate: 0,
..Config::default()
});
Expand Down
Loading

0 comments on commit 0b37d9f

Please sign in to comment.