1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ARK_RUNTIME_JSVM_JSVM_TYPE_H 17 #define ARK_RUNTIME_JSVM_JSVM_TYPE_H 18 19 /** 20 * @addtogroup JSVM 21 * @{ 22 * 23 * @brief Provides the standard JavaScript engine capabilities. 24 * 25 * Provides API to Provide independent, standard, and complete JavaScript engine capabilities for developers, 26 * including managing the engine lifecycle, compiling and running JS code, implementing JS/C++ cross language calls, 27 * and taking snapshots. 28 * 29 * @since 11 30 */ 31 32 /** 33 * @file jsvm_types.h 34 * 35 * @brief Provides the JSVM API type define. 36 * 37 * Provides API to Provide independent, standard, and complete JavaScript engine capabilities for developers, 38 * including managing the engine lifecycle, compiling and running JS code, implementing JS/C++ cross language calls, 39 * and taking snapshots. 40 * @library libjsvm.so 41 * @syscap SystemCapability.ArkCompiler.JSVM 42 * @since 11 43 */ 44 45 #include <stddef.h> // NOLINT(modernize-deprecated-headers) 46 #include <stdint.h> // NOLINT(modernize-deprecated-headers) 47 #include <stdbool.h> // NOLINT(modernize-deprecated-headers) 48 49 #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900) 50 typedef uint16_t char16_t; 51 #endif 52 53 #ifndef JSVM_CDECL 54 #ifdef _WIN32 55 #define JSVM_CDECL __cdecl 56 #else 57 #define JSVM_CDECL 58 #endif 59 #endif 60 61 /** 62 * @brief To represent a JavaScript VM instance. 63 * 64 * @since 11 65 */ 66 typedef struct JSVM_VM__* JSVM_VM; 67 68 /** 69 * @brief To represent a JavaScript VM scope. 70 * 71 * @since 11 72 */ 73 typedef struct JSVM_VMScope__* JSVM_VMScope; 74 75 /** 76 * @brief To represent a JavaScript VM environment scope. 77 * 78 * @since 11 79 */ 80 typedef struct JSVM_EnvScope__* JSVM_EnvScope; 81 82 /** 83 * @brief To represent a JavaScript code. 84 * 85 * @since 11 86 */ 87 typedef struct JSVM_Script__* JSVM_Script; 88 89 /** 90 * @brief To represent a JavaScript VM instance. 91 * 92 * @since 11 93 */ 94 typedef struct JSVM_Env__* JSVM_Env; 95 96 /** 97 * @brief To represent a JavaScript profiler. 98 * 99 * @since 12 100 */ 101 typedef struct JSVM_CpuProfiler__* JSVM_CpuProfiler; 102 103 /** 104 * @brief To represent a JavaScript VM environment. 105 * 106 * @since 11 107 */ 108 typedef struct JSVM_Value__* JSVM_Value; 109 110 /** 111 * @brief To represent a JavaScript value references. 112 * 113 * @since 11 114 */ 115 typedef struct JSVM_Ref__* JSVM_Ref; 116 117 /** 118 * @brief To represent a JavaScript VM handle scope. 119 * 120 * @since 11 121 */ 122 typedef struct JSVM_HandleScope__* JSVM_HandleScope; 123 124 /** 125 * @brief To represent a JavaScript VM escapable handle scope. 126 * 127 * @since 11 128 */ 129 typedef struct JSVM_EscapableHandleScope__* JSVM_EscapableHandleScope; 130 131 /** 132 * @brief To represent a JavaScript VM callback additional information. 133 * 134 * @since 11 135 */ 136 typedef struct JSVM_CallbackInfo__* JSVM_CallbackInfo; 137 138 /** 139 * @brief To represent a JavaScript VM value deferred. 140 * 141 * @since 11 142 */ 143 typedef struct JSVM_Deferred__* JSVM_Deferred; 144 145 146 /** 147 * @brief Callback function pointer and data for user-provided native function which are to exposed to js via JSVM-API. 148 * 149 * @since 11 150 */ 151 typedef struct { 152 JSVM_Value(JSVM_CDECL* callback)(JSVM_Env env, 153 JSVM_CallbackInfo info); 154 void* data; 155 } JSVM_CallbackStruct; 156 157 /** 158 * @brief Function pointer type for user-provided native function which are to exposed to js via JSVM-API. 159 * 160 * @since 11 161 */ 162 typedef JSVM_CallbackStruct* JSVM_Callback; 163 164 /** 165 * @brief Function pointer type for add-on provided function that allow the user to be notified. 166 * 167 * @since 11 168 */ 169 typedef void(JSVM_CDECL* JSVM_Finalize)(JSVM_Env env, 170 void* finalizeData, 171 void* finalizeHint); 172 173 /** 174 * @brief Function pointer type for callback of ASCII output stream. 175 * 176 * @since 12 177 */ 178 typedef bool(JSVM_CDECL* JSVM_OutputStream)(const char* data, 179 int size, 180 void* streamData); 181 182 /** 183 * @brief JSVM_PropertyAttributes are flag used to control the behavior of properties set on a js object. 184 * 185 * @since 11 186 */ 187 typedef enum { 188 /** No explicit attributes are set on the property. */ 189 JSVM_DEFAULT = 0, 190 /** The property is writable. */ 191 JSVM_WRITABLE = 1 << 0, 192 /** The property is enumeable. */ 193 JSVM_ENUMERABLE = 1 << 1, 194 /** The property is configurable. */ 195 JSVM_CONFIGURABLE = 1 << 2, 196 /** Used to mark the receiver of a native method need not be checked. 197 * If JSVM_NO_RECEIVER_CHECK is not set, the method only accept instance of the defined class as receiver, 198 * Otherwise Exception "Type Error: Illegal Ivocation" will be throw into JSVM. 199 */ 200 JSVM_NO_RECEIVER_CHECK = 1 << 3, 201 /** Used with OH_JSVM_DefineClass to distinguish static properties from instance properties. */ 202 JSVM_STATIC = 1 << 10, 203 /** Default for class methods. */ 204 JSVM_DEFAULT_METHOD = JSVM_WRITABLE | JSVM_CONFIGURABLE, 205 /** Class method with no receiver check*/ 206 JSVM_METHOD_NO_RECEIVER_CHECK = JSVM_DEFAULT_METHOD | JSVM_NO_RECEIVER_CHECK, 207 /** Default for object properties, like in JS obj[prop]. */ 208 JSVM_DEFAULT_JSPROPERTY = JSVM_WRITABLE | JSVM_ENUMERABLE | JSVM_CONFIGURABLE, 209 /** Object properties with no receiver check*/ 210 JSVM_JSPROPERTY_NO_RECEIVER_CHECK = JSVM_DEFAULT_JSPROPERTY | JSVM_NO_RECEIVER_CHECK, 211 } JSVM_PropertyAttributes; 212 213 /** 214 * @brief Describes the type of a JSVM_Value. 215 * 216 * @since 11 217 */ 218 typedef enum { 219 /** undefined type. */ 220 JSVM_UNDEFINED, 221 /** null type. */ 222 JSVM_NULL, 223 /** boolean type. */ 224 JSVM_BOOLEAN, 225 /** number type. */ 226 JSVM_NUMBER, 227 /** string type. */ 228 JSVM_STRING, 229 /** symbol type. */ 230 JSVM_SYMBOL, 231 /** object type. */ 232 JSVM_OBJECT, 233 /** function type. */ 234 JSVM_FUNCTION, 235 /** external type. */ 236 JSVM_EXTERNAL, 237 /** bigint type. */ 238 JSVM_BIGINT, 239 } JSVM_ValueType; 240 241 /** 242 * @brief Describes the type of a typedarray. 243 * 244 * @since 11 245 */ 246 typedef enum { 247 /** int8 type. */ 248 JSVM_INT8_ARRAY, 249 /** uint8 type. */ 250 JSVM_UINT8_ARRAY, 251 /** uint8 clamped type. */ 252 JSVM_UINT8_CLAMPED_ARRAY, 253 /** int16 type. */ 254 JSVM_INT16_ARRAY, 255 /** uint16 type. */ 256 JSVM_UINT16_ARRAY, 257 /** int32 type. */ 258 JSVM_INT32_ARRAY, 259 /** uint32 type. */ 260 JSVM_UINT32_ARRAY, 261 /** float32 type. */ 262 JSVM_FLOAT32_ARRAY, 263 /** float64 type. */ 264 JSVM_FLOAT64_ARRAY, 265 /** bigint64 type. */ 266 JSVM_BIGINT64_ARRAY, 267 /** biguint64 type. */ 268 JSVM_BIGUINT64_ARRAY, 269 } JSVM_TypedarrayType; 270 271 /** 272 * @brief Integral status code indicating the success or failure of a JSVM-API call. 273 * 274 * @since 11 275 */ 276 typedef enum { 277 /** success status. */ 278 JSVM_OK, 279 /** invalidarg status. */ 280 JSVM_INVALID_ARG, 281 /** object expected status. */ 282 JSVM_OBJECT_EXPECTED, 283 /** string expected status. */ 284 JSVM_STRING_EXPECTED, 285 /** name expected status. */ 286 JSVM_NAME_EXPECTED, 287 /** function expected status. */ 288 JSVM_FUNCTION_EXPECTED, 289 /** number expected status. */ 290 JSVM_NUMBER_EXPECTED, 291 /** boolean expected status. */ 292 JSVM_BOOLEAN_EXPECTED, 293 /** array expected status. */ 294 JSVM_ARRAY_EXPECTED, 295 /** generic failure status. */ 296 JSVM_GENERIC_FAILURE, 297 /** pending exception status. */ 298 JSVM_PENDING_EXCEPTION, 299 /** cancelled status. */ 300 JSVM_CANCELLED, 301 /** escape called twice status. */ 302 JSVM_ESCAPE_CALLED_TWICE, 303 /** handle scope mismatch status. */ 304 JSVM_HANDLE_SCOPE_MISMATCH, 305 /** callback scope mismatch status. */ 306 JSVM_CALLBACK_SCOPE_MISMATCH, 307 /** queue full status. */ 308 JSVM_QUEUE_FULL, 309 /** closing status. */ 310 JSVM_CLOSING, 311 /** bigint expected status. */ 312 JSVM_BIGINT_EXPECTED, 313 /** date expected status. */ 314 JSVM_DATE_EXPECTED, 315 /** arraybuffer expected status. */ 316 JSVM_ARRAYBUFFER_EXPECTED, 317 /** detachable arraybuffer expected status. */ 318 JSVM_DETACHABLE_ARRAYBUFFER_EXPECTED, 319 /** would deadlock status. */ 320 JSVM_WOULD_DEADLOCK, 321 /** no external buffers allowed status. */ 322 JSVM_NO_EXTERNAL_BUFFERS_ALLOWED, 323 /** cannot run +js status. */ 324 JSVM_CANNOT_RUN_JS, 325 } JSVM_Status; 326 327 /** 328 * @brief limits the range of collected properties.. 329 * 330 * @since 11 331 */ 332 typedef enum { 333 /** will include all keys of the objects's prototype chain as well. */ 334 JSVM_KEY_INCLUDE_PROTOTYPES, 335 /** limits the collected properties to the given object only. */ 336 JSVM_KEY_OWN_ONLY 337 } JSVM_KeyCollectionMode; 338 339 /** 340 * @brief Property filter bits. They can be or'ed to build a composite filter.. 341 * 342 * @since 11 343 */ 344 typedef enum { 345 /** key all properties. */ 346 JSVM_KEY_ALL_PROPERTIES = 0, 347 /** key writable. */ 348 JSVM_KEY_WRITABLE = 1, 349 /** key enumerable. */ 350 JSVM_KEY_ENUMERABLE = 1 << 1, 351 /** key configurable. */ 352 JSVM_KEY_CONFIGURABLE = 1 << 2, 353 /** key skip strings. */ 354 JSVM_KEY_SKIP_STRINGS = 1 << 3, 355 /** key skip symbols. */ 356 JSVM_KEY_SKIP_SYMBOLS = 1 << 4 357 } JSVM_KeyFilter; 358 359 /** 360 * @brief key conversion select. 361 * 362 * @since 11 363 */ 364 typedef enum { 365 /** will return numbers for integer indices. */ 366 JSVM_KEY_KEEP_NUMBERS, 367 /** will convert integer indices to strings. */ 368 JSVM_KEY_NUMBERS_TO_STRINGS 369 } JSVM_KeyConversion; 370 371 /** 372 * @brief Memory pressure level. 373 * 374 * @since 11 375 */ 376 typedef enum { 377 /** none pressure. */ 378 JSVM_MEMORY_PRESSURE_LEVEL_NONE, 379 /** moderate pressure. */ 380 JSVM_MEMORY_PRESSURE_LEVEL_MODERATE, 381 /** critical pressure. */ 382 JSVM_MEMORY_PRESSURE_LEVEL_CRITICAL, 383 } JSVM_MemoryPressureLevel; 384 385 /** 386 * 387 * @brief Compile mode 388 * 389 * @since 12 390 */ 391 typedef enum { 392 /** default mode. */ 393 JSVM_COMPILE_MODE_DEFAULT, 394 /** consume code cache. */ 395 JSVM_COMPILE_MODE_CONSUME_CODE_CACHE, 396 /** apply eager compile. */ 397 JSVM_COMPILE_MODE_EAGER_COMPILE, 398 /** preset for compile profile. */ 399 JSVM_COMPILE_MODE_PRODUCE_COMPILE_PROFILE, 400 /** consume compile profile. */ 401 JSVM_COMPILE_MODE_CONSUME_COMPILE_PROFILE, 402 } JSVM_CompileMode; 403 404 /** 405 * @brief Compile option id 406 * 407 * @since 12 408 */ 409 typedef enum { 410 /** compile mode. */ 411 JSVM_COMPILE_MODE, 412 /** code cache content. */ 413 JSVM_COMPILE_CODE_CACHE, 414 /** script origin. */ 415 JSVM_COMPILE_SCRIPT_ORIGIN, 416 /** compile profile content. */ 417 JSVM_COMPILE_COMPILE_PROFILE, 418 /** switch for source map support. */ 419 JSVM_COMPILE_ENABLE_SOURCE_MAP, 420 } JSVM_CompileOptionId; 421 422 /** 423 * @brief Heap statisics. 424 * 425 * @since 12 426 */ 427 typedef struct { 428 /** the size of the total heap. */ 429 size_t totalHeapSize; 430 /** the executable size of the total heap. */ 431 size_t totalHeapSizeExecutable; 432 /** the physical size of the total heap. */ 433 size_t totalPhysicalSize; 434 /** the available size of the total heap. */ 435 size_t totalAvailableSize; 436 /** used size of the heap. */ 437 size_t usedHeapSize; 438 /** heap size limit. */ 439 size_t heapSizeLimit; 440 /** memory requested by the heap. */ 441 size_t mallocedMemory; 442 /** heap-requested external memory. */ 443 size_t externalMemory; 444 /** peak memory requested by the heap. */ 445 size_t peakMallocedMemory; 446 /** the number of native contexts. */ 447 size_t numberOfNativeContexts; 448 /** the number of detached contexts. */ 449 size_t numberOfDetachedContexts; 450 /** the size of the total global handles. */ 451 size_t totalGlobalHandlesSize; 452 /** the size of the used global handles. */ 453 size_t usedGlobalHandlesSize; 454 } JSVM_HeapStatistics; 455 456 /** 457 * @brief Init the JavaScript VM with init option. 458 * 459 * @since 11 460 */ 461 typedef struct { 462 /** 463 * Optional nullptr-terminated array of raw adddresses in the embedder that the 464 * VM can match against during serialization and use for deserialization. This 465 * array and its content must stay valid for the entire lifetime of the VM 466 * instance. 467 */ 468 const intptr_t* externalReferences; 469 470 /** 471 * Flags for the VM. IF removeFlags is true, recognized flags will be removed 472 * from (argc, argv). Note that these flags are specific to VM. 473 * They are mainly used for development. Do not include them in production as 474 * they might not take effect if the VM is different from the development 475 * environment. 476 */ 477 int* argc; 478 /** argv . */ 479 char** argv; 480 /** remove flags. */ 481 bool removeFlags; 482 } JSVM_InitOptions; 483 484 /** 485 * @brief Create the JavaScript VM with init option. 486 * 487 * @since 11 488 */ 489 typedef struct { 490 /** optional limits of memory use of the vm. */ 491 size_t maxOldGenerationSize; 492 /** optional limits of memory use of the vm. */ 493 size_t maxYoungGenerationSize; 494 /** optional limits of memory use of the vm. */ 495 size_t initialOldGenerationSize; 496 /** optional limits of memory use of the vm. */ 497 size_t initialYoungGenerationSize; 498 /** Optional startup snapshot data. */ 499 const char* snapshotBlobData; 500 /** Optional size of the startup snapshot data. */ 501 size_t snapshotBlobSize; 502 /** Whether the VM is used for creating snapshot. */ 503 bool isForSnapshotting; 504 } JSVM_CreateVMOptions; 505 506 /** 507 * @brief JavaScript VM info. 508 * 509 * @since 11 510 */ 511 typedef struct { 512 /** The highest API version this VM supports. */ 513 uint32_t apiVersion; 514 /** The engine name implementing the VM. */ 515 const char* engine; 516 /** The version of the VM. */ 517 const char* version; 518 /** The cached data version tag. */ 519 uint32_t cachedDataVersionTag; 520 } JSVM_VMInfo; 521 522 /** 523 * @brief Property descriptor. 524 * 525 * @since 11 526 */ 527 typedef struct { 528 /** Optional string describing the key for the property, encoded as UTF8. 529 * One of utf8name or name must be provided for the property. 530 */ 531 const char* utf8name; 532 /** Optional value that points to a JavaScript string or symbol to be used as the key for the property. */ 533 JSVM_Value name; 534 /** Set this to make the property descriptor object's value property to be 535 * a JavaScript function represented by method. 536 */ 537 JSVM_Callback method; 538 /** A function to call when a get access of the property is performed. */ 539 JSVM_Callback getter; 540 /** A function to call when a set access of the property is performed. */ 541 JSVM_Callback setter; 542 /** The value that's retrieved by a get access of the property if the property is a data property. */ 543 JSVM_Value value; 544 /** The attributes associated with the particular property. */ 545 JSVM_PropertyAttributes attributes; 546 } JSVM_PropertyDescriptor; 547 548 /** 549 * @brief JSVM-API uses both return values and JavaScript exceptions for error handling 550 * @since 11 551 */ 552 typedef struct { 553 /** UTF8-encoded string containing a VM-neutral description of the error. */ 554 const char* errorMessage; 555 /** Reserved for VM-specific error details. This is currently not implemented for any VM. */ 556 void* engineReserved; 557 /** VM-specific error code. This is currently not implemented for any VM. */ 558 uint32_t engineErrorCode; 559 /** The JSVM-API status code that originated with the last error. */ 560 JSVM_Status errorCode; 561 } JSVM_ExtendedErrorInfo; 562 563 /** 564 * @brief A 128-bit value stored as two unsigned 64-bit integers. 565 * It serves as a UUID with which JavaScript objects or externals can be "tagged" 566 * in order to ensure that they are of a certain type. 567 * 568 * @since 11 569 */ 570 typedef struct { 571 /** lower type. */ 572 uint64_t lower; 573 /** upper type. */ 574 uint64_t upper; 575 } JSVM_TypeTag; 576 577 /** 578 * @brief When the getter, setter, call, etc. behavior occurs on the object, the corresponding 579 * the corresponding callback will be triggered. 580 * 581 * @since 12 582 */ 583 typedef struct { 584 /** A callback function triggered by getting a named property of an instance object. */ 585 JSVM_Value(JSVM_CDECL* genericNamedPropertyGetterCallback)(JSVM_Env env, 586 JSVM_Value name, 587 JSVM_Value thisArg, 588 JSVM_Value namedPropertyData); 589 590 /** A callback function triggered by setting a named property of an instance object. */ 591 JSVM_Value(JSVM_CDECL* genericNamedPropertySetterCallback)(JSVM_Env env, 592 JSVM_Value name, 593 JSVM_Value property, 594 JSVM_Value thisArg, 595 JSVM_Value namedPropertyData); 596 597 /** A callback function triggered by deleting a named property of an instance object. */ 598 JSVM_Value(JSVM_CDECL* genericNamedPropertyDeleterCallback)(JSVM_Env env, 599 JSVM_Value name, 600 JSVM_Value thisArg, 601 JSVM_Value namedPropertyData); 602 603 /** A callback function triggered by getting all named properties requests on an object. */ 604 JSVM_Value(JSVM_CDECL* genericNamedPropertyEnumeratorCallback)(JSVM_Env env, 605 JSVM_Value thisArg, 606 JSVM_Value namedPropertyData); 607 608 /** A callback function triggered by getting an indexed property of an instance object. */ 609 JSVM_Value(JSVM_CDECL* genericIndexedPropertyGetterCallback)(JSVM_Env env, 610 JSVM_Value index, 611 JSVM_Value thisArg, 612 JSVM_Value indexedPropertyData); 613 614 /** A callback function triggered by setting an indexed property of an instance object. */ 615 JSVM_Value(JSVM_CDECL* genericIndexedPropertySetterCallback)(JSVM_Env env, 616 JSVM_Value index, 617 JSVM_Value property, 618 JSVM_Value thisArg, 619 JSVM_Value indexedPropertyData); 620 621 /** A callback function triggered by deleting an indexed property of an instance object. */ 622 JSVM_Value(JSVM_CDECL* genericIndexedPropertyDeleterCallback)(JSVM_Env env, 623 JSVM_Value index, 624 JSVM_Value thisArg, 625 JSVM_Value indexedPropertyData); 626 627 /** A callback function triggered by getting all indexed properties requests on an object. */ 628 JSVM_Value(JSVM_CDECL* genericIndexedPropertyEnumeratorCallback)(JSVM_Env env, 629 JSVM_Value thisArg, 630 JSVM_Value indexedPropertyData); 631 632 /** data will be utilized by the named property callbacks in this struct. */ 633 JSVM_Value namedPropertyData; 634 635 /** data will be utilized by the indexed property callbacks in this struct. */ 636 JSVM_Value indexedPropertyData; 637 } JSVM_PropertyHandlerConfigurationStruct; 638 639 /** 640 * @brief The function pointer type of the callback provided by the instance object, which triggers the 641 * corresponding callback when getter, setter, call, and other behaviors occur on the object. 642 * 643 * @since 12 644 */ 645 typedef JSVM_PropertyHandlerConfigurationStruct* JSVM_PropertyHandlerCfg; 646 647 /** 648 * 649 * @brief Source code information. 650 * 651 * @since 12 652 */ 653 typedef struct { 654 /** Sourcemap url. */ 655 const char* sourceMapUrl; 656 /** Resource name. */ 657 const char* resourceName; 658 /** Resource line offset. */ 659 size_t resourceLineOffset; 660 /** Resource column offset. */ 661 size_t resourceColumnOffset; 662 } JSVM_ScriptOrigin; 663 664 /** 665 * @brief Compile Options 666 * 667 * @since 12 668 */ 669 typedef struct { 670 /** compile option id. */ 671 JSVM_CompileOptionId id; 672 /** option content. */ 673 union { 674 /** ptr type. */ 675 void *ptr; 676 /** int type. */ 677 int num; 678 /** bool type. */ 679 bool boolean; 680 } content; 681 } JSVM_CompileOptions; 682 683 /** 684 * @brief code cache passed with JSVM_COMPILE_CODE_CACHE 685 * 686 * @since 12 687 */ 688 typedef struct { 689 /** cache pointer. */ 690 uint8_t *cache; 691 /** length. */ 692 size_t length; 693 } JSVM_CodeCache; 694 695 /** 696 * @brief WebAssembly function optimization level 697 * 698 * @since 12 699 */ 700 typedef enum { 701 /** baseline optimization level. */ 702 JSVM_WASM_OPT_BASELINE = 10, 703 /** high optimization level. */ 704 JSVM_WASM_OPT_HIGH = 20, 705 } JSVM_WasmOptLevel; 706 707 /** 708 * @brief Cache data type 709 * 710 * @since 12 711 */ 712 typedef enum { 713 /** js code cache, generated by OH_JSVM_CreateCodeCache */ 714 JSVM_CACHE_TYPE_JS, 715 /** WebAssembly cache, generated by OH_JSVM_CreateWasmCache */ 716 JSVM_CACHE_TYPE_WASM, 717 } JSVM_CacheType; 718 719 /** 720 * @brief compile profile passed with JSVM_COMPILE_COMPILE_PROFILE 721 * 722 * @since 12 723 */ 724 typedef const struct { 725 /** profile pointer. */ 726 int *profile; 727 /** length. */ 728 size_t length; 729 } JSVM_CompileProfile; 730 731 /** 732 * @brief Regular expression flag bits. They can be or'ed to enable a set of flags. 733 * 734 * @since 12 735 */ 736 typedef enum { 737 /** None mode. */ 738 JSVM_REGEXP_NONE = 0, 739 /** Global mode. */ 740 JSVM_REGEXP_GLOBAL = 1 << 0, 741 /** Ignore Case mode. */ 742 JSVM_REGEXP_IGNORE_CASE = 1 << 1, 743 /** Multiline mode. */ 744 JSVM_REGEXP_MULTILINE = 1 << 2, 745 /** Sticky mode. */ 746 JSVM_REGEXP_STICKY = 1 << 3, 747 /** Unicode mode. */ 748 JSVM_REGEXP_UNICODE = 1 << 4, 749 /** dotAll mode. */ 750 JSVM_REGEXP_DOT_ALL = 1 << 5, 751 /** Linear mode. */ 752 JSVM_REGEXP_LINEAR = 1 << 6, 753 /** Has Indices mode. */ 754 JSVM_REGEXP_HAS_INDICES = 1 << 7, 755 /** Unicode Sets mode. */ 756 JSVM_REGEXP_UNICODE_SETS = 1 << 8, 757 } JSVM_RegExpFlags; 758 759 /** 760 * @brief initialization flag 761 * 762 * @since 12 763 */ 764 typedef enum { 765 /** initialize with zero. */ 766 JSVM_ZERO_INITIALIZED, 767 /** leave uninitialized. */ 768 JSVM_UNINITIALIZED, 769 } JSVM_InitializedFlag; 770 /** @} */ 771 #endif /* ARK_RUNTIME_JSVM_JSVM_TYPE_H */ 772