Implement linear memory instructions in WebAssembly
[WebKit-https.git] / Source / JavaScriptCore / wasm / JSWASMModule.h
index a7266b5..2d16791 100644 (file)
@@ -37,9 +37,28 @@ class JSWASMModule : public JSDestructibleObject {
 public:
     typedef JSDestructibleObject Base;
 
-    static JSWASMModule* create(VM& vm, Structure* structure)
+    union GlobalVariable {
+        GlobalVariable(int32_t value)
+            : intValue(value)
+        {
+        }
+        GlobalVariable(float value)
+            : floatValue(value)
+        {
+        }
+        GlobalVariable(double value)
+            : doubleValue(value)
+        {
+        }
+
+        int32_t intValue;
+        float floatValue;
+        double doubleValue;
+    };
+
+    static JSWASMModule* create(VM& vm, Structure* structure, JSArrayBuffer* arrayBuffer)
     {
-        JSWASMModule* module = new (NotNull, allocateCell<JSWASMModule>(vm.heap)) JSWASMModule(vm, structure);
+        JSWASMModule* module = new (NotNull, allocateCell<JSWASMModule>(vm.heap)) JSWASMModule(vm, structure, arrayBuffer);
         module->finishCreation(vm);
         return module;
     }
@@ -64,11 +83,15 @@ public:
     Vector<WASMFunctionDeclaration>& functionDeclarations() { return m_functionDeclarations; }
     Vector<WASMFunctionPointerTable>& functionPointerTables() { return m_functionPointerTables; }
 
+    const JSArrayBuffer* arrayBuffer() const { return m_arrayBuffer.get(); }
+    Vector<WriteBarrier<JSFunction>>& functions() { return m_functions; }
+    Vector<unsigned>& functionStartOffsetsInSource() { return m_functionStartOffsetsInSource; }
+    Vector<unsigned>& functionStackHeights() { return m_functionStackHeights; }
+    Vector<GlobalVariable>& globalVariables() { return m_globalVariables; }
+    Vector<WriteBarrier<JSFunction>>& importedFunctions() { return m_importedFunctions; }
+
 private:
-    JSWASMModule(VM& vm, Structure* structure)
-        : Base(vm, structure)
-    {
-    }
+    JSWASMModule(VM&, Structure*, JSArrayBuffer*);
 
     Vector<uint32_t> m_i32Constants;
     Vector<float> m_f32Constants;
@@ -80,7 +103,12 @@ private:
     Vector<WASMFunctionDeclaration> m_functionDeclarations;
     Vector<WASMFunctionPointerTable> m_functionPointerTables;
 
+    WriteBarrier<JSArrayBuffer> m_arrayBuffer;
     Vector<WriteBarrier<JSFunction>> m_functions;
+    Vector<unsigned> m_functionStartOffsetsInSource;
+    Vector<unsigned> m_functionStackHeights;
+    Vector<GlobalVariable> m_globalVariables;
+    Vector<WriteBarrier<JSFunction>> m_importedFunctions;
 };
 
 } // namespace JSC