@@ -18239,6 +18239,38 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
1823918239 }
1824018240 BREAK;
1824118241
18242+ CASE(OP_get_array_el3):
18243+ {
18244+ JSValue val;
18245+
18246+ switch (JS_VALUE_GET_TAG(sp[-2])) {
18247+ case JS_TAG_INT:
18248+ case JS_TAG_STRING:
18249+ case JS_TAG_SYMBOL:
18250+ /* undefined and null are tested in JS_GetPropertyValue() */
18251+ break;
18252+ default:
18253+ /* must be tested nefore JS_ToPropertyKey */
18254+ if (unlikely(JS_IsUndefined(sp[-2]) || JS_IsNull(sp[-2]))) {
18255+ JS_ThrowTypeError(ctx, "value has no property");
18256+ goto exception;
18257+ }
18258+ sf->cur_pc = pc;
18259+ ret_val = JS_ToPropertyKey(ctx, sp[-1]);
18260+ if (JS_IsException(ret_val))
18261+ goto exception;
18262+ JS_FreeValue(ctx, sp[-1]);
18263+ sp[-1] = ret_val;
18264+ break;
18265+ }
18266+ sf->cur_pc = pc;
18267+ val = JS_GetPropertyValue(ctx, sp[-2], JS_DupValue(ctx, sp[-1]));
18268+ *sp++ = val;
18269+ if (unlikely(JS_IsException(val)))
18270+ goto exception;
18271+ }
18272+ BREAK;
18273+
1824218274 CASE(OP_get_ref_value):
1824318275 {
1824418276 JSValue val;
@@ -18966,27 +18998,6 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
1896618998 }
1896718999 BREAK;
1896819000
18969- CASE(OP_to_propkey2):
18970- /* must be tested first */
18971- if (unlikely(JS_IsUndefined(sp[-2]) || JS_IsNull(sp[-2]))) {
18972- JS_ThrowTypeError(ctx, "value has no property");
18973- goto exception;
18974- }
18975- switch (JS_VALUE_GET_TAG(sp[-1])) {
18976- case JS_TAG_INT:
18977- case JS_TAG_STRING:
18978- case JS_TAG_SYMBOL:
18979- break;
18980- default:
18981- sf->cur_pc = pc;
18982- ret_val = JS_ToPropertyKey(ctx, sp[-1]);
18983- if (JS_IsException(ret_val))
18984- goto exception;
18985- JS_FreeValue(ctx, sp[-1]);
18986- sp[-1] = ret_val;
18987- break;
18988- }
18989- BREAK;
1899019001#if 0
1899119002 CASE(OP_to_string):
1899219003 if (JS_VALUE_GET_TAG(sp[-1]) != JS_TAG_STRING) {
@@ -24307,10 +24318,7 @@ static __exception int get_lvalue(JSParseState *s, int *popcode, int *pscope,
2430724318 emit_u16(s, scope);
2430824319 break;
2430924320 case OP_get_array_el:
24310- /* XXX: replace by a single opcode ? */
24311- emit_op(s, OP_to_propkey2);
24312- emit_op(s, OP_dup2);
24313- emit_op(s, OP_get_array_el);
24321+ emit_op(s, OP_get_array_el3);
2431424322 break;
2431524323 case OP_get_super_value:
2431624324 emit_op(s, OP_to_propkey);
@@ -24739,7 +24747,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg,
2473924747 continue;
2474024748 }
2474124749 if (prop_name == JS_ATOM_NULL) {
24742- emit_op(s, OP_to_propkey2 );
24750+ emit_op(s, OP_to_propkey );
2474324751 if (has_ellipsis) {
2474424752 /* define the property in excludeList */
2474524753 emit_op(s, OP_perm3);
@@ -33334,9 +33342,8 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
3333433342 goto no_change;
3333533343
3333633344 case OP_to_propkey:
33337- case OP_to_propkey2:
3333833345 if (OPTIMIZE) {
33339- /* remove redundant to_propkey/to_propkey2 opcodes when storing simple data */
33346+ /* remove redundant to_propkey opcodes when storing simple data */
3334033347 if (code_match(&cc, pos_next, M3(OP_get_loc, OP_get_arg, OP_get_var_ref), -1, OP_put_array_el, -1)
3334133348 || code_match(&cc, pos_next, M3(OP_push_i32, OP_push_const, OP_push_atom_value), OP_put_array_el, -1)
3334233349 || code_match(&cc, pos_next, M4(OP_undefined, OP_null, OP_push_true, OP_push_false), OP_put_array_el, -1)) {
0 commit comments