export_wrapper) { Handle name; if (maybe_name.is_null()) { EmbeddedVector buffer; int length = SNPrintF(buffer, "%d", func_index); name = isolate->factory() ->NewStringFromAscii( Vector::cast(buffer.SubVector(0, length))) .ToHandleChecked(); } else { name = maybe_name.ToHandleChecked(); } DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, export_wrapper->kind()); Handle shared = isolate->factory()->NewSharedFunctionInfo(name, export_wrapper, false); shared->set_length(arity); shared->set_internal_formal_parameter_count(arity); Handle function = isolate->factory()->NewFunction( isolate->wasm_function_map(), name, export_wrapper); function->set_shared(*shared); function->SetInternalField(kInstance, *instance); function->SetInternalField(kIndex, Smi::FromInt(func_index)); return Handle::cast(function); } bool WasmSharedModuleData::IsWasmSharedModuleData(Object* object) { if (!object->IsFixedArray()) return false; FixedArray* arr = FixedArray::cast(object); if (arr->length() != kFieldCount) return false; Isolate* isolate = arr->GetIsolate(); if (!arr->get(kModuleWrapper)->IsForeign()) return false; if (!arr->get(kModuleBytes)->IsUndefined(isolate) && !arr->get(kModuleBytes)->IsSeqOneByteString()) return false; if (!arr->get(kScript)->IsScript()) return false; if (!arr->get(kAsmJsOffsetTable)->IsUndefined(isolate) && !arr->get(kAsmJsOffsetTable)->IsByteArray()) return false; if (!arr->get(kBreakPointInfos)->IsUndefined(isolate) && !arr->get(kBreakPointInfos)->IsFixedArray()) return false; return true; } WasmSharedModuleData* WasmSharedModuleData::cast(Object* object) { DCHECK(IsWasmSharedModuleData(object)); return reinterpret_cast(object); } wasm::WasmModule* WasmSharedModuleData::module() { // We populate the kModuleWrapper field with a Foreign holding the // address to the address of a WasmModule. This is because we can // handle both cases when the WasmModule's lifetime is managed through // a Managed object, as well as cases when it's managed // by the embedder. CcTests fall into the latter case. return *(reinterpret_cast( Foreign::cast(get(kModuleWrapper))->foreign_address())); } DEFINE_OPTIONAL_ARR_ACCESSORS(WasmSharedModuleData, module_bytes, kModuleBytes, SeqOneByteString); DEFINE_ARR_GETTER(WasmSharedModuleData, script, kScript, Script); DEFINE_OPTIONAL_ARR_ACCESSORS(WasmSharedModuleData, asm_js_offset_table, kAsmJsOffsetTable, ByteArray); DEFINE_OPTIONAL_ARR_GETTER(WasmSharedModuleData, breakpoint_infos, kBreakPointInfos, FixedArray); Handle WasmSharedModuleData::New( Isolate* isolate, Handle module_wrapper, Handle module_bytes, Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册