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

Unified Diff: src/wasm/encoder.h

Issue 2280063002: [asm.js] (Re)use temporaries in asm->wasm conversion. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [asm.js] (Re)use temporaries in asm->wasm conversion. Created 4 years, 4 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.cc ('k') | src/wasm/encoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/encoder.h
diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h
index eb8aa64abde2f82bc7e39dfa2e37436dc05fb34d..50ec6e5eaf61d32ec1141aa3dc342d8d519f5205 100644
--- a/src/wasm/encoder.h
+++ b/src/wasm/encoder.h
@@ -136,12 +136,56 @@ class WasmFunctionBuilder : public ZoneObject {
private:
explicit WasmFunctionBuilder(WasmModuleBuilder* builder);
friend class WasmModuleBuilder;
+ friend class WasmTemporary;
WasmModuleBuilder* builder_;
LocalDeclEncoder locals_;
uint32_t signature_index_;
bool exported_;
ZoneVector<uint8_t> body_;
ZoneVector<char> name_;
+ ZoneVector<uint32_t> i32_temps_;
+ ZoneVector<uint32_t> i64_temps_;
+ ZoneVector<uint32_t> f32_temps_;
+ ZoneVector<uint32_t> f64_temps_;
+};
+
+class WasmTemporary {
+ public:
+ WasmTemporary(WasmFunctionBuilder* builder, LocalType type) {
+ switch (type) {
+ case kAstI32:
+ temporary_ = &builder->i32_temps_;
+ break;
+ case kAstI64:
+ temporary_ = &builder->i64_temps_;
+ break;
+ case kAstF32:
+ temporary_ = &builder->f32_temps_;
+ break;
+ case kAstF64:
+ temporary_ = &builder->f64_temps_;
+ break;
+ default:
+ UNREACHABLE();
+ temporary_ = nullptr;
+ }
+ if (temporary_->size() == 0) {
+ // Allocate a new temporary.
+ index_ = builder->AddLocal(type);
+ } else {
+ // Reuse a previous temporary.
+ index_ = temporary_->back();
+ temporary_->pop_back();
+ }
+ }
+ ~WasmTemporary() {
+ temporary_->push_back(index_); // return the temporary to the list.
+ }
+ uint32_t index() { return index_; }
+
+ private:
+ ZoneVector<uint32_t>* temporary_;
+ uint32_t index_;
};
// TODO(titzer): kill!
« no previous file with comments | « src/asmjs/asm-wasm-builder.cc ('k') | src/wasm/encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698