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

Unified Diff: runtime/wasm-runtime.cpp

Issue 1938643002: Subzero, WASM: stop writing uninitialized data to .o file. Add timers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Make sanitizeAddress private. Created 4 years, 8 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/IceTimerTree.def » ('j') | src/WasmTranslator.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/wasm-runtime.cpp
diff --git a/runtime/wasm-runtime.cpp b/runtime/wasm-runtime.cpp
index 3ea82a0bace4fe926b01314ec47407603c4e4d11..37d5d9050506eccfad7203c22c293c4cfd39d93a 100644
--- a/runtime/wasm-runtime.cpp
+++ b/runtime/wasm-runtime.cpp
@@ -12,11 +12,14 @@
//
//===----------------------------------------------------------------------===//
+#include <algorithm>
#include <cassert>
#include <cmath>
+#include <iostream>
+#include <vector>
+
#include <errno.h>
#include <fcntl.h>
-#include <iostream>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
@@ -44,7 +47,7 @@ void trace() {}
#endif // WASM_TRACE_RUNTIME
extern "C" {
-extern char WASM_MEMORY[];
+char *WASM_MEMORY;
extern uint32_t WASM_DATA_SIZE;
extern uint32_t WASM_NUM_PAGES;
} // end of extern "C"
@@ -137,6 +140,8 @@ void __Sz_indirect_fail() {
abort();
}
+extern char WASM_DATA_INIT[];
+
void env$$abort() {
fprintf(stderr, "Aborting...\n");
abort();
@@ -217,6 +222,11 @@ extern int __szwasm_main(int, WasmPtr<WasmCharPtr>);
#define WASM_DEREF(Type, Index) (*WASM_REF(Type, Index))
int main(int argc, const char **argv) {
+ // Create the heap.
+ std::vector<char> WasmHeap(WASM_NUM_PAGES << PageSizeLog2);
+ WASM_MEMORY = &WasmHeap[0];
John 2016/04/30 04:11:55 WasmHeap->data()?
Eric Holk 2016/05/02 17:42:37 Done.
+ std::copy(WASM_DATA_INIT, WASM_DATA_INIT + WASM_DATA_SIZE, WasmHeap.begin());
+
// TODO (eholk): align these allocations correctly.
// Allocate space for the global data.
« no previous file with comments | « no previous file | src/IceTimerTree.def » ('j') | src/WasmTranslator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698