Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: src/asmjs/asm-wasm-builder.cc

Issue 2406133003: [wasm] Decouple function name and exported name in WasmFunctionBuilder (Closed)
Patch Set: Change interface to Vector<const char>; avoids size_t/int confusion Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-module-builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/asmjs/asm-wasm-builder.cc
diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc
index 47545876b1afc82170347375869d8693485c637f..1cb67edd6e0dbc28c14f5277e4b89d0afcf4f2cb 100644
--- a/src/asmjs/asm-wasm-builder.cc
+++ b/src/asmjs/asm-wasm-builder.cc
@@ -82,14 +82,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
++i) {
b.AddParam(i->type);
}
- foreign_init_function_->SetExported();
- std::string raw_name = "__foreign_init__";
- foreign_init_function_->SetName(
- AsmWasmBuilder::foreign_init_name,
- static_cast<int>(strlen(AsmWasmBuilder::foreign_init_name)));
-
- foreign_init_function_->SetName(raw_name.data(),
- static_cast<int>(raw_name.size()));
+ foreign_init_function_->ExportAs(
+ CStrVector(AsmWasmBuilder::foreign_init_name));
foreign_init_function_->SetSignature(b.Build());
for (size_t pos = 0; pos < foreign_variables_.size(); ++pos) {
foreign_init_function_->EmitGetLocal(static_cast<uint32_t>(pos));
@@ -564,10 +558,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
Variable* var = expr->var();
DCHECK(var->is_function());
WasmFunctionBuilder* function = LookupOrInsertFunction(var);
- function->SetExported();
- function->SetName(
- AsmWasmBuilder::single_function_name,
- static_cast<int>(strlen(AsmWasmBuilder::single_function_name)));
+ function->ExportAs(CStrVector(AsmWasmBuilder::single_function_name));
}
}
@@ -651,9 +642,9 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
const AstRawString* raw_name = name->AsRawPropertyName();
if (var->is_function()) {
WasmFunctionBuilder* function = LookupOrInsertFunction(var);
- function->SetExported();
- function->SetName(reinterpret_cast<const char*>(raw_name->raw_data()),
- raw_name->length());
+ function->Export();
+ function->SetName({reinterpret_cast<const char*>(raw_name->raw_data()),
+ raw_name->length()});
}
}
}
@@ -1822,8 +1813,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
entry = functions_.LookupOrInsert(v, ComputePointerHash(v),
ZoneAllocationPolicy(zone()));
function->SetName(
- reinterpret_cast<const char*>(v->raw_name()->raw_data()),
- v->raw_name()->length());
+ {reinterpret_cast<const char*>(v->raw_name()->raw_data()),
+ v->raw_name()->length()});
entry->value = function;
}
return (reinterpret_cast<WasmFunctionBuilder*>(entry->value));
« no previous file with comments | « no previous file | src/wasm/wasm-module-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698