2 ms·
This is the chicken or egg problem. If one of the leading languages had required bounds checking back when the processor instruction sets were being defined, th
by mark-r 11y ago
This is the chicken or egg problem. If one of the leading languages had required bounds checking back when the processor instruction sets were being defined, those instructions would already exist and the cost today would be negligible. But the languages didn't include it because it would have been expensive at the time.
- kybernetikos 11y agoI'm sure I did a bunch of assembly programming on a CPU that had a flag telling you if the last calculation overflowed or not. Branch if overflow was a straightforward opcode.
- hga 11y agoIndeed. I'm not sure how far back this goes, but definitely to the PDP-11, and looks like the IBM 360.
- mark-r 11y agoYes, but adding the branch instruction itself is the killer. If the processor had some kind of trap to set for overflow, there would be no extra instructions and no timing overhead when there wasn't an overflow.