@@ -18239,6 +18239,38 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
18239
18239
}
18240
18240
BREAK;
18241
18241
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
+
18242
18274
CASE(OP_get_ref_value):
18243
18275
{
18244
18276
JSValue val;
@@ -18966,27 +18998,6 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
18966
18998
}
18967
18999
BREAK;
18968
19000
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;
18990
19001
#if 0
18991
19002
CASE(OP_to_string):
18992
19003
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,
24307
24318
emit_u16(s, scope);
24308
24319
break;
24309
24320
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);
24314
24322
break;
24315
24323
case OP_get_super_value:
24316
24324
emit_op(s, OP_to_propkey);
@@ -24739,7 +24747,7 @@ static int js_parse_destructuring_element(JSParseState *s, int tok, int is_arg,
24739
24747
continue;
24740
24748
}
24741
24749
if (prop_name == JS_ATOM_NULL) {
24742
- emit_op(s, OP_to_propkey2 );
24750
+ emit_op(s, OP_to_propkey );
24743
24751
if (has_ellipsis) {
24744
24752
/* define the property in excludeList */
24745
24753
emit_op(s, OP_perm3);
@@ -33334,9 +33342,8 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
33334
33342
goto no_change;
33335
33343
33336
33344
case OP_to_propkey:
33337
- case OP_to_propkey2:
33338
33345
if (OPTIMIZE) {
33339
- /* remove redundant to_propkey/to_propkey2 opcodes when storing simple data */
33346
+ /* remove redundant to_propkey opcodes when storing simple data */
33340
33347
if (code_match(&cc, pos_next, M3(OP_get_loc, OP_get_arg, OP_get_var_ref), -1, OP_put_array_el, -1)
33341
33348
|| code_match(&cc, pos_next, M3(OP_push_i32, OP_push_const, OP_push_atom_value), OP_put_array_el, -1)
33342
33349
|| code_match(&cc, pos_next, M4(OP_undefined, OP_null, OP_push_true, OP_push_false), OP_put_array_el, -1)) {
0 commit comments