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

Unified Diff: src/wasm/wasm-module.h

Issue 2381393002: [wasm] further simplification of WasmCompiledModule (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 | « no previous file | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.h
diff --git a/src/wasm/wasm-module.h b/src/wasm/wasm-module.h
index 8cf5501efb0274afa7018c2964e8001c8a36c390..c3ccf619a979f00ed6d3a7cc0c82c64d76cb0bbd 100644
--- a/src/wasm/wasm-module.h
+++ b/src/wasm/wasm-module.h
@@ -374,19 +374,6 @@ class WasmCompiledModule : public FixedArray {
#define WCM_SMALL_NUMBER(TYPE, NAME) \
TYPE NAME() const { \
return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \
- } \
- \
- void set_##NAME(TYPE value) { \
- set(kID_##NAME, Smi::FromInt(static_cast<int>(value))); \
- }
-
-#define WCM_LARGE_NUMBER(TYPE, NAME) \
- TYPE NAME() const { \
- return static_cast<TYPE>(HeapNumber::cast(get(kID_##NAME))->value()); \
- } \
- \
- void set_##NAME(TYPE value) { \
- HeapNumber::cast(get(kID_##NAME))->set_value(static_cast<double>(value)); \
}
#define WCM_WEAK_LINK(TYPE, NAME) \
@@ -404,12 +391,11 @@ class WasmCompiledModule : public FixedArray {
MACRO(OBJECT, FixedArray, indirect_function_tables) \
MACRO(OBJECT, String, module_bytes) \
MACRO(OBJECT, ByteArray, function_names) \
- MACRO(LARGE_NUMBER, uint32_t, min_required_memory) \
+ MACRO(SMALL_NUMBER, uint32_t, min_memory_pages) \
MACRO(OBJECT, FixedArray, data_segments_info) \
MACRO(OBJECT, ByteArray, data_segments) \
- MACRO(LARGE_NUMBER, uint32_t, globals_size) \
- MACRO(LARGE_NUMBER, uint32_t, mem_size) \
- MACRO(OBJECT, JSArrayBuffer, mem_start) \
+ MACRO(SMALL_NUMBER, uint32_t, globals_size) \
+ MACRO(OBJECT, JSArrayBuffer, heap) \
MACRO(SMALL_NUMBER, bool, export_memory) \
MACRO(SMALL_NUMBER, ModuleOrigin, origin) \
MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \
@@ -425,34 +411,28 @@ class WasmCompiledModule : public FixedArray {
};
public:
- static Handle<WasmCompiledModule> New(Isolate* isolate) {
- Handle<FixedArray> ret =
- isolate->factory()->NewFixedArray(PropertyIndices::Count, TENURED);
- Handle<HeapNumber> number;
-#define WCM_INIT_OBJECT(IGNORE1, IGNORE2)
-#define WCM_INIT_WEAK_LINK(IGNORE1, IGNORE2)
-#define WCM_INIT_SMALL_NUMBER(IGNORE1, IGNORE2)
-#define WCM_INIT_LARGE_NUMBER(IGNORE, NAME) \
- number = isolate->factory()->NewHeapNumber(0.0, MUTABLE, TENURED); \
- ret->set(kID_##NAME, *number);
-
-#define INITIALIZER(KIND, TYPE, NAME) WCM_INIT_##KIND(TYPE, NAME)
- WCM_PROPERTY_TABLE(INITIALIZER)
-#undef INITIALIZER
- return handle(WasmCompiledModule::cast(*ret));
- }
+ static Handle<WasmCompiledModule> New(Isolate* isolate,
+ uint32_t min_memory_pages,
+ uint32_t globals_size,
+ bool export_memory,
+ ModuleOrigin origin);
static Handle<WasmCompiledModule> Clone(Isolate* isolate,
Handle<WasmCompiledModule> module) {
Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast(
isolate->factory()->CopyFixedArray(module));
- Handle<HeapNumber> number =
- isolate->factory()->NewHeapNumber(0.0, MUTABLE, TENURED);
- ret->set(kID_mem_size, *number);
- ret->set_mem_size(module->mem_size());
return ret;
}
+ uint32_t mem_size() const {
+ DCHECK(has_heap());
+ return heap()->byte_length()->Number();
+ }
+
+ uint32_t default_mem_size() const {
+ return min_memory_pages() * WasmModule::kPageSize;
+ }
+
#define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
WCM_PROPERTY_TABLE(DECLARATION)
#undef DECLARATION
« no previous file with comments | « no previous file | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698