Lines Matching refs:instance
192 void RelocateInstanceCode(WasmModuleInstance* instance) {
193 for (uint32_t i = 0; i < instance->function_code.size(); ++i) {
194 Handle<Code> function = instance->function_code[i];
200 nullptr, instance->mem_start, GetMinModuleMemSize(instance->module),
201 static_cast<uint32_t>(instance->mem_size));
206 // Set the memory for a module instance to be the {memory} array buffer.
207 void SetMemory(WasmModuleInstance* instance, Handle<JSArrayBuffer> memory) {
209 instance->mem_start = reinterpret_cast<byte*>(memory->backing_store());
210 instance->mem_size = memory->byte_length()->Number();
211 instance->mem_buffer = memory;
212 RelocateInstanceCode(instance);
215 // Allocate memory for a module instance as a new JSArrayBuffer.
217 WasmModuleInstance* instance) {
218 DCHECK(instance->module);
219 DCHECK(instance->mem_buffer.is_null());
221 if (instance->module->min_mem_pages > WasmModule::kMaxMemPages) {
225 instance->mem_size = GetMinModuleMemSize(instance->module);
226 instance->mem_buffer =
227 NewArrayBuffer(isolate, instance->mem_size, &instance->mem_start);
228 if (instance->mem_start == nullptr) {
230 instance->mem_size = 0;
233 RelocateInstanceCode(instance);
238 WasmModuleInstance* instance) {
239 uint32_t globals_size = instance->module->globals_size;
241 instance->globals_buffer =
242 NewArrayBuffer(isolate, globals_size, &instance->globals_start);
243 if (!instance->globals_start) {
249 for (uint32_t i = 0; i < instance->function_code.size(); ++i) {
250 Handle<Code> function = instance->function_code[i];
255 instance->globals_start);
498 WasmModuleInstance* instance, ErrorThrower* thrower, Factory* factory) {
500 instance->import_code.reserve(module->import_table.size());
514 instance->import_code[index] = code;
673 void PopulateFunctionTable(WasmModuleInstance* instance) {
674 if (!instance->function_table.is_null()) {
675 uint32_t table_size = instance->module->FunctionTableSize();
676 DCHECK_EQ(table_size * 2, instance->function_table->length());
678 static_cast<uint32_t>(instance->module->function_table.size());
680 instance->function_table->set(
682 *instance->function_code[instance->module->function_table[i]]);
718 module_env.instance = &temp_instance_for_compilation;
774 // Allocate the instance and its JS counterpart.
779 WasmModuleInstance instance(this);
780 instance.context = isolate->native_context();
781 instance.js_object = factory->NewJSObjectFromMap(map, TENURED);
786 instance.js_object->SetInternalField(kWasmModuleCodeTable, *code_table);
788 instance.module->module_end - instance.module->module_start;
790 Vector<const uint8_t> module_bytes_vec(instance.module->module_start,
795 instance.js_object->SetInternalField(kWasmModuleBytesString,
800 instance.function_code[i] = code;
807 instance.module->min_mem_pages);
809 instance.module->max_mem_pages);
811 if (!AllocateMemory(&thrower, isolate, &instance)) {
815 SetMemory(&instance, memory);
817 instance.js_object->SetInternalField(kWasmMemArrayBuffer,
818 *instance.mem_buffer);
819 LoadDataSegments(this, instance.mem_start, instance.mem_size);
824 if (!AllocateGlobals(&thrower, isolate, &instance)) {
827 if (!instance.globals_buffer.is_null()) {
828 instance.js_object->SetInternalField(kWasmGlobalsArrayBuffer,
829 *instance.globals_buffer);
837 module_env.instance = &instance;
843 if (!CompileWrappersToImportedFunctions(isolate, this, ffi, &instance,
853 for (Handle<Code> c : instance
854 for (Handle<Code> c : instance.import_code) code_stats.Record(*c);
858 instance.js_object->SetInternalField(kWasmModuleFunctionTable,
860 LinkImports(isolate, instance.function_code, instance.import_code);
862 SetDeoptimizationData(factory, instance.js_object, instance.function_code);
875 JSObject::AddProperty(instance.js_object, exports_name, exports_object,
879 exports_object = instance.js_object;
890 Handle<Code> code = instance.function_code[exp.func_index];
892 isolate, &module_env, name, code, instance.js_object,
909 JSObject::AddProperty(exports_object, name, instance.mem_buffer,
923 instance.js_object->SetInternalField(kWasmFunctionNamesArray,
931 Handle<Code> code = instance.function_code[index];
933 isolate, &module_env, name, code, instance.js_object, index);
944 return instance.js_object;
951 DCHECK_NOT_NULL(instance);
952 return instance->function_code[index];
957 return instance ? instance->import_code[index] : Handle<Code>::null();
1060 Handle<JSObject> instance =
1068 JSObject::GetProperty(instance, exports).ToHandleChecked());