Lines Matching full:v8
24 #include "v8-debug.h"
25 #include "v8-internal.h"
26 #include "v8-local-handle.h"
27 #include "v8-primitive.h"
28 #include "v8-statistics.h"
29 #include "v8-version-string.h"
38 #include "libplatform/v8-tracing.h"
76 // Always compare the final element of IsolateDataSlot with v8 limit.
77 static_assert(K_ISOLATE_HANDLER_POOL_SLOT < v8::internal::Internals::kNumIsolateDataSlots);
111 static IsolateHandlerPool* GetIsolateHandlerPool(v8::Isolate* isolate) in GetIsolateHandlerPool()
117 static IsolateHandlerPool* GetOrCreateIsolateHandlerPool(v8::Isolate* isolate) in GetOrCreateIsolateHandlerPool()
132 static JSVM_Env GetEnvByContext(v8::Local<v8::Context> context) in GetEnvByContext()
139 IsolateData(v8::StartupData* blob) : blob(blob) {} in IsolateData()
146 v8::StartupData* blob;
147 v8::Eternal<v8::Private> typeTagKey;
148 v8::Eternal<v8::Private> wrapperKey;
151 static void CreateIsolateData(v8::Isolate* isolate, v8::StartupData* blob) in CreateIsolateData()
154 v8::Isolate::Scope isolateScope(isolate); in CreateIsolateData()
155 v8::HandleScope handleScope(isolate); in CreateIsolateData()
159 auto wrapperKey = isolate->GetDataFromSnapshotOnce<v8::Private>(0); in CreateIsolateData()
160 auto typeTagKey = isolate->GetDataFromSnapshotOnce<v8::Private>(1); in CreateIsolateData()
164 data->wrapperKey.Set(isolate, v8::Private::New(isolate)); in CreateIsolateData()
165 data->typeTagKey.Set(isolate, v8::Private::New(isolate)); in CreateIsolateData()
170 static IsolateData* GetIsolateData(v8::Isolate* isolate) in GetIsolateData()
176 static void SetIsolateSnapshotCreator(v8::Isolate* isolate, v8::SnapshotCreator* creator) in SetIsolateSnapshotCreator()
181 static v8::SnapshotCreator* GetIsolateSnapshotCreator(v8::Isolate* isolate) in GetIsolateSnapshotCreator()
184 return reinterpret_cast<v8::SnapshotCreator*>(data); in GetIsolateSnapshotCreator()
187 static void SetContextEnv(v8::Local<v8::Context> context, JSVM_Env env) in SetContextEnv()
192 static JSVM_Env GetContextEnv(v8::Local<v8::Context> context) in GetContextEnv()
198 class OutputStream : public v8::OutputStream {
225 static std::unique_ptr<v8::Platform> g_platform = v8::platform::NewDefaultPlatform();
235 "v8",
236 TRACE_DISABLED_BY_DEFAULT("v8.compile"),
237 "v8.execute",
238 TRACE_DISABLED_BY_DEFAULT("v8.runtime"),
239 TRACE_DISABLED_BY_DEFAULT("v8.stack_trace"),
240 "v8.wasm",
241 TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
248 static inline v8::ArrayBuffer::Allocator* GetOrCreateDefaultArrayBufferAllocator() in GetOrCreateDefaultArrayBufferAllocator()
250 static std::unique_ptr<v8::ArrayBuffer::Allocator> defaultArrayBufferAllocator( in GetOrCreateDefaultArrayBufferAllocator()
251 v8::ArrayBuffer::Allocator::NewDefaultAllocator()); in GetOrCreateDefaultArrayBufferAllocator()
323 v8::Local<v8::Name>* result) in V8NameFromPropertyDescriptor()
328 v8::Local<v8::Value> propertyValue = v8impl::V8LocalValueFromJsValue(p->name); in V8NameFromPropertyDescriptor()
331 *result = propertyValue.As<v8::Name>(); in V8NameFromPropertyDescriptor()
337 // convert from jsvm-api property attributes to v8::PropertyAttribute
338 v8::PropertyAttribute V8PropertyAttributesFromDescriptor(const JSVM_PropertyDescriptor* descriptor) in V8PropertyAttributesFromDescriptor()
340 unsigned int attributeFlags = v8::PropertyAttribute::None; in V8PropertyAttributesFromDescriptor()
343 // V8 would throw `TypeError`s on assignment with nonexistence of a setter. in V8PropertyAttributesFromDescriptor()
346 attributeFlags |= v8::PropertyAttribute::ReadOnly; in V8PropertyAttributesFromDescriptor()
350 attributeFlags |= v8::PropertyAttribute::DontEnum; in V8PropertyAttributesFromDescriptor()
353 attributeFlags |= v8::PropertyAttribute::DontDelete; in V8PropertyAttributesFromDescriptor()
356 return static_cast<v8::PropertyAttribute>(attributeFlags); in V8PropertyAttributesFromDescriptor()
360 inline v8::Maybe<bool> ConcludeDeferred(JSVM_Env env, JSVM_Deferred deferred, JSVM_Value result) in ConcludeDeferred()
362 v8::Local<v8::Context> context = env->context(); in ConcludeDeferred()
363 v8impl::Persistent<v8::Value>* deferredRef = PersistentFromJsDeferred(deferred); in ConcludeDeferred()
364 v8::Local<v8::Value> v8Deferred = v8::Local<v8::Value>::New(env->isolate, *deferredRef); in ConcludeDeferred()
366 auto resolver = v8Deferred.As<v8::Promise::Resolver>(); in ConcludeDeferred()
368 …v8::Maybe<bool> success = isResolved ? resolver->Resolve(context, v8impl::V8LocalValueFromJsValue(… in ConcludeDeferred()
386 v8::Local<v8::Context> context = env->context(); in Unwrap()
388 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(jsObject); in Unwrap()
390 v8::Local<v8::Object> obj = value.As<v8::Object>(); in Unwrap()
394 …RuntimeReference* reference = static_cast<v8impl::RuntimeReference*>(val.As<v8::External>()->Value… in Unwrap()
411 // exposed to JavaScript. The structure is stored in a v8::External which gets
420 static inline v8::Local<v8::Value> New(JSVM_Env env, JSVM_Callback cb) in New()
422 return v8::External::New(env->isolate, cb); in New()
425 static inline v8::Local<v8::Value> New(JSVM_Env env, v8impl::JSVM_PropertyHandlerCfgStruct* cb) in New()
427 return v8::External::New(env->isolate, cb); in New()
431 // Base class extended by classes that wrap V8 function and property callback
468 …inline CallbackWrapperBase(const v8::FunctionCallbackInfo<v8::Value>& cbinfo, const size_t argsLen… in CallbackWrapperBase()
471 cb = static_cast<JSVM_Callback>(cbinfo.Data().As<v8::External>()->Value()); in CallbackWrapperBase()
476 inline const v8::FunctionCallbackInfo<v8::Value>& GetCbInfo() in GetCbInfo()
493 [&](JSVM_Env env, v8::Local<v8::Value> value) { in InvokeCallback()
507 const v8::FunctionCallbackInfo<v8::Value>& cbinfo;
513 static void Invoke(const v8::FunctionCallbackInfo<v8::Value>& info) in Invoke()
519 …static inline JSVM_Status NewFunction(JSVM_Env env, JSVM_Callback cb, v8::Local<v8::Function>* res… in NewFunction()
521 v8::Local<v8::Value> cbdata = v8impl::CallbackBundle::New(env, cb); in NewFunction()
524 … v8::MaybeLocal<v8::Function> maybeFunction = v8::Function::New(env->context(), Invoke, cbdata); in NewFunction()
533 v8::Local<v8::FunctionTemplate>* result, in NewTemplate()
534 v8::Local<v8::Signature> sig = v8::Local<v8::Signature>()) in NewTemplate()
536 v8::Local<v8::Value> cbdata = v8impl::CallbackBundle::New(env, cb); in NewTemplate()
539 *result = v8::FunctionTemplate::New(env->isolate, Invoke, cbdata, sig); in NewTemplate()
543 explicit FunctionCallbackWrapper(const v8::FunctionCallbackInfo<v8::Value>& cbinfo) in FunctionCallbackWrapper()
568 … JSVM_Value undefined = v8impl::JsValueFromV8LocalValue(v8::Undefined(info.GetIsolate())); in GetArgs()
578 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in SetReturnValue()
587 v8::Local<v8::Name> property, in PropertyCallbackWrapperBase()
588 v8::Local<v8::Value> value, in PropertyCallbackWrapperBase()
589 const v8::PropertyCallbackInfo<T>& cbinfo, in PropertyCallbackWrapperBase()
595 …static_cast<v8impl::JSVM_PropertyHandlerCfgStruct*>(cbinfo.Data().template As<v8::External>()->Val… in PropertyCallbackWrapperBase()
633 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in NameSetterInvokeCallback()
660 … JSVM_Value v8Index = JsValueFromV8LocalValue(v8::Integer::NewFromUnsigned(env->isolate, index)); in IndexSetterInvokeCallback()
672 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in IndexSetterInvokeCallback()
710 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in NameGetterInvokeCallback()
748 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in NameDeleterInvokeCallback()
786 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in NameEnumeratorInvokeCallback()
816 … JSVM_Value v8Index = JsValueFromV8LocalValue(v8::Integer::NewFromUnsigned(env->isolate, index)); in IndexGetterInvokeCallback()
826 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in IndexGetterInvokeCallback()
854 … JSVM_Value v8Index = JsValueFromV8LocalValue(v8::Integer::NewFromUnsigned(env->isolate, index)); in IndexDeleterInvokeCallback()
864 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in IndexDeleterInvokeCallback()
902 [&](JSVM_Env env, v8::Local<v8::Value> v8Value) { in IndexEnumeratorInvokeCallback()
916 const v8::PropertyCallbackInfo<T>& cbinfo;
918 v8::Local<v8::Name> property;
919 v8::Local<v8::Value> value;
926 static v8::Intercepted NameSetterInvoke(v8::Local<v8::Name> property, in NameSetterInvoke()
927 v8::Local<v8::Value> value, in NameSetterInvoke()
928 const v8::PropertyCallbackInfo<void>& info) in NameSetterInvoke()
932 return v8::Intercepted::kYes; in NameSetterInvoke()
935 static v8::Intercepted NameGetterInvoke(v8::Local<v8::Name> property, in NameGetterInvoke()
936 const v8::PropertyCallbackInfo<v8::Value>& info) in NameGetterInvoke()
938 … PropertyCallbackWrapper<v8::Value> propertyCbWrapper(property, v8::Local<v8::Value>(), info); in NameGetterInvoke()
940 return v8::Intercepted::kYes; in NameGetterInvoke()
943 static v8::Intercepted NameDeleterInvoke(v8::Local<v8::Name> property, in NameDeleterInvoke()
944 const v8::PropertyCallbackInfo<v8::Boolean>& info) in NameDeleterInvoke()
946 … PropertyCallbackWrapper<v8::Boolean> propertyCbWrapper(property, v8::Local<v8::Value>(), info); in NameDeleterInvoke()
948 return v8::Intercepted::kYes; in NameDeleterInvoke()
951 static void NameEnumeratorInvoke(const v8::PropertyCallbackInfo<v8::Array>& info) in NameEnumeratorInvoke()
953 …PropertyCallbackWrapper<v8::Array> propertyCbWrapper(v8::Local<v8::Name>(), v8::Local<v8::Value>()… in NameEnumeratorInvoke()
957 static v8::Intercepted IndexSetterInvoke(uint32_t index, in IndexSetterInvoke()
958 v8::Local<v8::Value> value, in IndexSetterInvoke()
959 const v8::PropertyCallbackInfo<void>& info) in IndexSetterInvoke()
963 return v8::Intercepted::kYes; in IndexSetterInvoke()
966 …static v8::Intercepted IndexGetterInvoke(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>… in IndexGetterInvoke()
968 PropertyCallbackWrapper<v8::Value> propertyCbWrapper(index, v8::Local<v8::Value>(), info); in IndexGetterInvoke()
970 return v8::Intercepted::kYes; in IndexGetterInvoke()
973 …static v8::Intercepted IndexDeleterInvoke(uint32_t index, const v8::PropertyCallbackInfo<v8::Boole… in IndexDeleterInvoke()
975 PropertyCallbackWrapper<v8::Boolean> propertyCbWrapper(index, v8::Local<v8::Value>(), info); in IndexDeleterInvoke()
977 return v8::Intercepted::kYes; in IndexDeleterInvoke()
980 static void IndexEnumeratorInvoke(const v8::PropertyCallbackInfo<v8::Array>& info) in IndexEnumeratorInvoke()
982 PropertyCallbackWrapper<v8::Array> propertyCbWrapper(0, v8::Local<v8::Value>(), info); in IndexEnumeratorInvoke()
986 explicit PropertyCallbackWrapper(v8::Local<v8::Name> name, in PropertyCallbackWrapper()
987 v8::Local<v8::Value> value, in PropertyCallbackWrapper()
988 const v8::PropertyCallbackInfo<T>& cbinfo) in PropertyCallbackWrapper()
993 v8::Local<v8::Value> value, in PropertyCallbackWrapper()
994 const v8::PropertyCallbackInfo<T>& cbinfo) in PropertyCallbackWrapper()
995 … : PropertyCallbackWrapperBase<T>(index, v8::Local<v8::Name>(), value, cbinfo, 0), cbinfo(cbinfo) in PropertyCallbackWrapper()
1002 const v8::PropertyCallbackInfo<T>& cbinfo;
1014 v8::Local<T> val = v8impl::V8LocalValueFromJsValue(value).As<T>(); in SetReturnValue()
1028 v8::Local<v8::Context> context = env->context(); in Wrap()
1030 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(jsObject); in Wrap()
1032 v8::Local<v8::Object> obj = value.As<v8::Object>(); in Wrap()
1044 …CHECK(obj->SetPrivate(context, JSVM_PRIVATE_KEY(env->isolate, wrapper), v8::External::New(env->iso… in Wrap()
1054 v8::Platform* JSVM_Env__::platform() in platform()
1069 v8::V8::InitializePlatform(v8impl::g_platform.get()); in OH_JSVM_Init()
1072 v8::V8::SetFlagsFromCommandLine(options->argc, options->argv, options->removeFlags); in OH_JSVM_Init()
1075 v8::V8::Initialize(); in OH_JSVM_Init()
1098 v8::Isolate::CreateParams createParams; in OH_JSVM_CreateVM()
1103 v8::StartupData* snapshotBlob = nullptr; in OH_JSVM_CreateVM()
1105 snapshotBlob = new v8::StartupData(); in OH_JSVM_CreateVM()
1116 v8::Isolate* isolate; in OH_JSVM_CreateVM()
1118 isolate = v8::Isolate::Allocate(); in OH_JSVM_CreateVM()
1119 auto creator = new v8::SnapshotCreator(isolate, externalReferences); in OH_JSVM_CreateVM()
1123 isolate = v8::Isolate::New(createParams); in OH_JSVM_CreateVM()
1138 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_DestroyVM()
1161 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_OpenVMScope()
1162 auto scope = new v8::Isolate::Scope(isolate); in OH_JSVM_OpenVMScope()
1169 auto v8scope = reinterpret_cast<v8::Isolate::Scope*>(scope); in OH_JSVM_CloseVMScope()
1179 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_CreateEnv()
1181 v8::HandleScope handleScope(isolate); in OH_JSVM_CreateEnv()
1182 auto globalTemplate = v8::ObjectTemplate::New(isolate); in OH_JSVM_CreateEnv()
1192 v8::Local<v8::Name> propertyName = in OH_JSVM_CreateEnv()
1193 … v8::String::NewFromUtf8(isolate, p->utf8name, v8::NewStringType::kInternalized).ToLocalChecked(); in OH_JSVM_CreateEnv()
1195 v8::PropertyAttribute attributes = v8impl::V8PropertyAttributesFromDescriptor(p); in OH_JSVM_CreateEnv()
1198 v8::Local<v8::FunctionTemplate> getterTpl; in OH_JSVM_CreateEnv()
1199 v8::Local<v8::FunctionTemplate> setterTpl; in OH_JSVM_CreateEnv()
1209 v8::Local<v8::FunctionTemplate> methodTpl; in OH_JSVM_CreateEnv()
1214 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(p->value); in OH_JSVM_CreateEnv()
1219 v8::Local<v8::Context> context = v8::Context::New(isolate, nullptr, globalTemplate); in OH_JSVM_CreateEnv()
1235 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_CreateEnvFromSnapshot()
1236 v8::HandleScope handleScope(isolate); in OH_JSVM_CreateEnvFromSnapshot()
1238 auto maybe = v8::Context::FromSnapshot(isolate, index); in OH_JSVM_CreateEnvFromSnapshot()
1262 auto *v8scope = env->scopeMemoryManager.New<v8::Context::Scope>(env->context()); in OH_JSVM_OpenEnvScope()
1269 auto v8scope = reinterpret_cast<v8::Context::Scope*>(scope); in OH_JSVM_CloseEnvScope()
1287 v8::Local<v8::Value> v8Script = v8impl::V8LocalValueFromJsValue(script); in OH_JSVM_CompileScript()
1291 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CompileScript()
1293 v8::ScriptCompiler::CachedData* cache = in OH_JSVM_CompileScript()
1294 cachedData ? new v8::ScriptCompiler::CachedData(cachedData, cachedDataLength) : nullptr; in OH_JSVM_CompileScript()
1295 v8::ScriptCompiler::Source scriptSource(v8Script.As<v8::String>(), cache); in OH_JSVM_CompileScript()
1296 auto option = cache ? v8::ScriptCompiler::kConsumeCodeCache in OH_JSVM_CompileScript()
1297 … : (eagerCompile ? v8::ScriptCompiler::kEagerCompile : v8::ScriptCompiler::kNoCompileOptions); in OH_JSVM_CompileScript()
1299 auto maybeScript = v8::ScriptCompiler::Compile(context, &scriptSource, option); in OH_JSVM_CompileScript()
1306 v8::Local<v8::Script> compiledScript = maybeScript.ToLocalChecked(); in OH_JSVM_CompileScript()
1312 v8::ScriptOrigin CreateScriptOrigin(v8::Isolate* isolate, v8::Local<v8::String> resourceName, v8::S… in CreateScriptOrigin()
1316 auto options = v8::PrimitiveArray::New(isolate, kOptionsLength); in CreateScriptOrigin()
1317 options->Set(isolate, 0, v8::Uint32::New(isolate, kOptionsMagicConstant)); in CreateScriptOrigin()
1319 return v8::ScriptOrigin(resourceName, 0, 0, false, -1, v8::Local<v8::Value>(), false, false, in CreateScriptOrigin()
1320 type == v8::ScriptType::kModule, options); in CreateScriptOrigin()
1323 v8::MaybeLocal<v8::Value> PrepareStackTraceCallback(v8::Local<v8::Context> context, in PrepareStackTraceCallback()
1324 v8::Local<v8::Value> error, in PrepareStackTraceCallback()
1325 v8::Local<v8::Array> trace) in PrepareStackTraceCallback()
1328 v8::TryCatch tryCatch(isolate); in PrepareStackTraceCallback()
1329 … v8::Local<v8::String> moduleName = v8::String::NewFromUtf8(isolate, "sourcemap").ToLocalChecked(); in PrepareStackTraceCallback()
1330 v8::Local<v8::String> moduleSourceString = in PrepareStackTraceCallback()
1331 v8::String::NewFromUtf8(isolate, SourceMapRunner.c_str()).ToLocalChecked(); in PrepareStackTraceCallback()
1333 … v8::ScriptOrigin moduleOrigin = CreateScriptOrigin(isolate, moduleName, v8::ScriptType::kClassic); in PrepareStackTraceCallback()
1334 v8::Local<v8::Context> moduleContext = v8::Context::New(isolate); in PrepareStackTraceCallback()
1335 v8::ScriptCompiler::Source moduleSource(moduleSourceString, moduleOrigin); in PrepareStackTraceCallback()
1336 …auto script = v8::Script::Compile(moduleContext, moduleSourceString, &moduleOrigin).ToLocalChecked… in PrepareStackTraceCallback()
1338 auto resultFunc = v8::Local<v8::Function>::Cast(result); in PrepareStackTraceCallback()
1340 v8::Local<v8::Value> element = trace->Get(context, 0).ToLocalChecked(); in PrepareStackTraceCallback()
1344 … auto getFileName = v8::String::NewFromUtf8(isolate, "getFileName", v8::NewStringType::kNormal); in PrepareStackTraceCallback()
1346 auto lineNumberFunction = v8::Local<v8::Function>::Cast(function); in PrepareStackTraceCallback()
1348 fileName = std::string(*v8::String::Utf8Value(isolate, fileNameObj.ToLocalChecked())); in PrepareStackTraceCallback()
1376 v8::Local<v8::Value> v8Script = v8impl::V8LocalValueFromJsValue(script); in OH_JSVM_CompileScriptWithOrigin()
1380 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CompileScriptWithOrigin()
1388 ? v8::Local<v8::Value>() in OH_JSVM_CompileScriptWithOrigin()
1389 … : v8::String::NewFromUtf8(isolate, origin->sourceMapUrl).ToLocalChecked().As<v8::Value>(); in OH_JSVM_CompileScriptWithOrigin()
1390 auto resourceName = v8::String::NewFromUtf8(isolate, origin->resourceName).ToLocalChecked(); in OH_JSVM_CompileScriptWithOrigin()
1391 …v8::ScriptOrigin scriptOrigin(resourceName, origin->resourceLineOffset, origin->resourceColumnOffs… in OH_JSVM_CompileScriptWithOrigin()
1394 v8::ScriptCompiler::CachedData* cache = in OH_JSVM_CompileScriptWithOrigin()
1395 cachedData ? new v8::ScriptCompiler::CachedData(cachedData, cachedDataLength) : nullptr; in OH_JSVM_CompileScriptWithOrigin()
1396 v8::ScriptCompiler::Source scriptSource(v8Script.As<v8::String>(), scriptOrigin, cache); in OH_JSVM_CompileScriptWithOrigin()
1397 auto option = cache ? v8::ScriptCompiler::kConsumeCodeCache in OH_JSVM_CompileScriptWithOrigin()
1398 … : (eagerCompile ? v8::ScriptCompiler::kEagerCompile : v8::ScriptCompiler::kNoCompileOptions); in OH_JSVM_CompileScriptWithOrigin()
1400 auto maybeScript = v8::ScriptCompiler::Compile(context, &scriptSource, option); in OH_JSVM_CompileScriptWithOrigin()
1406 v8::Local<v8::Script> compiledScript = maybeScript.ToLocalChecked(); in OH_JSVM_CompileScriptWithOrigin()
1414 CompileOptionResolver(size_t length, JSVM_CompileOptions options[], v8::Isolate* isolate) in CompileOptionResolver()
1425 … cache->cache ? new v8::ScriptCompiler::CachedData(cache->cache, cache->length) : nullptr; in CompileOptionResolver()
1449 … ? v8::String::NewFromUtf8(isolate, jsvmOrigin->sourceMapUrl).ToLocalChecked().As<v8::Value>() in CompileOptionResolver()
1450 : v8::Local<v8::Value>(); in CompileOptionResolver()
1451 auto resourceName = v8::String::NewFromUtf8(isolate, sourceString.c_str()).ToLocalChecked(); in CompileOptionResolver()
1452 … v8Origin = new v8::ScriptOrigin(resourceName, jsvmOrigin ? jsvmOrigin->resourceLineOffset : 0, in CompileOptionResolver()
1458 if (v8Option == v8::ScriptCompiler::kConsumeCodeCache && !cachedData) { in CompileOptionResolver()
1469 v8::ScriptCompiler::CompileOptions v8Option = v8::ScriptCompiler::kNoCompileOptions;
1470 v8::ScriptCompiler::CachedData* cachedData = nullptr;
1471 v8::ScriptOrigin* v8Origin = nullptr;
1479 static constexpr v8::ScriptCompiler::CompileOptions jsvmToOptions[] = {
1480 v8::ScriptCompiler::kNoCompileOptions,
1481 v8::ScriptCompiler::kConsumeCodeCache,
1482 v8::ScriptCompiler::kEagerCompile,
1483 v8::ScriptCompiler::kProduceCompileHints,
1484 v8::ScriptCompiler::kConsumeCompileHints};
1509 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CompileScriptWithOptions()
1514 v8::Local<v8::Value> v8Script = v8impl::V8LocalValueFromJsValue(script); in OH_JSVM_CompileScriptWithOptions()
1518 v8::ScriptCompiler::Source scriptSource(v8Script.As<v8::String>(), *optionResolver.v8Origin, in OH_JSVM_CompileScriptWithOptions()
1520 auto maybeScript = v8::ScriptCompiler::Compile(context, &scriptSource, optionResolver.v8Option); in OH_JSVM_CompileScriptWithOptions()
1522 v8::Local<v8::Script> compiledScript = maybeScript.ToLocalChecked(); in OH_JSVM_CompileScriptWithOptions()
1536 auto v8script = jsvmData->ToV8Local<v8::Script>(env->isolate); in OH_JSVM_CreateCodeCache()
1538 …v8::ScriptCompiler::CachedData* cache = v8::ScriptCompiler::CreateCodeCache(v8script->GetUnboundSc… in OH_JSVM_CreateCodeCache()
1545 cache->buffer_policy = v8::ScriptCompiler::CachedData::BufferNotOwned; in OH_JSVM_CreateCodeCache()
1562 auto v8script = jsvmData->ToV8Local<v8::Script>(env->isolate); in OH_JSVM_RunScript()
1577 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(json_string); in OH_JSVM_JsonParse()
1580 auto maybe = v8::JSON::Parse(env->context(), val.As<v8::String>()); in OH_JSVM_JsonParse()
1594 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(json_object); in OH_JSVM_JsonStringify()
1596 auto maybe = v8::JSON::Stringify(env->context(), val); in OH_JSVM_JsonStringify()
1610 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_CreateSnapshot()
1616 v8::HandleScope scope(isolate); in OH_JSVM_CreateSnapshot()
1617 v8::Local<v8::Context> defaultContext = v8::Context::New(isolate); in OH_JSVM_CreateSnapshot()
1630 auto blob = creator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep); in OH_JSVM_CreateSnapshot()
1640 result->engine = "v8"; in OH_JSVM_GetVMInfo()
1642 result->cachedDataVersionTag = v8::ScriptCompiler::CachedDataVersionTag(); in OH_JSVM_GetVMInfo()
1649 env->isolate->MemoryPressureNotification(v8::MemoryPressureLevel(level)); in OH_JSVM_MemoryPressureNotification()
1655 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_GetHeapStatistics()
1656 v8::HeapStatistics stats; in OH_JSVM_GetHeapStatistics()
1676 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_StartCpuProfiler()
1677 auto profiler = v8::CpuProfiler::New(isolate); in OH_JSVM_StartCpuProfiler()
1678 v8::HandleScope scope(isolate); in OH_JSVM_StartCpuProfiler()
1679 v8::CpuProfilingOptions options; in OH_JSVM_StartCpuProfiler()
1680 profiler->Start(v8::String::Empty(isolate), std::move(options)); in OH_JSVM_StartCpuProfiler()
1691 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_StopCpuProfiler()
1692 auto v8profiler = reinterpret_cast<v8::CpuProfiler*>(profiler); in OH_JSVM_StopCpuProfiler()
1693 v8::HandleScope scope(isolate); in OH_JSVM_StopCpuProfiler()
1694 auto profile = v8profiler->StopProfiling(v8::String::Empty(isolate)); in OH_JSVM_StopCpuProfiler()
1703 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_TakeHeapSnapshot()
1757 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_PumpMessageLoop()
1758 *result = v8::platform::PumpMessageLoop(v8impl::g_platform.get(), isolate); in OH_JSVM_PumpMessageLoop()
1764 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_PerformMicrotaskCheckpoint()
1834 v8::Local<v8::Function> returnValue; in OH_JSVM_CreateFunction()
1835 v8::EscapableHandleScope scope(env->isolate); in OH_JSVM_CreateFunction()
1836 v8::Local<v8::Function> fn; in OH_JSVM_CreateFunction()
1841 v8::Local<v8::String> nameString; in OH_JSVM_CreateFunction()
1871 v8::Local<v8::Value> v8Script = v8impl::V8LocalValueFromJsValue(script); in OH_JSVM_CreateFunctionWithScript()
1875 v8::ScriptCompiler::Source scriptSource(v8Script.As<v8::String>()); in OH_JSVM_CreateFunctionWithScript()
1877 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CreateFunctionWithScript()
1879 v8::MaybeLocal<v8::Function> maybeFunc = in OH_JSVM_CreateFunctionWithScript()
1880 v8::ScriptCompiler::CompileFunction(context, &scriptSource, argc, in OH_JSVM_CreateFunctionWithScript()
1881 … reinterpret_cast<v8::Local<v8::String>*>(const_cast<JSVM_Value*>(argv))); in OH_JSVM_CreateFunctionWithScript()
1884 v8::Local<v8::Function> func = maybeFunc.ToLocalChecked(); in OH_JSVM_CreateFunctionWithScript()
1887 v8::Local<v8::String> funcNameString; in OH_JSVM_CreateFunctionWithScript()
1914 v8::Isolate* isolate = env->isolate; in OH_JSVM_DefineClass()
1916 v8::EscapableHandleScope scope(isolate); in OH_JSVM_DefineClass()
1917 v8::Local<v8::FunctionTemplate> tpl; in OH_JSVM_DefineClass()
1920 v8::Local<v8::String> nameString; in OH_JSVM_DefineClass()
1934 v8::Local<v8::Name> propertyName; in OH_JSVM_DefineClass()
1937 v8::PropertyAttribute attributes = v8impl::V8PropertyAttributesFromDescriptor(p); in OH_JSVM_DefineClass()
1944 v8::Local<v8::FunctionTemplate> getterTpl; in OH_JSVM_DefineClass()
1945 v8::Local<v8::FunctionTemplate> setterTpl; in OH_JSVM_DefineClass()
1955 v8::Local<v8::FunctionTemplate> t; in OH_JSVM_DefineClass()
1960 …v8impl::FunctionCallbackWrapper::NewTemplate(env, p->method, &t, v8::Signature::New(isolate, tpl))… in OH_JSVM_DefineClass()
1965 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(p->value); in OH_JSVM_DefineClass()
1970 v8::Local<v8::Context> context = env->context(); in OH_JSVM_DefineClass()
2009 v8::Local<v8::Context> context = env->context(); in OH_JSVM_GetAllPropertyNames()
2010 v8::Local<v8::Object> obj; in OH_JSVM_GetAllPropertyNames()
2013 v8::PropertyFilter filter = v8::PropertyFilter::ALL_PROPERTIES; in OH_JSVM_GetAllPropertyNames()
2015 filter = static_cast<v8::PropertyFilter>(filter | v8::PropertyFilter::ONLY_WRITABLE); in OH_JSVM_GetAllPropertyNames()
2018 filter = static_cast<v8::PropertyFilter>(filter | v8::PropertyFilter::ONLY_ENUMERABLE); in OH_JSVM_GetAllPropertyNames()
2021 filter = static_cast<v8::PropertyFilter>(filter | v8::PropertyFilter::ONLY_CONFIGURABLE); in OH_JSVM_GetAllPropertyNames()
2024 filter = static_cast<v8::PropertyFilter>(filter | v8::PropertyFilter::SKIP_STRINGS); in OH_JSVM_GetAllPropertyNames()
2027 filter = static_cast<v8::PropertyFilter>(filter | v8::PropertyFilter::SKIP_SYMBOLS); in OH_JSVM_GetAllPropertyNames()
2029 v8::KeyCollectionMode collectionMode; in OH_JSVM_GetAllPropertyNames()
2030 v8::KeyConversionMode conversionMode; in OH_JSVM_GetAllPropertyNames()
2034 collectionMode = v8::KeyCollectionMode::kIncludePrototypes; in OH_JSVM_GetAllPropertyNames()
2037 collectionMode = v8::KeyCollectionMode::kOwnOnly; in OH_JSVM_GetAllPropertyNames()
2045 conversionMode = v8::KeyConversionMode::kKeepNumbers; in OH_JSVM_GetAllPropertyNames()
2048 conversionMode = v8::KeyConversionMode::kConvertToString; in OH_JSVM_GetAllPropertyNames()
2054 v8::MaybeLocal<v8::Array> maybeAllPropertynames = in OH_JSVM_GetAllPropertyNames()
2055 …obj->GetPropertyNames(context, collectionMode, filter, v8::IndexFilter::kIncludeIndices, conversio… in OH_JSVM_GetAllPropertyNames()
2073 v8::Local<v8::Context> context = env->context(); in OH_JSVM_SetProperty()
2074 v8::Local<v8::Object> obj; in OH_JSVM_SetProperty()
2078 v8::Local<v8::Value> k = v8impl::V8LocalValueFromJsValue(key); in OH_JSVM_SetProperty()
2079 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_SetProperty()
2081 v8::Maybe<bool> setMaybe = obj->Set(context, k, val); in OH_JSVM_SetProperty()
2094 v8::Local<v8::Context> context = env->context(); in OH_JSVM_HasProperty()
2095 v8::Local<v8::Object> obj; in OH_JSVM_HasProperty()
2099 v8::Local<v8::Value> k = v8impl::V8LocalValueFromJsValue(key); in OH_JSVM_HasProperty()
2100 v8::Maybe<bool> hasMaybe = obj->Has(context, k); in OH_JSVM_HasProperty()
2115 v8::Local<v8::Context> context = env->context(); in OH_JSVM_GetProperty()
2116 v8::Local<v8::Value> k = v8impl::V8LocalValueFromJsValue(key); in OH_JSVM_GetProperty()
2117 v8::Local<v8::Object> obj; in OH_JSVM_GetProperty()
2124 v8::Local<v8::Value> val = getMaybe.ToLocalChecked(); in OH_JSVM_GetProperty()
2137 v8::Local<v8::Context> context = env->context(); in OH_JSVM_DeleteProperty()
2138 v8::Local<v8::Value> k = v8impl::V8LocalValueFromJsValue(key); in OH_JSVM_DeleteProperty()
2139 v8::Local<v8::Object> obj; in OH_JSVM_DeleteProperty()
2142 v8::Maybe<bool> deleteMaybe = obj->Delete(context, k); in OH_JSVM_DeleteProperty()
2159 v8::Local<v8::Context> context = env->context(); in OH_JSVM_HasOwnProperty()
2160 v8::Local<v8::Object> obj; in OH_JSVM_HasOwnProperty()
2163 v8::Local<v8::Value> k = v8impl::V8LocalValueFromJsValue(key); in OH_JSVM_HasOwnProperty()
2165 v8::Maybe<bool> hasMaybe = obj->HasOwnProperty(context, k.As<v8::Name>()); in OH_JSVM_HasOwnProperty()
2179 v8::Local<v8::Context> context = env->context(); in OH_JSVM_SetNamedProperty()
2180 v8::Local<v8::Object> obj; in OH_JSVM_SetNamedProperty()
2184 v8::Local<v8::Name> key; in OH_JSVM_SetNamedProperty()
2187 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_SetNamedProperty()
2189 v8::Maybe<bool> setMaybe = obj->Set(context, key, val); in OH_JSVM_SetNamedProperty()
2200 v8::Local<v8::Context> context = env->context(); in OH_JSVM_HasNamedProperty()
2201 v8::Local<v8::Object> obj; in OH_JSVM_HasNamedProperty()
2205 v8::Local<v8::Name> key; in OH_JSVM_HasNamedProperty()
2208 v8::Maybe<bool> hasMaybe = obj->Has(context, key); in OH_JSVM_HasNamedProperty()
2221 v8::Local<v8::Context> context = env->context(); in OH_JSVM_GetNamedProperty()
2223 v8::Local<v8::Name> key; in OH_JSVM_GetNamedProperty()
2226 v8::Local<v8::Object> obj; in OH_JSVM_GetNamedProperty()
2233 v8::Local<v8::Value> val = getMaybe.ToLocalChecked(); in OH_JSVM_GetNamedProperty()
2246 v8::Local<v8::Context> context = env->context(); in OH_JSVM_SetElement()
2247 v8::Local<v8::Object> obj; in OH_JSVM_SetElement()
2251 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_SetElement()
2264 v8::Local<v8::Context> context = env->context(); in OH_JSVM_HasElement()
2265 v8::Local<v8::Object> obj; in OH_JSVM_HasElement()
2269 v8::Maybe<bool> hasMaybe = obj->Has(context, index); in OH_JSVM_HasElement()
2282 v8::Local<v8::Context> context = env->context(); in OH_JSVM_GetElement()
2283 v8::Local<v8::Object> obj; in OH_JSVM_GetElement()
2300 v8::Local<v8::Context> context = env->context(); in OH_JSVM_DeleteElement()
2301 v8::Local<v8::Object> obj; in OH_JSVM_DeleteElement()
2304 v8::Maybe<bool> deleteMaybe = obj->Delete(context, index); in OH_JSVM_DeleteElement()
2324 v8::Local<v8::Context> context = env->context(); in OH_JSVM_DefineProperties()
2326 v8::Local<v8::Object> obj; in OH_JSVM_DefineProperties()
2332 v8::Local<v8::Name> propertyName; in OH_JSVM_DefineProperties()
2336 v8::Local<v8::Function> localGetter; in OH_JSVM_DefineProperties()
2337 v8::Local<v8::Function> localSetter; in OH_JSVM_DefineProperties()
2346 v8::PropertyDescriptor descriptor(localGetter, localSetter); in OH_JSVM_DefineProperties()
2355 v8::Local<v8::Function> method; in OH_JSVM_DefineProperties()
2357 v8::PropertyDescriptor descriptor(method, (p->attributes & JSVM_WRITABLE) != 0); in OH_JSVM_DefineProperties()
2366 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(p->value); in OH_JSVM_DefineProperties()
2375 v8::PropertyDescriptor descriptor(value, (p->attributes & JSVM_WRITABLE) != 0); in OH_JSVM_DefineProperties()
2397 v8::Local<v8::Context> context = env->context(); in OH_JSVM_ObjectFreeze()
2398 v8::Local<v8::Object> obj; in OH_JSVM_ObjectFreeze()
2402 v8::Maybe<bool> setFrozen = obj->SetIntegrityLevel(context, v8::IntegrityLevel::kFrozen); in OH_JSVM_ObjectFreeze()
2414 v8::Local<v8::Context> context = env->context(); in OH_JSVM_ObjectSeal()
2415 v8::Local<v8::Object> obj; in OH_JSVM_ObjectSeal()
2419 v8::Maybe<bool> setSealed = obj->SetIntegrityLevel(context, v8::IntegrityLevel::kSealed); in OH_JSVM_ObjectSeal()
2433 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsArray()
2446 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsRegExp()
2459 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetArrayLength()
2465 v8::Local<v8::Array> arr = val.As<v8::Array>(); in OH_JSVM_GetArrayLength()
2480 v8::Local<v8::Value> a = v8impl::V8LocalValueFromJsValue(lhs); in OH_JSVM_StrictEquals()
2481 v8::Local<v8::Value> b = v8impl::V8LocalValueFromJsValue(rhs); in OH_JSVM_StrictEquals()
2496 v8::Local<v8::Value> a = v8impl::V8LocalValueFromJsValue(lhs); in OH_JSVM_Equals()
2497 v8::Local<v8::Value> b = v8impl::V8LocalValueFromJsValue(rhs); in OH_JSVM_Equals()
2498 v8::Local<v8::Context> context = env->context(); in OH_JSVM_Equals()
2510 v8::Local<v8::Context> context = env->context(); in OH_JSVM_GetPrototype()
2512 v8::Local<v8::Object> obj; in OH_JSVM_GetPrototype()
2515 v8::Local<v8::Value> val = obj->GetPrototype(); in OH_JSVM_GetPrototype()
2526 *result = v8impl::JsValueFromV8LocalValue(v8::Object::New(env->isolate)); in OH_JSVM_CreateObject()
2538 *result = v8impl::JsValueFromV8LocalValue(v8::Array::New(env->isolate)); in OH_JSVM_CreateArray()
2550 *result = v8impl::JsValueFromV8LocalValue(v8::Array::New(env->isolate, length)); in OH_JSVM_CreateArrayWithLength()
2559 return v8impl::NewString(env, str, length, result, [&](v8::Isolate* isolate) { in OH_JSVM_CreateStringLatin1()
2560 …return v8::String::NewFromOneByte(isolate, reinterpret_cast<const uint8_t*>(str), v8::NewStringTyp… in OH_JSVM_CreateStringLatin1()
2567 return v8impl::NewString(env, str, length, result, [&](v8::Isolate* isolate) { in OH_JSVM_CreateStringUtf8()
2568 …return v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal, static_cast<int>(length)); in OH_JSVM_CreateStringUtf8()
2574 return v8impl::NewString(env, str, length, result, [&](v8::Isolate* isolate) { in OH_JSVM_CreateStringUtf16()
2575 …return v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*>(str), v8::NewStringTy… in OH_JSVM_CreateStringUtf16()
2585 *result = v8impl::JsValueFromV8LocalValue(v8::Number::New(env->isolate, value)); in OH_JSVM_CreateDouble()
2597 *result = v8impl::JsValueFromV8LocalValue(v8::Integer::New(env->isolate, value)); in OH_JSVM_CreateInt32()
2609 *result = v8impl::JsValueFromV8LocalValue(v8::Integer::NewFromUnsigned(env->isolate, value)); in OH_JSVM_CreateUint32()
2621 …*result = v8impl::JsValueFromV8LocalValue(v8::Number::New(env->isolate, static_cast<double>(value)… in OH_JSVM_CreateInt64()
2633 *result = v8impl::JsValueFromV8LocalValue(v8::BigInt::New(env->isolate, value)); in OH_JSVM_CreateBigintInt64()
2645 *result = v8impl::JsValueFromV8LocalValue(v8::BigInt::NewFromUnsigned(env->isolate, value)); in OH_JSVM_CreateBigintUint64()
2662 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CreateBigintWords()
2666 v8::MaybeLocal<v8::BigInt> b = v8::BigInt::NewFromWords(context, signBit, wordCount, words); in OH_JSVM_CreateBigintWords()
2680 v8::Isolate* isolate = env->isolate; in OH_JSVM_GetBoolean()
2683 *result = v8impl::JsValueFromV8LocalValue(v8::True(isolate)); in OH_JSVM_GetBoolean()
2685 *result = v8impl::JsValueFromV8LocalValue(v8::False(isolate)); in OH_JSVM_GetBoolean()
2699 v8::Isolate* isolate = env->isolate; in OH_JSVM_CreateSymbol()
2702 *result = v8impl::JsValueFromV8LocalValue(v8::Symbol::New(isolate)); in OH_JSVM_CreateSymbol()
2704 v8::Local<v8::Value> desc = v8impl::V8LocalValueFromJsValue(description); in OH_JSVM_CreateSymbol()
2707 *result = v8impl::JsValueFromV8LocalValue(v8::Symbol::New(isolate, desc.As<v8::String>())); in OH_JSVM_CreateSymbol()
2722 …v8::Local<v8::String> descriptionString = v8impl::V8LocalValueFromJsValue(jsDescriptionString).As<… in OH_JSVM_SymbolFor()
2724 *result = v8impl::JsValueFromV8LocalValue(v8::Symbol::For(env->isolate, descriptionString)); in OH_JSVM_SymbolFor()
2730 static JSVM_Status SetErrorCode(JSVM_Env env, v8::Local<v8::Value> error, JSVM_Value code, const ch… in SetErrorCode()
2733 v8::Local<v8::Context> context = env->context(); in SetErrorCode()
2734 v8::Local<v8::Object> errObject = error.As<v8::Object>(); in SetErrorCode()
2736 v8::Local<v8::Value> codeValue = v8impl::V8LocalValueFromJsValue(code); in SetErrorCode()
2744 v8::Local<v8::Name> codeKey; in SetErrorCode()
2747 v8::Maybe<bool> setMaybe = errObject->Set(context, codeKey, codeValue); in SetErrorCode()
2761 v8::Local<v8::Value> messageValue = v8impl::V8LocalValueFromJsValue(msg); in OH_JSVM_CreateError()
2764 v8::Local<v8::Value> errorObj = v8::Exception::Error(messageValue.As<v8::String>()); in OH_JSVM_CreateError()
2780 v8::Local<v8::Value> messageValue = v8impl::V8LocalValueFromJsValue(msg); in OH_JSVM_CreateTypeError()
2783 v8::Local<v8::Value> errorObj = v8::Exception::TypeError(messageValue.As<v8::String>()); in OH_JSVM_CreateTypeError()
2800 v8::Local<v8::Value> messageValue = v8impl::V8LocalValueFromJsValue(msg); in OH_JSVM_CreateRangeError()
2803 v8::Local<v8::Value> errorObj = v8::Exception::RangeError(messageValue.As<v8::String>()); in OH_JSVM_CreateRangeError()
2820 v8::Local<v8::Value> messageValue = v8impl::V8LocalValueFromJsValue(msg); in OH_JSVM_CreateSyntaxError()
2823 v8::Local<v8::Value> errorObj = v8::Exception::SyntaxError(messageValue.As<v8::String>()); in OH_JSVM_CreateSyntaxError()
2834 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_Typeof()
2841 v8::Local<v8::Value> v = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_Typeof()
2868 // Should not get here unless V8 has added some new kind of value. in OH_JSVM_Typeof()
2880 *result = v8impl::JsValueFromV8LocalValue(v8::Undefined(env->isolate)); in OH_JSVM_GetUndefined()
2891 *result = v8impl::JsValueFromV8LocalValue(v8::Null(env->isolate)); in OH_JSVM_GetNull()
2967 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CallFunction()
2969 v8::Local<v8::Value> v8recv = v8impl::V8LocalValueFromJsValue(recv); in OH_JSVM_CallFunction()
2971 v8::Local<v8::Function> v8func; in OH_JSVM_CallFunction()
2975 …v8func->Call(context, v8recv, argc, reinterpret_cast<v8::Local<v8::Value>*>(const_cast<JSVM_Value*… in OH_JSVM_CallFunction()
3015 v8::Isolate* isolate = env->isolate; in OH_JSVM_Throw()
3027 v8::Isolate* isolate = env->isolate; in OH_JSVM_ThrowError()
3028 v8::Local<v8::String> str; in OH_JSVM_ThrowError()
3031 v8::Local<v8::Value> errorObj = v8::Exception::Error(str); in OH_JSVM_ThrowError()
3044 v8::Isolate* isolate = env->isolate; in OH_JSVM_ThrowTypeError()
3045 v8::Local<v8::String> str; in OH_JSVM_ThrowTypeError()
3048 v8::Local<v8::Value> errorObj = v8::Exception::TypeError(str); in OH_JSVM_ThrowTypeError()
3061 v8::Isolate* isolate = env->isolate; in OH_JSVM_ThrowRangeError()
3062 v8::Local<v8::String> str; in OH_JSVM_ThrowRangeError()
3065 v8::Local<v8::Value> errorObj = v8::Exception::RangeError(str); in OH_JSVM_ThrowRangeError()
3078 v8::Isolate* isolate = env->isolate; in OH_JSVM_ThrowSyntaxError()
3079 v8::Local<v8::String> str; in OH_JSVM_ThrowSyntaxError()
3082 v8::Local<v8::Value> errorObj = v8::Exception::SyntaxError(str); in OH_JSVM_ThrowSyntaxError()
3093 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot in OH_JSVM_IsError()
3100 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsError()
3108 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetValueDouble()
3115 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueDouble()
3118 *result = val.As<v8::Number>()->Value(); in OH_JSVM_GetValueDouble()
3125 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetValueInt32()
3132 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueInt32()
3135 *result = val.As<v8::Int32>()->Value(); in OH_JSVM_GetValueInt32()
3140 v8::Local<v8::Context> context; in OH_JSVM_GetValueInt32()
3149 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetValueUint32()
3156 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueUint32()
3159 *result = val.As<v8::Uint32>()->Value(); in OH_JSVM_GetValueUint32()
3164 v8::Local<v8::Context> context; in OH_JSVM_GetValueUint32()
3173 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetValueInt64()
3180 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueInt64()
3184 *result = val.As<v8::Int32>()->Value(); in OH_JSVM_GetValueInt64()
3190 // v8::Value::IntegerValue() converts NaN, +Inf, and -Inf to INT64_MIN, in OH_JSVM_GetValueInt64()
3191 // inconsistent with v8::Value::Int32Value() which converts those values to 0. in OH_JSVM_GetValueInt64()
3193 double doubleValue = val.As<v8::Number>()->Value(); in OH_JSVM_GetValueInt64()
3196 v8::Local<v8::Context> context; in OH_JSVM_GetValueInt64()
3213 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueBigintInt64()
3217 *result = val.As<v8::BigInt>()->Int64Value(lossless); in OH_JSVM_GetValueBigintInt64()
3230 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueBigintUint64()
3234 *result = val.As<v8::BigInt>()->Uint64Value(lossless); in OH_JSVM_GetValueBigintUint64()
3250 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueBigintWords()
3254 v8::Local<v8::BigInt> big = val.As<v8::BigInt>(); in OH_JSVM_GetValueBigintWords()
3273 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetValueBool()
3280 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueBool()
3283 *result = val.As<v8::Boolean>()->Value(); in OH_JSVM_GetValueBool()
3302 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueStringLatin1()
3307 *result = val.As<v8::String>()->Length(); in OH_JSVM_GetValueStringLatin1()
3309 …int copied = val.As<v8::String>()->WriteOneByte(env->isolate, reinterpret_cast<uint8_t*>(buf), 0, … in OH_JSVM_GetValueStringLatin1()
3310 v8::String::NO_NULL_TERMINATION); in OH_JSVM_GetValueStringLatin1()
3337 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueStringUtf8()
3342 *result = val.As<v8::String>()->Utf8Length(env->isolate); in OH_JSVM_GetValueStringUtf8()
3345 val.As<v8::String>()->WriteUtf8(env->isolate, buf, bufsize - 1, nullptr, in OH_JSVM_GetValueStringUtf8()
3346 … v8::String::REPLACE_INVALID_UTF8 | v8::String::NO_NULL_TERMINATION); in OH_JSVM_GetValueStringUtf8()
3373 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueStringUtf16()
3378 // V8 assumes UTF-16 length is the same as the number of characters. in OH_JSVM_GetValueStringUtf16()
3379 *result = val.As<v8::String>()->Length(); in OH_JSVM_GetValueStringUtf16()
3381 …int copied = val.As<v8::String>()->Write(env->isolate, reinterpret_cast<uint16_t*>(buf), 0, bufsiz… in OH_JSVM_GetValueStringUtf16()
3382 v8::String::NO_NULL_TERMINATION); in OH_JSVM_GetValueStringUtf16()
3402 v8::Isolate* isolate = env->isolate; in OH_JSVM_CoerceToBool()
3403 v8::Local<v8::Boolean> b = v8impl::V8LocalValueFromJsValue(value)->ToBoolean(isolate); in OH_JSVM_CoerceToBool()
3417 … v8::Local<v8::Context> context = env->context(); \
3418 … v8::Local<v8::MixedCaseName> str; \
3463 v8::Isolate* isolate = env->isolate; in OH_JSVM_CreateExternal()
3465 v8::Local<v8::Value> externalValue = v8::External::New(isolate, data); in OH_JSVM_CreateExternal()
3482 v8::Local<v8::Context> context = env->context(); in OH_JSVM_TypeTagObject()
3483 v8::Local<v8::Object> obj; in OH_JSVM_TypeTagObject()
3492 auto tag = v8::BigInt::NewFromWords(context, 0, 2, reinterpret_cast<const uint64_t*>(typeTag)); in OH_JSVM_TypeTagObject()
3506 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CheckObjectTypeTag()
3507 v8::Local<v8::Object> obj; in OH_JSVM_CheckObjectTypeTag()
3514 v8::Local<v8::Value> val = maybeValue.ToLocalChecked(); in OH_JSVM_CheckObjectTypeTag()
3524 val.As<v8::BigInt>()->ToWordsArray(&sign, &size, reinterpret_cast<uint64_t*>(&tag)); in OH_JSVM_CheckObjectTypeTag()
3546 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetValueExternal()
3549 v8::Local<v8::External> externalValue = val.As<v8::External>(); in OH_JSVM_GetValueExternal()
3558 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_CreateReference()
3565 v8::Local<v8::Value> v8Value = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_CreateReference()
3576 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_DeleteReference()
3593 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_ReferenceRef()
3614 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_ReferenceUnref()
3639 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetReferenceValue()
3654 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_OpenHandleScope()
3675 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_CloseHandleScope()
3700 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_OpenEscapableHandleScope()
3720 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_CloseEscapableHandleScope()
3754 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_EscapeHandle()
3785 v8::Local<v8::Context> context = env->context(); in OH_JSVM_NewInstance()
3787 v8::Local<v8::Function> ctor; in OH_JSVM_NewInstance()
3791 …ctor->NewInstance(context, argc, reinterpret_cast<v8::Local<v8::Value>*>(const_cast<JSVM_Value*>(a… in OH_JSVM_NewInstance()
3809 v8::Local<v8::Object> ctor; in OH_JSVM_Instanceof()
3810 v8::Local<v8::Context> context = env->context(); in OH_JSVM_Instanceof()
3822 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(object); in OH_JSVM_Instanceof()
3851 …*result = v8impl::JsValueFromV8LocalValue(v8::Local<v8::Value>::New(env->isolate, env->lastExcepti… in OH_JSVM_GetAndClearLastException()
3868 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsArraybuffer()
3879 v8::Isolate* isolate = env->isolate; in OH_JSVM_CreateArraybuffer()
3880 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, byteLength); in OH_JSVM_CreateArraybuffer()
3931 …v8::ArrayBuffer::NewBackingStore(dataPtr, arrayBufferSize, v8::BackingStore::EmptyDeleter, nullptr… in OH_JSVM_CreateArrayBufferFromBackingStoreData()
3932 …v8::Local<v8::ArrayBuffer> arrayBuffer = v8::ArrayBuffer::New(env->isolate, std::move(backingStore… in OH_JSVM_CreateArrayBufferFromBackingStoreData()
3944 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer); in OH_JSVM_GetArraybufferInfo()
3947 v8::Local<v8::ArrayBuffer> ab = value.As<v8::ArrayBuffer>(); in OH_JSVM_GetArraybufferInfo()
3967 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsTypedarray()
3985 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer); in OH_JSVM_CreateTypedarray()
3988 v8::Local<v8::ArrayBuffer> buffer = value.As<v8::ArrayBuffer>(); in OH_JSVM_CreateTypedarray()
3989 v8::Local<v8::TypedArray> typedArray; in OH_JSVM_CreateTypedarray()
4046 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(typedarray); in OH_JSVM_GetTypedarrayInfo()
4049 v8::Local<v8::TypedArray> array = value.As<v8::TypedArray>(); in OH_JSVM_GetTypedarrayInfo()
4081 v8::Local<v8::ArrayBuffer> buffer; in OH_JSVM_GetTypedarrayInfo()
4115 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer); in OH_JSVM_CreateDataview()
4118 v8::Local<v8::ArrayBuffer> buffer = value.As<v8::ArrayBuffer>(); in OH_JSVM_CreateDataview()
4126 v8::Local<v8::DataView> DataView = v8::DataView::New(buffer, byteOffset, byteLength); in OH_JSVM_CreateDataview()
4140 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsDataview()
4157 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(dataview); in OH_JSVM_GetDataviewInfo()
4160 v8::Local<v8::DataView> array = value.As<v8::DataView>(); in OH_JSVM_GetDataviewInfo()
4166 v8::Local<v8::ArrayBuffer> buffer; in OH_JSVM_GetDataviewInfo()
4203 auto maybe = v8::Promise::Resolver::New(env->context()); in OH_JSVM_CreatePromise()
4207 auto v8Deferred = new v8impl::Persistent<v8::Value>(); in OH_JSVM_CreatePromise()
4257 v8::MaybeLocal<v8::Value> maybeDate = v8::Date::New(env->context(), time); in OH_JSVM_CreateDate()
4285 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_GetDateValue()
4288 v8::Local<v8::Date> date = val.As<v8::Date>(); in OH_JSVM_GetDateValue()
4301 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_AddFinalizer()
4308 v8::Local<v8::Value> v8Value = v8impl::V8LocalValueFromJsValue(jsObject); in OH_JSVM_AddFinalizer()
4364 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer); in OH_JSVM_DetachArraybuffer()
4367 v8::Local<v8::ArrayBuffer> it = value.As<v8::ArrayBuffer>(); in OH_JSVM_DetachArraybuffer()
4382 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer); in OH_JSVM_IsDetachedArraybuffer()
4384 *result = value->IsArrayBuffer() && value.As<v8::ArrayBuffer>()->WasDetached(); in OH_JSVM_IsDetachedArraybuffer()
4409 v8::Isolate* isolate = env->isolate; in OH_JSVM_DefineClassWithPropertyHandler()
4410 v8::EscapableHandleScope scope(isolate); in OH_JSVM_DefineClassWithPropertyHandler()
4411 v8::Local<v8::FunctionTemplate> tpl; in OH_JSVM_DefineClassWithPropertyHandler()
4414 v8::Local<v8::String> nameString; in OH_JSVM_DefineClassWithPropertyHandler()
4428 v8::Local<v8::Name> propertyName; in OH_JSVM_DefineClassWithPropertyHandler()
4430 v8::PropertyAttribute attributes = v8impl::V8PropertyAttributesFromDescriptor(p); in OH_JSVM_DefineClassWithPropertyHandler()
4437 v8::Local<v8::FunctionTemplate> getterTpl; in OH_JSVM_DefineClassWithPropertyHandler()
4438 v8::Local<v8::FunctionTemplate> setterTpl; in OH_JSVM_DefineClassWithPropertyHandler()
4448 v8::Local<v8::FunctionTemplate> t; in OH_JSVM_DefineClassWithPropertyHandler()
4453 …v8impl::FunctionCallbackWrapper::NewTemplate(env, p->method, &t, v8::Signature::New(isolate, tpl))… in OH_JSVM_DefineClassWithPropertyHandler()
4458 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(p->value); in OH_JSVM_DefineClassWithPropertyHandler()
4468 v8::Local<v8::Value> cbdata = v8impl::CallbackBundle::New(env, propertyHandleCfg); in OH_JSVM_DefineClassWithPropertyHandler()
4471 v8::NamedPropertyHandlerConfiguration namedPropertyHandler(nullptr); in OH_JSVM_DefineClassWithPropertyHandler()
4473 namedPropertyHandler.getter = v8impl::PropertyCallbackWrapper<v8::Value>::NameGetterInvoke; in OH_JSVM_DefineClassWithPropertyHandler()
4479 … namedPropertyHandler.deleter = v8impl::PropertyCallbackWrapper<v8::Boolean>::NameDeleterInvoke; in OH_JSVM_DefineClassWithPropertyHandler()
4482 …namedPropertyHandler.enumerator = v8impl::PropertyCallbackWrapper<v8::Array>::NameEnumeratorInvoke; in OH_JSVM_DefineClassWithPropertyHandler()
4488 v8::IndexedPropertyHandlerConfiguration indexPropertyHandler; in OH_JSVM_DefineClassWithPropertyHandler()
4490 indexPropertyHandler.getter = v8impl::PropertyCallbackWrapper<v8::Value>::IndexGetterInvoke; in OH_JSVM_DefineClassWithPropertyHandler()
4496 … indexPropertyHandler.deleter = v8impl::PropertyCallbackWrapper<v8::Boolean>::IndexDeleterInvoke; in OH_JSVM_DefineClassWithPropertyHandler()
4499 …indexPropertyHandler.enumerator = v8impl::PropertyCallbackWrapper<v8::Array>::IndexEnumeratorInvok… in OH_JSVM_DefineClassWithPropertyHandler()
4506 v8::Local<v8::Value> funcCbdata = v8impl::CallbackBundle::New(env, callAsFunctionCallback); in OH_JSVM_DefineClassWithPropertyHandler()
4510 v8::Local<v8::Context> context = env->context(); in OH_JSVM_DefineClassWithPropertyHandler()
4539 *isLocked = v8::Locker::IsLocked(env->isolate); in OH_JSVM_IsLocked()
4548 bool isLocked = v8::Locker::IsLocked(env->isolate); in OH_JSVM_AcquireLock()
4550 env->locker = new v8::Locker(env->isolate); in OH_JSVM_AcquireLock()
4560 bool isLocked = v8::Locker::IsLocked(env->isolate); in OH_JSVM_ReleaseLock()
4576 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsCallable()
4584 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in IsUndefinedImpl()
4592 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsUndefined()
4604 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in IsNullImpl()
4612 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsNull()
4624 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in IsNullOrUndefinedImpl()
4632 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsNullOrUndefined()
4644 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsBoolean()
4651 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsBoolean()
4659 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsNumber()
4666 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsNumber()
4674 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in IsStringImpl()
4682 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsString()
4694 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsSymbol()
4701 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsSymbol()
4709 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsFunction()
4716 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsFunction()
4724 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsObject()
4731 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsObject()
4739 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsBigInt()
4746 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsBigInt()
4759 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsConstructor()
4764 v8::Local<v8::Object> obj = val.As<v8::Object>(); in OH_JSVM_IsConstructor()
4777 v8::Local<v8::Value> pattern = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_CreateRegExp()
4779 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CreateRegExp()
4780 v8::MaybeLocal<v8::RegExp> regExp = in OH_JSVM_CreateRegExp()
4781 v8::RegExp::New(context, pattern.As<v8::String>(), static_cast<v8::RegExp::Flags>(flags)); in OH_JSVM_CreateRegExp()
4794 *result = v8impl::JsValueFromV8LocalValue(v8::Map::New(env->isolate)); in OH_JSVM_CreateMap()
4807 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsMap()
4820 …jsvmData->taggedPointer = v8::Global<v8::Script>(env->isolate, jsvmData->ToV8Local<v8::Script>(env… in OH_JSVM_RetainScript()
4834 std::get<v8::Global<v8::Script>>(jsvmData->taggedPointer).Reset(); in OH_JSVM_ReleaseScript()
4858 *result = v8impl::JsValueFromV8LocalValue(v8::Set::New(env->isolate)); in OH_JSVM_CreateSet()
4871 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsSet()
4883 v8::Local<v8::Context> context = env->context(); in OH_JSVM_ObjectGetPrototypeOf()
4885 v8::Local<v8::Object> obj; in OH_JSVM_ObjectGetPrototypeOf()
4888 v8::Local<v8::Value> val = obj->GetPrototypeV2(); in OH_JSVM_ObjectGetPrototypeOf()
4900 v8::Local<v8::Context> context = env->context(); in OH_JSVM_ObjectSetPrototypeOf()
4902 v8::Local<v8::Object> obj; in OH_JSVM_ObjectSetPrototypeOf()
4905 v8::Local<v8::Value> type = v8impl::V8LocalValueFromJsValue(prototype); in OH_JSVM_ObjectSetPrototypeOf()
4907 v8::Maybe<bool> setMaybe = obj->SetPrototypeV2(context, type); in OH_JSVM_ObjectSetPrototypeOf()
4930 v8::MaybeLocal<v8::WasmModuleObject> maybeModule; in OH_JSVM_CompileWasmModule()
4932 … maybeModule = v8::WasmModuleObject::Compile(env->isolate, { wasmBytecode, wasmBytecodeLength }); in OH_JSVM_CompileWasmModule()
4936 …maybeModule = v8::WasmModuleObject::DeserializeOrCompile(env->isolate, { wasmBytecode, wasmBytecod… in OH_JSVM_CompileWasmModule()
4942 …// To avoid the status code caused by exception being override, check exception once v8 API finish… in OH_JSVM_CompileWasmModule()
4964 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(wasmModule); in OH_JSVM_CompileWasmFunction()
4967 v8::Local<v8::WasmModuleObject> v8WasmModule = val.As<v8::WasmModuleObject>(); in OH_JSVM_CompileWasmFunction()
4968 v8::WasmExecutionTier tier = v8::WasmExecutionTier::kNone; in OH_JSVM_CompileWasmFunction()
4970 // v8 liftoff has bug, keep BASELINE same as HIGH. in OH_JSVM_CompileWasmFunction()
4971 tier = v8::WasmExecutionTier::kTurbofan; in OH_JSVM_CompileWasmFunction()
4973 tier = v8::WasmExecutionTier::kTurbofan; in OH_JSVM_CompileWasmFunction()
4979 …// To avoid the status code caused by exception being override, check exception once v8 API finish… in OH_JSVM_CompileWasmFunction()
4987 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 in OH_JSVM_IsWasmModuleObject()
4994 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsWasmModuleObject()
5014 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(wasmModule); in OH_JSVM_CreateWasmCache()
5017 v8::Local<v8::WasmModuleObject> v8WasmModule = val.As<v8::WasmModuleObject>(); in OH_JSVM_CreateWasmCache()
5018 v8::CompiledWasmModule compiledWasmModule = v8WasmModule->GetCompiledModule(); in OH_JSVM_CreateWasmCache()
5019 v8::OwnedBuffer serializedBytes = compiledWasmModule.Serialize(); in OH_JSVM_CreateWasmCache()
5020 …// To avoid the status code caused by exception being override, check exception once v8 API finish… in OH_JSVM_CreateWasmCache()
5056 v8::Local<v8::Value> v = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsBooleanObject()
5069 v8::Local<v8::Value> v = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsBigIntObject()
5082 v8::Local<v8::Value> v = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsStringObject()
5095 v8::Local<v8::Value> v = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsNumberObject()
5108 v8::Local<v8::Value> v = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsSymbolObject()
5119 v8::Local<v8::Symbol> symbolToStringTag = v8::Symbol::GetToStringTag(env->isolate); in OH_JSVM_GetSymbolToStringTag()
5131 v8::Local<v8::Symbol> symbolIterator = v8::Symbol::GetIterator(env->isolate); in OH_JSVM_GetSymbolIterator()
5143 v8::Local<v8::Symbol> symbolAsyncIterator = v8::Symbol::GetAsyncIterator(env->isolate); in OH_JSVM_GetSymbolAsyncIterator()
5155 v8::Local<v8::Symbol> symbolHasInstance = v8::Symbol::GetHasInstance(env->isolate); in OH_JSVM_GetSymbolHasInstance()
5167 v8::Local<v8::Symbol> symbolUnscopables = v8::Symbol::GetUnscopables(env->isolate); in OH_JSVM_GetSymbolUnscopables()
5179 … v8::Local<v8::Symbol> symbolIsConcatSpreadable = v8::Symbol::GetIsConcatSpreadable(env->isolate); in OH_JSVM_GetSymbolIsConcatSpreadable()
5191 v8::Local<v8::Symbol> symbolMatch = v8::Symbol::GetMatch(env->isolate); in OH_JSVM_GetSymbolMatch()
5203 v8::Local<v8::Symbol> symbolReplace = v8::Symbol::GetReplace(env->isolate); in OH_JSVM_GetSymbolReplace()
5215 v8::Local<v8::Symbol> symbolSearch = v8::Symbol::GetSearch(env->isolate); in OH_JSVM_GetSymbolSearch()
5227 v8::Local<v8::Symbol> symbolSplit = v8::Symbol::GetSplit(env->isolate); in OH_JSVM_GetSymbolSplit()
5239 v8::Local<v8::Symbol> symbolToPrimitive = v8::Symbol::GetToPrimitive(env->isolate); in OH_JSVM_GetSymbolToPrimitive()
5248 static constexpr v8::MicrotasksPolicy converter[] = { v8::MicrotasksPolicy::kExplicit, in OH_JSVM_SetMicrotaskPolicy()
5249 v8::MicrotasksPolicy::kAuto }; in OH_JSVM_SetMicrotaskPolicy()
5255 auto isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_SetMicrotaskPolicy()
5270 // Check target and handler are v8 Object in OH_JSVM_CreateProxy()
5276 v8::Local<v8::Context> context = env->context(); in OH_JSVM_CreateProxy()
5278 v8::MaybeLocal<v8::Proxy> maybeProxy = in OH_JSVM_CreateProxy()
5279 v8::Proxy::New(context, localTarget.As<v8::Object>(), localHandler.As<v8::Object>()); in OH_JSVM_CreateProxy()
5283 v8::Local<v8::Proxy> proxy = maybeProxy.ToLocalChecked(); in OH_JSVM_CreateProxy()
5297 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_IsProxy()
5310 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue(value); in OH_JSVM_ProxyGetTarget()
5314 *result = v8impl::JsValueFromV8LocalValue(val.As<v8::Proxy>()->GetTarget()); in OH_JSVM_ProxyGetTarget()
5322 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_CreateDataReference()
5329 v8::Local<v8::Data> v8_value = v8impl::V8LocalDataFromJsData(data); in OH_JSVM_CreateDataReference()
5341 // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw in OH_JSVM_GetReferenceData()
5360 v8::Isolate* isolate = env->isolate; in OH_JSVM_CreatePrivate()
5363 *result = v8impl::JsDataFromV8LocalData(v8::Private::New(isolate)); in OH_JSVM_CreatePrivate()
5365 v8::Local<v8::Value> v8Name = v8impl::V8LocalValueFromJsValue(description); in OH_JSVM_CreatePrivate()
5368 *result = v8impl::JsDataFromV8LocalData(v8::Private::New(isolate, v8Name.As<v8::String>())); in OH_JSVM_CreatePrivate()
5390 auto set_maybe = obj.As<v8::Object>()->SetPrivate(context, privateKey.As<v8::Private>(), val); in OH_JSVM_SetPrivate()
5410 auto getMaybe = obj.As<v8::Object>()->GetPrivate(context, privateKey.As<v8::Private>()); in OH_JSVM_GetPrivate()
5413 v8::Local<v8::Value> val = getMaybe.ToLocalChecked(); in OH_JSVM_GetPrivate()
5432 auto deleteMaybe = obj.As<v8::Object>()->DeletePrivate(context, privateKey.As<v8::Private>()); in OH_JSVM_DeletePrivate()
5448 OH_JSVM_CreateStringLatin1, [&](v8::Isolate* isolate) { in OH_JSVM_CreateExternalStringLatin1()
5455 return v8::String::NewExternalOneByte(isolate, resource); in OH_JSVM_CreateExternalStringLatin1()
5469 OH_JSVM_CreateStringUtf16, [&](v8::Isolate* isolate) { in OH_JSVM_CreateExternalStringUtf16()
5476 return v8::String::NewExternalTwoByte(isolate, resource); in OH_JSVM_CreateExternalStringUtf16()
5480 JSVM_GCType GetJSVMGCType(v8::GCType gcType) in GetJSVMGCType()
5483 case v8::GCType::kGCTypeScavenge: in GetJSVMGCType()
5485 case v8::GCType::kGCTypeMinorMarkSweep: in GetJSVMGCType()
5487 case v8::GCType::kGCTypeMarkSweepCompact: in GetJSVMGCType()
5489 case v8::GCType::kGCTypeIncrementalMarking: in GetJSVMGCType()
5491 case v8::GCType::kGCTypeProcessWeakCallbacks: in GetJSVMGCType()
5498 static v8::GCType GetV8GCType(JSVM_GCType gcType) in GetV8GCType()
5502 return v8::GCType::kGCTypeScavenge; in GetV8GCType()
5504 return v8::GCType::kGCTypeMinorMarkSweep; in GetV8GCType()
5506 return v8::GCType::kGCTypeMarkSweepCompact; in GetV8GCType()
5508 return v8::GCType::kGCTypeIncrementalMarking; in GetV8GCType()
5510 return v8::GCType::kGCTypeProcessWeakCallbacks; in GetV8GCType()
5512 return v8::GCType::kGCTypeAll; in GetV8GCType()
5516 JSVM_GCCallbackFlags GetJSVMGCCallbackFlags(v8::GCCallbackFlags flag) in GetJSVMGCCallbackFlags()
5519 case v8::GCCallbackFlags::kGCCallbackFlagConstructRetainedObjectInfos: in GetJSVMGCCallbackFlags()
5521 case v8::GCCallbackFlags::kGCCallbackFlagForced: in GetJSVMGCCallbackFlags()
5523 case v8::GCCallbackFlags::kGCCallbackFlagSynchronousPhantomCallbackProcessing: in GetJSVMGCCallbackFlags()
5525 case v8::GCCallbackFlags::kGCCallbackFlagCollectAllAvailableGarbage: in GetJSVMGCCallbackFlags()
5527 case v8::GCCallbackFlags::kGCCallbackFlagCollectAllExternalMemory: in GetJSVMGCCallbackFlags()
5529 case v8::GCCallbackFlags::kGCCallbackScheduleIdleGarbageCollection: in GetJSVMGCCallbackFlags()
5536 static void OnBeforeGC(v8::Isolate* isolate, v8::GCType type, v8::GCCallbackFlags flags, void* data) in OnBeforeGC()
5546 static void OnAfterGC(v8::Isolate* isolate, v8::GCType type, v8::GCCallbackFlags flags, void* data) in OnAfterGC()
5565 auto* isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_AddHandlerForGC()
5594 auto* isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_RemoveHandlerForGC()
5619 static void OnOOMError(const char* location, const v8::OOMDetails& details) in OnOOMError()
5621 auto* isolate = v8::Isolate::GetCurrent(); in OnOOMError()
5638 auto* isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_SetHandlerForOOMError()
5647 auto* isolate = v8::Isolate::GetCurrent(); in OnFatalError()
5664 auto* isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_SetHandlerForFatalError()
5671 static void OnPromiseReject(v8::PromiseRejectMessage rejectMessage) in OnPromiseReject()
5673 auto* isolate = v8::Isolate::GetCurrent(); in OnPromiseReject()
5684 v8::HandleScope scope(isolate); in OnPromiseReject()
5685 v8::Local<v8::Object> rejectInfo = v8::Object::New(isolate); in OnPromiseReject()
5686 auto strPromise = v8::String::NewFromUtf8(isolate, "promise").ToLocalChecked(); in OnPromiseReject()
5688 auto strValue = v8::String::NewFromUtf8(isolate, "value").ToLocalChecked(); in OnPromiseReject()
5694 case v8::kPromiseRejectWithNoHandler: { in OnPromiseReject()
5698 case v8::kPromiseHandlerAddedAfterReject: { in OnPromiseReject()
5702 case v8::kPromiseRejectAfterResolved: { in OnPromiseReject()
5706 case v8::kPromiseResolveAfterResolved: { in OnPromiseReject()
5722 auto* isolate = reinterpret_cast<v8::Isolate*>(vm); in OH_JSVM_SetHandlerForPromiseReject()
5744 using namespace v8::platform::tracing; in OH_JSVM_TraceStart()
5756 v8::Platform* platform = v8impl::g_platform.get(); in OH_JSVM_TraceStart()
5791 using namespace v8::platform::tracing; in OH_JSVM_TraceStop()
5792 v8::Platform* platform = v8impl::g_platform.get(); in OH_JSVM_TraceStop()
5808 v8::Local<v8::FunctionTemplate> tpl, in ProcessPropertyHandler()
5818 v8::Local<v8::Value> cbdata = v8impl::CallbackBundle::New(env, *propertyHandlerCfgStruct); in ProcessPropertyHandler()
5821 v8::NamedPropertyHandlerConfiguration namedPropertyHandler(nullptr); in ProcessPropertyHandler()
5823 namedPropertyHandler.getter = v8impl::PropertyCallbackWrapper<v8::Value>::NameGetterInvoke; in ProcessPropertyHandler()
5826 namedPropertyHandler.setter = v8impl::PropertyCallbackWrapper<v8::Value>::NameSetterInvoke; in ProcessPropertyHandler()
5829 … namedPropertyHandler.deleter = v8impl::PropertyCallbackWrapper<v8::Boolean>::NameDeleterInvoke; in ProcessPropertyHandler()
5832 …namedPropertyHandler.enumerator = v8impl::PropertyCallbackWrapper<v8::Array>::NameEnumeratorInvoke; in ProcessPropertyHandler()
5838 v8::IndexedPropertyHandlerConfiguration indexPropertyHandler(nullptr); in ProcessPropertyHandler()
5840 indexPropertyHandler.getter = v8impl::PropertyCallbackWrapper<v8::Value>::IndexGetterInvoke; in ProcessPropertyHandler()
5843 indexPropertyHandler.setter = v8impl::PropertyCallbackWrapper<v8::Value>::IndexSetterInvoke; in ProcessPropertyHandler()
5846 … indexPropertyHandler.deleter = v8impl::PropertyCallbackWrapper<v8::Boolean>::IndexDeleterInvoke; in ProcessPropertyHandler()
5849 …indexPropertyHandler.enumerator = v8impl::PropertyCallbackWrapper<v8::Array>::IndexEnumeratorInvok… in ProcessPropertyHandler()
5856 v8::Local<v8::Value> funcCbdata = v8impl::CallbackBundle::New(env, callAsFunctionCallback); in ProcessPropertyHandler()
5867 v8::Local<v8::FunctionTemplate> tpl) in ProcessOptions()
5878 v8::Local<v8::ObjectTemplate> instance_templ = tpl->InstanceTemplate(); in ProcessOptions()
5942 v8::Isolate* isolate = env->isolate; in OH_JSVM_DefineClassWithOptions()
5943 v8::EscapableHandleScope scope(isolate); in OH_JSVM_DefineClassWithOptions()
5944 v8::Local<v8::FunctionTemplate> tpl; in OH_JSVM_DefineClassWithOptions()
5947 v8::Local<v8::String> nameString; in OH_JSVM_DefineClassWithOptions()
5960 v8::Local<v8::Name> propertyName; in OH_JSVM_DefineClassWithOptions()
5962 v8::PropertyAttribute attributes = v8impl::V8PropertyAttributesFromDescriptor(p); in OH_JSVM_DefineClassWithOptions()
5968 v8::Local<v8::FunctionTemplate> getterTpl; in OH_JSVM_DefineClassWithOptions()
5969 v8::Local<v8::FunctionTemplate> setterTpl; in OH_JSVM_DefineClassWithOptions()
5979 v8::Local<v8::FunctionTemplate> temp; in OH_JSVM_DefineClassWithOptions()
5981 …v8impl::FunctionCallbackWrapper::NewTemplate(env, p->method, &temp, v8::Signature::New(isolate, tp… in OH_JSVM_DefineClassWithOptions()
5985 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(p->value); in OH_JSVM_DefineClassWithOptions()
5991 v8::Local<v8::Function> parentFunc; in OH_JSVM_DefineClassWithOptions()
6005 v8::Local<v8::Context> context = env->context(); in OH_JSVM_DefineClassWithOptions()
6042 v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(promise); in OH_JSVM_PromiseRegisterHandler()
6044 auto localPromise = value.As<v8::Promise>(); in OH_JSVM_PromiseRegisterHandler()
6046 v8::Local<v8::Context> ctx = env->context(); in OH_JSVM_PromiseRegisterHandler()
6047 v8::MaybeLocal<v8::Promise> maybe; in OH_JSVM_PromiseRegisterHandler()
6049 // Only pass onRejected, call v8::Promise::Catch in OH_JSVM_PromiseRegisterHandler()
6052 maybe = localPromise->Catch(ctx, rejectedHandler.As<v8::Function>()); in OH_JSVM_PromiseRegisterHandler()
6054 // Only pass onFulfilled, call v8::Promise::Then in OH_JSVM_PromiseRegisterHandler()
6057 maybe = value.As<v8::Promise>()->Then(ctx, fulfiledHandler.As<v8::Function>()); in OH_JSVM_PromiseRegisterHandler()
6059 // Pass onFulfilled and onRejected, call v8::Promise::Then in OH_JSVM_PromiseRegisterHandler()
6065 …value.As<v8::Promise>()->Then(ctx, fulfiledHandler.As<v8::Function>(), rejectedHandler.As<v8::Func… in OH_JSVM_PromiseRegisterHandler()
6096 if (v8::V8::CreateJSVMExtractor(extractorPtr, pid) == 0) { in create_jsvm_extractor()
6106 v8::V8::DeleteJSVMExtractor(extractorPtr); in destroy_jsvm_extractor()
6115 int ret = v8::V8::GetJSVMCodeName(jsvmExtractorPtr, pc, codeName); in jsvm_parse_js_frame_info()