| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_OBJECTS_H_ | 5 #ifndef V8_WASM_OBJECTS_H_ |
| 6 #define V8_WASM_OBJECTS_H_ | 6 #define V8_WASM_OBJECTS_H_ |
| 7 | 7 |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/debug/interface-types.h" | 9 #include "src/debug/interface-types.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 static Handle<WasmModuleObject> New( | 70 static Handle<WasmModuleObject> New( |
| 71 Isolate* isolate, Handle<WasmCompiledModule> compiled_module); | 71 Isolate* isolate, Handle<WasmCompiledModule> compiled_module); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Representation of a WebAssembly.Table JavaScript-level object. | 74 // Representation of a WebAssembly.Table JavaScript-level object. |
| 75 class WasmTableObject : public JSObject { | 75 class WasmTableObject : public JSObject { |
| 76 public: | 76 public: |
| 77 DECL_CAST(WasmTableObject) | 77 DECL_CAST(WasmTableObject) |
| 78 | 78 |
| 79 DECL_ACCESSORS(functions, FixedArray) | 79 DECL_ACCESSORS(functions, FixedArray) |
| 80 DECL_INT_ACCESSORS(maximum_length) | 80 // TODO(titzer): introduce DECL_I64_ACCESSORS macro |
| 81 DECL_ACCESSORS(maximum_length, Object) |
| 81 DECL_ACCESSORS(dispatch_tables, FixedArray) | 82 DECL_ACCESSORS(dispatch_tables, FixedArray) |
| 82 | 83 |
| 83 enum { // -- | 84 enum { // -- |
| 84 kFunctionsIndex, | 85 kFunctionsIndex, |
| 85 kMaximumLengthIndex, | 86 kMaximumLengthIndex, |
| 86 kDispatchTablesIndex, | 87 kDispatchTablesIndex, |
| 87 kFieldCount | 88 kFieldCount |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 DEF_SIZE(JSObject) | 91 DEF_SIZE(JSObject) |
| 91 DEF_OFFSET(Functions) | 92 DEF_OFFSET(Functions) |
| 92 DEF_OFFSET(MaximumLength) | 93 DEF_OFFSET(MaximumLength) |
| 93 DEF_OFFSET(DispatchTables) | 94 DEF_OFFSET(DispatchTables) |
| 94 | 95 |
| 95 inline uint32_t current_length() { return functions()->length(); } | 96 inline uint32_t current_length() { return functions()->length(); } |
| 96 inline bool has_maximum_length() { return maximum_length() >= 0; } | 97 inline bool has_maximum_length() { return maximum_length()->Number() >= 0; } |
| 97 void grow(Isolate* isolate, uint32_t count); | 98 void grow(Isolate* isolate, uint32_t count); |
| 98 | 99 |
| 99 static Handle<WasmTableObject> New(Isolate* isolate, uint32_t initial, | 100 static Handle<WasmTableObject> New(Isolate* isolate, uint32_t initial, |
| 100 int64_t maximum, | 101 int64_t maximum, |
| 101 Handle<FixedArray>* js_functions); | 102 Handle<FixedArray>* js_functions); |
| 102 static Handle<FixedArray> AddDispatchTable( | 103 static Handle<FixedArray> AddDispatchTable( |
| 103 Isolate* isolate, Handle<WasmTableObject> table, | 104 Isolate* isolate, Handle<WasmTableObject> table, |
| 104 Handle<WasmInstanceObject> instance, int table_index, | 105 Handle<WasmInstanceObject> instance, int table_index, |
| 105 Handle<FixedArray> function_table, Handle<FixedArray> signature_table); | 106 Handle<FixedArray> function_table, Handle<FixedArray> signature_table); |
| 106 }; | 107 }; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 CAST_ACCESSOR(WasmMemoryObject) | 674 CAST_ACCESSOR(WasmMemoryObject) |
| 674 CAST_ACCESSOR(WasmModuleObject) | 675 CAST_ACCESSOR(WasmModuleObject) |
| 675 CAST_ACCESSOR(WasmTableObject) | 676 CAST_ACCESSOR(WasmTableObject) |
| 676 | 677 |
| 677 // WasmModuleObject | 678 // WasmModuleObject |
| 678 ACCESSORS(WasmModuleObject, compiled_module, WasmCompiledModule, | 679 ACCESSORS(WasmModuleObject, compiled_module, WasmCompiledModule, |
| 679 kCompiledModuleOffset) | 680 kCompiledModuleOffset) |
| 680 | 681 |
| 681 // WasmTableObject | 682 // WasmTableObject |
| 682 ACCESSORS(WasmTableObject, functions, FixedArray, kFunctionsOffset) | 683 ACCESSORS(WasmTableObject, functions, FixedArray, kFunctionsOffset) |
| 683 SMI_ACCESSORS(WasmTableObject, maximum_length, kMaximumLengthOffset) | 684 ACCESSORS(WasmTableObject, maximum_length, Object, kMaximumLengthOffset) |
| 684 ACCESSORS(WasmTableObject, dispatch_tables, FixedArray, kDispatchTablesOffset) | 685 ACCESSORS(WasmTableObject, dispatch_tables, FixedArray, kDispatchTablesOffset) |
| 685 | 686 |
| 686 // WasmMemoryObject | 687 // WasmMemoryObject |
| 687 ACCESSORS(WasmMemoryObject, array_buffer, JSArrayBuffer, kArrayBufferOffset) | 688 ACCESSORS(WasmMemoryObject, array_buffer, JSArrayBuffer, kArrayBufferOffset) |
| 688 SMI_ACCESSORS(WasmMemoryObject, maximum_pages, kMaximumPagesOffset) | 689 SMI_ACCESSORS(WasmMemoryObject, maximum_pages, kMaximumPagesOffset) |
| 689 ACCESSORS(WasmMemoryObject, instances, WeakFixedArray, kInstancesOffset) | 690 ACCESSORS(WasmMemoryObject, instances, WeakFixedArray, kInstancesOffset) |
| 690 | 691 |
| 691 // WasmInstanceObject | 692 // WasmInstanceObject |
| 692 ACCESSORS(WasmInstanceObject, compiled_module, WasmCompiledModule, | 693 ACCESSORS(WasmInstanceObject, compiled_module, WasmCompiledModule, |
| 693 kCompiledModuleOffset) | 694 kCompiledModuleOffset) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 #undef DECL_GETTER | 741 #undef DECL_GETTER |
| 741 #undef DECL_OPTIONAL_ACCESSORS | 742 #undef DECL_OPTIONAL_ACCESSORS |
| 742 #undef DECL_OPTIONAL_GETTER | 743 #undef DECL_OPTIONAL_GETTER |
| 743 | 744 |
| 744 #include "src/objects/object-macros-undef.h" | 745 #include "src/objects/object-macros-undef.h" |
| 745 | 746 |
| 746 } // namespace internal | 747 } // namespace internal |
| 747 } // namespace v8 | 748 } // namespace v8 |
| 748 | 749 |
| 749 #endif // V8_WASM_OBJECTS_H_ | 750 #endif // V8_WASM_OBJECTS_H_ |
| OLD | NEW |