| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_WASM_JS_H_ | 5 #ifndef V8_WASM_JS_H_ |
| 6 #define V8_WASM_JS_H_ | 6 #define V8_WASM_JS_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 // Exposes a WASM API to JavaScript through the V8 API. | 13 // Exposes a WASM API to JavaScript through the V8 API. |
| 14 class WasmJs { | 14 class WasmJs { |
| 15 public: | 15 public: |
| 16 static void Install(Isolate* isolate, Handle<JSGlobalObject> global_object); | 16 static void Install(Isolate* isolate, Handle<JSGlobalObject> global_object); |
| 17 | 17 |
| 18 V8_EXPORT_PRIVATE static void InstallWasmModuleSymbolIfNeeded( | 18 V8_EXPORT_PRIVATE static void InstallWasmModuleSymbolIfNeeded( |
| 19 Isolate* isolate, Handle<JSGlobalObject> global, Handle<Context> context); | 19 Isolate* isolate, Handle<JSGlobalObject> global, Handle<Context> context); |
| 20 | 20 |
| 21 V8_EXPORT_PRIVATE static void InstallWasmMapsIfNeeded( | 21 V8_EXPORT_PRIVATE static void InstallWasmMapsIfNeeded( |
| 22 Isolate* isolate, Handle<Context> context); | 22 Isolate* isolate, Handle<Context> context); |
| 23 static void InstallWasmConstructors(Isolate* isolate, | 23 static void InstallWasmConstructors(Isolate* isolate, |
| 24 Handle<JSGlobalObject> global, | 24 Handle<JSGlobalObject> global, |
| 25 Handle<Context> context); | 25 Handle<Context> context); |
| 26 | 26 |
| 27 // WebAssembly.Table. |
| 28 static Handle<JSObject> CreateWasmTableObject( |
| 29 Isolate* isolate, uint32_t initial, bool has_maximum, uint32_t maximum, |
| 30 Handle<FixedArray>* js_functions); |
| 31 |
| 32 static bool IsWasmTableObject(Isolate* isolate, Handle<Object> value); |
| 33 |
| 34 static Handle<FixedArray> GetWasmTableFunctions(Isolate* isolate, |
| 35 Handle<JSObject> object); |
| 36 |
| 37 static Handle<FixedArray> AddWasmTableDispatchTable( |
| 38 Isolate* isolate, Handle<JSObject> table_obj, Handle<JSObject> instance, |
| 39 int table_index, Handle<FixedArray> dispatch_table); |
| 40 |
| 41 // WebAssembly.Memory |
| 27 static Handle<JSObject> CreateWasmMemoryObject(Isolate* isolate, | 42 static Handle<JSObject> CreateWasmMemoryObject(Isolate* isolate, |
| 28 Handle<JSArrayBuffer> buffer, | 43 Handle<JSArrayBuffer> buffer, |
| 29 bool has_maximum, int maximum); | 44 bool has_maximum, int maximum); |
| 30 | 45 |
| 31 static Handle<JSObject> CreateWasmTableObject(Isolate* isolate, | |
| 32 uint32_t initial, | |
| 33 bool has_maximum, | |
| 34 uint32_t maximum, | |
| 35 Handle<FixedArray>* array); | |
| 36 | |
| 37 static bool IsWasmMemoryObject(Isolate* isolate, Handle<Object> value); | 46 static bool IsWasmMemoryObject(Isolate* isolate, Handle<Object> value); |
| 38 | 47 |
| 39 static Handle<JSArrayBuffer> GetWasmMemoryArrayBuffer(Isolate* isolate, | 48 static Handle<JSArrayBuffer> GetWasmMemoryArrayBuffer(Isolate* isolate, |
| 40 Handle<Object> value); | 49 Handle<Object> value); |
| 41 | 50 |
| 42 static void SetWasmMemoryArrayBuffer(Isolate* isolate, Handle<Object> value, | 51 static void SetWasmMemoryArrayBuffer(Isolate* isolate, Handle<Object> value, |
| 43 Handle<JSArrayBuffer> buffer); | 52 Handle<JSArrayBuffer> buffer); |
| 44 | 53 |
| 45 static uint32_t GetWasmMemoryMaximumSize(Isolate* isolate, | 54 static uint32_t GetWasmMemoryMaximumSize(Isolate* isolate, |
| 46 Handle<Object> value); | 55 Handle<Object> value); |
| 47 | 56 |
| 48 static void SetWasmMemoryInstance(Isolate* isolate, Handle<Object> value, | 57 static void SetWasmMemoryInstance(Isolate* isolate, Handle<Object> value, |
| 49 Handle<JSObject> instance); | 58 Handle<JSObject> instance); |
| 50 }; | 59 }; |
| 51 | 60 |
| 52 } // namespace internal | 61 } // namespace internal |
| 53 } // namespace v8 | 62 } // namespace v8 |
| 54 #endif | 63 #endif |
| OLD | NEW |