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/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 } | 1304 } |
1305 | 1305 |
1306 | 1306 |
1307 void Debug::ClearStepNext() { | 1307 void Debug::ClearStepNext() { |
1308 thread_local_.last_step_action_ = StepNone; | 1308 thread_local_.last_step_action_ = StepNone; |
1309 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; | 1309 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; |
1310 thread_local_.last_fp_ = 0; | 1310 thread_local_.last_fp_ = 0; |
1311 } | 1311 } |
1312 | 1312 |
1313 | 1313 |
1314 // We start counting call sites from the stack check because the declaration | 1314 bool MatchingCodeTargets(Code* target1, Code* target2) { |
1315 // code at the start of the function may have changed on recompile. | 1315 if (target1 == target2) return true; |
1316 static void SkipToStackCheck(Isolate* isolate, RelocIterator* it) { | 1316 if (target1->kind() != target2->kind()) return false; |
1317 while (Code::GetCodeFromTargetAddress(it->rinfo()->target_address()) != | 1317 return target1->is_handler() || target1->is_inline_cache_stub(); |
1318 *isolate->builtins()->StackCheck()) { | |
1319 it->next(); | |
1320 } | |
1321 } | 1318 } |
1322 | 1319 |
1323 | 1320 |
1324 // Count the number of calls before the current frame PC to find the | 1321 // Count the number of calls before the current frame PC to find the |
1325 // corresponding PC in the newly recompiled code. | 1322 // corresponding PC in the newly recompiled code. |
1326 static Address ComputeNewPcForRedirect(Code* new_code, Code* old_code, | 1323 static Address ComputeNewPcForRedirect(Code* new_code, Code* old_code, |
1327 Address old_pc) { | 1324 Address old_pc) { |
1328 DCHECK_EQ(old_code->kind(), Code::FUNCTION); | 1325 DCHECK_EQ(old_code->kind(), Code::FUNCTION); |
1329 DCHECK_EQ(new_code->kind(), Code::FUNCTION); | 1326 DCHECK_EQ(new_code->kind(), Code::FUNCTION); |
1330 DCHECK(new_code->has_debug_break_slots()); | 1327 DCHECK(new_code->has_debug_break_slots()); |
1331 int mask = RelocInfo::kCodeTargetMask; | 1328 static const int mask = RelocInfo::kCodeTargetMask; |
1332 int index = 0; | 1329 |
| 1330 // Find the target of the current call. |
| 1331 Code* target = NULL; |
1333 intptr_t delta = 0; | 1332 intptr_t delta = 0; |
1334 Isolate* isolate = new_code->GetIsolate(); | 1333 for (RelocIterator it(old_code, mask); !it.done(); it.next()) { |
1335 RelocIterator old_it(old_code, mask); | 1334 RelocInfo* rinfo = it.rinfo(); |
1336 for (SkipToStackCheck(isolate, &old_it); !old_it.done(); old_it.next()) { | |
1337 RelocInfo* rinfo = old_it.rinfo(); | |
1338 Address current_pc = rinfo->pc(); | 1335 Address current_pc = rinfo->pc(); |
1339 // The frame PC is behind the call instruction by the call instruction size. | 1336 // The frame PC is behind the call instruction by the call instruction size. |
1340 if (current_pc > old_pc) break; | 1337 if (current_pc > old_pc) break; |
1341 index++; | |
1342 delta = old_pc - current_pc; | 1338 delta = old_pc - current_pc; |
| 1339 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
1343 } | 1340 } |
1344 | 1341 |
1345 RelocIterator new_it(new_code, mask); | 1342 // Count the number of calls to the same target before the current call. |
1346 SkipToStackCheck(isolate, &new_it); | 1343 int index = 0; |
1347 for (int i = 1; i < index; i++) new_it.next(); | 1344 for (RelocIterator it(old_code, mask); !it.done(); it.next()) { |
1348 return new_it.rinfo()->pc() + delta; | 1345 RelocInfo* rinfo = it.rinfo(); |
| 1346 Address current_pc = rinfo->pc(); |
| 1347 if (current_pc > old_pc) break; |
| 1348 Code* current = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1349 if (MatchingCodeTargets(target, current)) index++; |
| 1350 } |
| 1351 |
| 1352 DCHECK(index > 0); |
| 1353 |
| 1354 // Repeat the count on the new code to find corresponding call. |
| 1355 for (RelocIterator it(new_code, mask); !it.done(); it.next()) { |
| 1356 RelocInfo* rinfo = it.rinfo(); |
| 1357 Code* current = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1358 if (MatchingCodeTargets(target, current)) index--; |
| 1359 if (index == 0) return rinfo->pc() + delta; |
| 1360 } |
| 1361 |
| 1362 UNREACHABLE(); |
| 1363 return NULL; |
1349 } | 1364 } |
1350 | 1365 |
1351 | 1366 |
1352 // Count the number of continuations at which the current pc offset is at. | 1367 // Count the number of continuations at which the current pc offset is at. |
1353 static int ComputeContinuationIndexFromPcOffset(Code* code, int pc_offset) { | 1368 static int ComputeContinuationIndexFromPcOffset(Code* code, int pc_offset) { |
1354 DCHECK_EQ(code->kind(), Code::FUNCTION); | 1369 DCHECK_EQ(code->kind(), Code::FUNCTION); |
1355 Address pc = code->instruction_start() + pc_offset; | 1370 Address pc = code->instruction_start() + pc_offset; |
1356 int mask = RelocInfo::ModeMask(RelocInfo::GENERATOR_CONTINUATION); | 1371 int mask = RelocInfo::ModeMask(RelocInfo::GENERATOR_CONTINUATION); |
1357 int index = 0; | 1372 int index = 0; |
1358 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 1373 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2787 } | 2802 } |
2788 | 2803 |
2789 | 2804 |
2790 void LockingCommandMessageQueue::Clear() { | 2805 void LockingCommandMessageQueue::Clear() { |
2791 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2806 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2792 queue_.Clear(); | 2807 queue_.Clear(); |
2793 } | 2808 } |
2794 | 2809 |
2795 } // namespace internal | 2810 } // namespace internal |
2796 } // namespace v8 | 2811 } // namespace v8 |
OLD | NEW |