Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported opcode fallback #22

Merged
merged 6 commits into from
Dec 19, 2024
Merged

Unsupported opcode fallback #22

merged 6 commits into from
Dec 19, 2024

Conversation

ailrst
Copy link
Contributor

@ailrst ailrst commented Sep 23, 2024

Emit a Stmt_TCall("unsupported_opcode", Expr_IntLiteral(opcode)) on lift failures rather than crashing. This occurs currently due to svc, ldaxr, and mrs instructions

          "svc #0": [
            "Stmt_TCall(\"unsupported_opcode.0\",[],[3556769793])"
          "ldaxr w2, [x21]": [
            "Stmt_TCall(\"unsupported_opcode.0\",[],[2287992482])"
          ]
          "mrs x0, FPSR": [
            "Stmt_TCall(\"unsupported_opcode.0\",[],[3577431072])"
          ]

Also fixed dune config for new release of ocaml_protoc_plugin

Copy link
Member

@katrinafyi katrinafyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm aside from typo.

it would be nice to make this configurable by a command-line argument, in case one wanted to see the stack trace from failed instructions. but this could come later.

bin/main.ml Outdated Show resolved Hide resolved
lib/dune Show resolved Hide resolved
Co-authored-by: Kait Lam <[email protected]>
@katrinafyi
Copy link
Member

it occurs to me that this is better placed within aslp, especially since it introduces a new kind of intrinsic. but this can be merged for now.

@katrinafyi
Copy link
Member

Maybe it would be better to use a distinct JSON structure to represent the error, instead of embedding it as a fake ASL statement.

@katrinafyi katrinafyi self-requested a review November 11, 2024 04:11
Copy link
Member

@katrinafyi katrinafyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"use a distinct JSON structure to represent the error, instead of embedding it as a fake ASL statement".

@ailrst
Copy link
Contributor Author

ailrst commented Nov 11, 2024

Probably implement as a map containing the same information (debug gts output):

    "+YG2ow7IRuybtIDNCYkdUw==": {
      "name": "__sfp_handle_exceptions [ 7/11]",
--
          "assembly": "fmul s0, s1, s1",
          "semantics": [
            "Stmt_ConstDecl(Type_Bits(32),\"Exp9__5\",Expr_TApply(\"FPMul.0\",[32],[Expr_Slices(Expr_Array(Expr_Var(\"_Z\"),1),[Slice_LoWd(0,32)]);Expr_Slices(Expr_Array(Expr_Var(\"
_Z\"),1),[Slice_LoWd(0,32)]);Expr_Var(\"FPCR\")]))",
            "Stmt_Assign(LExpr_Array(LExpr_Var(\"_Z\"),0),Expr_TApply(\"ZeroExtend.0\",[32;128],[Expr_Var(\"Exp9__5\");128]))"
          ]
        },
        {
          "address": "0x0040f0a0 (4255904)",
          "assembly": "mrs x1, FPSR",
          "semantics": {
            "decode_error": {
              "opcode": "0xd53b4421",
              "error": "Failure(\"Casting unhandled value type to expression: {.NS = 1'0', .exceptype = Exception_AdvSIMDFPAccessTrap, .ipaddress = 52'000000000000000000000000000000
0000000000000000000000', .ipavalid = FALSE, .syndrome = 25'0000000000000000000000000', .vaddress = 64'0000000000000000000000000000000000000000000000000000000000000000'}\")"
            }
          }
        }
      ],

ailrst and others added 2 commits November 11, 2024 15:04
some module renaming because every library we import shadows Result
@ailrst ailrst requested a review from katrinafyi December 19, 2024 07:45
@ailrst
Copy link
Contributor Author

ailrst commented Dec 19, 2024

lgtm

Copy link
Member

@katrinafyi katrinafyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forecast looks good

@katrinafyi katrinafyi merged commit 3044b50 into main Dec 19, 2024
@katrinafyi katrinafyi deleted the unsupported-opcode-fallback branch December 19, 2024 07:47
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