Record information about sections of emitted code+data.
The result of the emitter is a vector of bytes holding machine code, jump tables, and (in the future) other read-only data. Some clients, notably Firefox's Wasm compiler, needs to separate the machine code from the data in order to insert more code directly after the code generated by Cranelift. To make such separation possible, we record more information about the emitted bytes: the sizes of each of the sections of code, jump tables, and read-only data, as well as the locations within the code that reference (PC-relatively) the jump tables and read-only data.
This commit is contained in:
committed by
Lars T Hansen
parent
70f79d23bf
commit
420850adf0
@@ -8,8 +8,9 @@
|
||||
use super::HashMap;
|
||||
use crate::data_context::DataContext;
|
||||
use crate::Backend;
|
||||
use cranelift_codegen::binemit::{self, CodeInfo};
|
||||
use cranelift_codegen::entity::{entity_impl, PrimaryMap};
|
||||
use cranelift_codegen::{binemit, ir, isa, CodegenError, Context};
|
||||
use cranelift_codegen::{ir, isa, CodegenError, Context};
|
||||
use failure::Fail;
|
||||
use log::info;
|
||||
use std::borrow::ToOwned;
|
||||
@@ -519,7 +520,7 @@ where
|
||||
|
||||
/// Define a function, producing the function body from the given `Context`.
|
||||
///
|
||||
/// Returns the size of the function's code.
|
||||
/// Returns the size of the function's code and constant data.
|
||||
///
|
||||
/// Note: After calling this function the given `Context` will contain the compiled function.
|
||||
pub fn define_function(
|
||||
@@ -527,7 +528,7 @@ where
|
||||
func: FuncId,
|
||||
ctx: &mut Context,
|
||||
) -> ModuleResult<binemit::CodeOffset> {
|
||||
let code_size = ctx.compile(self.backend.isa()).map_err(|e| {
|
||||
let CodeInfo { total_size, .. } = ctx.compile(self.backend.isa()).map_err(|e| {
|
||||
info!(
|
||||
"defining function {}: {}",
|
||||
func,
|
||||
@@ -550,12 +551,12 @@ where
|
||||
&ModuleNamespace::<B> {
|
||||
contents: &self.contents,
|
||||
},
|
||||
code_size,
|
||||
total_size,
|
||||
)?);
|
||||
|
||||
self.contents.functions[func].compiled = compiled;
|
||||
self.functions_to_finalize.push(func);
|
||||
Ok(code_size)
|
||||
Ok(total_size)
|
||||
}
|
||||
|
||||
/// Define a function, producing the data contents from the given `DataContext`.
|
||||
|
||||
Reference in New Issue
Block a user