1 /* Copyright JS Foundation and other contributors, http://js.foundation 2 * 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 VM_H 17 #define VM_H 18 19 #include "ecma-globals.h" 20 #include "jrt.h" 21 #include "vm-defines.h" 22 23 /** \addtogroup vm Virtual machine 24 * @{ 25 * 26 * \addtogroup vm_executor Executor 27 * @{ 28 */ 29 30 /** 31 * Each CBC opcode is transformed to three vm opcodes: 32 * 33 * - first opcode is a "get arguments" opcode which specifies 34 * the type (register, literal, stack, etc.) and number 35 * (from 0 to 2) of input arguments 36 * - second opcode is a "group" opcode which specifies 37 * the actual operation (add, increment, call, etc.) 38 * - third opcode is a "put result" opcode which specifies 39 * the destination where the result is stored (register, 40 * stack, etc.) 41 */ 42 43 /** 44 * If VM_OC_GET_ARGS_INDEX(opcode) == VM_OC_GET_BRANCH, 45 * this flag signals that the branch is a backward branch. 46 */ 47 #define VM_OC_BACKWARD_BRANCH (1 << 15) 48 49 /** 50 * Position of "get arguments" opcode. 51 */ 52 #define VM_OC_GET_ARGS_SHIFT 8 53 54 /** 55 * Mask of "get arguments" opcode. 56 */ 57 #define VM_OC_GET_ARGS_MASK 0x7 58 59 /** 60 * Generate the binary representation of a "get arguments" opcode. 61 */ 62 #define VM_OC_GET_ARGS_CREATE_INDEX(V) (((V) & VM_OC_GET_ARGS_MASK) << VM_OC_GET_ARGS_SHIFT) 63 64 /** 65 * Extract the "get arguments" opcode. 66 */ 67 #define VM_OC_GET_ARGS_INDEX(O) ((O) & (VM_OC_GET_ARGS_MASK << VM_OC_GET_ARGS_SHIFT)) 68 69 /** 70 * Checks whether the result is stored somewhere. 71 */ 72 #define VM_OC_HAS_GET_ARGS(V) ((V) & (VM_OC_GET_ARGS_MASK << VM_OC_GET_ARGS_SHIFT)) 73 74 /** 75 * Argument getters that are part of the opcodes. 76 */ 77 typedef enum 78 { 79 VM_OC_GET_NONE = VM_OC_GET_ARGS_CREATE_INDEX (0), /**< do nothing */ 80 VM_OC_GET_BRANCH = VM_OC_GET_ARGS_CREATE_INDEX (1), /**< branch argument */ 81 VM_OC_GET_STACK = VM_OC_GET_ARGS_CREATE_INDEX (2), /**< pop one element from the stack */ 82 VM_OC_GET_STACK_STACK = VM_OC_GET_ARGS_CREATE_INDEX (3), /**< pop two elements from the stack */ 83 84 VM_OC_GET_LITERAL = VM_OC_GET_ARGS_CREATE_INDEX (4), /**< resolve literal */ 85 VM_OC_GET_LITERAL_LITERAL = VM_OC_GET_ARGS_CREATE_INDEX (5), /**< resolve two literals */ 86 VM_OC_GET_STACK_LITERAL = VM_OC_GET_ARGS_CREATE_INDEX (6), /**< pop one element from the stack 87 * and resolve a literal */ 88 VM_OC_GET_THIS_LITERAL = VM_OC_GET_ARGS_CREATE_INDEX (7), /**< get this and resolve a literal */ 89 } vm_oc_get_types; 90 91 /** 92 * Mask of "group" opcode. 93 */ 94 #define VM_OC_GROUP_MASK 0xff 95 96 /** 97 * Extract the "group" opcode. 98 */ 99 #define VM_OC_GROUP_GET_INDEX(O) ((O) & VM_OC_GROUP_MASK) 100 101 /** 102 * Opcodes. 103 */ 104 typedef enum 105 { 106 VM_OC_POP, /**< pop from stack */ 107 VM_OC_POP_BLOCK, /**< pop block */ 108 VM_OC_PUSH, /**< push one literal */ 109 VM_OC_PUSH_TWO, /**< push two literals */ 110 VM_OC_PUSH_THREE, /**< push three literals */ 111 VM_OC_PUSH_UNDEFINED, /**< push undefined value */ 112 VM_OC_PUSH_TRUE, /**< push true value */ 113 VM_OC_PUSH_FALSE, /**< push false value */ 114 VM_OC_PUSH_NULL, /**< push null value */ 115 VM_OC_PUSH_THIS, /**< push this */ 116 VM_OC_PUSH_0, /**< push number zero */ 117 VM_OC_PUSH_POS_BYTE, /**< push number between 1 and 256 */ 118 VM_OC_PUSH_NEG_BYTE, /**< push number between -1 and -256 */ 119 VM_OC_PUSH_LIT_0, /**< push literal and number zero */ 120 VM_OC_PUSH_LIT_POS_BYTE, /**< push literal and number between 1 and 256 */ 121 VM_OC_PUSH_LIT_NEG_BYTE, /**< push literal and number between -1 and -256 */ 122 VM_OC_PUSH_OBJECT, /**< push object */ 123 VM_OC_PUSH_NAMED_FUNC_EXPR, /**< push named function expression */ 124 VM_OC_SET_PROPERTY, /**< set property */ 125 126 VM_OC_SET_GETTER, /**< set getter */ 127 VM_OC_SET_SETTER, /**< set setter */ 128 VM_OC_PUSH_ARRAY, /**< push array */ 129 VM_OC_PUSH_ELISON, /**< push elison */ 130 VM_OC_APPEND_ARRAY, /**< append array */ 131 VM_OC_IDENT_REFERENCE, /**< ident reference */ 132 VM_OC_PROP_REFERENCE, /**< prop reference */ 133 VM_OC_PROP_GET, /**< prop get */ 134 135 /* These eight opcodes must be in this order. */ 136 VM_OC_PROP_PRE_INCR, /**< prefix increment of a property */ 137 VM_OC_PROP_PRE_DECR, /**< prop prefix decrement of a property */ 138 VM_OC_PROP_POST_INCR, /**< prop postfix increment of a property */ 139 VM_OC_PROP_POST_DECR, /**< prop postfix decrement of a property */ 140 VM_OC_PRE_INCR, /**< prefix increment */ 141 VM_OC_PRE_DECR, /**< prefix decrement */ 142 VM_OC_POST_INCR, /**< postfix increment */ 143 VM_OC_POST_DECR, /**< postfix decrement */ 144 145 VM_OC_PROP_DELETE, /**< delete property */ 146 VM_OC_DELETE, /**< delete */ 147 148 VM_OC_MOV_IDENT, /**< move identifier register reference */ 149 VM_OC_ASSIGN, /**< assign */ 150 VM_OC_ASSIGN_PROP, /**< assign property */ 151 VM_OC_ASSIGN_PROP_THIS, /**< assign prop this */ 152 153 VM_OC_RETURN, /**< return */ 154 VM_OC_THROW, /**< throw */ 155 VM_OC_THROW_REFERENCE_ERROR, /**< throw reference error */ 156 157 VM_OC_EVAL, /**< eval */ 158 VM_OC_CALL, /**< call */ 159 VM_OC_NEW, /**< new */ 160 VM_OC_RESOLVE_BASE_FOR_CALL, /**< resolve base value before call */ 161 VM_OC_ERROR, /**< error while the vm_loop is suspended */ 162 163 VM_OC_JUMP, /**< jump */ 164 VM_OC_BRANCH_IF_STRICT_EQUAL, /**< branch if strict equal */ 165 166 /* These four opcodes must be in this order. */ 167 VM_OC_BRANCH_IF_TRUE, /**< branch if true */ 168 VM_OC_BRANCH_IF_FALSE, /**< branch if false */ 169 VM_OC_BRANCH_IF_LOGICAL_TRUE, /**< branch if logical true */ 170 VM_OC_BRANCH_IF_LOGICAL_FALSE, /**< branch if logical false */ 171 172 VM_OC_PLUS, /**< unary plus */ 173 VM_OC_MINUS, /**< unary minus */ 174 VM_OC_NOT, /**< not */ 175 VM_OC_BIT_NOT, /**< bitwise not */ 176 VM_OC_VOID, /**< void */ 177 VM_OC_TYPEOF_IDENT, /**< typeof identifier */ 178 VM_OC_TYPEOF, /**< typeof */ 179 180 VM_OC_ADD, /**< binary add */ 181 VM_OC_SUB, /**< binary sub */ 182 VM_OC_MUL, /**< mul */ 183 VM_OC_DIV, /**< div */ 184 VM_OC_MOD, /**< mod */ 185 #if ENABLED (JERRY_ES2015) 186 VM_OC_EXP, /**< exponentiation */ 187 #endif /* ENABLED (JERRY_ES2015) */ 188 189 VM_OC_EQUAL, /**< equal */ 190 VM_OC_NOT_EQUAL, /**< not equal */ 191 VM_OC_STRICT_EQUAL, /**< strict equal */ 192 VM_OC_STRICT_NOT_EQUAL, /**< strict not equal */ 193 VM_OC_LESS, /**< less */ 194 VM_OC_GREATER, /**< greater */ 195 VM_OC_LESS_EQUAL, /**< less equal */ 196 VM_OC_GREATER_EQUAL, /**< greater equal */ 197 VM_OC_IN, /**< in */ 198 VM_OC_INSTANCEOF, /**< instanceof */ 199 200 VM_OC_BIT_OR, /**< bitwise or */ 201 VM_OC_BIT_XOR, /**< bitwise xor */ 202 VM_OC_BIT_AND, /**< bitwise and */ 203 VM_OC_LEFT_SHIFT, /**< left shift */ 204 VM_OC_RIGHT_SHIFT, /**< right shift */ 205 VM_OC_UNS_RIGHT_SHIFT, /**< unsigned right shift */ 206 207 VM_OC_BLOCK_CREATE_CONTEXT, /**< create lexical environment for blocks enclosed in braces */ 208 VM_OC_WITH, /**< with */ 209 VM_OC_FOR_IN_CREATE_CONTEXT, /**< for in create context */ 210 VM_OC_FOR_IN_GET_NEXT, /**< get next */ 211 VM_OC_FOR_IN_HAS_NEXT, /**< has next */ 212 213 VM_OC_TRY, /**< try */ 214 VM_OC_CATCH, /**< catch */ 215 VM_OC_FINALLY, /**< finally */ 216 VM_OC_CONTEXT_END, /**< context end */ 217 VM_OC_JUMP_AND_EXIT_CONTEXT, /**< jump and exit context */ 218 219 VM_OC_CREATE_BINDING, /**< create variables */ 220 VM_OC_SET_BYTECODE_PTR, /**< setting bytecode pointer */ 221 VM_OC_VAR_EVAL, /**< variable and function evaluation */ 222 #if ENABLED (JERRY_ES2015) 223 VM_OC_EXT_VAR_EVAL, /**< variable and function evaluation for 224 * functions with separate argument context */ 225 #endif /* ENABLED (JERRY_ES2015) */ 226 VM_OC_INIT_ARG_OR_FUNC, /**< create and init a function or argument binding */ 227 228 #if ENABLED (JERRY_DEBUGGER) 229 VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */ 230 VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */ 231 #endif /* ENABLED (JERRY_DEBUGGER) */ 232 #if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) 233 VM_OC_RESOURCE_NAME, /**< resource name of the current function */ 234 #endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ 235 #if ENABLED (JERRY_LINE_INFO) 236 VM_OC_LINE, /**< line number of the next statement */ 237 #endif /* ENABLED (JERRY_LINE_INFO) */ 238 #if ENABLED (JERRY_ES2015) 239 VM_OC_CHECK_VAR, /**< check redeclared vars in the global scope */ 240 VM_OC_CHECK_LET, /**< check redeclared lets in the global scope */ 241 VM_OC_ASSIGN_LET_CONST, /**< assign values to let/const declarations */ 242 VM_OC_INIT_BINDING, /**< create and intialize a binding */ 243 VM_OC_THROW_CONST_ERROR, /**< throw invalid assignment to const variable error */ 244 VM_OC_COPY_TO_GLOBAL, /**< copy value to global lex env */ 245 VM_OC_COPY_FROM_ARG, /**< copy value from arg lex env */ 246 VM_OC_CLONE_CONTEXT, /**< clone lexical environment with let/const declarations */ 247 VM_OC_SET_COMPUTED_PROPERTY, /**< set computed property */ 248 249 VM_OC_FOR_OF_CREATE_CONTEXT, /**< for of create context */ 250 VM_OC_FOR_OF_GET_NEXT, /**< get next */ 251 VM_OC_FOR_OF_HAS_NEXT, /**< has next */ 252 253 VM_OC_LOCAL_EVAL, /**< eval in local context */ 254 VM_OC_SUPER_CALL, /**< call the 'super' constructor */ 255 VM_OC_PUSH_CLASS_ENVIRONMENT, /**< push class environment */ 256 VM_OC_PUSH_IMPLICIT_CTOR, /**< create implicit class constructor */ 257 VM_OC_INIT_CLASS, /**< initialize class */ 258 VM_OC_FINALIZE_CLASS, /**< finalize class */ 259 VM_OC_PUSH_SUPER_CONSTRUCTOR, /**< getSuperConstructor operation */ 260 VM_OC_RESOLVE_LEXICAL_THIS, /**< resolve this_binding from from the lexical environment */ 261 VM_OC_SUPER_REFERENCE, /**< push super reference */ 262 263 VM_OC_PUSH_SPREAD_ELEMENT, /**< push spread element */ 264 VM_OC_GET_ITERATOR, /**< GetIterator abstract operation */ 265 VM_OC_ITERATOR_STEP, /**< IteratorStep abstract operation */ 266 VM_OC_ITERATOR_CLOSE, /**< IteratorClose abstract operation */ 267 VM_OC_DEFAULT_INITIALIZER, /**< default initializer inside a pattern */ 268 VM_OC_REST_INITIALIZER, /**< create rest object inside an array pattern */ 269 VM_OC_INITIALIZER_PUSH_PROP, /**< push property for object initializer */ 270 VM_OC_SPREAD_ARGUMENTS, /**< perform function call/construct with spreaded arguments */ 271 VM_OC_CREATE_GENERATOR, /**< create a generator object */ 272 VM_OC_YIELD, /**< yield operation */ 273 VM_OC_AWAIT, /**< await operation */ 274 VM_OC_EXT_RETURN, /**< return which also clears the stack */ 275 VM_OC_RETURN_PROMISE, /**< return from an async function */ 276 VM_OC_STRING_CONCAT, /**< string concatenation */ 277 VM_OC_GET_TEMPLATE_OBJECT, /**< GetTemplateObject operation */ 278 VM_OC_PUSH_NEW_TARGET, /**< push new.target onto the stack */ 279 VM_OC_REQUIRE_OBJECT_COERCIBLE,/**< RequireObjectCoercible opretaion */ 280 VM_OC_ASSIGN_SUPER, /**< assign super reference */ 281 VM_OC_SET__PROTO__, /**< set prototpe when __proto__: form is used */ 282 #endif /* ENABLED (JERRY_ES2015) */ 283 VM_OC_NONE, /**< a special opcode for unsupported byte codes */ 284 } vm_oc_types; 285 286 /** 287 * Unused opcodes, but required by byte-code types. 288 */ 289 typedef enum 290 { 291 #if !ENABLED (JERRY_ES2015) 292 VM_OC_EXP = VM_OC_NONE, /**< exponentiation */ 293 #endif /* !ENABLED (JERRY_ES2015) */ 294 #if !ENABLED (JERRY_DEBUGGER) 295 VM_OC_BREAKPOINT_ENABLED = VM_OC_NONE, /**< enabled breakpoint for debugger is unused */ 296 VM_OC_BREAKPOINT_DISABLED = VM_OC_NONE, /**< disabled breakpoint for debugger is unused */ 297 #endif /* !ENABLED (JERRY_DEBUGGER) */ 298 #if !ENABLED (JERRY_LINE_INFO) && !ENABLED (JERRY_ES2015_MODULE_SYSTEM) 299 VM_OC_RESOURCE_NAME = VM_OC_NONE, /**< resource name of the current function is unused */ 300 #endif /* !ENABLED (JERRY_LINE_INFO) && !ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ 301 #if !ENABLED (JERRY_LINE_INFO) 302 VM_OC_LINE = VM_OC_NONE, /**< line number of the next statement is unused */ 303 #endif /* !ENABLED (JERRY_LINE_INFO) */ 304 #if !ENABLED (JERRY_ES2015) 305 VM_OC_EXT_VAR_EVAL = VM_OC_NONE, /**< variable and function evaluation for 306 * functions with separate argument context */ 307 VM_OC_CHECK_VAR = VM_OC_NONE, /**< check redeclared vars in the global scope */ 308 VM_OC_CHECK_LET = VM_OC_NONE, /**< check redeclared lets in the global scope */ 309 VM_OC_ASSIGN_LET_CONST = VM_OC_NONE, /**< assign values to let/const declarations */ 310 VM_OC_INIT_BINDING = VM_OC_NONE, /**< create and intialize a binding */ 311 VM_OC_THROW_CONST_ERROR = VM_OC_NONE, /**< throw invalid assignment to const variable error */ 312 VM_OC_COPY_TO_GLOBAL = VM_OC_NONE, /**< copy value to global lex env */ 313 VM_OC_COPY_FROM_ARG = VM_OC_NONE, /**< copy value from arg lex env */ 314 VM_OC_CLONE_CONTEXT = VM_OC_NONE, /**< clone lexical environment with let/const declarations */ 315 VM_OC_SET_COMPUTED_PROPERTY = VM_OC_NONE, /**< set computed property is unused */ 316 317 VM_OC_FOR_OF_CREATE_CONTEXT = VM_OC_NONE, /**< for of create context */ 318 VM_OC_FOR_OF_GET_NEXT = VM_OC_NONE, /**< get next */ 319 VM_OC_FOR_OF_HAS_NEXT = VM_OC_NONE, /**< has next */ 320 321 VM_OC_LOCAL_EVAL = VM_OC_NONE, /**< eval in local context */ 322 VM_OC_SUPER_CALL = VM_OC_NONE, /**< call the 'super' constructor */ 323 VM_OC_PUSH_CLASS_ENVIRONMENT = VM_OC_NONE, /**< push class environment */ 324 VM_OC_PUSH_IMPLICIT_CTOR = VM_OC_NONE, /**< create implicit class constructor */ 325 VM_OC_INIT_CLASS = VM_OC_NONE, /**< initialize class */ 326 VM_OC_FINALIZE_CLASS = VM_OC_NONE, /**< finalize class */ 327 VM_OC_PUSH_SUPER_CONSTRUCTOR = VM_OC_NONE, /**< getSuperConstructor operation */ 328 VM_OC_RESOLVE_LEXICAL_THIS = VM_OC_NONE, /**< resolve this_binding from from the lexical environment */ 329 VM_OC_SUPER_REFERENCE = VM_OC_NONE, /**< push super reference */ 330 331 VM_OC_PUSH_SPREAD_ELEMENT = VM_OC_NONE, /**< push spread element */ 332 VM_OC_GET_ITERATOR = VM_OC_NONE, /**< GetIterator abstract operation */ 333 VM_OC_ITERATOR_STEP = VM_OC_NONE, /**< IteratorStep abstract operation */ 334 VM_OC_ITERATOR_CLOSE = VM_OC_NONE, /**< IteratorClose abstract operation */ 335 VM_OC_DEFAULT_INITIALIZER = VM_OC_NONE, /**< default initializer inside a pattern */ 336 VM_OC_REST_INITIALIZER = VM_OC_NONE, /**< create rest object inside an array pattern */ 337 VM_OC_INITIALIZER_PUSH_PROP = VM_OC_NONE, /**< push property for object initializer */ 338 VM_OC_SPREAD_ARGUMENTS = VM_OC_NONE, /**< perform function call/construct with spreaded arguments */ 339 VM_OC_CREATE_GENERATOR = VM_OC_NONE, /**< create a generator object */ 340 VM_OC_YIELD = VM_OC_NONE, /**< yield operation */ 341 VM_OC_AWAIT = VM_OC_NONE, /**< await operation */ 342 VM_OC_EXT_RETURN = VM_OC_NONE, /**< return which also clears the stack */ 343 VM_OC_RETURN_PROMISE = VM_OC_NONE, /**< return from an async function */ 344 VM_OC_STRING_CONCAT = VM_OC_NONE, /**< string concatenation */ 345 VM_OC_GET_TEMPLATE_OBJECT = VM_OC_NONE, /**< GetTemplateObject operation */ 346 VM_OC_PUSH_NEW_TARGET = VM_OC_NONE, /**< push new.target onto the stack */ 347 VM_OC_REQUIRE_OBJECT_COERCIBLE = VM_OC_NONE,/**< RequireObjectCoercible opretaion */ 348 VM_OC_ASSIGN_SUPER = VM_OC_NONE, /**< assign super reference */ 349 VM_OC_SET__PROTO__ = VM_OC_NONE, /**< set prototpe when __proto__: form is used */ 350 #endif /* !ENABLED (JERRY_ES2015) */ 351 352 VM_OC_UNUSED = VM_OC_NONE /**< placeholder if the list is empty */ 353 } vm_oc_unused_types; 354 355 /** 356 * Decrement operator. 357 */ 358 #define VM_OC_DECREMENT_OPERATOR_FLAG 0x1 359 360 /** 361 * Postfix increment/decrement operator. 362 */ 363 #define VM_OC_POST_INCR_DECR_OPERATOR_FLAG 0x2 364 365 /** 366 * An named variable is updated by the increment/decrement operator. 367 */ 368 #define VM_OC_IDENT_INCR_DECR_OPERATOR_FLAG 0x4 369 370 /** 371 * Jump to target offset if input value is logical false. 372 */ 373 #define VM_OC_BRANCH_IF_FALSE_FLAG 0x1 374 375 /** 376 * Branch optimized for logical and/or opcodes. 377 */ 378 #define VM_OC_LOGICAL_BRANCH_FLAG 0x2 379 380 /** 381 * Bit index shift for non-static property initializers. 382 */ 383 #define VM_OC_NON_STATIC_SHIFT 15 384 385 /** 386 * This flag is set for static property initializers. 387 */ 388 #define VM_OC_NON_STATIC_FLAG (0x1 << VM_OC_NON_STATIC_SHIFT) 389 390 /** 391 * Position of "put result" opcode. 392 */ 393 #define VM_OC_PUT_RESULT_SHIFT 11 394 395 /** 396 * Mask of "put result" opcode. 397 */ 398 #define VM_OC_PUT_RESULT_MASK 0xf 399 400 /** 401 * Generate a "put result" opcode flag bit. 402 */ 403 #define VM_OC_PUT_RESULT_CREATE_FLAG(V) (((V) & VM_OC_PUT_RESULT_MASK) << VM_OC_PUT_RESULT_SHIFT) 404 405 /** 406 * Checks whether the result is stored somewhere. 407 */ 408 #define VM_OC_HAS_PUT_RESULT(V) ((V) & (VM_OC_PUT_RESULT_MASK << VM_OC_PUT_RESULT_SHIFT)) 409 410 /** 411 * Specify where the result is stored 412 */ 413 typedef enum 414 { 415 VM_OC_PUT_IDENT = VM_OC_PUT_RESULT_CREATE_FLAG (0x1), 416 VM_OC_PUT_REFERENCE = VM_OC_PUT_RESULT_CREATE_FLAG (0x2), 417 VM_OC_PUT_STACK = VM_OC_PUT_RESULT_CREATE_FLAG (0x4), 418 VM_OC_PUT_BLOCK = VM_OC_PUT_RESULT_CREATE_FLAG (0x8), 419 } vm_oc_put_types; 420 421 /** 422 * Non-recursive vm_loop: the vm_loop can be suspended 423 * to execute a call /construct operation. These return 424 * types of the vm_loop tells whether a call operation 425 * is in progress or the vm_loop is finished. 426 */ 427 typedef enum 428 { 429 VM_NO_EXEC_OP, /**< do nothing */ 430 VM_EXEC_CALL, /**< invoke a function */ 431 VM_EXEC_SUPER_CALL, /**< invoke a function through 'super' keyword */ 432 VM_EXEC_SPREAD_OP, /**< call/construct operation with spreaded argument list */ 433 VM_EXEC_RETURN, /**< return with the completion value without freeing registers */ 434 VM_EXEC_CONSTRUCT, /**< construct a new object */ 435 } vm_call_operation; 436 437 ecma_value_t vm_run_global (const ecma_compiled_code_t *bytecode_p); 438 ecma_value_t vm_run_eval (ecma_compiled_code_t *bytecode_data_p, uint32_t parse_opts); 439 440 #if ENABLED (JERRY_ES2015_MODULE_SYSTEM) 441 ecma_value_t vm_run_module (const ecma_compiled_code_t *bytecode_p, ecma_object_t *lex_env_p); 442 #endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */ 443 444 ecma_value_t vm_run (const ecma_compiled_code_t *bytecode_header_p, ecma_value_t this_binding_value, 445 ecma_object_t *lex_env_p, const ecma_value_t *arg_list_p, ecma_length_t arg_list_len); 446 ecma_value_t vm_execute (vm_frame_ctx_t *frame_ctx_p); 447 448 bool vm_is_strict_mode (void); 449 bool vm_is_direct_eval_form_call (void); 450 451 ecma_value_t vm_get_backtrace (uint32_t max_depth); 452 453 /** 454 * @} 455 * @} 456 */ 457 458 #endif /* !VM_H */ 459