Page MenuHomePhabricator

OP_MUL implementation
AbandonedPublic

Authored by danconnolly on Jul 25 2018, 22:13.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Implementation of OP_MUL for the magnetic upgrade. The specification for this opcode is here.

Overflow: The operands to the OP_MUL opcode must be valid numerical values, otherwise the opcode will fail. Numerical values are limited to 32-bits. The result of the OP_MUL opcode can be longer than 32-bits. A result of that size would not be considered a valid numerical value but it is a valid byte sequence. The product of two maximum sized numerical values will fit in a 64-bit integer and will not produce an overflow in the implementation. Tests exist in script_tests.json for these scenarios, currently at lines 1059-1060 & 1070-1071.

Test Plan

make check

Diff Detail

Branch
opcodes_mul
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 3046
Build 4181: arc lint + arc unit
danconnolly created this revision.Jul 25 2018, 22:13
danconnolly updated this revision to Diff 4428.Jul 25 2018, 22:39
  • add negative zero test
danconnolly planned changes to this revision.Jul 28 2018, 12:42
This comment was removed by danconnolly.
danconnolly updated this revision to Diff 4540.Aug 8 2018, 23:00

refactor based on re-organizing prior diffs

schancel added a subscriber: schancel.Aug 9 2018, 01:07
schancel added inline comments.
src/script/interpreter.cpp
758

I was under the impression there was some overflow issue that needed to be addressed?

danconnolly edited the summary of this revision. (Show Details)Aug 9 2018, 07:56
danconnolly edited the summary of this revision. (Show Details)
danconnolly marked an inline comment as done.Aug 9 2018, 07:58
danconnolly added inline comments.
src/script/interpreter.cpp
758

I've updated the revision description to describe the potential for overflow and the related tests.

danconnolly marked 2 inline comments as done.Aug 9 2018, 07:58
danconnolly abandoned this revision.Tue, Sep 4, 09:29