Skip to content

Commit 4fd3297

Browse files
author
Alexander Spies
committed
Update variable names and README
1 parent 7ed1270 commit 4fd3297

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The `JIT` class is defined [here](./src/jit.rs#L9) and contains several fields:
100100
- `builder_context` - Cranelift uses this to reuse dynamic allocations between
101101
compiling multiple functions.
102102
- `ctx` - This is the main `Context` object for compiling functions.
103-
- `data_ctx` - Similar to `ctx`, but for "compiling" data sections.
103+
- `data_description` - Similar to `ctx`, but for "compiling" data sections.
104104
- `module` - The `Module` which holds information about all functions and data
105105
objects defined in the current `JIT`.
106106

@@ -368,9 +368,9 @@ And there's a hello world example which demonstrates several other features.
368368

369369
This program needs to allocate some [data](./src/toy.rs#L33) to hold the string
370370
data. Inside jit.rs, [`create_data`](./src/jit.rs#L95) we initialize a
371-
`DataContext` with the contents of the hello string, and also declare a data
372-
object. Then we use the `DataContext` object to define the object. At that
373-
point, we're done with the `DataContext` object and can clear it. We then call
371+
`DataDescription` with the contents of the hello string, and also declare a data
372+
object. Then we use the `DataDescription` object to define the object. At that
373+
point, we're done with the `DataDescription` object and can clear it. We then call
374374
`finalize_data` to perform linking (although our simple hello string doesn't
375375
make any references so there isn't anything to do) and to obtain the final
376376
runtime address of the data, which we then convert back into a Rust slice for

‎src/jit.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub struct JIT {
1616
/// context per thread, though this isn't in the simple demo here.
1717
ctx: codegen::Context,
1818

19-
/// The data context, which is to data objects what `ctx` is to functions.
20-
data_ctx: DataDescription,
19+
/// The data description, which is to data objects what `ctx` is to functions.
20+
data_description: DataDescription,
2121

2222
/// The module, with the jit backend, which manages the JIT'd
2323
/// functions.
@@ -41,7 +41,7 @@ impl Default for JIT {
4141
Self {
4242
builder_context: FunctionBuilderContext::new(),
4343
ctx: module.make_context(),
44-
data_ctx: DataDescription::new(),
44+
data_description: DataDescription::new(),
4545
module,
4646
}
4747
}
@@ -95,16 +95,16 @@ impl JIT {
9595
pub fn create_data(&mut self, name: &str, contents: Vec<u8>) -> Result<&[u8], String> {
9696
// The steps here are analogous to `compile`, except that data is much
9797
// simpler than functions.
98-
self.data_ctx.define(contents.into_boxed_slice());
98+
self.data_description.define(contents.into_boxed_slice());
9999
let id = self
100100
.module
101101
.declare_data(name, Linkage::Export, true, false)
102102
.map_err(|e| e.to_string())?;
103103

104104
self.module
105-
.define_data(id, &self.data_ctx)
105+
.define_data(id, &self.data_description)
106106
.map_err(|e| e.to_string())?;
107-
self.data_ctx.clear();
107+
self.data_description.clear();
108108
self.module.finalize_definitions().unwrap();
109109
let buffer = self.module.get_finalized_data(id);
110110
// TODO: Can we move the unsafe into cranelift?

0 commit comments

Comments
 (0)