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 // The main idea in Courgette is to do patching *under a tranformation*. The | 5 // The main idea in Courgette is to do patching *under a tranformation*. The |
6 // input is transformed into a new representation, patching occurs in the new | 6 // input is transformed into a new representation, patching occurs in the new |
7 // repesentation, and then the tranform is reversed to get the patched data. | 7 // repesentation, and then the tranform is reversed to get the patched data. |
8 // | 8 // |
9 // The idea is applied to pieces (or 'elements') of the whole (or 'ensemble'). | 9 // The idea is applied to pieces (or 'elements') of the whole (or 'ensemble'). |
10 // Each of the elements has to go through the same set of steps in lock-step. | 10 // Each of the elements has to go through the same set of steps in lock-step. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 Status TransformationPatchGenerator::Reform( | 58 Status TransformationPatchGenerator::Reform( |
59 SourceStreamSet* transformed_element, | 59 SourceStreamSet* transformed_element, |
60 SinkStream* reformed_element) { | 60 SinkStream* reformed_element) { |
61 return patcher_->Reform(transformed_element, reformed_element); | 61 return patcher_->Reform(transformed_element, reformed_element); |
62 } | 62 } |
63 | 63 |
64 // Makes a TransformationPatchGenerator of the appropriate variety for the | 64 // Makes a TransformationPatchGenerator of the appropriate variety for the |
65 // Element kind. | 65 // Element kind. |
66 TransformationPatchGenerator* MakeGenerator(Element* old_element, | 66 TransformationPatchGenerator* MakeGenerator(Element* old_element, |
67 Element* new_element) { | 67 Element* new_element) { |
68 if (new_element->kind() == Element::WIN32_X86_WITH_CODE) { | 68 switch (new_element->kind()) { |
69 CourgetteWin32X86PatchGenerator* generator = | 69 case UNKNOWN: |
70 new CourgetteWin32X86PatchGenerator( | 70 break; |
71 old_element, | 71 case WIN32_X86: { |
72 new_element, | 72 TransformationPatchGenerator* generator = |
73 new CourgetteWin32X86Patcher(old_element->region())); | 73 new CourgetteWin32X86PatchGenerator( |
Chris Masone
2011/10/21 01:18:08
Hm. Why not just return the allocated object? Le
dgarrett
2011/10/21 01:22:38
Probably because the block that does real work I j
| |
74 return generator; | 74 old_element, |
75 } else { | 75 new_element, |
76 LOG(WARNING) << "Unexpected Element::Kind " << old_element->kind(); | 76 new CourgetteWin32X86Patcher(old_element->region())); |
77 return NULL; | 77 return generator; |
78 } | |
78 } | 79 } |
80 | |
81 LOG(WARNING) << "Unexpected Element::Kind " << old_element->kind(); | |
82 return NULL; | |
79 } | 83 } |
80 | 84 |
81 // Checks to see if the proposed comparison is 'unsafe'. Sometimes one element | 85 // Checks to see if the proposed comparison is 'unsafe'. Sometimes one element |
82 // from 'old' is matched as the closest element to multiple elements from 'new'. | 86 // from 'old' is matched as the closest element to multiple elements from 'new'. |
83 // Each time this happens, the old element is transformed and serialized. This | 87 // Each time this happens, the old element is transformed and serialized. This |
84 // is a problem when the old element is huge compared with the new element | 88 // is a problem when the old element is huge compared with the new element |
85 // because the mutliple serialized copies can be much bigger than the size of | 89 // because the mutliple serialized copies can be much bigger than the size of |
86 // either ensemble. | 90 // either ensemble. |
87 // | 91 // |
88 // The right way to avoid this is to ensure any one element from 'old' is | 92 // The right way to avoid this is to ensure any one element from 'old' is |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 return C_STREAM_ERROR; | 419 return C_STREAM_ERROR; |
416 } | 420 } |
417 | 421 |
418 VLOG(1) << "done GenerateEnsemblePatch " | 422 VLOG(1) << "done GenerateEnsemblePatch " |
419 << (base::Time::Now() - start_time).InSecondsF() << "s"; | 423 << (base::Time::Now() - start_time).InSecondsF() << "s"; |
420 | 424 |
421 return C_OK; | 425 return C_OK; |
422 } | 426 } |
423 | 427 |
424 } // namespace | 428 } // namespace |
OLD | NEW |