Skip to content

Commit

Permalink
feat(hermes): close demo v8 serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikethese committed Dec 28, 2023
1 parent 624b46b commit 6a1c29f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion driver/js/include/driver/vm/hermes/hermes_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct HermesVMInitParam : public VM::VMInitParam {

class HermesVM : public VM {
public:
HermesVM(const std::shared_ptr<HermesVMInitParam>& param) : VM(param) {}
HermesVM(const std::shared_ptr<HermesVMInitParam>& param);
~HermesVM() = default;

virtual std::shared_ptr<CtxValue> ParseJson(const std::shared_ptr<Ctx>& ctx, const string_view& json) override;
Expand Down
6 changes: 3 additions & 3 deletions driver/js/src/js_driver_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ bool JsDriverUtils::RunScript(const std::shared_ptr<Scope>& scope,
worker_task_runner->PostTask(std::move(func));
}
}
#elifdef JS_HERMES
#elif defined(JS_HERMES)
std::shared_ptr<CtxValue> ret = nullptr;
try {
ret = scope->GetContext()->RunScript(script_content, file_name);
Expand Down Expand Up @@ -613,7 +613,7 @@ void JsDriverUtils::CallNative(hippy::napi::CallbackInfo& info, const std::funct
StringViewUtils::ConvertEncoding(json, string_view::Encoding::Utf8).utf8_value());
}
}
#elifdef JS_HERMES
#elif defined(JS_HERMES)
if (info[3] && context->IsObject(info[3])) {
string_view json;
auto flag = context->GetValueJson(info[3], &json);
Expand Down Expand Up @@ -661,7 +661,7 @@ void JsDriverUtils::LoadInstance(const std::shared_ptr<Scope>& scope, byte_strin
} else {
scope->GetContext()->ThrowException("LoadInstance param error");
}
#elifdef JS_HERMES
#elif defined(JS_HERMES)
std::u16string str(reinterpret_cast<const char16_t*>(&buffer_data_[0]), buffer_data_.length() / sizeof(char16_t));
string_view buf_str(std::move(str));
auto engine = scope->GetEngine().lock();
Expand Down
2 changes: 1 addition & 1 deletion driver/js/src/modules/contextify_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void ContextifyModule::RunInThisContext(hippy::napi::CallbackInfo& info, void* d
} else {
info.GetReturnValue()->Set(ret);
}
#elifdef JS_HERMES
#elif defined(JS_HERMES)
try {
auto ret = context->RunScript(str_view, key);
info.GetReturnValue()->Set(ret);
Expand Down
3 changes: 1 addition & 2 deletions driver/js/src/napi/hermes/hermes_ctx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ static Value InvokeJsCallback(Runtime& runtime, const Value& this_value, const V
}
}

// TODO construct call
if (this_value.isObject()) {
cb_info.SetReceiver(std::make_shared<HermesCtxValue>(runtime, this_value.asObject(runtime)));
} else {
Expand Down Expand Up @@ -964,7 +963,7 @@ std::shared_ptr<CtxValue> HermesCtx::RunScript(const string_view& data, const st
}
}

// void HermesCtx::SetDefaultContext(const std::shared_ptr<v8::SnapshotCreator>& creator) {}

// TODO: add throw exception
void HermesCtx::ThrowException(const std::shared_ptr<CtxValue>& exception) {}

Expand Down
5 changes: 5 additions & 0 deletions driver/js/src/vm/hermes/hermes_vm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace hippy {
inline namespace driver {
inline namespace vm {

HermesVM::HermesVM(const std::shared_ptr<HermesVMInitParam>& param) : VM(param) {
FOOTSTONE_DLOG(INFO) << "HermesVM begin";
FOOTSTONE_DLOG(INFO) << "HermesVM end";
}

std::shared_ptr<CtxValue> HermesVM::ParseJson(const std::shared_ptr<Ctx>& ctx, const string_view& json) {
if (footstone::StringViewUtils::IsEmpty(json)) {
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static class EngineInitParams {
public List<HippyAPIProvider> providers;
public List<Processor> processors;
//Optional is use V8 serialization or json
public boolean enableV8Serialization = false;
public boolean enableV8Serialization = true;
// 可选参数 是否打印引擎的完整的log。默认为false
public boolean enableLog = false;
// 可选参数 code cache的名字,如果设置为空,则不启用code cache,默认为 ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static class Builder {
private List<HippyAPIProvider> mPackages;
private boolean mSupportDev = false;
private String mDebugJs;
private boolean enableV8Serialization = false;
private boolean enableV8Serialization = true;
private int mGroupId = -1;
private String mRemoteServerUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class HippyEngineWrapper//TODO: Coming soon
initParams.debugMode = isDebug
initParams.enableLog = true
initParams.logAdapter = DefaultLogAdapter()
initParams.enableV8Serialization = false;
when(driverMode) {
PageConfiguration.DriverMode.JS_REACT -> {
initParams.coreJSAssetsPath = "react/vendor.android.js"
Expand Down

0 comments on commit 6a1c29f

Please sign in to comment.