| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * ncdecode.c - table driven decoder for Native Client | 8 * ncdecode.c - table driven decoder for Native Client |
| 9 * | 9 * |
| 10 * Most x86 decoders I've looked at are big case statements. While | 10 * Most x86 decoders I've looked at are big case statements. While |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 | 678 |
| 679 /* Default action for a decoder state pair. */ | 679 /* Default action for a decoder state pair. */ |
| 680 static Bool NullNCDecoderStatePairAction(struct NCDecoderStatePair* tthis, | 680 static Bool NullNCDecoderStatePairAction(struct NCDecoderStatePair* tthis, |
| 681 NCDecoderInst* old_inst, | 681 NCDecoderInst* old_inst, |
| 682 NCDecoderInst* new_inst) { | 682 NCDecoderInst* new_inst) { |
| 683 return TRUE; | 683 return TRUE; |
| 684 } | 684 } |
| 685 | 685 |
| 686 void NCDecoderStatePairConstruct(NCDecoderStatePair* tthis, | 686 void NCDecoderStatePairConstruct(NCDecoderStatePair* tthis, |
| 687 NCDecoderState* old_dstate, | 687 NCDecoderState* old_dstate, |
| 688 NCDecoderState* new_dstate) { | 688 NCDecoderState* new_dstate, |
| 689 NaClCopyInstructionFunc copy_func) { |
| 689 tthis->old_dstate = old_dstate; | 690 tthis->old_dstate = old_dstate; |
| 690 tthis->new_dstate = new_dstate; | 691 tthis->new_dstate = new_dstate; |
| 691 tthis->action_fn = NullNCDecoderStatePairAction; | 692 tthis->action_fn = NullNCDecoderStatePairAction; |
| 693 tthis->copy_func = copy_func; |
| 692 } | 694 } |
| 693 | 695 |
| 694 void NCDecoderStatePairDestruct(NCDecoderStatePair* tthis) { | 696 void NCDecoderStatePairDestruct(NCDecoderStatePair* tthis) { |
| 695 } | 697 } |
| 696 | 698 |
| 697 Bool NCDecoderStatePairDecode(NCDecoderStatePair* tthis) { | 699 Bool NCDecoderStatePairDecode(NCDecoderStatePair* tthis) { |
| 698 NCDecoderInst* old_dinst = | 700 NCDecoderInst* old_dinst = |
| 699 &tthis->old_dstate->inst_buffer[tthis->old_dstate->cur_inst_index]; | 701 &tthis->old_dstate->inst_buffer[tthis->old_dstate->cur_inst_index]; |
| 700 NCDecoderInst* new_dinst = | 702 NCDecoderInst* new_dinst = |
| 701 &tthis->new_dstate->inst_buffer[tthis->new_dstate->cur_inst_index]; | 703 &tthis->new_dstate->inst_buffer[tthis->new_dstate->cur_inst_index]; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (! (tthis->action_fn)(tthis, old_dinst, new_dinst)) { | 766 if (! (tthis->action_fn)(tthis, old_dinst, new_dinst)) { |
| 765 return FALSE; | 767 return FALSE; |
| 766 } | 768 } |
| 767 | 769 |
| 768 /* Move to next instruction. */ | 770 /* Move to next instruction. */ |
| 769 old_dinst = IncrementInst(old_dinst); | 771 old_dinst = IncrementInst(old_dinst); |
| 770 new_dinst = IncrementInst(new_dinst); | 772 new_dinst = IncrementInst(new_dinst); |
| 771 } | 773 } |
| 772 return TRUE; | 774 return TRUE; |
| 773 } | 775 } |
| OLD | NEW |