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

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

Issue 2348383003: [wasm] Support asm.js modules with a single function. (Closed)
Patch Set: fix Created 4 years, 3 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 | « src/asmjs/asm-wasm-builder.h ('k') | test/mjsunit/wasm/asm-wasm.js » ('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 00e304bbcb76edd7b89d4408b720cd434c9b2161..ac2585e6eaacc5453d317981309671a121c0ec22 100644
--- a/src/asmjs/asm-wasm-builder.cc
+++ b/src/asmjs/asm-wasm-builder.cc
@@ -90,9 +90,9 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
current_function_builder_ =
builder_->FunctionAt(foreign_init_function_index_);
current_function_builder_->SetExported();
- std::string raw_name = "__foreign_init__";
- current_function_builder_->SetName(raw_name.data(),
- static_cast<int>(raw_name.size()));
+ current_function_builder_->SetName(
+ AsmWasmBuilder::foreign_init_name,
+ static_cast<int>(strlen(AsmWasmBuilder::foreign_init_name)));
current_function_builder_->SetSignature(b.Build());
for (size_t pos = 0; pos < foreign_variables_.size(); ++pos) {
current_function_builder_->EmitGetLocal(static_cast<uint32_t>(pos));
@@ -551,6 +551,14 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
current_function_builder_->EmitGetLocal(
LookupOrInsertLocal(var, var_type));
}
+ } else if (scope_ == kExportScope) {
+ Variable* var = expr->var();
+ DCHECK(var->is_function());
+ uint32_t index = LookupOrInsertFunction(var);
+ builder_->FunctionAt(index)->SetExported();
+ builder_->FunctionAt(index)->SetName(
+ AsmWasmBuilder::single_function_name,
+ static_cast<int>(strlen(AsmWasmBuilder::single_function_name)));
}
}
@@ -1792,6 +1800,10 @@ ZoneBuffer* AsmWasmBuilder::Run(i::Handle<i::FixedArray>* foreign_args) {
impl.builder_->WriteTo(*buffer);
return buffer;
}
+
+const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
+const char* AsmWasmBuilder::single_function_name = "__single_function__";
+
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/asmjs/asm-wasm-builder.h ('k') | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698