Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "courgette/encoded_program.h" | 5 #include "courgette/encoded_program.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 uint32 page_rva; | 703 uint32 page_rva; |
| 704 uint32 block_size; | 704 uint32 block_size; |
| 705 uint16 relocs[4096]; // Allow up to one relocation per byte of a 4k page. | 705 uint16 relocs[4096]; // Allow up to one relocation per byte of a 4k page. |
| 706 }; | 706 }; |
| 707 | 707 |
| 708 COMPILE_ASSERT(offsetof(RelocBlockPOD, relocs) == 8, reloc_block_header_size); | 708 COMPILE_ASSERT(offsetof(RelocBlockPOD, relocs) == 8, reloc_block_header_size); |
| 709 | 709 |
| 710 class RelocBlock { | 710 class RelocBlock { |
| 711 public: | 711 public: |
| 712 RelocBlock() { | 712 RelocBlock() { |
| 713 pod.page_rva = ~0; | 713 pod.page_rva = 0xFFFFFFFF; |
|
tommi (sloooow) - chröme
2014/07/08 07:56:15
I'm curious - does this actually make a difference
Peter Kasting
2014/07/08 19:33:47
~0 is signed (I believe because 0 is signed), whil
| |
| 714 pod.block_size = 8; | 714 pod.block_size = 8; |
| 715 } | 715 } |
| 716 | 716 |
| 717 void Add(uint16 item) { | 717 void Add(uint16 item) { |
| 718 pod.relocs[(pod.block_size-8)/2] = item; | 718 pod.relocs[(pod.block_size-8)/2] = item; |
| 719 pod.block_size += 2; | 719 pod.block_size += 2; |
| 720 } | 720 } |
| 721 | 721 |
| 722 CheckBool Flush(SinkStream* buffer) WARN_UNUSED_RESULT { | 722 CheckBool Flush(SinkStream* buffer) WARN_UNUSED_RESULT { |
| 723 bool ok = true; | 723 bool ok = true; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 if (assembled) | 793 if (assembled) |
| 794 return C_OK; | 794 return C_OK; |
| 795 return C_ASSEMBLY_FAILED; | 795 return C_ASSEMBLY_FAILED; |
| 796 } | 796 } |
| 797 | 797 |
| 798 void DeleteEncodedProgram(EncodedProgram* encoded) { | 798 void DeleteEncodedProgram(EncodedProgram* encoded) { |
| 799 delete encoded; | 799 delete encoded; |
| 800 } | 800 } |
| 801 | 801 |
| 802 } // end namespace | 802 } // end namespace |
| OLD | NEW |