mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
Bug 1532689: Use a ModuleEnvironment pointer (instead of a reference) to work around a bindgen bug; r=sunfish
The structure layout was incorrectly computed because of the reference, meaning that the data located after the reference was incorrect. In particular, it means the minimal memory size wasn't correctly read. This works around it by using a pointer, and rename a few function parameters to make their role clearer. Differential Revision: https://phabricator.services.mozilla.com/D22139 --HG-- extra : rebase_source : 77d341968bd40df311b49aeeebe12437ca0d6c57
This commit is contained in:
parent
a0e5b5dae7
commit
216ad268c0
@ -247,40 +247,42 @@ static size_t globalToTlsOffset(size_t globalOffset) {
|
||||
|
||||
CraneliftModuleEnvironment::CraneliftModuleEnvironment(
|
||||
const ModuleEnvironment& env)
|
||||
: env(env), min_memory_length(env.minMemoryLength) {}
|
||||
: env(&env),
|
||||
min_memory_length(env.minMemoryLength)
|
||||
{}
|
||||
|
||||
TypeCode env_unpack(BD_ValType valType) {
|
||||
return TypeCode(UnpackTypeCodeType(PackedTypeCode(valType.packed)));
|
||||
}
|
||||
|
||||
const FuncTypeWithId* env_function_signature(
|
||||
const CraneliftModuleEnvironment* env, size_t funcIndex) {
|
||||
return env->env.funcTypes[funcIndex];
|
||||
const CraneliftModuleEnvironment* wrapper, size_t funcIndex) {
|
||||
return wrapper->env->funcTypes[funcIndex];
|
||||
}
|
||||
|
||||
size_t env_func_import_tls_offset(const CraneliftModuleEnvironment* env,
|
||||
size_t env_func_import_tls_offset(const CraneliftModuleEnvironment* wrapper,
|
||||
size_t funcIndex) {
|
||||
return globalToTlsOffset(env->env.funcImportGlobalDataOffsets[funcIndex]);
|
||||
return globalToTlsOffset(wrapper->env->funcImportGlobalDataOffsets[funcIndex]);
|
||||
}
|
||||
|
||||
bool env_func_is_import(const CraneliftModuleEnvironment* env,
|
||||
bool env_func_is_import(const CraneliftModuleEnvironment* wrapper,
|
||||
size_t funcIndex) {
|
||||
return env->env.funcIsImport(funcIndex);
|
||||
return wrapper->env->funcIsImport(funcIndex);
|
||||
}
|
||||
|
||||
const FuncTypeWithId* env_signature(const CraneliftModuleEnvironment* env,
|
||||
const FuncTypeWithId* env_signature(const CraneliftModuleEnvironment* wrapper,
|
||||
size_t funcTypeIndex) {
|
||||
return &env->env.types[funcTypeIndex].funcType();
|
||||
return &wrapper->env->types[funcTypeIndex].funcType();
|
||||
}
|
||||
|
||||
const TableDesc* env_table(const CraneliftModuleEnvironment* env,
|
||||
const TableDesc* env_table(const CraneliftModuleEnvironment* wrapper,
|
||||
size_t tableIndex) {
|
||||
return &env->env.tables[tableIndex];
|
||||
return &wrapper->env->tables[tableIndex];
|
||||
}
|
||||
|
||||
const GlobalDesc* env_global(const CraneliftModuleEnvironment* env,
|
||||
const GlobalDesc* env_global(const CraneliftModuleEnvironment* wrapper,
|
||||
size_t globalIndex) {
|
||||
return &env->env.globals[globalIndex];
|
||||
return &wrapper->env->globals[globalIndex];
|
||||
}
|
||||
|
||||
bool wasm::CraneliftCompileFunctions(const ModuleEnvironment& env,
|
||||
@ -332,8 +334,7 @@ bool wasm::CraneliftCompileFunctions(const ModuleEnvironment& env,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!code->codeRanges.emplaceBack(func.index, func.lineOrBytecode,
|
||||
offsets)) {
|
||||
if (!code->codeRanges.emplaceBack(func.index, lineOrBytecode, offsets)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ struct CraneliftStaticEnvironment {
|
||||
// contains.
|
||||
|
||||
struct CraneliftModuleEnvironment {
|
||||
const js::wasm::ModuleEnvironment& env;
|
||||
// This is a pointer and not a reference to work-around a bug in bindgen.
|
||||
const js::wasm::ModuleEnvironment* env;
|
||||
uint32_t min_memory_length;
|
||||
|
||||
// Not bindgen'd because it's inlined.
|
||||
@ -119,8 +120,8 @@ struct CraneliftMetadataEntry {
|
||||
MemoryAccess,
|
||||
SymbolicAccess
|
||||
} which;
|
||||
uint32_t offset;
|
||||
uint32_t srcLoc;
|
||||
uint32_t offset; // relative to the beginning of the function generated code
|
||||
uint32_t srcLoc; // relative to the beginning of the module bytecode
|
||||
size_t extra;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user