MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add special_object(3) to jit

+27 -3
+1
include/silver/glue.h
··· 49 49 50 50 ant_value_t jit_helper_delete(sv_vm_t *vm, ant_t *js, ant_value_t obj, ant_value_t key); 51 51 ant_value_t jit_helper_typeof(sv_vm_t *vm, ant_t *js, ant_value_t v); 52 + ant_value_t jit_helper_special_obj(ant_t *js, uint32_t which); 52 53 53 54 ant_value_t jit_helper_get_global( 54 55 ant_t *js, const char *str,
+5
src/silver/glue.c
··· 102 102 return sv_global_get_interned_ic(js, str, func, ip); 103 103 } 104 104 105 + ant_value_t jit_helper_special_obj(ant_t *js, uint32_t which) { 106 + if (which == 3) return js_get_module_import_binding(js); 107 + return js_mkundef(); 108 + } 109 + 105 110 ant_value_t jit_helper_seq(sv_vm_t *vm, ant_t *js, ant_value_t l, ant_value_t r) { 106 111 return mkval(T_BOOL, strict_eq_values(js, l, r)); 107 112 }
+21 -3
src/silver/swarm.c
··· 59 59 LOAD_EXT(jit_helper_apply); 60 60 LOAD_EXT(jit_helper_rest); 61 61 LOAD_EXT(jit_helper_tov); 62 + LOAD_EXT(jit_helper_special_obj); 62 63 LOAD_EXT(jit_helper_get_global); 63 64 LOAD_EXT(jit_helper_get_field); 64 65 LOAD_EXT(jit_helper_to_propkey); ··· 1761 1762 case OP_LINE_NUM: case OP_COL_NUM: case OP_LABEL: 1762 1763 break; 1763 1764 case OP_SPECIAL_OBJ: 1764 - if (sv_get_u8(ip + 1) != 1) { 1765 + if (sv_get_u8(ip + 1) != 1 && sv_get_u8(ip + 1) != 3) { 1765 1766 if (sv_jit_warn_unlikely) 1766 1767 fprintf(stderr, "jit: ineligible op SPECIAL_OBJ(%d) in %s\n", 1767 1768 sv_get_u8(ip + 1), ··· 2031 2032 MIR_T_P, "args", 2032 2033 MIR_T_I32, "argc"); 2033 2034 2035 + MIR_type_t special_obj_ret = MIR_JSVAL; 2036 + MIR_item_t special_obj_proto = MIR_new_proto(ctx, "soj_proto", 2037 + 1, &special_obj_ret, 2, 2038 + MIR_T_I64, "js", 2039 + MIR_T_I32, "which"); 2034 2040 2035 2041 MIR_item_t imp_add = MIR_new_import(ctx, "jit_helper_add"); 2036 2042 MIR_item_t imp_sub = MIR_new_import(ctx, "jit_helper_sub"); ··· 2045 2051 MIR_item_t imp_apply = MIR_new_import(ctx, "jit_helper_apply"); 2046 2052 MIR_item_t imp_rest = MIR_new_import(ctx, "jit_helper_rest"); 2047 2053 MIR_item_t imp_tov = MIR_new_import(ctx, "jit_helper_tov"); 2054 + MIR_item_t imp_special_obj = MIR_new_import(ctx, "jit_helper_special_obj"); 2048 2055 MIR_item_t imp_gg = MIR_new_import(ctx, "jit_helper_get_global"); 2049 2056 MIR_item_t imp_get_field = MIR_new_import(ctx, "jit_helper_get_field"); 2050 2057 MIR_item_t imp_to_propkey = MIR_new_import(ctx, "jit_helper_to_propkey"); ··· 4564 4571 break; 4565 4572 } 4566 4573 4567 - case OP_SPECIAL_OBJ: 4568 - mir_load_imm(ctx, jit_func, vstack_push(&vs), mkval(T_UNDEF, 0)); 4574 + case OP_SPECIAL_OBJ: { 4575 + uint8_t which = sv_get_u8(ip + 1); 4576 + MIR_reg_t dst = vstack_push(&vs); 4577 + if (which == 3) { 4578 + MIR_append_insn(ctx, jit_func, 4579 + MIR_new_call_insn(ctx, 5, 4580 + MIR_new_ref_op(ctx, special_obj_proto), 4581 + MIR_new_ref_op(ctx, imp_special_obj), 4582 + MIR_new_reg_op(ctx, dst), 4583 + MIR_new_reg_op(ctx, r_js), 4584 + MIR_new_int_op(ctx, (int64_t)which))); 4585 + } else mir_load_imm(ctx, jit_func, dst, mkval(T_UNDEF, 0)); 4569 4586 break; 4587 + } 4570 4588 4571 4589 case OP_GET_UPVAL: { 4572 4590 uint16_t idx = sv_get_u16(ip + 1);