Compare commits

...
7 Commits
66 changed files with 834 additions and 748 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8 -3
View File
@@ -202,7 +202,6 @@ local $ENV{WAMR_USE_LINEAR_POOL_IN_TEXT} =
# ========================================================================================= #
# NOTE: The runner will prefix "-Wf," to each flag
# TODO: Exclude --wamr-exceptions from C builds automatically
my %catch_flag_map = (
"--catch-outer" => "--catch-outerspace",
"--catch-text" => "--catch-write-textsegment",
@@ -224,6 +223,12 @@ foreach my $experiment (@selected_experiments) {
foreach my $target (@selected_targets) {
foreach my $mode (@selected_modes) {
# Remove --wamr-exceptions for C builds, it is WAMR-specific
my @build_catch_flags =
$mode eq "c"
? grep { $_ ne "--wamr-exceptions" } @selected_catch_flags
: @selected_catch_flags;
my $allocator_info = "";
if ( $mode eq "aot" || $mode eq "interp" ) {
$allocator_info =
@@ -267,7 +272,7 @@ foreach my $experiment (@selected_experiments) {
&& $selected_linear_pool_variant eq $linear_pool_variants[0] )
? "wamr_linear_pool"
: "";
my $flags_info = join " ", @selected_catch_flags;
my $flags_info = join " ", @build_catch_flags;
my $info_str = join " ",
grep { length } (
@@ -288,7 +293,7 @@ foreach my $experiment (@selected_experiments) {
"$local_root/build-$experiment/runner_flags";
open( my $fhandle, '>', $runner_flags_path )
or die "Cannot write $runner_flags_path: $!";
print $fhandle "$catch_flag_map{$_}\n" for @selected_catch_flags;
print $fhandle "$catch_flag_map{$_}\n" for @build_catch_flags;
close($fhandle);
system( "mv", "$local_root/build.log",
@@ -1,8 +1,11 @@
library(ggplot2)
library(dplyr)
library(readr)
library(stringr)
# Usage: Rscript combined_comparison.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# One coordinate system per base experiment (facet); c/aot/interp variants
# share each facet, coloured by variant.
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
@@ -20,17 +23,36 @@ exp_args <- if (grepl("\\.csv$", args[length(args)])) {
args
}
extract_info <- function(path) {
dir_name <- basename(path)
match <- str_match(
dir_name,
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
)
if (is.na(match[1, 1])) {
warning(paste("Could not parse:", dir_name))
return(NULL)
}
list(base_name = match[1, 2], variant = match[1, 3], path = path)
}
all_data <- data.frame()
for (arg in exp_args) {
csv_file <- file.path(arg, csv_suffix)
info <- extract_info(arg)
if (is.null(info)) {
next
}
csv_file <- file.path(info$path, csv_suffix)
if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file))
next
}
df <- read_csv(csv_file, col_types = cols())
df$experiment <- basename(arg)
df$base_name <- info$base_name
df$variant <- info$variant
all_data <- bind_rows(all_data, df)
}
@@ -39,7 +61,7 @@ if (nrow(all_data) == 0) {
}
totals <- all_data |>
group_by(experiment, resulttype) |>
group_by(base_name, variant, resulttype) |>
summarise(faults = sum(faults, na.rm = TRUE), .groups = "drop") |>
ungroup()
@@ -57,21 +79,25 @@ totals$resulttype <- factor(totals$resulttype, levels = marker_order)
plot <- ggplot(
totals,
aes(x = resulttype, y = faults, colour = experiment, group = experiment)
aes(x = resulttype, y = faults, colour = variant, group = variant)
) +
geom_point(size = 2) +
geom_line() +
facet_wrap(~base_name) +
scale_y_log10() +
labs(
x = "Marker",
y = "Faults",
title = "Combined Comparison",
color = "Experiment"
x = "Fault Type",
y = "Fault Count",
title = "Fault Count Comparison",
color = "Variant"
) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
plot.title = element_text(size = 14, face = "bold")
)
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/combined_comparison", suffix, ".svg")
outfile <- paste0("injections/fault_count_comparison", suffix, ".svg")
ggsave(outfile, plot = plot, width = 12, height = 6)
print(paste("Saved", outfile))
@@ -4,8 +4,8 @@ library(readr)
library(stringr)
library(tidyr)
# Usage: Rscript ratio_correlation.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# Plots correlation between aot/c and interp/c ratios
# Usage: Rscript combined_fault_correlation.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# Plots correlation between raw aot and interp fault counts (no C baseline).
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
@@ -69,48 +69,52 @@ all_data <- all_data |>
group_by(base_name, variant, benchmark, resulttype) |>
summarise(faults = sum(faults), .groups = "drop")
baseline <- all_data |> filter(variant == "c")
comparisons <- all_data |> filter(variant != "c")
# Only aot/interp matter; C is not used as a baseline here.
counts <- all_data |> filter(variant %in% c("aot", "interp"))
ratios <- comparisons |>
left_join(
baseline |> select(base_name, benchmark, resulttype, faults),
by = c("base_name", "benchmark", "resulttype"),
suffix = c("", "_baseline")
) |>
filter(!is.na(faults_baseline), faults_baseline > 0) |>
mutate(ratio = faults / faults_baseline)
if (nrow(ratios) == 0) {
stop("No ratios computed (missing baseline or zero values)")
}
# Pivot to get aot and interp ratios side by side
ratio_wide <- ratios |>
select(base_name, benchmark, resulttype, variant, ratio) |>
pivot_wider(names_from = variant, values_from = ratio) |>
# Pivot to get aot and interp fault counts side by side
counts_wide <- counts |>
select(base_name, benchmark, resulttype, variant, faults) |>
pivot_wider(names_from = variant, values_from = faults) |>
filter(!is.na(aot), !is.na(interp))
if (nrow(ratio_wide) == 0) {
stop("No paired aot/interp ratios found")
if (nrow(counts_wide) == 0) {
stop("No paired aot/interp fault counts found")
}
# Compute correlation
cor_result <- cor(ratio_wide$aot, ratio_wide$interp, method = "pearson")
cat(sprintf("Pearson correlation: %.4f\n", cor_result))
cor_raw <- cor(counts_wide$aot, counts_wide$interp, method = "pearson")
cor_log <- cor(
log10(counts_wide$aot),
log10(counts_wide$interp),
method = "pearson"
)
cat(sprintf("Pearson correlation (raw): %.4f\n", cor_raw))
cat(sprintf("Pearson correlation (log10): %.4f\n", cor_log))
# Create plot
plot <- ggplot(
ratio_wide,
counts_wide,
aes(x = aot, y = interp, color = base_name, shape = resulttype)
) +
# geom_abline(
# slope = 1,
# intercept = 0,
# colour = "grey70",
# linetype = "dotted"
# ) +
geom_point(size = 3, alpha = 0.7) +
scale_x_log10(name = "AOT / C Ratio") +
scale_y_log10(name = "Interpreter / C Ratio") +
scale_x_log10(name = "AOT Fault Count") +
scale_y_log10(name = "Interpreter Fault Count") +
labs(
title = sprintf("Ratio Correlation (r = %.4f)", cor_result),
# title = sprintf(
# "Fault Count Correlation (r_raw = %.4f, r_log = %.4f)",
# cor_raw,
# cor_log
# ),
title = "Fault Count Correlation",
color = "Experiment",
shape = "Marker"
shape = "Fault Type"
) +
theme_minimal() +
theme(
@@ -118,5 +122,7 @@ plot <- ggplot(
plot.title = element_text(size = 14, face = "bold")
)
ggsave("injections/ratio_correlation.svg", plot = plot, width = 10, height = 8)
print("Saved ratio_correlation.svg")
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/fault_count_correlation", suffix, ".svg")
ggsave(outfile, plot = plot, width = 10, height = 8)
print(paste("Saved", outfile))
@@ -0,0 +1,115 @@
library(ggplot2)
library(dplyr)
library(readr)
library(stringr)
# Usage: Rscript combined_fault_rates.r exp_abspath1 exp_abspath2 ... [faults_file]
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
stop("Need at least 1 experiment")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)]
} else {
"faults.csv"
}
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)]
} else {
args
}
# Faults / instruction count, per experiment
rates <- data.frame()
for (arg in exp_args) {
faults_file <- file.path(arg, csv_suffix)
mnem_file <- file.path(arg, "mnemonics.csv")
if (!file.exists(faults_file)) {
warning(paste("Missing:", faults_file))
next
}
if (!file.exists(mnem_file)) {
warning(paste("Missing:", mnem_file))
next
}
df <- read_csv(faults_file, col_types = cols())
mdf <- read_csv(mnem_file, col_types = cols())
total_faults <- df |>
filter(resulttype != "OK_MARKER") |>
summarise(faults = sum(faults, na.rm = TRUE)) |>
pull(faults)
total_instrs <- sum(mdf$count, na.rm = TRUE)
if (is.na(total_instrs) || total_instrs == 0) {
warning(paste("Zero instruction count for", arg))
next
}
match <- str_match(
basename(arg),
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
)
if (is.na(match[1, 1])) {
base_name <- basename(arg)
variant <- "unknown"
} else {
base_name <- match[1, 2]
variant <- match[1, 3]
}
rates <- bind_rows(
rates,
data.frame(
base_name = base_name,
variant = variant,
fault_rate = total_faults / total_instrs
)
)
}
if (nrow(rates) == 0) {
stop("No data loaded")
}
# Order base_names by their max fault rate
base_order <- rates |>
group_by(base_name) |>
summarise(max_rate = max(fault_rate), .groups = "drop") |>
arrange(desc(max_rate)) |>
pull(base_name)
rates <- rates |>
mutate(
base_name = factor(base_name, levels = base_order),
variant = factor(variant, levels = c("c", "aot", "interp", "unknown"))
)
plot <- ggplot(
rates,
aes(x = base_name, y = fault_rate, fill = variant)
) +
geom_col(position = position_dodge(preserve = "single")) +
scale_y_log10() +
labs(
title = "Fault Rate per Instruction",
x = "Experiment",
y = "Faults / Instruction Count",
fill = "Variant"
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
plot.title = element_text(size = 14, face = "bold")
)
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/fault_rates_per_instruction", suffix, ".svg")
ggsave(outfile, plot = plot, width = 12, height = 6)
print(paste("Saved", outfile))
@@ -0,0 +1,133 @@
library(ggplot2)
library(dplyr)
library(readr)
# Usage: Rscript combined_instr_fault_correlation.r exp_abspath1 exp_abspath2 ... [faults_file]
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
stop("Need at least 1 experiment")
}
# TODO: I should probably stop duplicating this each time
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)]
} else {
"faults.csv"
}
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)]
} else {
args
}
# Don't use counts from faults.csv, as that would correlate completely
# because only mnemonics with faults are listed there
# NOTE: Doesn't match selected filters for faults.csv
mnemonics_file <- "mnemonics.csv"
freq_data <- data.frame()
faults_data <- data.frame()
# TODO: I should probably stop duplicating this each time
for (arg in exp_args) {
mnem_path <- file.path(arg, mnemonics_file)
faults_path <- file.path(arg, csv_suffix)
if (!file.exists(mnem_path)) {
warning(paste("Missing:", mnem_path))
next
}
if (!file.exists(faults_path)) {
warning(paste("Missing:", faults_path))
next
}
mdf <- read_csv(mnem_path, col_types = cols())
mdf$experiment <- basename(arg)
freq_data <- bind_rows(freq_data, mdf)
fdf <- read_csv(faults_path, col_types = cols())
fdf$experiment <- basename(arg)
faults_data <- bind_rows(faults_data, fdf)
}
if (nrow(freq_data) == 0 || nrow(faults_data) == 0) {
stop("No data loaded")
}
# x-axis: mnemonics.csv counts
instr_freq <- freq_data |>
filter(!is.na(mnemonic), mnemonic != "NULL") |>
group_by(mnemonic) |>
summarise(instr_count = sum(count, na.rm = TRUE), .groups = "drop")
# y-axis: no OK_MARKERs, sum GROUP1_MARKER + TRAP.
marker_count <- faults_data |>
filter(!is.na(mnemonic), mnemonic != "NULL") |>
filter(resulttype != "OK_MARKER") |>
mutate(
resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype)
) |>
group_by(mnemonic) |>
summarise(marker_count = sum(faults, na.rm = TRUE), .groups = "drop")
correlation <- instr_freq |>
inner_join(marker_count, by = "mnemonic") |>
filter(instr_count > 0, marker_count > 0)
if (nrow(correlation) < 2) {
stop("Not enough mnemonics to compute a correlation")
}
cor_raw <- cor(
correlation$instr_count,
correlation$marker_count,
method = "pearson"
)
cor_log <- cor(
log10(correlation$instr_count),
log10(correlation$marker_count),
method = "pearson"
)
cat(sprintf("Pearson correlation (raw): %.4f\n", cor_raw))
cat(sprintf("Pearson correlation (log10): %.4f\n", cor_log))
plot <- ggplot(
correlation,
aes(x = instr_count, y = marker_count)
) +
geom_smooth(
method = "lm",
se = FALSE,
colour = "grey50",
linetype = "dashed"
) +
geom_point(aes(colour = mnemonic), size = 3, alpha = 0.8) +
geom_text(
aes(label = mnemonic),
size = 3,
vjust = -0.8,
check_overlap = TRUE
) +
scale_x_log10(name = "Instruction Executions") +
scale_y_log10(name = "Fault Count") +
labs(
# title = sprintf(
# "Instruction / Fault Correlation (r_raw = %.4f, r_log = %.4f)",
# cor_raw,
# cor_log
# ),
title = "Instruction / Fault Correlation",
colour = "Mnemonic"
) +
theme_minimal() +
theme(
legend.position = "none",
plot.title = element_text(size = 14, face = "bold")
)
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/instr_fault_correlation", suffix, ".svg")
ggsave(outfile, plot = plot, width = 10, height = 8)
print(paste("Saved", outfile))
@@ -0,0 +1,120 @@
library(ggplot2)
library(dplyr)
library(readr)
library(viridisLite)
# Usage: Rscript combined_instr_fault_correlation_heatmap.r exp_abspath1 ... [faults_file]
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
stop("Need at least 1 experiment")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)]
} else {
"faults.csv"
}
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)]
} else {
args
}
all_data <- data.frame()
all_mnem <- data.frame()
for (arg in exp_args) {
csv_file <- file.path(arg, csv_suffix)
if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file))
next
}
df <- read_csv(csv_file, col_types = cols())
df$experiment <- basename(arg)
all_data <- bind_rows(all_data, df)
# TODO: This is ignoring any filters currently
mnem_file <- file.path(arg, "mnemonics.csv")
if (!file.exists(mnem_file)) {
warning(paste("Missing:", mnem_file))
next
}
mdf <- read_csv(mnem_file, col_types = cols())
all_mnem <- bind_rows(all_mnem, mdf)
}
if (nrow(all_data) == 0) {
stop("No faults.csv data loaded")
}
if (nrow(all_mnem) == 0) {
stop("No mnemonics.csv data loaded")
}
# no OK_MARKER, sum GROUP1 + TRAP.
all_data <- all_data |>
filter(!is.na(mnemonic), mnemonic != "NULL") |>
filter(resulttype != "OK_MARKER") |>
mutate(
resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype)
)
if (nrow(all_data) == 0) {
stop("No failure-marker data to plot")
}
# Sum faults per (mnemonic, marker) pair for all experiments
heat <- all_data |>
group_by(mnemonic, resulttype) |>
summarise(faults = sum(faults, na.rm = TRUE), .groups = "drop")
# Sum mnemonic counts for all experiments
mnem_counts <- all_mnem |>
filter(!is.na(mnemonic), mnemonic != "NULL") |>
group_by(mnemonic) |>
summarise(count = sum(count, na.rm = TRUE), .groups = "drop")
# Normalize by mnemonic count
heat <- heat |>
left_join(mnem_counts, by = "mnemonic") |>
filter(!is.na(count), count > 0) |>
mutate(fault_rate = faults / count)
if (nrow(heat) == 0) {
stop("Heat join failed")
}
# Order by fault rate
mnem_order <- heat |>
group_by(mnemonic) |>
summarise(total = sum(fault_rate), .groups = "drop") |>
arrange(desc(total)) |>
pull(mnemonic)
heat <- heat |>
mutate(mnemonic = factor(mnemonic, levels = mnem_order))
plot <- ggplot(
heat,
aes(x = mnemonic, y = resulttype, fill = fault_rate)
) +
geom_tile(colour = "white") +
scale_fill_viridis_c(name = "Fault rate", trans = "log10") +
labs(
title = "Instruction / Fault Rate Heatmap (Normalized)",
x = "Instruction",
y = "Fault Type"
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
panel.grid = element_blank(),
plot.title = element_text(size = 14, face = "bold")
)
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
outfile <- paste0("injections/instr_fault_rate_heatmap", suffix, ".svg")
ggsave(outfile, plot = plot, width = 12, height = 6)
print(paste("Saved", outfile))
+10 -4
View File
@@ -83,12 +83,18 @@ plot <- ggplot(
) +
geom_point(size = 2) +
geom_line() +
facet_wrap(~base_name, scales = "free_x") +
facet_wrap(~base_name) +
scale_y_log10(name = "Ratio (to C)") +
scale_x_discrete(name = "Marker") +
labs(color = "Variant") +
scale_x_discrete(name = "Fault Type") +
labs(
title = "Fault Count Ratios",
color = "Variant"
) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
plot.title = element_text(size = 14, face = "bold")
)
ggsave("injections/ratio_comparison.svg", plot = plot, width = 12, height = 8)
print("Saved ratio_comparison.svg")
@@ -3,8 +3,8 @@ library(dplyr)
library(readr)
library(stringr)
# Usage: Rscript ratio_comparison_merged.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# Sums all benchmarks
# Usage: Rscript ratio_comparison_merged_trap.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# Sums all benchmarks, merges GROUP1_MARKER into TRAP
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
@@ -59,7 +59,9 @@ if (nrow(all_data) == 0) {
stop("No data loaded")
}
# Add all benchs together (per marker type)
all_data <- all_data |>
mutate(resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype))
merged_data <- all_data |>
group_by(base_name, variant, resulttype) |>
summarise(faults = sum(faults), .groups = "drop")
@@ -88,15 +90,21 @@ plot <- ggplot(
geom_line() +
facet_wrap(~base_name) +
scale_y_log10(name = "Ratio (to C)") +
scale_x_discrete(name = "Marker") +
labs(color = "Variant") +
scale_x_discrete(name = "Fault Type") +
labs(
color = "Variant",
title = "Fault Count Ratios"
) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
plot.title = element_text(size = 14, face = "bold")
)
ggsave(
"injections/ratio_comparison_merged.svg",
"injections/ratio_comparison_merged_trap.svg",
plot = plot,
width = 12,
height = 8
)
print("Saved ratio_comparison_merged.svg")
print("Saved ratio_comparison_merged_trap.svg")
@@ -1,100 +0,0 @@
library(ggplot2)
library(dplyr)
library(readr)
library(stringr)
# Usage: Rscript ratio_comparison_merged_trap.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# Sums all benchmarks, merges GROUP1_MARKER into TRAP
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)]
} else {
"resultsdata.csv"
}
exp_args <- if (grepl("\\.csv$", args[length(args)])) args[-length(args)] else args
extract_info <- function(path) {
dir_name <- basename(path)
match <- str_match(
dir_name,
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
)
if (is.na(match[1, 1])) {
warning(paste("Could not parse:", dir_name))
return(NULL)
}
list(base_name = match[1, 2], variant = match[1, 3], path = path)
}
all_data <- data.frame()
for (arg in exp_args) {
info <- extract_info(arg)
if (is.null(info)) {
next
}
csv_file <- file.path(info$path, csv_suffix)
if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file))
next
}
df <- read_csv(csv_file, col_types = cols())
df$base_name <- info$base_name
df$variant <- info$variant
all_data <- bind_rows(all_data, df)
}
if (nrow(all_data) == 0) {
stop("No data loaded")
}
all_data <- all_data |>
mutate(resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype))
merged_data <- all_data |>
group_by(base_name, variant, resulttype) |>
summarise(faults = sum(faults), .groups = "drop")
baseline <- merged_data |> filter(variant == "c")
comparisons <- merged_data |> filter(variant != "c")
ratios <- comparisons |>
left_join(
baseline |> select(base_name, resulttype, faults),
by = c("base_name", "resulttype"),
suffix = c("", "_baseline")
) |>
filter(!is.na(faults_baseline), faults_baseline > 0) |>
mutate(ratio = faults / faults_baseline)
if (nrow(ratios) == 0) {
stop("No ratios computed (missing baseline or zero values)")
}
plot <- ggplot(
ratios,
aes(x = resulttype, y = ratio, color = variant, group = variant)
) +
geom_point(size = 2) +
geom_line() +
facet_wrap(~base_name) +
scale_y_log10(name = "Ratio (to C)") +
scale_x_discrete(name = "Marker") +
labs(color = "Variant") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
ggsave(
"injections/ratio_comparison_merged_trap.svg",
plot = plot,
width = 12,
height = 8
)
print("Saved ratio_comparison_merged_trap.svg")
@@ -1,129 +0,0 @@
library(ggplot2)
library(dplyr)
library(readr)
library(stringr)
library(tidyr)
# Usage: Rscript ratio_correlation_no_mem.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
# Plots correlation between aot/c and interp/c ratios, ignoring mem benchmark
# NOTE: Just a copy of the ratio_correlation.r script where I've changed the filter in line 67
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
stop("Need at least 2 experiments")
}
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
args[length(args)]
} else {
"resultsdata.csv"
}
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
args[-length(args)]
} else {
args
}
extract_info <- function(path) {
dir_name <- basename(path)
match <- str_match(
dir_name,
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
)
if (is.na(match[1, 1])) {
warning(paste("Could not parse:", dir_name))
return(NULL)
}
list(base_name = match[1, 2], variant = match[1, 3], path = path)
}
all_data <- data.frame()
for (arg in exp_args) {
info <- extract_info(arg)
if (is.null(info)) {
next
}
csv_file <- file.path(info$path, csv_suffix)
if (!file.exists(csv_file)) {
warning(paste("Missing:", csv_file))
next
}
df <- read_csv(csv_file, col_types = cols())
df$base_name <- info$base_name
df$variant <- info$variant
all_data <- bind_rows(all_data, df)
}
if (nrow(all_data) == 0) {
stop("No data loaded")
}
# Ignore OK_MARKER (only plot failures) and sum GROUP1_MARKER with TRAP
# Also ignore mem benchmark
all_data <- all_data |>
filter(resulttype %in% c("TRAP", "GROUP1_MARKER"), benchmark == "ip") |>
mutate(resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype))
all_data <- all_data |>
group_by(base_name, variant, benchmark, resulttype) |>
summarise(faults = sum(faults), .groups = "drop")
baseline <- all_data |> filter(variant == "c")
comparisons <- all_data |> filter(variant != "c")
ratios <- comparisons |>
left_join(
baseline |> select(base_name, benchmark, resulttype, faults),
by = c("base_name", "benchmark", "resulttype"),
suffix = c("", "_baseline")
) |>
filter(!is.na(faults_baseline), faults_baseline > 0) |>
mutate(ratio = faults / faults_baseline)
if (nrow(ratios) == 0) {
stop("No ratios computed (missing baseline or zero values)")
}
# Pivot to get aot and interp ratios side by side
ratio_wide <- ratios |>
select(base_name, benchmark, resulttype, variant, ratio) |>
pivot_wider(names_from = variant, values_from = ratio) |>
filter(!is.na(aot), !is.na(interp))
if (nrow(ratio_wide) == 0) {
stop("No paired aot/interp ratios found")
}
# Compute correlation
cor_result <- cor(ratio_wide$aot, ratio_wide$interp, method = "pearson")
cat(sprintf("Pearson correlation: %.4f\n", cor_result))
# Create plot
plot <- ggplot(
ratio_wide,
aes(x = aot, y = interp, color = base_name, shape = resulttype)
) +
geom_point(size = 3, alpha = 0.7) +
scale_x_log10(name = "AOT / C Ratio") +
scale_y_log10(name = "Interpreter / C Ratio") +
labs(
title = sprintf("Ratio Correlation (r = %.4f)", cor_result),
color = "Experiment",
shape = "Marker"
) +
theme_minimal() +
theme(
legend.position = "right",
plot.title = element_text(size = 14, face = "bold")
)
ggsave(
"injections/ratio_correlation_customized.svg",
plot = plot,
width = 10,
height = 8
)
print("Saved ratio_correlation_customized.svg")
+6 -3
View File
@@ -631,10 +631,13 @@ my %handlers = (
# Need to know which chart uses which datafile
my @faults_charts =
grep { /heatmap|scatter|sankey|instr_fault_correlation/ }
@selected_charts;
grep {
/_heatmap|_scatter|_sankey|_instr_fault_correlation|_instr_fault_rate_heatmap|fault_rates_per_instruction/
} @selected_charts;
my @resultsdata_charts =
grep { /result|combined_comparison|combined_ratio/ } @selected_charts;
grep {
/_result|_fault_count_comparison|_ratio_comparison|_fault_count_correlation/
} @selected_charts;
# Select if faults.csv or a filtered variant should be used
my $faults_csv;
+2 -1
View File
@@ -39,7 +39,8 @@
#endif
#ifdef TARGET_LINUX
#include "stdio.h"
#include <stdio.h>
#include <string.h>
#define MAIN int main(int argc, char *argv[])
#define PRINT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
#define PRINT_ERROR(fmt, ...) \
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/**
* @file lib_export.h
*
*/
#ifndef _LIB_EXPORT_H_
#define _LIB_EXPORT_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct NativeSymbol {
const char *symbol;
void *func_ptr;
const char *signature;
/* attachment which can be retrieved in native API by
calling wasm_runtime_get_function_attachment(exec_env) */
void *attachment;
} NativeSymbol;
/* clang-format off */
#define EXPORT_WASM_API(symbol) \
{ #symbol, (void *)symbol, NULL, NULL }
#define EXPORT_WASM_API2(symbol) \
{ #symbol, (void *)symbol##_wrapper, NULL, NULL }
#define EXPORT_WASM_API_WITH_SIG(symbol, signature) \
{ #symbol, (void *)symbol, signature, NULL }
#define EXPORT_WASM_API_WITH_SIG2(symbol, signature) \
{ #symbol, (void *)symbol##_wrapper, signature, NULL }
#define EXPORT_WASM_API_WITH_ATT(symbol, signature, attachment) \
{ #symbol, (void *)symbol, signature, attachment }
#define EXPORT_WASM_API_WITH_ATT2(symbol, signature, attachment) \
{ #symbol, (void *)symbol##_wrapper, signature, attachment }
/* clang-format on */
/**
* Get the exported APIs of base lib
*
* @param p_base_lib_apis return the exported API array of base lib
*
* @return the number of the exported API
*/
uint32_t get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
#ifdef __cplusplus
}
#endif
#endif /* end of _LIB_EXPORT_H_ */
+6 -12
View File
@@ -3,10 +3,6 @@
#include "bh_platform.h"
#include "__WASM_ARRAY_FILE__"
#ifdef TARGET_LINUX
#include <stdio.h>
#include <string.h>
#endif
// FAIL* instrumentation symbols
void fail_start_trace(void) {}
@@ -38,12 +34,12 @@ void host_print(wasm_exec_env_t exec_env, const char *msg) {
// Another bump allocator
#define WASM_LINEAR_MEMORY_SIZE (64 * 1024) // Need to match --initial-memory?
#define RUNTIME_POOL_SIZE (2 * 1024 * 1024)
#define LINEAR_POOL_SIZE (WASM_LINEAR_MEMORY_SIZE + 512 * 1024)
#define RUNTIME_POOL_SIZE (2 * 1024 * 1024)
#define LINEAR_POOL_SIZE (WASM_LINEAR_MEMORY_SIZE + 512 * 1024)
#define ALIGNMENT 8
typedef struct {
char *buf;
char *buf;
size_t size;
size_t offset;
} BumpPool;
@@ -60,13 +56,11 @@ static char linear_pool_buf[LINEAR_POOL_SIZE];
// mem_alloc_usage_t: 0 = Alloc_For_Runtime, 1 = Alloc_For_LinearMemory
static BumpPool pools[] = {
{ runtime_pool_buf, RUNTIME_POOL_SIZE, 0 },
{ linear_pool_buf, LINEAR_POOL_SIZE, 0 },
{runtime_pool_buf, RUNTIME_POOL_SIZE, 0},
{linear_pool_buf, LINEAR_POOL_SIZE, 0},
};
static size_t align_up(size_t x, size_t a) {
return (x + a - 1) & ~(a - 1);
}
static size_t align_up(size_t x, size_t a) { return (x + a - 1) & ~(a - 1); }
static size_t alloc_size(void *ptr) {
size_t header_size = align_up(sizeof(size_t), ALIGNMENT);
+264 -314
View File
@@ -12,9 +12,9 @@
#ifndef _WASM_EXPORT_H
#define _WASM_EXPORT_H
#include <stdint.h>
#include <stdbool.h>
#include "lib_export.h"
#include <stdbool.h>
#include <stdint.h>
#ifndef WASM_RUNTIME_API_EXTERN
#if defined(_MSC_BUILD)
@@ -36,20 +36,20 @@ extern "C" {
#define get_module_inst(exec_env) wasm_runtime_get_module_inst(exec_env)
#define validate_app_addr(offset, size) \
wasm_runtime_validate_app_addr(module_inst, offset, size)
#define validate_app_addr(offset, size) \
wasm_runtime_validate_app_addr(module_inst, offset, size)
#define validate_app_str_addr(offset) \
wasm_runtime_validate_app_str_addr(module_inst, offset)
#define validate_app_str_addr(offset) \
wasm_runtime_validate_app_str_addr(module_inst, offset)
#define addr_app_to_native(offset) \
wasm_runtime_addr_app_to_native(module_inst, offset)
#define addr_app_to_native(offset) \
wasm_runtime_addr_app_to_native(module_inst, offset)
#define addr_native_to_app(ptr) \
wasm_runtime_addr_native_to_app(module_inst, ptr)
#define addr_native_to_app(ptr) \
wasm_runtime_addr_native_to_app(module_inst, ptr)
#define module_malloc(size, p_native_addr) \
wasm_runtime_module_malloc(module_inst, size, p_native_addr)
#define module_malloc(size, p_native_addr) \
wasm_runtime_module_malloc(module_inst, size, p_native_addr)
#define module_free(offset) wasm_runtime_module_free(module_inst, offset)
@@ -68,10 +68,10 @@ typedef struct WASMModuleCommon *wasm_module_t;
#endif
typedef enum {
WASM_IMPORT_EXPORT_KIND_FUNC,
WASM_IMPORT_EXPORT_KIND_TABLE,
WASM_IMPORT_EXPORT_KIND_MEMORY,
WASM_IMPORT_EXPORT_KIND_GLOBAL
WASM_IMPORT_EXPORT_KIND_FUNC,
WASM_IMPORT_EXPORT_KIND_TABLE,
WASM_IMPORT_EXPORT_KIND_MEMORY,
WASM_IMPORT_EXPORT_KIND_GLOBAL
} wasm_import_export_kind_t;
struct WASMFuncType;
@@ -91,27 +91,27 @@ typedef struct WASMMemory WASMMemoryType;
typedef WASMMemoryType *wasm_memory_type_t;
typedef struct wasm_import_t {
const char *module_name;
const char *name;
wasm_import_export_kind_t kind;
bool linked;
union {
wasm_func_type_t func_type;
wasm_table_type_t table_type;
wasm_global_type_t global_type;
wasm_memory_type_t memory_type;
} u;
const char *module_name;
const char *name;
wasm_import_export_kind_t kind;
bool linked;
union {
wasm_func_type_t func_type;
wasm_table_type_t table_type;
wasm_global_type_t global_type;
wasm_memory_type_t memory_type;
} u;
} wasm_import_t;
typedef struct wasm_export_t {
const char *name;
wasm_import_export_kind_t kind;
union {
wasm_func_type_t func_type;
wasm_table_type_t table_type;
wasm_global_type_t global_type;
wasm_memory_type_t memory_type;
} u;
const char *name;
wasm_import_export_kind_t kind;
union {
wasm_func_type_t func_type;
wasm_table_type_t table_type;
wasm_global_type_t global_type;
wasm_memory_type_t memory_type;
} u;
} wasm_export_t;
/* Instantiated WASM module */
@@ -127,27 +127,27 @@ struct WASMMemoryInstance;
typedef struct WASMMemoryInstance *wasm_memory_inst_t;
typedef struct wasm_frame_t {
/* wasm_instance_t */
void *instance;
uint32_t module_offset;
uint32_t func_index;
uint32_t func_offset;
const char *func_name_wp;
/* wasm_instance_t */
void *instance;
uint32_t module_offset;
uint32_t func_index;
uint32_t func_offset;
const char *func_name_wp;
uint32_t *sp;
uint8_t *frame_ref;
uint32_t *lp;
uint32_t *sp;
uint8_t *frame_ref;
uint32_t *lp;
} WASMCApiFrame;
/* WASM section */
typedef struct wasm_section_t {
struct wasm_section_t *next;
/* section type */
int section_type;
/* section body, not include type and size */
uint8_t *section_body;
/* section body size */
uint32_t section_body_size;
struct wasm_section_t *next;
/* section type */
int section_type;
/* section body, not include type and size */
uint8_t *section_body;
/* section body size */
uint32_t section_body_size;
} wasm_section_t, aot_section_t, *wasm_section_list_t, *aot_section_list_t;
/* Execution environment, e.g. stack info */
@@ -159,123 +159,123 @@ typedef struct WASMSharedHeap *wasm_shared_heap_t;
/* Package Type */
typedef enum {
Wasm_Module_Bytecode = 0,
Wasm_Module_AoT,
Package_Type_Unknown = 0xFFFF
Wasm_Module_Bytecode = 0,
Wasm_Module_AoT,
Package_Type_Unknown = 0xFFFF
} package_type_t;
#ifndef MEM_ALLOC_OPTION_DEFINED
#define MEM_ALLOC_OPTION_DEFINED
/* Memory allocator type */
typedef enum {
/* pool mode, allocate memory from user defined heap buffer */
Alloc_With_Pool = 0,
/* user allocator mode, allocate memory from user defined
malloc function */
Alloc_With_Allocator,
/* system allocator mode, allocate memory from system allocator,
or, platform's os_malloc function */
Alloc_With_System_Allocator,
/* pool mode, allocate memory from user defined heap buffer */
Alloc_With_Pool = 0,
/* user allocator mode, allocate memory from user defined
malloc function */
Alloc_With_Allocator,
/* system allocator mode, allocate memory from system allocator,
or, platform's os_malloc function */
Alloc_With_System_Allocator,
} mem_alloc_type_t;
typedef enum { Alloc_For_Runtime, Alloc_For_LinearMemory } mem_alloc_usage_t;
/* Memory allocator option */
typedef union MemAllocOption {
struct {
void *heap_buf;
uint32_t heap_size;
} pool;
struct {
/* the function signature is varied when
WASM_MEM_ALLOC_WITH_USER_DATA and
WASM_MEM_ALLOC_WITH_USAGE are defined */
void *malloc_func;
void *realloc_func;
void *free_func;
/* allocator user data, only used when
WASM_MEM_ALLOC_WITH_USER_DATA is defined */
void *user_data;
} allocator;
struct {
void *heap_buf;
uint32_t heap_size;
} pool;
struct {
/* the function signature is varied when
WASM_MEM_ALLOC_WITH_USER_DATA and
WASM_MEM_ALLOC_WITH_USAGE are defined */
void *malloc_func;
void *realloc_func;
void *free_func;
/* allocator user data, only used when
WASM_MEM_ALLOC_WITH_USER_DATA is defined */
void *user_data;
} allocator;
} MemAllocOption;
#endif
/* Memory pool info */
typedef struct mem_alloc_info_t {
uint32_t total_size;
uint32_t total_free_size;
uint32_t highmark_size;
uint32_t total_size;
uint32_t total_free_size;
uint32_t highmark_size;
} mem_alloc_info_t;
/* Running mode of runtime and module instance*/
typedef enum RunningMode {
Mode_Interp = 1,
Mode_Fast_JIT,
Mode_LLVM_JIT,
Mode_Multi_Tier_JIT,
Mode_Interp = 1,
Mode_Fast_JIT,
Mode_LLVM_JIT,
Mode_Multi_Tier_JIT,
} RunningMode;
/* WASM runtime initialize arguments */
typedef struct RuntimeInitArgs {
mem_alloc_type_t mem_alloc_type;
MemAllocOption mem_alloc_option;
mem_alloc_type_t mem_alloc_type;
MemAllocOption mem_alloc_option;
const char *native_module_name;
NativeSymbol *native_symbols;
uint32_t n_native_symbols;
const char *native_module_name;
NativeSymbol *native_symbols;
uint32_t n_native_symbols;
/* maximum thread number, only used when
WASM_ENABLE_THREAD_MGR is defined */
uint32_t max_thread_num;
/* maximum thread number, only used when
WASM_ENABLE_THREAD_MGR is defined */
uint32_t max_thread_num;
/* Debug settings, only used when
WASM_ENABLE_DEBUG_INTERP != 0 */
char ip_addr[128];
int unused; /* was platform_port */
int instance_port;
/* Debug settings, only used when
WASM_ENABLE_DEBUG_INTERP != 0 */
char ip_addr[128];
int unused; /* was platform_port */
int instance_port;
/* Fast JIT code cache size */
uint32_t fast_jit_code_cache_size;
/* Fast JIT code cache size */
uint32_t fast_jit_code_cache_size;
/* Default GC heap size */
uint32_t gc_heap_size;
/* Default GC heap size */
uint32_t gc_heap_size;
/* Default running mode of the runtime */
RunningMode running_mode;
/* Default running mode of the runtime */
RunningMode running_mode;
/* LLVM JIT opt and size level */
uint32_t llvm_jit_opt_level;
uint32_t llvm_jit_size_level;
/* Segue optimization flags for LLVM JIT */
uint32_t segue_flags;
/**
* If enabled
* - llvm-jit will output a jitdump file for `perf inject`
* - aot will output a perf-${pid}.map for `perf record`
* - fast-jit. TBD
* - multi-tier-jit. TBD
* - interpreter. TBD
*/
bool enable_linux_perf;
/* LLVM JIT opt and size level */
uint32_t llvm_jit_opt_level;
uint32_t llvm_jit_size_level;
/* Segue optimization flags for LLVM JIT */
uint32_t segue_flags;
/**
* If enabled
* - llvm-jit will output a jitdump file for `perf inject`
* - aot will output a perf-${pid}.map for `perf record`
* - fast-jit. TBD
* - multi-tier-jit. TBD
* - interpreter. TBD
*/
bool enable_linux_perf;
} RuntimeInitArgs;
#ifndef LOAD_ARGS_OPTION_DEFINED
#define LOAD_ARGS_OPTION_DEFINED
typedef struct LoadArgs {
char *name;
/* This option is only used by the Wasm C API (see wasm_c_api.h) */
bool clone_wasm_binary;
/* False by default, used by AOT/wasm loader only.
If true, the AOT/wasm loader creates a copy of some module fields (e.g.
const strings), making it possible to free the wasm binary buffer after
loading. */
bool wasm_binary_freeable;
char *name;
/* This option is only used by the Wasm C API (see wasm_c_api.h) */
bool clone_wasm_binary;
/* False by default, used by AOT/wasm loader only.
If true, the AOT/wasm loader creates a copy of some module fields (e.g.
const strings), making it possible to free the wasm binary buffer after
loading. */
bool wasm_binary_freeable;
/* false by default, if true, don't resolve the symbols yet. The
wasm_runtime_load_ex has to be followed by a wasm_runtime_resolve_symbols
call */
bool no_resolve;
/* TODO: more fields? */
/* false by default, if true, don't resolve the symbols yet. The
wasm_runtime_load_ex has to be followed by a wasm_runtime_resolve_symbols
call */
bool no_resolve;
/* TODO: more fields? */
} LoadArgs;
#endif /* LOAD_ARGS_OPTION_DEFINED */
@@ -283,9 +283,9 @@ typedef struct LoadArgs {
#define INSTANTIATION_ARGS_OPTION_DEFINED
/* WASM module instantiation arguments */
typedef struct InstantiationArgs {
uint32_t default_stack_size;
uint32_t host_managed_heap_size;
uint32_t max_memory_pages;
uint32_t default_stack_size;
uint32_t host_managed_heap_size;
uint32_t max_memory_pages;
} InstantiationArgs;
#endif /* INSTANTIATION_ARGS_OPTION_DEFINED */
@@ -295,13 +295,13 @@ struct InstantiationArgs2;
#define WASM_VALKIND_T_DEFINED
typedef uint8_t wasm_valkind_t;
enum wasm_valkind_enum {
WASM_I32,
WASM_I64,
WASM_F32,
WASM_F64,
WASM_V128,
WASM_EXTERNREF = 128,
WASM_FUNCREF,
WASM_I32,
WASM_I64,
WASM_F32,
WASM_F64,
WASM_V128,
WASM_EXTERNREF = 128,
WASM_FUNCREF,
};
#endif
@@ -310,48 +310,48 @@ enum wasm_valkind_enum {
struct wasm_ref_t;
typedef struct wasm_val_t {
wasm_valkind_t kind;
uint8_t _paddings[7];
union {
/* also represent a function index */
int32_t i32;
int64_t i64;
float f32;
double f64;
/* represent a foreign object, aka externref in .wat */
uintptr_t foreign;
struct wasm_ref_t *ref;
} of;
wasm_valkind_t kind;
uint8_t _paddings[7];
union {
/* also represent a function index */
int32_t i32;
int64_t i64;
float f32;
double f64;
/* represent a foreign object, aka externref in .wat */
uintptr_t foreign;
struct wasm_ref_t *ref;
} of;
} wasm_val_t;
#endif
/* Global instance*/
typedef struct wasm_global_inst_t {
wasm_valkind_t kind;
bool is_mutable;
void *global_data;
wasm_valkind_t kind;
bool is_mutable;
void *global_data;
} wasm_global_inst_t;
/* Table instance*/
typedef struct wasm_table_inst_t {
wasm_valkind_t elem_kind;
uint32_t cur_size;
uint32_t max_size;
/* represents the elements of the table, for internal use only */
void *elems;
wasm_valkind_t elem_kind;
uint32_t cur_size;
uint32_t max_size;
/* represents the elements of the table, for internal use only */
void *elems;
} wasm_table_inst_t;
typedef enum {
WASM_LOG_LEVEL_FATAL = 0,
WASM_LOG_LEVEL_ERROR = 1,
WASM_LOG_LEVEL_WARNING = 2,
WASM_LOG_LEVEL_DEBUG = 3,
WASM_LOG_LEVEL_VERBOSE = 4
WASM_LOG_LEVEL_FATAL = 0,
WASM_LOG_LEVEL_ERROR = 1,
WASM_LOG_LEVEL_WARNING = 2,
WASM_LOG_LEVEL_DEBUG = 3,
WASM_LOG_LEVEL_VERBOSE = 4
} log_level_t;
typedef struct SharedHeapInitArgs {
uint32_t size;
void *pre_allocated_addr;
uint32_t size;
void *pre_allocated_addr;
} SharedHeapInitArgs;
/**
@@ -361,8 +361,7 @@ typedef struct SharedHeapInitArgs {
*
* @return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_init(void);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_init(void);
/**
* Initialize the WASM runtime environment, WASM running mode,
@@ -373,16 +372,14 @@ wasm_runtime_init(void);
*
* @return return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_full_init(RuntimeInitArgs *init_args);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_full_init(RuntimeInitArgs *init_args);
/**
* Set the log level. To be called after the runtime is initialized.
*
* @param level the log level to set
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_log_level(log_level_t level);
WASM_RUNTIME_API_EXTERN void wasm_runtime_set_log_level(log_level_t level);
/**
* Query whether a certain running mode is supported for the runtime
@@ -409,8 +406,7 @@ wasm_runtime_set_default_running_mode(RunningMode running_mode);
/**
* Destroy the WASM runtime environment.
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_destroy(void);
WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy(void);
/**
* Allocate memory from runtime memory environment.
@@ -419,8 +415,7 @@ wasm_runtime_destroy(void);
*
* @return the pointer to memory allocated
*/
WASM_RUNTIME_API_EXTERN void *
wasm_runtime_malloc(unsigned int size);
WASM_RUNTIME_API_EXTERN void *wasm_runtime_malloc(unsigned int size);
/**
* Reallocate memory from runtime memory environment
@@ -430,14 +425,13 @@ wasm_runtime_malloc(unsigned int size);
*
* @return the pointer to memory reallocated
*/
WASM_RUNTIME_API_EXTERN void *
wasm_runtime_realloc(void *ptr, unsigned int size);
WASM_RUNTIME_API_EXTERN void *wasm_runtime_realloc(void *ptr,
unsigned int size);
/*
* Free memory to runtime memory environment.
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_free(void *ptr);
WASM_RUNTIME_API_EXTERN void wasm_runtime_free(void *ptr);
/*
* Get memory info, only pool mode is supported now.
@@ -453,8 +447,8 @@ wasm_runtime_get_mem_alloc_info(mem_alloc_info_t *mem_alloc_info);
*
* @return the package type, return Package_Type_Unknown if the type is unknown
*/
WASM_RUNTIME_API_EXTERN package_type_t
get_package_type(const uint8_t *buf, uint32_t size);
WASM_RUNTIME_API_EXTERN package_type_t get_package_type(const uint8_t *buf,
uint32_t size);
/**
* Get the package type of a buffer (same as get_package_type).
@@ -517,8 +511,8 @@ wasm_runtime_get_current_package_version(package_type_t package_type);
*
* @return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_is_xip_file(const uint8_t *buf, uint32_t size);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_is_xip_file(const uint8_t *buf,
uint32_t size);
/**
* Callback to load a module file into a buffer in multi-module feature
@@ -588,9 +582,8 @@ wasm_runtime_find_module_registered(const char *module_name);
*
* @return return WASM module loaded, NULL if failed
*/
WASM_RUNTIME_API_EXTERN wasm_module_t
wasm_runtime_load(uint8_t *buf, uint32_t size, char *error_buf,
uint32_t error_buf_size);
WASM_RUNTIME_API_EXTERN wasm_module_t wasm_runtime_load(
uint8_t *buf, uint32_t size, char *error_buf, uint32_t error_buf_size);
/**
* Load a WASM module with specified load argument.
@@ -603,8 +596,7 @@ wasm_runtime_load_ex(uint8_t *buf, uint32_t size, const LoadArgs *args,
* Resolve symbols for a previously loaded WASM module. Only useful when the
* module was loaded with LoadArgs::no_resolve set to true
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_resolve_symbols(wasm_module_t module);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_resolve_symbols(wasm_module_t module);
/**
* Load a WASM module from a specified WASM or AOT section list.
*
@@ -624,8 +616,7 @@ wasm_runtime_load_from_sections(wasm_section_list_t section_list, bool is_aot,
*
* @param module the module to be unloaded
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_unload(wasm_module_t module);
WASM_RUNTIME_API_EXTERN void wasm_runtime_unload(wasm_module_t module);
/**
* Get the module hash of a WASM module, currently only available on
@@ -635,8 +626,7 @@ wasm_runtime_unload(wasm_module_t module);
*
* @return the module hash of the WASM module
*/
char *
wasm_runtime_get_module_hash(wasm_module_t module);
char *wasm_runtime_get_module_hash(wasm_module_t module);
/**
* Set WASI parameters.
@@ -671,13 +661,11 @@ wasm_runtime_get_module_hash(wasm_module_t module);
* INVALID_HANDLE_VALUE on Windows), the platform default
* for STDERR is used.
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_wasi_args_ex(wasm_module_t module, const char *dir_list[],
uint32_t dir_count, const char *map_dir_list[],
uint32_t map_dir_count, const char *env[],
uint32_t env_count, char *argv[], int argc,
int64_t stdinfd, int64_t stdoutfd,
int64_t stderrfd);
WASM_RUNTIME_API_EXTERN void wasm_runtime_set_wasi_args_ex(
wasm_module_t module, const char *dir_list[], uint32_t dir_count,
const char *map_dir_list[], uint32_t map_dir_count, const char *env[],
uint32_t env_count, char *argv[], int argc, int64_t stdinfd,
int64_t stdoutfd, int64_t stderrfd);
/**
* Set WASI parameters.
@@ -718,11 +706,9 @@ wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module,
*
* @return return the instantiated WASM module instance, NULL if failed
*/
WASM_RUNTIME_API_EXTERN wasm_module_inst_t
wasm_runtime_instantiate(const wasm_module_t module,
uint32_t default_stack_size,
uint32_t host_managed_heap_size, char *error_buf,
uint32_t error_buf_size);
WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate(
const wasm_module_t module, uint32_t default_stack_size,
uint32_t host_managed_heap_size, char *error_buf, uint32_t error_buf_size);
/**
* Instantiate a WASM module, with specified instantiation arguments
@@ -730,10 +716,9 @@ wasm_runtime_instantiate(const wasm_module_t module,
* Same as wasm_runtime_instantiate, but it also allows overwriting maximum
* memory
*/
WASM_RUNTIME_API_EXTERN wasm_module_inst_t
wasm_runtime_instantiate_ex(const wasm_module_t module,
const InstantiationArgs *args, char *error_buf,
uint32_t error_buf_size);
WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex(
const wasm_module_t module, const InstantiationArgs *args, char *error_buf,
uint32_t error_buf_size);
/**
* Create an InstantiationArgs2 object with default parameters.
@@ -768,23 +753,16 @@ WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_wasi_arg(struct InstantiationArgs2 *p,
char *argv[], int argc);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_wasi_env(struct InstantiationArgs2 *p,
const char *env[],
uint32_t env_count);
WASM_RUNTIME_API_EXTERN void wasm_runtime_instantiation_args_set_wasi_env(
struct InstantiationArgs2 *p, const char *env[], uint32_t env_count);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_wasi_dir(struct InstantiationArgs2 *p,
const char *dir_list[],
uint32_t dir_count,
const char *map_dir_list[],
uint32_t map_dir_count);
WASM_RUNTIME_API_EXTERN void wasm_runtime_instantiation_args_set_wasi_dir(
struct InstantiationArgs2 *p, const char *dir_list[], uint32_t dir_count,
const char *map_dir_list[], uint32_t map_dir_count);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_wasi_stdio(struct InstantiationArgs2 *p,
int64_t stdinfd,
int64_t stdoutfd,
int64_t stderrfd);
WASM_RUNTIME_API_EXTERN void wasm_runtime_instantiation_args_set_wasi_stdio(
struct InstantiationArgs2 *p, int64_t stdinfd, int64_t stdoutfd,
int64_t stderrfd);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_wasi_addr_pool(struct InstantiationArgs2 *p,
@@ -802,10 +780,9 @@ wasm_runtime_instantiation_args_set_wasi_ns_lookup_pool(
* Same as wasm_runtime_instantiate_ex, but this version takes
* InstantiationArgs2, which can be extended without breaking the ABI.
*/
WASM_RUNTIME_API_EXTERN wasm_module_inst_t
wasm_runtime_instantiate_ex2(const wasm_module_t module,
const struct InstantiationArgs2 *args,
char *error_buf, uint32_t error_buf_size);
WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex2(
const wasm_module_t module, const struct InstantiationArgs2 *args,
char *error_buf, uint32_t error_buf_size);
/**
* Set the running mode of a WASM module instance, override the
@@ -879,9 +856,8 @@ wasm_runtime_get_wasi_exit_code(wasm_module_inst_t module_inst);
*
* @return the function instance found, NULL if not found
*/
WASM_RUNTIME_API_EXTERN wasm_function_inst_t
wasm_runtime_lookup_function(const wasm_module_inst_t module_inst,
const char *name);
WASM_RUNTIME_API_EXTERN wasm_function_inst_t wasm_runtime_lookup_function(
const wasm_module_inst_t module_inst, const char *name);
/**
* Get parameter count of the function instance
@@ -891,9 +867,8 @@ wasm_runtime_lookup_function(const wasm_module_inst_t module_inst,
*
* @return the parameter count of the function instance
*/
WASM_RUNTIME_API_EXTERN uint32_t
wasm_func_get_param_count(const wasm_function_inst_t func_inst,
const wasm_module_inst_t module_inst);
WASM_RUNTIME_API_EXTERN uint32_t wasm_func_get_param_count(
const wasm_function_inst_t func_inst, const wasm_module_inst_t module_inst);
/**
* Get result count of the function instance
@@ -903,9 +878,8 @@ wasm_func_get_param_count(const wasm_function_inst_t func_inst,
*
* @return the result count of the function instance
*/
WASM_RUNTIME_API_EXTERN uint32_t
wasm_func_get_result_count(const wasm_function_inst_t func_inst,
const wasm_module_inst_t module_inst);
WASM_RUNTIME_API_EXTERN uint32_t wasm_func_get_result_count(
const wasm_function_inst_t func_inst, const wasm_module_inst_t module_inst);
/**
* Get parameter types of the function instance
@@ -940,9 +914,8 @@ wasm_func_get_result_types(const wasm_function_inst_t func_inst,
* @return the execution environment, NULL if failed, e.g. invalid
* stack size is passed
*/
WASM_RUNTIME_API_EXTERN wasm_exec_env_t
wasm_runtime_create_exec_env(wasm_module_inst_t module_inst,
uint32_t stack_size);
WASM_RUNTIME_API_EXTERN wasm_exec_env_t wasm_runtime_create_exec_env(
wasm_module_inst_t module_inst, uint32_t stack_size);
/**
* Destroy the execution environment.
@@ -1018,9 +991,8 @@ wasm_runtime_get_exec_env_singleton(wasm_module_inst_t module_inst);
*
* @return debug port if success, 0 otherwise.
*/
WASM_RUNTIME_API_EXTERN uint32_t
wasm_runtime_start_debug_instance_with_port(wasm_exec_env_t exec_env,
int32_t port);
WASM_RUNTIME_API_EXTERN uint32_t wasm_runtime_start_debug_instance_with_port(
wasm_exec_env_t exec_env, int32_t port);
/**
* Same as wasm_runtime_start_debug_instance_with_port(env, -1).
@@ -1040,20 +1012,17 @@ wasm_runtime_start_debug_instance(wasm_exec_env_t exec_env);
*
* @return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_init_thread_env(void);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_init_thread_env(void);
/**
* Destroy the thread environment
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_destroy_thread_env(void);
WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_thread_env(void);
/**
* Whether the thread environment is initialized
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_thread_env_inited(void);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_thread_env_inited(void);
/**
* Get WASM module instance from execution environment
@@ -1088,9 +1057,8 @@ wasm_runtime_set_module_inst(wasm_exec_env_t exec_env,
*
* @return The memory instance if found, NULL otherwise
*/
WASM_RUNTIME_API_EXTERN wasm_memory_inst_t
wasm_runtime_lookup_memory(const wasm_module_inst_t module_inst,
const char *name);
WASM_RUNTIME_API_EXTERN wasm_memory_inst_t wasm_runtime_lookup_memory(
const wasm_module_inst_t module_inst, const char *name);
/**
* @brief Get the default memory instance
@@ -1171,8 +1139,8 @@ wasm_memory_get_base_address(const wasm_memory_inst_t memory_inst);
*
* @return True if successful, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_memory_enlarge(wasm_memory_inst_t memory_inst, uint64_t inc_page_count);
WASM_RUNTIME_API_EXTERN bool wasm_memory_enlarge(wasm_memory_inst_t memory_inst,
uint64_t inc_page_count);
/**
* Call the given WASM function of a WASM module instance with
@@ -1409,9 +1377,8 @@ wasm_runtime_is_bounds_checks_enabled(wasm_module_inst_t module_inst);
* it is not an absolute address.
* Return non-zero if success, zero if failed.
*/
WASM_RUNTIME_API_EXTERN uint64_t
wasm_runtime_module_malloc(wasm_module_inst_t module_inst, uint64_t size,
void **p_native_addr);
WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_module_malloc(
wasm_module_inst_t module_inst, uint64_t size, void **p_native_addr);
/**
* Free memory to the heap of WASM module instance
@@ -1435,9 +1402,8 @@ wasm_runtime_module_free(wasm_module_inst_t module_inst, uint64_t ptr);
* it is not an absolute address.
* Return non-zero if success, zero if failed.
*/
WASM_RUNTIME_API_EXTERN uint64_t
wasm_runtime_module_dup_data(wasm_module_inst_t module_inst, const char *src,
uint64_t size);
WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_module_dup_data(
wasm_module_inst_t module_inst, const char *src, uint64_t size);
/**
* Validate the app address, check whether it belongs to WASM module
@@ -1516,9 +1482,8 @@ wasm_runtime_addr_app_to_native(wasm_module_inst_t module_inst,
*
* @return the app address converted
*/
WASM_RUNTIME_API_EXTERN uint64_t
wasm_runtime_addr_native_to_app(wasm_module_inst_t module_inst,
void *native_ptr);
WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_addr_native_to_app(
wasm_module_inst_t module_inst, void *native_ptr);
/**
* Get the app address range (relative address) that a app address belongs to
@@ -1530,11 +1495,9 @@ wasm_runtime_addr_native_to_app(wasm_module_inst_t module_inst,
*
* @return true if success, false otherwise.
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_get_app_addr_range(wasm_module_inst_t module_inst,
uint64_t app_offset,
uint64_t *p_app_start_offset,
uint64_t *p_app_end_offset);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_get_app_addr_range(
wasm_module_inst_t module_inst, uint64_t app_offset,
uint64_t *p_app_start_offset, uint64_t *p_app_end_offset);
/**
* Get the native address range (absolute address) that a native address
@@ -1549,11 +1512,9 @@ wasm_runtime_get_app_addr_range(wasm_module_inst_t module_inst,
*
* @return true if success, false otherwise.
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_get_native_addr_range(wasm_module_inst_t module_inst,
uint8_t *native_ptr,
uint8_t **p_native_start_addr,
uint8_t **p_native_end_addr);
WASM_RUNTIME_API_EXTERN bool wasm_runtime_get_native_addr_range(
wasm_module_inst_t module_inst, uint8_t *native_ptr,
uint8_t **p_native_start_addr, uint8_t **p_native_end_addr);
/**
* Get the number of import items for a WASM module
@@ -1631,9 +1592,8 @@ wasm_func_type_get_param_count(const wasm_func_type_t func_type);
*
* @return the kind of the parameter if successful, -1 otherwise
*/
WASM_RUNTIME_API_EXTERN wasm_valkind_t
wasm_func_type_get_param_valkind(const wasm_func_type_t func_type,
uint32_t param_index);
WASM_RUNTIME_API_EXTERN wasm_valkind_t wasm_func_type_get_param_valkind(
const wasm_func_type_t func_type, uint32_t param_index);
/**
* Get the number of results for a function type
@@ -1653,9 +1613,8 @@ wasm_func_type_get_result_count(const wasm_func_type_t func_type);
*
* @return the kind of the result if successful, -1 otherwise
*/
WASM_RUNTIME_API_EXTERN wasm_valkind_t
wasm_func_type_get_result_valkind(const wasm_func_type_t func_type,
uint32_t result_index);
WASM_RUNTIME_API_EXTERN wasm_valkind_t wasm_func_type_get_result_valkind(
const wasm_func_type_t func_type, uint32_t result_index);
/**
* Get the kind for a global type
@@ -1978,8 +1937,7 @@ typedef uintptr_t wasm_thread_t;
*
* @param num maximum thread num
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_max_thread_num(uint32_t num);
WASM_RUNTIME_API_EXTERN void wasm_runtime_set_max_thread_num(uint32_t num);
/**
* Spawn a new exec_env, the spawned exec_env
@@ -2022,8 +1980,8 @@ wasm_runtime_spawn_thread(wasm_exec_env_t exec_env, wasm_thread_t *tid,
*
* @return 0 if success, error number otherwise
*/
WASM_RUNTIME_API_EXTERN int32_t
wasm_runtime_join_thread(wasm_thread_t tid, void **retval);
WASM_RUNTIME_API_EXTERN int32_t wasm_runtime_join_thread(wasm_thread_t tid,
void **retval);
/**
* Map external object to an internal externref index: if the index
@@ -2076,8 +2034,8 @@ wasm_externref_set_cleanup(wasm_module_inst_t module_inst, void *extern_obj,
*
* @return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_externref_ref2obj(uint32_t externref_idx, void **p_extern_obj);
WASM_RUNTIME_API_EXTERN bool wasm_externref_ref2obj(uint32_t externref_idx,
void **p_extern_obj);
/**
* Retain an extern object which is mapped to the internal externref
@@ -2088,8 +2046,7 @@ wasm_externref_ref2obj(uint32_t externref_idx, void **p_extern_obj);
* to retain
* @return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_externref_retain(uint32_t externref_idx);
WASM_RUNTIME_API_EXTERN bool wasm_externref_retain(uint32_t externref_idx);
/**
* Dump the call stack to stdout
@@ -2123,9 +2080,8 @@ wasm_runtime_get_call_stack_buf_size(wasm_exec_env_t exec_env);
* @return bytes dumped to the buffer, including the terminating null
* byte ('\0'), 0 means error and data in buf may be invalid
*/
WASM_RUNTIME_API_EXTERN uint32_t
wasm_runtime_dump_call_stack_to_buf(wasm_exec_env_t exec_env, char *buf,
uint32_t len);
WASM_RUNTIME_API_EXTERN uint32_t wasm_runtime_dump_call_stack_to_buf(
wasm_exec_env_t exec_env, char *buf, uint32_t len);
/**
* Get the size required to store the LLVM PGO profile data
@@ -2147,9 +2103,8 @@ wasm_runtime_get_pgo_prof_data_size(wasm_module_inst_t module_inst);
* @return bytes dumped to the buffer, 0 means error and data in buf
* may be invalid
*/
WASM_RUNTIME_API_EXTERN uint32_t
wasm_runtime_dump_pgo_prof_data_to_buf(wasm_module_inst_t module_inst,
char *buf, uint32_t len);
WASM_RUNTIME_API_EXTERN uint32_t wasm_runtime_dump_pgo_prof_data_to_buf(
wasm_module_inst_t module_inst, char *buf, uint32_t len);
/**
* Get a custom section by name
@@ -2200,8 +2155,8 @@ wasm_runtime_enlarge_memory(wasm_module_inst_t module_inst,
uint64_t inc_page_count);
typedef enum {
INTERNAL_ERROR,
MAX_SIZE_REACHED,
INTERNAL_ERROR,
MAX_SIZE_REACHED,
} enlarge_memory_error_reason_t;
typedef void (*enlarge_memory_error_callback_t)(
@@ -2212,8 +2167,7 @@ typedef void (*enlarge_memory_error_callback_t)(
/**
* Setup callback invoked when memory.grow fails
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_enlarge_mem_error_callback(
WASM_RUNTIME_API_EXTERN void wasm_runtime_set_enlarge_mem_error_callback(
const enlarge_memory_error_callback_t callback, void *user_data);
/*
@@ -2268,21 +2222,19 @@ wasm_runtime_set_enlarge_mem_error_callback(
* - The destructor is called only on the main instance.
*/
WASM_RUNTIME_API_EXTERN void *
wasm_runtime_create_context_key(void (*dtor)(wasm_module_inst_t inst,
void *ctx));
WASM_RUNTIME_API_EXTERN void *wasm_runtime_create_context_key(
void (*dtor)(wasm_module_inst_t inst, void *ctx));
WASM_RUNTIME_API_EXTERN void
wasm_runtime_destroy_context_key(void *key);
WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_context_key(void *key);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_context(wasm_module_inst_t inst, void *key, void *ctx);
WASM_RUNTIME_API_EXTERN void wasm_runtime_set_context(wasm_module_inst_t inst,
void *key, void *ctx);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_context_spread(wasm_module_inst_t inst, void *key, void *ctx);
WASM_RUNTIME_API_EXTERN void *
wasm_runtime_get_context(wasm_module_inst_t inst, void *key);
WASM_RUNTIME_API_EXTERN void *wasm_runtime_get_context(wasm_module_inst_t inst,
void *key);
/*
* wasm_runtime_begin_blocking_op/wasm_runtime_end_blocking_op
@@ -2419,9 +2371,8 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args);
* @param body The body of the shared heap chain to be appended.
* @return The new head of the shared heap chain. NULL if failed.
*/
WASM_RUNTIME_API_EXTERN wasm_shared_heap_t
wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head,
wasm_shared_heap_t body);
WASM_RUNTIME_API_EXTERN wasm_shared_heap_t wasm_runtime_chain_shared_heaps(
wasm_shared_heap_t head, wasm_shared_heap_t body);
/**
* This function unchains the shared heaps from the given head. If
@@ -2434,8 +2385,8 @@ wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head,
* @return The new head of the shared heap chain. Or the last shared heap in the
* chain if `entire_chain` is true.
*/
wasm_shared_heap_t
wasm_runtime_unchain_shared_heaps(wasm_shared_heap_t head, bool entire_chain);
wasm_shared_heap_t wasm_runtime_unchain_shared_heaps(wasm_shared_heap_t head,
bool entire_chain);
/**
* Reset shared heap chain. For each shared heap in the chain, if it is a
@@ -2482,9 +2433,8 @@ wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst);
* (when the wasm memory is 64-bit). Note that it is not an absolute address.
* Return non-zero if success, zero if failed.
*/
WASM_RUNTIME_API_EXTERN uint64_t
wasm_runtime_shared_heap_malloc(wasm_module_inst_t module_inst, uint64_t size,
void **p_native_addr);
WASM_RUNTIME_API_EXTERN uint64_t wasm_runtime_shared_heap_malloc(
wasm_module_inst_t module_inst, uint64_t size, void **p_native_addr);
/**
* Free the memory allocated from shared heap, or the non-preallocated shared