OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // ----------------------------------------------------------------------------- | 150 // ----------------------------------------------------------------------------- |
151 // Implementation of RelocInfo | 151 // Implementation of RelocInfo |
152 | 152 |
153 | 153 |
154 const int RelocInfo::kApplyMask = | 154 const int RelocInfo::kApplyMask = |
155 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY | | 155 RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY | |
156 1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE; | 156 1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE; |
157 | 157 |
158 | 158 |
159 void RelocInfo::patch_code(byte* instructions, int instruction_count) { | 159 void RelocInfo::PatchCode(byte* instructions, int instruction_count) { |
160 // Patch the code at the current address with the supplied instructions. | 160 // Patch the code at the current address with the supplied instructions. |
161 for (int i = 0; i < instruction_count; i++) { | 161 for (int i = 0; i < instruction_count; i++) { |
162 *(pc_ + i) = *(instructions + i); | 162 *(pc_ + i) = *(instructions + i); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 | 166 |
167 // Patch the code at the current PC with a call to the target address. | 167 // Patch the code at the current PC with a call to the target address. |
168 // Additional guard int3 instructions can be added if required. | 168 // Additional guard int3 instructions can be added if required. |
169 void RelocInfo::patch_code_with_call(Address target, int guard_bytes) { | 169 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) { |
170 // Call instruction takes up 5 bytes and int3 takes up one byte. | 170 // Call instruction takes up 5 bytes and int3 takes up one byte. |
171 int code_size = 5 + guard_bytes; | 171 int code_size = 5 + guard_bytes; |
172 | 172 |
173 // Patch the code. | 173 // Patch the code. |
174 CodePatcher patcher(pc_, code_size); | 174 CodePatcher patcher(pc_, code_size); |
175 patcher.masm()->call(target, RelocInfo::NONE); | 175 patcher.masm()->call(target, RelocInfo::NONE); |
176 | 176 |
177 // Add the requested number of int3 instructions after the call. | 177 // Add the requested number of int3 instructions after the call. |
178 for (int i = 0; i < guard_bytes; i++) { | 178 for (int i = 0; i < guard_bytes; i++) { |
179 patcher.masm()->int3(); | 179 patcher.masm()->int3(); |
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 ASSERT(bound_label.is_bound()); | 2142 ASSERT(bound_label.is_bound()); |
2143 ASSERT(0 <= position); | 2143 ASSERT(0 <= position); |
2144 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2144 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
2145 ASSERT(long_at(position) == 0); // only initialize once! | 2145 ASSERT(long_at(position) == 0); // only initialize once! |
2146 | 2146 |
2147 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2147 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
2148 long_at_put(position, label_loc); | 2148 long_at_put(position, label_loc); |
2149 } | 2149 } |
2150 | 2150 |
2151 } } // namespace v8::internal | 2151 } } // namespace v8::internal |
OLD | NEW |