| 777 | } |
| 778 | |
| 779 | static void backtrace_oom_current_exception(void) |
| 780 | { |
| 781 | static const char setup_code[] = |
| 782 | "globalThis.f = function() { missing; };\n" |
| 783 | "Object.defineProperty(f, 'name', { value: 'x'.repeat(2 * 1024 * 1024) });"; |
| 784 | JSMemoryUsage stats; |
| 785 | JSValue ret, exception; |
| 786 | JSRuntime *rt; |
| 787 | JSContext *ctx; |
| 788 | |
| 789 | rt = new_runtime(); |
| 790 | ctx = JS_NewContext(rt); |
| 791 | |
| 792 | ret = eval(ctx, setup_code); |
| 793 | assert(!JS_IsException(ret)); |
| 794 | JS_FreeValue(ctx, ret); |
| 795 | |
| 796 | JS_ComputeMemoryUsage(rt, &stats); |
| 797 | JS_SetMemoryLimit(rt, (size_t)stats.malloc_size + 128 * 1024); |
| 798 | |
| 799 | ret = eval(ctx, "f()"); |
| 800 | assert(JS_IsException(ret)); |
| 801 | assert(JS_HasException(ctx)); |
| 802 | exception = JS_GetException(ctx); |
| 803 | JS_FreeValue(ctx, exception); |
| 804 | JS_SetMemoryLimit(rt, 0); |
| 805 | |
| 806 | JS_FreeContext(ctx); |
| 807 | JS_FreeRuntime(rt); |
| 808 | } |
| 809 | |
| 810 | static int gop_get_own_property(JSContext *ctx, JSPropertyDescriptor *desc, |
| 811 | JSValueConst obj, JSAtom prop) |
no test coverage detected