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