Skip to content

Conversation

bnoordhuis
Copy link
Contributor

Observed in generated code for static initializers. We could in theory track and correct it in js_parse_class() but doing it as a peephole optimization is both easier and more general.

Observed in generated code for static initializers. We could in theory
track and correct it in js_parse_class() but doing it as a peephole
optimization is both easier and more general.
@saghul
Copy link
Contributor

saghul commented Nov 26, 2023

Out of curiosity how are you digging these things up?

@bnoordhuis
Copy link
Contributor Author

puts() and patience basically :-)

diff --git a/quickjs.c b/quickjs.c
index e9f5197..e9cd759 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -14170,7 +14170,12 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
 #include "quickjs-opcode.h"
         [ OP_COUNT ... 255 ] = &&case_default
     };
-#define SWITCH(pc)      goto *dispatch_table[opcode = *pc++];
+    static const char * const opnames[] = {
+#undef DEF
+#define DEF(id, size, n_pop, n_push, f) #id,
+#include "quickjs-opcode.h"
+    };
+#define SWITCH(pc)      puts(opnames[*pc]); goto *dispatch_table[opcode = *pc++];
 #define CASE(op)        case_ ## op
 #define DEFAULT         case_default
 #define BREAK           SWITCH(pc)

@bnoordhuis bnoordhuis merged commit 51633af into quickjs-ng:master Nov 26, 2023
@bnoordhuis bnoordhuis deleted the swap-swap branch November 26, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants