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.

undo arguments lowering change

+19 -36
+3 -36
src/silver/compiler.c
··· 398 398 return c && !c->is_arrow && c->enclosing; 399 399 } 400 400 401 - static bool ast_arguments_captured_by_arrow(const sv_ast_t *node, bool in_arrow) { 402 - if (!node) return false; 403 - if (in_arrow && node->type == N_IDENT && 404 - is_ident_str(node->str, node->len, "arguments", 9)) 405 - return true; 406 - 407 - if (node->type == N_FUNC) { 408 - if (!(node->flags & FN_ARROW)) return false; 409 - 410 - for (int i = 0; i < node->args.count; i++) { 411 - if (ast_arguments_captured_by_arrow(node->args.items[i], true)) return true; 412 - } 413 - return ast_arguments_captured_by_arrow(node->body, true); 414 - } 415 - 416 - if (ast_arguments_captured_by_arrow(node->left, in_arrow)) return true; 417 - if (ast_arguments_captured_by_arrow(node->right, in_arrow)) return true; 418 - if (ast_arguments_captured_by_arrow(node->cond, in_arrow)) return true; 419 - if (ast_arguments_captured_by_arrow(node->body, in_arrow)) return true; 420 - if (ast_arguments_captured_by_arrow(node->catch_body, in_arrow)) return true; 421 - if (ast_arguments_captured_by_arrow(node->finally_body, in_arrow)) return true; 422 - if (ast_arguments_captured_by_arrow(node->catch_param, in_arrow)) return true; 423 - if (ast_arguments_captured_by_arrow(node->init, in_arrow)) return true; 424 - if (ast_arguments_captured_by_arrow(node->update, in_arrow)) return true; 425 - 426 - for (int i = 0; i < node->args.count; i++) { 427 - if (ast_arguments_captured_by_arrow(node->args.items[i], in_arrow)) return true; 428 - } 429 - 430 - return false; 431 - } 432 - 433 401 static int resolve_local(sv_compiler_t *c, const char *name, uint32_t len) { 434 402 if (c->local_lookup_heads && c->local_lookup_cap > 0) { 435 403 uint32_t hash = sv_compile_ctx_hash_local_name(name, len); ··· 4499 4467 } 4500 4468 } 4501 4469 4502 - if (!comp.is_arrow && has_implicit_arguments_obj(&comp) && 4503 - (node->flags & FN_USES_ARGS) && 4504 - ast_arguments_captured_by_arrow(node->body, false)) { 4505 - comp.strict_args_local = add_local(&comp, "", 0, false, comp.scope_depth); 4470 + if (!comp.is_arrow && has_implicit_arguments_obj(&comp) && (node->flags & FN_USES_ARGS)) { 4471 + static const char args_name[] = "\x01arguments"; 4472 + comp.strict_args_local = add_local(&comp, args_name, sizeof(args_name) - 1, false, comp.scope_depth); 4506 4473 emit_op(&comp, OP_SPECIAL_OBJ); 4507 4474 emit(&comp, 0); 4508 4475 emit_put_local(&comp, comp.strict_args_local);
+16
tests/test_jit_arguments_object.cjs
··· 22 22 }; 23 23 } 24 24 25 + function strictUnmappedRead(a) { 26 + "use strict"; 27 + a = 2; 28 + return arguments[0]; 29 + } 30 + 31 + function strictUnmappedWrite(a) { 32 + "use strict"; 33 + arguments[0] = 2; 34 + return a; 35 + } 36 + 25 37 function directRead(a) { 26 38 return arguments[0] + a; 27 39 } ··· 36 48 assertEq(mappedWrite(1), 2, "warm mapped write"); 37 49 assertEq(directRead(3), 6, "warm direct read"); 38 50 assertEq(arrowCapture(4), 8, "warm arrow capture"); 51 + assertEq(strictUnmappedRead(1), 1, "warm strict unmapped read"); 52 + assertEq(strictUnmappedWrite(1), 1, "warm strict unmapped write"); 39 53 const warmStrict = strictSlice("/", "mw"); 40 54 assertEq(warmStrict.argc, 2, "warm strict argc"); 41 55 assertEq(warmStrict.tail.length, 1, "warm strict tail length"); ··· 46 60 assertEq(mappedWrite(1), 2, "hot mapped write"); 47 61 assertEq(directRead(3), 6, "hot direct read"); 48 62 assertEq(arrowCapture(4), 8, "hot arrow capture"); 63 + assertEq(strictUnmappedRead(1), 1, "hot strict unmapped read"); 64 + assertEq(strictUnmappedWrite(1), 1, "hot strict unmapped write"); 49 65 50 66 const hotStrict = strictSlice("/route", "mw1", "mw2"); 51 67 assertEq(hotStrict.argc, 3, "hot strict argc");