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.

fix call koff stack

+118 -48
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.2.1.5') 77 + version_conf.set('ANT_VERSION', '0.2.1.6') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+117 -47
src/ant.c
··· 53 53 typedef struct call_frame { 54 54 const char *filename; 55 55 const char *function_name; 56 + const char *code; 57 + uint32_t pos; 56 58 int line; 57 59 int col; 58 60 } call_frame_t; ··· 233 235 static const char *INTERN_VALUE = NULL; 234 236 static const char *INTERN_GET = NULL; 235 237 static const char *INTERN_SET = NULL; 238 + static const char *INTERN_CODE = NULL; 239 + static const char *INTERN_SCOPE = NULL; 240 + static const char *INTERN_THIS = NULL; 241 + static const char *INTERN_NATIVE_FUNC = NULL; 242 + static const char *INTERN_ASYNC = NULL; 243 + static const char *INTERN_BOUND_THIS = NULL; 244 + static const char *INTERN_BOUND_ARGS = NULL; 245 + static const char *INTERN_TARGET_FUNC = NULL; 246 + static const char *INTERN_ARGUMENTS = NULL; 247 + static const char *INTERN_CALLEE = NULL; 248 + static const char *INTERN_IDX[10] = {NULL}; 236 249 237 250 #define INTERN_PROP_CACHE_SIZE 4096 238 251 typedef struct { ··· 1757 1770 1758 1771 static size_t strfunc(struct js *js, jsval_t value, char *buf, size_t len) { 1759 1772 jsval_t func_obj = mkval(T_OBJ, vdata(value)); 1760 - jsoff_t code_off = lkp(js, func_obj, "__code", 6); 1773 + jsoff_t code_off = lkp_interned(js, func_obj, INTERN_CODE, 6); 1761 1774 1762 1775 jsoff_t name_off = lkp(js, func_obj, "name", 4); 1763 1776 const char *name = NULL; ··· 1772 1785 } 1773 1786 1774 1787 if (code_off == 0) { 1775 - jsoff_t native_off = lkp(js, func_obj, "__native_func", 13); 1788 + jsoff_t native_off = lkp_interned(js, func_obj, INTERN_NATIVE_FUNC, 13); 1776 1789 if (native_off != 0) { 1777 1790 jsval_t native_val = resolveprop(js, mkval(T_PROP, native_off)); 1778 1791 if (vtype(native_val) == T_CFUNC) return strfunc_ctor(js, func_obj, buf, len); ··· 1880 1893 const char *fname = frame->function_name ? frame->function_name : "<anonymous>"; 1881 1894 const char *ffile = frame->filename ? frame->filename : "<eval>"; 1882 1895 1883 - *n += (size_t) snprintf(js->errmsg + *n, remaining, "\n at %s %s(%s:%d:%d)%s", fname, dim, ffile, frame->line, frame->col, reset); 1896 + if (frame->line < 0 && frame->code) { 1897 + get_line_col(frame->code, frame->pos, &frame->line, &frame->col); 1898 + } 1899 + int fline = frame->line > 0 ? frame->line : 1; 1900 + int fcol = frame->col > 0 ? frame->col : 1; 1901 + 1902 + *n += (size_t) snprintf(js->errmsg + *n, remaining, "\n at %s %s(%s:%d:%d)%s", fname, dim, ffile, fline, fcol, reset); 1884 1903 remaining = js->errmsg_size - *n; 1885 1904 } 1886 1905 ··· 2740 2759 INTERN_VALUE = intern_string("value", 5); 2741 2760 INTERN_GET = intern_string("get", 3); 2742 2761 INTERN_SET = intern_string("set", 3); 2762 + INTERN_CODE = intern_string("__code", 6); 2763 + INTERN_SCOPE = intern_string("__scope", 7); 2764 + INTERN_THIS = intern_string("__this", 6); 2765 + INTERN_NATIVE_FUNC = intern_string("__native_func", 13); 2766 + INTERN_ASYNC = intern_string("__async", 7); 2767 + INTERN_BOUND_THIS = intern_string("__bound_this", 12); 2768 + INTERN_BOUND_ARGS = intern_string("__bound_args", 12); 2769 + INTERN_TARGET_FUNC = intern_string("__target_func", 13); 2770 + INTERN_ARGUMENTS = intern_string("arguments", 9); 2771 + INTERN_CALLEE = intern_string("callee", 6); 2772 + INTERN_IDX[0] = intern_string("0", 1); 2773 + INTERN_IDX[1] = intern_string("1", 1); 2774 + INTERN_IDX[2] = intern_string("2", 1); 2775 + INTERN_IDX[3] = intern_string("3", 1); 2776 + INTERN_IDX[4] = intern_string("4", 1); 2777 + INTERN_IDX[5] = intern_string("5", 1); 2778 + INTERN_IDX[6] = intern_string("6", 1); 2779 + INTERN_IDX[7] = intern_string("7", 1); 2780 + INTERN_IDX[8] = intern_string("8", 1); 2781 + INTERN_IDX[9] = intern_string("9", 1); 2743 2782 } 2744 2783 2745 2784 static inline uint32_t koff_hash(jsoff_t koff) { ··· 3071 3110 return js_setprop(js, obj, k, v); 3072 3111 } 3073 3112 3113 + static jsval_t setprop_interned(struct js *js, jsval_t obj, const char *key, size_t len, jsval_t v) { 3114 + jsval_t k = js_mkstr(js, key, len); 3115 + if (is_err(k)) return k; 3116 + return js_setprop(js, obj, k, v); 3117 + } 3118 + 3074 3119 static jsval_t setprop_nonconfigurable(struct js *js, jsval_t obj, const char *key, size_t keylen, jsval_t v) { 3075 3120 jsval_t k = js_mkstr(js, key, keylen); 3076 3121 if (is_err(k)) return k; ··· 3286 3331 static bool is_builtin_or_system(jsoff_t offset, struct js *js) { 3287 3332 jsval_t obj_val = mkval(T_OBJ, offset); 3288 3333 3289 - jsoff_t native_off = lkp(js, obj_val, "__native_func", 13); 3334 + jsoff_t native_off = lkp_interned(js, obj_val, INTERN_NATIVE_FUNC, 13); 3290 3335 if (native_off != 0) return true; 3291 3336 3292 - jsoff_t code_off = lkp(js, obj_val, "__code", 6); 3337 + jsoff_t code_off = lkp_interned(js, obj_val, INTERN_CODE, 6); 3293 3338 if (code_off != 0) { 3294 3339 jsval_t code_val = resolveprop(js, mkval(T_PROP, code_off)); 3295 3340 if (vtype(code_val) == T_STR) { ··· 3889 3934 return js_mkundef(); 3890 3935 } 3891 3936 3892 - static inline bool push_call_frame(const char *filename, const char *function_name, int line, int col) { 3937 + static inline bool push_call_frame(const char *filename, const char *function_name, const char *code, uint32_t pos) { 3893 3938 if (global_call_stack.depth >= global_call_stack.capacity) { 3894 3939 int new_capacity = global_call_stack.capacity == 0 ? 32 : global_call_stack.capacity * 2; 3895 3940 call_frame_t *new_stack = (call_frame_t *) realloc(global_call_stack.frames, new_capacity * sizeof(call_frame_t)); ··· 3900 3945 3901 3946 global_call_stack.frames[global_call_stack.depth].filename = filename; 3902 3947 global_call_stack.frames[global_call_stack.depth].function_name = function_name; 3903 - global_call_stack.frames[global_call_stack.depth].line = line; 3904 - global_call_stack.frames[global_call_stack.depth].col = col; 3948 + global_call_stack.frames[global_call_stack.depth].code = code; 3949 + global_call_stack.frames[global_call_stack.depth].pos = pos; 3950 + global_call_stack.frames[global_call_stack.depth].line = -1; 3951 + global_call_stack.frames[global_call_stack.depth].col = -1; 3905 3952 global_call_stack.depth++; 3906 3953 3907 3954 return true; ··· 5164 5211 return false; 5165 5212 } 5166 5213 5214 + static bool code_uses_arguments(const char *code, jsoff_t len) { 5215 + if (len < 9) return false; 5216 + for (jsoff_t i = 0; i + 8 < len; i++) { 5217 + if (code[i] == 'a' && memcmp(&code[i], INTERN_ARGUMENTS, 9) == 0) { 5218 + if (i > 0 && (is_alpha(code[i-1]) || code[i-1] == '_' || (code[i-1] >= '0' && code[i-1] <= '9'))) continue; 5219 + if (i + 9 < len && (is_alpha(code[i+9]) || code[i+9] == '_' || (code[i+9] >= '0' && code[i+9] <= '9'))) continue; 5220 + return true; 5221 + } 5222 + } 5223 + return false; 5224 + } 5225 + 5167 5226 static void setup_arguments(struct js *js, jsval_t scope, jsval_t *args, int nargs, bool strict) { 5168 5227 if (vtype(js->current_func) == T_FUNC) { 5169 5228 jsval_t func_obj = mkval(T_OBJ, vdata(js->current_func)); 5170 - if (lkp(js, func_obj, "__this", 6) != 0) return; 5229 + if (lkp_interned(js, func_obj, INTERN_THIS, 6) != 0) return; 5171 5230 } 5172 5231 5173 5232 jsval_t arguments_obj = mkobj(js, 0); 5174 5233 for (int i = 0; i < nargs; i++) { 5175 - char idxstr[16]; 5176 - snprintf(idxstr, sizeof(idxstr), "%d", i); 5177 - setprop(js, arguments_obj, js_mkstr(js, idxstr, strlen(idxstr)), args[i]); 5234 + if (i < 10) { 5235 + setprop(js, arguments_obj, js_mkstr(js, INTERN_IDX[i], 1), args[i]); 5236 + } else { 5237 + char idxstr[16]; 5238 + snprintf(idxstr, sizeof(idxstr), "%d", i); 5239 + setprop(js, arguments_obj, js_mkstr(js, idxstr, strlen(idxstr)), args[i]); 5240 + } 5178 5241 } 5179 - setprop(js, arguments_obj, js_mkstr(js, "length", 6), tov((double) nargs)); 5242 + setprop_interned(js, arguments_obj, INTERN_LENGTH, 6, tov((double) nargs)); 5180 5243 if (strict) { 5181 5244 setprop(js, arguments_obj, js_mkstr(js, "__strict_args__", 15), js_mktrue()); 5182 5245 } else if (vtype(js->current_func) == T_FUNC) { 5183 - setprop(js, arguments_obj, js_mkstr(js, "callee", 6), js->current_func); 5246 + setprop_interned(js, arguments_obj, INTERN_CALLEE, 6, js->current_func); 5184 5247 } 5185 5248 5186 5249 const char *toStringTag_key = get_toStringTag_sym_key(); ··· 5189 5252 } 5190 5253 5191 5254 arguments_obj = mkval(T_ARR, vdata(arguments_obj)); 5192 - setprop(js, scope, js_mkstr(js, "arguments", 9), arguments_obj); 5255 + setprop_interned(js, scope, INTERN_ARGUMENTS, 9, arguments_obj); 5193 5256 } 5194 5257 5195 5258 static jsval_t call_js_internal(struct js *js, const char *fn, jsoff_t fnlen, jsval_t closure_scope, jsval_t *bound_args, int bound_argc) { ··· 5312 5375 } 5313 5376 } 5314 5377 5315 - setup_arguments(js, function_scope, args, argc, func_strict); 5378 + if (code_uses_arguments(&fn[pf->body_start], pf->body_len)) { 5379 + setup_arguments(js, function_scope, args, argc, func_strict); 5380 + } 5316 5381 5317 5382 if (vtype(func_name) == T_STR && vtype(func_val) == T_FUNC) { 5318 5383 jsoff_t len; ··· 5357 5422 int combined_nargs = nargs; 5358 5423 int bound_argc = 0; 5359 5424 5360 - jsoff_t bound_args_off = lkp(js, func_obj, "__bound_args", 12); 5425 + jsoff_t bound_args_off = lkp_interned(js, func_obj, INTERN_BOUND_ARGS, 12); 5361 5426 if (bound_args_off != 0) { 5362 5427 jsval_t bound_arr = resolveprop(js, mkval(T_PROP, bound_args_off)); 5363 5428 if (vtype(bound_arr) == T_ARR) { ··· 5389 5454 } 5390 5455 } 5391 5456 5392 - jsoff_t native_off = lkp(js, func_obj, "__native_func", 13); 5457 + jsoff_t native_off = lkp_interned(js, func_obj, INTERN_NATIVE_FUNC, 13); 5393 5458 if (native_off != 0) { 5394 5459 jsval_t native_val = resolveprop(js, mkval(T_PROP, native_off)); 5395 5460 if (vtype(native_val) == T_CFUNC) { 5396 - jsoff_t this_off = lkp(js, func_obj, "__bound_this", 12); 5461 + jsoff_t this_off = lkp_interned(js, func_obj, INTERN_BOUND_THIS, 12); 5397 5462 jsval_t bound_this = js_mkundef(); 5398 5463 if (this_off != 0) { 5399 5464 bound_this = resolveprop(js, mkval(T_PROP, this_off)); ··· 5418 5483 } 5419 5484 } 5420 5485 5421 - jsoff_t code_off = lkp(js, func_obj, "__code", 6); 5486 + jsoff_t code_off = lkp_interned(js, func_obj, INTERN_CODE, 6); 5422 5487 if (code_off == 0) { 5423 5488 if (combined_args) ANT_GC_FREE(combined_args); 5424 5489 return js_mkerr(js, "function has no code"); ··· 5433 5498 const char *fn = (const char *) (&js->mem[fnoff]); 5434 5499 5435 5500 jsval_t closure_scope = js_mkundef(); 5436 - jsoff_t scope_off = lkp(js, func_obj, "__scope", 7); 5501 + jsoff_t scope_off = lkp_interned(js, func_obj, INTERN_SCOPE, 7); 5437 5502 if (scope_off != 0) { 5438 5503 closure_scope = resolveprop(js, mkval(T_PROP, scope_off)); 5439 5504 } 5440 5505 5441 - jsoff_t this_off = lkp(js, func_obj, "__this", 6); 5506 + jsoff_t this_off = lkp_interned(js, func_obj, INTERN_THIS, 6); 5442 5507 if (this_off != 0) { 5443 5508 jsval_t captured_this = resolveprop(js, mkval(T_PROP, this_off)); 5444 5509 pop_this(); 5445 5510 push_this(captured_this); 5446 5511 } 5447 5512 5448 - jsoff_t bound_this_off = lkp(js, func_obj, "__bound_this", 12); 5513 + jsoff_t bound_this_off = lkp_interned(js, func_obj, INTERN_BOUND_THIS, 12); 5449 5514 if (bound_this_off != 0) { 5450 5515 jsval_t bound_this = resolveprop(js, mkval(T_PROP, bound_this_off)); 5451 5516 pop_this(); ··· 5586 5651 size_t body_len = fnlen - fnpos - 1; 5587 5652 5588 5653 bool func_strict = is_strict_function_body(&fn[fnpos], body_len); 5589 - setup_arguments(js, function_scope, args, nargs, func_strict); 5654 + if (code_uses_arguments(&fn[fnpos], body_len)) { 5655 + setup_arguments(js, function_scope, args, nargs, func_strict); 5656 + } 5590 5657 5591 5658 jsval_t saved_this = js->this_val; 5592 5659 jsval_t target_this = peek_this(); ··· 5621 5688 if (proto_check == 0) { 5622 5689 jsval_t func_obj = mkval(T_OBJ, vdata(func)); 5623 5690 5624 - jsoff_t target_func_off = lkp(js, func_obj, "__target_func", 13); 5691 + jsoff_t target_func_off = lkp_interned(js, func_obj, INTERN_TARGET_FUNC, 13); 5625 5692 jsval_t proto_source = func_obj; 5626 5693 if (target_func_off != 0) { 5627 5694 jsval_t target_func = resolveprop(js, mkval(T_PROP, target_func_off)); ··· 5650 5717 5651 5718 if (vtype(func) == T_FUNC) { 5652 5719 jsval_t func_obj = mkval(T_OBJ, vdata(func)); 5653 - jsoff_t native_off = lkp(js, func_obj, "__native_func", 13); 5720 + jsoff_t native_off = lkp_interned(js, func_obj, INTERN_NATIVE_FUNC, 13); 5654 5721 if (native_off != 0) { 5655 5722 jsval_t native_val = resolveprop(js, mkval(T_PROP, native_off)); 5656 5723 if (vtype(native_val) == T_CFUNC) { ··· 5660 5727 js->current_func = saved_func; 5661 5728 } 5662 5729 } else { 5663 - jsoff_t code_off = lkp(js, func_obj, "__code", 6); 5730 + jsoff_t code_off = lkp_interned(js, func_obj, INTERN_CODE, 6); 5664 5731 if (code_off == 0) return js_mkerr(js, "function has no code"); 5665 5732 jsval_t code_val = resolveprop(js, mkval(T_PROP, code_off)); 5666 5733 if (vtype(code_val) != T_STR) return js_mkerr(js, "function code not string"); 5667 5734 jsval_t closure_scope = js_mkundef(); 5668 - jsoff_t scope_off = lkp(js, func_obj, "__scope", 7); 5735 + jsoff_t scope_off = lkp_interned(js, func_obj, INTERN_SCOPE, 7); 5669 5736 if (scope_off != 0) { 5670 5737 closure_scope = resolveprop(js, mkval(T_PROP, scope_off)); 5671 5738 } 5672 5739 jsoff_t fnlen, fnoff = vstr(js, code_val, &fnlen); 5673 5740 const char *code_str = (const char *) (&js->mem[fnoff]); 5674 5741 bool is_async = false; 5675 - jsoff_t async_off = lkp(js, func_obj, "__async", 7); 5742 + jsoff_t async_off = lkp_interned(js, func_obj, INTERN_ASYNC, 7); 5676 5743 if (async_off != 0) { 5677 5744 jsval_t async_val = resolveprop(js, mkval(T_PROP, async_off)); 5678 5745 is_async = vtype(async_val) == T_BOOL && vdata(async_val) == 1; ··· 5682 5749 bool is_arrow = false; 5683 5750 bool is_bound = false; 5684 5751 5685 - jsoff_t this_off = lkp(js, func_obj, "__this", 6); 5752 + jsoff_t this_off = lkp_interned(js, func_obj, INTERN_THIS, 6); 5686 5753 if (this_off != 0) { 5687 5754 captured_this = resolveprop(js, mkval(T_PROP, this_off)); 5688 5755 is_arrow = true; 5689 5756 } 5690 5757 5691 - jsoff_t bound_this_off = lkp(js, func_obj, "__bound_this", 12); 5758 + jsoff_t bound_this_off = lkp_interned(js, func_obj, INTERN_BOUND_THIS, 12); 5692 5759 if (bound_this_off != 0 && !is_constructor_call) { 5693 5760 captured_this = resolveprop(js, mkval(T_PROP, bound_this_off)); 5694 5761 is_bound = true; ··· 5697 5764 jsval_t bound_args_storage[64]; 5698 5765 jsval_t *bound_args = NULL; 5699 5766 int bound_argc = 0; 5700 - jsoff_t bound_args_off = lkp(js, func_obj, "__bound_args", 12); 5767 + jsoff_t bound_args_off = lkp_interned(js, func_obj, INTERN_BOUND_ARGS, 12); 5701 5768 if (bound_args_off != 0) { 5702 5769 jsval_t bound_arr = resolveprop(js, mkval(T_PROP, bound_args_off)); 5703 5770 if (vtype(bound_arr) == T_ARR) { ··· 5730 5797 if (fnlen == 16 && memcmp(code_str, "__builtin_Object", 16) == 0) { 5731 5798 res = call_c(js, builtin_Object); 5732 5799 } else { 5733 - int call_line = 0, call_col = 0; 5734 - get_line_col(code, pos, &call_line, &call_col); 5735 - 5736 5800 static char full_func_name[256]; 5737 5801 const char *func_name = NULL; 5738 5802 const char *this_name = NULL; ··· 5782 5846 push_call_frame( 5783 5847 js->filename, 5784 5848 final_name, 5785 - call_line, call_col 5849 + code, pos 5786 5850 ); 5787 5851 5788 5852 jsval_t saved_func = js->current_func; ··· 5882 5946 result = ((jsval_t (*)(struct js *, jsval_t *, int))vdata(ts_func))(js, NULL, 0); 5883 5947 } else { 5884 5948 jsval_t func_obj = mkval(T_OBJ, vdata(ts_func)); 5885 - jsoff_t code_off = lkp(js, func_obj, "__code", 6); 5949 + jsoff_t code_off = lkp_interned(js, func_obj, INTERN_CODE, 6); 5886 5950 if (code_off == 0) goto restore_fallback; 5887 5951 5888 5952 jsval_t code_val = resolveprop(js, mkval(T_PROP, code_off)); 5889 5953 if (vtype(code_val) != T_STR) goto restore_fallback; 5890 5954 5891 - jsoff_t scope_off = lkp(js, func_obj, "__scope", 7); 5955 + jsoff_t scope_off = lkp_interned(js, func_obj, INTERN_SCOPE, 7); 5892 5956 jsval_t closure_scope = scope_off ? resolveprop(js, mkval(T_PROP, scope_off)) : js->scope; 5893 5957 5894 5958 jsoff_t fnlen, fnoff = vstr(js, code_val, &fnlen); ··· 11649 11713 jsval_t bound_func = mkobj(js, 0); 11650 11714 if (is_err(bound_func)) return bound_func; 11651 11715 11652 - jsoff_t code_off = lkp(js, func_obj, "__code", 6); 11716 + jsoff_t code_off = lkp_interned(js, func_obj, INTERN_CODE, 6); 11653 11717 if (code_off != 0) { 11654 11718 jsval_t code_val = resolveprop(js, mkval(T_PROP, code_off)); 11655 11719 setprop(js, bound_func, js_mkstr(js, "__code", 6), code_val); 11656 11720 } 11657 11721 11658 - jsoff_t scope_off = lkp(js, func_obj, "__scope", 7); 11722 + jsoff_t scope_off = lkp_interned(js, func_obj, INTERN_SCOPE, 7); 11659 11723 if (scope_off != 0) { 11660 11724 jsval_t scope_val = resolveprop(js, mkval(T_PROP, scope_off)); 11661 11725 setprop(js, bound_func, js_mkstr(js, "__scope", 7), scope_val); 11662 11726 } 11663 11727 11664 - jsoff_t async_off = lkp(js, func_obj, "__async", 7); 11728 + jsoff_t async_off = lkp_interned(js, func_obj, INTERN_ASYNC, 7); 11665 11729 if (async_off != 0) { 11666 11730 jsval_t async_val = resolveprop(js, mkval(T_PROP, async_off)); 11667 11731 setprop(js, bound_func, js_mkstr(js, "__async", 7), async_val); ··· 20933 20997 return fn(js, args, nargs); 20934 20998 } else if (vtype(func) == T_FUNC) { 20935 20999 jsval_t func_obj = mkval(T_OBJ, vdata(func)); 20936 - jsoff_t native_off = lkp(js, func_obj, "__native_func", 13); 21000 + jsoff_t native_off = lkp_interned(js, func_obj, INTERN_NATIVE_FUNC, 13); 20937 21001 if (native_off != 0) { 20938 21002 jsval_t native_val = resolveprop(js, mkval(T_PROP, native_off)); 20939 21003 if (vtype(native_val) == T_CFUNC) { ··· 20948 21012 return res; 20949 21013 } 20950 21014 } 20951 - jsoff_t code_off = lkp(js, func_obj, "__code", 6); 21015 + jsoff_t code_off = lkp_interned(js, func_obj, INTERN_CODE, 6); 20952 21016 20953 21017 if (code_off == 0) return js_mkerr(js, "function has no code"); 20954 21018 jsval_t code_val = resolveprop(js, mkval(T_PROP, code_off)); ··· 20956 21020 jsoff_t fnlen, fnoff = vstr(js, code_val, &fnlen); 20957 21021 const char *fn = (const char *) (&js->mem[fnoff]); 20958 21022 20959 - jsoff_t async_off = lkp(js, func_obj, "__async", 7); 21023 + jsoff_t async_off = lkp_interned(js, func_obj, INTERN_ASYNC, 7); 20960 21024 bool is_async = false; 20961 21025 if (async_off != 0) { 20962 21026 jsval_t async_val = resolveprop(js, mkval(T_PROP, async_off)); ··· 20965 21029 20966 21030 if (is_async) { 20967 21031 jsval_t closure_scope = js_mkundef(); 20968 - jsoff_t scope_off = lkp(js, func_obj, "__scope", 7); 21032 + jsoff_t scope_off = lkp_interned(js, func_obj, INTERN_SCOPE, 7); 20969 21033 if (scope_off != 0) { 20970 21034 closure_scope = resolveprop(js, mkval(T_PROP, scope_off)); 20971 21035 } ··· 20973 21037 } 20974 21038 20975 21039 jsval_t saved_scope = js->scope; 20976 - jsoff_t scope_off = lkp(js, func_obj, "__scope", 7); 21040 + jsoff_t scope_off = lkp_interned(js, func_obj, INTERN_SCOPE, 7); 20977 21041 if (scope_off != 0) { 20978 21042 jsval_t closure_scope = resolveprop(js, mkval(T_PROP, scope_off)); 20979 21043 if (vtype(closure_scope) == T_OBJ) { ··· 21154 21218 21155 21219 fprintf(stream, " (\x1b[90m"); 21156 21220 21221 + if (frame->line < 0 && frame->code) { 21222 + get_line_col(frame->code, frame->pos, &frame->line, &frame->col); 21223 + } 21224 + int fline = frame->line > 0 ? frame->line : 1; 21225 + int fcol = frame->col > 0 ? frame->col : 1; 21226 + 21157 21227 if (frame->filename) { 21158 - fprintf(stream, "%s:%d:%d", frame->filename, frame->line, frame->col); 21228 + fprintf(stream, "%s:%d:%d", frame->filename, fline, fcol); 21159 21229 } else fprintf(stream, "<unknown>"); 21160 21230 21161 21231 fprintf(stream, "\x1b[0m)\n");