[asm.js] Cleanup vector use in WasmModuleBuilder.
R=clemensh@chromium.org Change-Id: Ifa9f0f510bc5b864ebba199603919adb6a35d3a1 Reviewed-on: https://chromium-review.googlesource.com/500267 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#45190}
This commit is contained in:
parent
17d1530d21
commit
d40c6abd17
@ -365,8 +365,7 @@ void AsmJsParser::ValidateModule() {
|
||||
module_builder_->MarkStartFunction(start);
|
||||
for (auto& global_import : global_imports_) {
|
||||
uint32_t import_index = module_builder_->AddGlobalImport(
|
||||
global_import.import_name.start(), global_import.import_name.length(),
|
||||
global_import.value_type);
|
||||
global_import.import_name, global_import.value_type);
|
||||
start->EmitWithI32V(kExprGetGlobal, import_index);
|
||||
start->EmitWithI32V(kExprSetGlobal, VarIndex(global_import.var_info));
|
||||
}
|
||||
@ -2150,9 +2149,8 @@ AsmType* AsmJsParser::ValidateCall() {
|
||||
if (it != function_info->import->cache.end()) {
|
||||
index = it->second;
|
||||
} else {
|
||||
index = module_builder_->AddImport(
|
||||
function_info->import->function_name.start(),
|
||||
function_info->import->function_name.length(), sig);
|
||||
index =
|
||||
module_builder_->AddImport(function_info->import->function_name, sig);
|
||||
function_info->import->cache[sig] = index;
|
||||
}
|
||||
current_function_builder_->AddAsmWasmOffset(call_pos, to_number_pos);
|
||||
|
@ -308,16 +308,16 @@ void WasmModuleBuilder::SetIndirectFunction(uint32_t indirect,
|
||||
indirect_functions_[indirect] = direct;
|
||||
}
|
||||
|
||||
uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length,
|
||||
uint32_t WasmModuleBuilder::AddImport(Vector<const char> name,
|
||||
FunctionSig* sig) {
|
||||
function_imports_.push_back({AddSignature(sig), name, name_length});
|
||||
function_imports_.push_back({AddSignature(sig), name.start(), name.length()});
|
||||
return static_cast<uint32_t>(function_imports_.size() - 1);
|
||||
}
|
||||
|
||||
uint32_t WasmModuleBuilder::AddGlobalImport(const char* name, int name_length,
|
||||
uint32_t WasmModuleBuilder::AddGlobalImport(Vector<const char> name,
|
||||
ValueType type) {
|
||||
global_imports_.push_back(
|
||||
{WasmOpcodes::ValueTypeCodeFor(type), name, name_length});
|
||||
{WasmOpcodes::ValueTypeCodeFor(type), name.start(), name.length()});
|
||||
return static_cast<uint32_t>(global_imports_.size() - 1);
|
||||
}
|
||||
|
||||
|
@ -260,17 +260,15 @@ class V8_EXPORT_PRIVATE WasmModuleBuilder : public ZoneObject {
|
||||
explicit WasmModuleBuilder(Zone* zone);
|
||||
|
||||
// Building methods.
|
||||
// TODO(mstarzinger): Refactor to take Vector<const char> instead.
|
||||
uint32_t AddImport(const char* name, int name_length, FunctionSig* sig);
|
||||
void SetImportName(uint32_t index, const char* name, int name_length) {
|
||||
function_imports_[index].name = name;
|
||||
function_imports_[index].name_length = name_length;
|
||||
uint32_t AddImport(Vector<const char> name, FunctionSig* sig);
|
||||
void SetImportName(uint32_t index, Vector<const char> name) {
|
||||
function_imports_[index].name = name.start();
|
||||
function_imports_[index].name_length = name.length();
|
||||
}
|
||||
WasmFunctionBuilder* AddFunction(FunctionSig* sig = nullptr);
|
||||
uint32_t AddGlobal(ValueType type, bool exported, bool mutability = true,
|
||||
const WasmInitExpr& init = WasmInitExpr());
|
||||
// TODO(mstarzinger): Refactor to take Vector<const char> instead.
|
||||
uint32_t AddGlobalImport(const char* name, int name_length, ValueType type);
|
||||
uint32_t AddGlobalImport(Vector<const char> name, ValueType type);
|
||||
void AddDataSegment(const byte* data, uint32_t size, uint32_t dest);
|
||||
uint32_t AddSignature(FunctionSig* sig);
|
||||
uint32_t AllocateIndirectFunctions(uint32_t count);
|
||||
|
Loading…
Reference in New Issue
Block a user