OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/disasm.h" | 7 #include "src/disasm.h" |
8 #include "src/disassembler.h" | 8 #include "src/disassembler.h" |
9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
10 #include "src/jsregexp.h" | 10 #include "src/jsregexp.h" |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 bool skip_weak_cell = (mode == kNoContextSpecificPointers) ? false : true; | 1270 bool skip_weak_cell = (mode == kNoContextSpecificPointers) ? false : true; |
1271 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 1271 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
1272 Object* target = it.rinfo()->rmode() == RelocInfo::CELL | 1272 Object* target = it.rinfo()->rmode() == RelocInfo::CELL |
1273 ? it.rinfo()->target_cell() | 1273 ? it.rinfo()->target_cell() |
1274 : it.rinfo()->target_object(); | 1274 : it.rinfo()->target_object(); |
1275 CHECK(!CanLeak(target, heap, skip_weak_cell)); | 1275 CHECK(!CanLeak(target, heap, skip_weak_cell)); |
1276 } | 1276 } |
1277 } | 1277 } |
1278 | 1278 |
1279 | 1279 |
| 1280 // Verify that the debugger can redirect old code to the new code. |
| 1281 void Code::VerifyRecompiledCode(Code* old_code, Code* new_code) { |
| 1282 if (old_code->kind() != FUNCTION) return; |
| 1283 if (new_code->kind() != FUNCTION) return; |
| 1284 static const int mask = RelocInfo::kCodeTargetMask; |
| 1285 |
| 1286 Isolate* isolate = old_code->GetIsolate(); |
| 1287 RelocIterator old_it(old_code, mask); |
| 1288 RelocIterator new_it(new_code, mask); |
| 1289 Code* stack_check = isolate->builtins()->builtin(Builtins::kStackCheck); |
| 1290 |
| 1291 while (!old_it.done()) { |
| 1292 RelocInfo* rinfo = old_it.rinfo(); |
| 1293 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1294 CHECK(!target->is_handler() && !target->is_inline_cache_stub()); |
| 1295 if (target == stack_check) break; |
| 1296 old_it.next(); |
| 1297 } |
| 1298 |
| 1299 while (!new_it.done()) { |
| 1300 RelocInfo* rinfo = new_it.rinfo(); |
| 1301 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1302 CHECK(!target->is_handler() && !target->is_inline_cache_stub()); |
| 1303 if (target == stack_check) break; |
| 1304 new_it.next(); |
| 1305 } |
| 1306 |
| 1307 // Either both are done because there is no stack check. |
| 1308 // Or we are past the prologue for both. |
| 1309 CHECK_EQ(new_it.done(), old_it.done()); |
| 1310 |
| 1311 // After the prologue, each call in the old code has a corresponding call |
| 1312 // in the new code. |
| 1313 while (!old_it.done() && !new_it.done()) { |
| 1314 Code* old_target = |
| 1315 Code::GetCodeFromTargetAddress(old_it.rinfo()->target_address()); |
| 1316 Code* new_target = |
| 1317 Code::GetCodeFromTargetAddress(new_it.rinfo()->target_address()); |
| 1318 CHECK_EQ(old_target->kind(), new_target->kind()); |
| 1319 if (!old_target->is_handler() && !old_target->is_inline_cache_stub()) { |
| 1320 CHECK_EQ(old_target, new_target); |
| 1321 } |
| 1322 old_it.next(); |
| 1323 new_it.next(); |
| 1324 } |
| 1325 |
| 1326 // Both are done at the same time. |
| 1327 CHECK_EQ(new_it.done(), old_it.done()); |
| 1328 } |
| 1329 |
| 1330 |
1280 #endif // DEBUG | 1331 #endif // DEBUG |
1281 | 1332 |
1282 } // namespace internal | 1333 } // namespace internal |
1283 } // namespace v8 | 1334 } // namespace v8 |
OLD | NEW |