| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/utils.h" | 5 #include "platform/utils.h" |
| 6 | 6 |
| 7 #include "vm/allocation.h" | 7 #include "vm/allocation.h" |
| 8 #include "vm/atomic.h" | 8 #include "vm/atomic.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 } | 955 } |
| 956 CodeRegion* region = new CodeRegion(CodeRegion::kTagCode, | 956 CodeRegion* region = new CodeRegion(CodeRegion::kTagCode, |
| 957 tag, | 957 tag, |
| 958 tag + 1, | 958 tag + 1, |
| 959 0); | 959 0); |
| 960 index = tag_code_table_->InsertCodeRegion(region); | 960 index = tag_code_table_->InsertCodeRegion(region); |
| 961 ASSERT(index >= 0); | 961 ASSERT(index >= 0); |
| 962 region->set_creation_serial(visited()); | 962 region->set_creation_serial(visited()); |
| 963 } | 963 } |
| 964 | 964 |
| 965 void TickTag(uword tag, bool exclusive) { | |
| 966 CodeRegionTable::TickResult r; | |
| 967 intptr_t serial = exclusive ? -1 : visited(); | |
| 968 r = tag_code_table_->Tick(tag, exclusive, serial, 0); | |
| 969 if (r == CodeRegionTable::kTicked) { | |
| 970 // Live code found and ticked. | |
| 971 return; | |
| 972 } | |
| 973 ASSERT(r == CodeRegionTable::kNotFound); | |
| 974 CreateAndTickTagCodeRegion(tag, exclusive, serial); | |
| 975 } | |
| 976 | |
| 977 void CreateAndTickTagCodeRegion(uword tag, bool exclusive, intptr_t serial) { | |
| 978 // Need to create tag code. | |
| 979 CodeRegion* region = new CodeRegion(CodeRegion::kTagCode, | |
| 980 tag, | |
| 981 tag + 1, | |
| 982 0); | |
| 983 intptr_t index = tag_code_table_->InsertCodeRegion(region); | |
| 984 region->set_creation_serial(visited()); | |
| 985 ASSERT(index >= 0); | |
| 986 tag_code_table_->At(index)->Tick(tag, exclusive, serial); | |
| 987 } | |
| 988 | |
| 989 void Tick(uword pc, bool exclusive, int64_t timestamp) { | 965 void Tick(uword pc, bool exclusive, int64_t timestamp) { |
| 990 CodeRegionTable::TickResult r; | 966 CodeRegionTable::TickResult r; |
| 991 intptr_t serial = exclusive ? -1 : visited(); | 967 intptr_t serial = exclusive ? -1 : visited(); |
| 992 r = live_code_table_->Tick(pc, exclusive, serial, timestamp); | 968 r = live_code_table_->Tick(pc, exclusive, serial, timestamp); |
| 993 if (r == CodeRegionTable::kTicked) { | 969 if (r == CodeRegionTable::kTicked) { |
| 994 // Live code found and ticked. | 970 // Live code found and ticked. |
| 995 return; | 971 return; |
| 996 } | 972 } |
| 997 if (r == CodeRegionTable::kNewerCode) { | 973 if (r == CodeRegionTable::kNewerCode) { |
| 998 // Code has been overwritten by newer code. | 974 // Code has been overwritten by newer code. |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 | 1522 |
| 1547 | 1523 |
| 1548 Sample* sample_; | 1524 Sample* sample_; |
| 1549 const uword stack_upper_; | 1525 const uword stack_upper_; |
| 1550 const uword original_pc_; | 1526 const uword original_pc_; |
| 1551 const uword original_fp_; | 1527 const uword original_fp_; |
| 1552 const uword original_sp_; | 1528 const uword original_sp_; |
| 1553 uword lower_bound_; | 1529 uword lower_bound_; |
| 1554 }; | 1530 }; |
| 1555 | 1531 |
| 1532 |
| 1556 void Profiler::RecordSampleInterruptCallback( | 1533 void Profiler::RecordSampleInterruptCallback( |
| 1557 const InterruptedThreadState& state, | 1534 const InterruptedThreadState& state, |
| 1558 void* data) { | 1535 void* data) { |
| 1559 Isolate* isolate = reinterpret_cast<Isolate*>(data); | 1536 Isolate* isolate = reinterpret_cast<Isolate*>(data); |
| 1560 if (isolate == NULL) { | 1537 if (isolate == NULL) { |
| 1561 return; | 1538 return; |
| 1562 } | 1539 } |
| 1540 VMTagCounters* counters = isolate->vm_tag_counters(); |
| 1541 ASSERT(counters != NULL); |
| 1542 counters->Increment(isolate->vm_tag()); |
| 1563 IsolateProfilerData* profiler_data = isolate->profiler_data(); | 1543 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| 1564 if (profiler_data == NULL) { | 1544 if (profiler_data == NULL) { |
| 1565 return; | 1545 return; |
| 1566 } | 1546 } |
| 1567 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); | 1547 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); |
| 1568 if (sample_buffer == NULL) { | 1548 if (sample_buffer == NULL) { |
| 1569 return; | 1549 return; |
| 1570 } | 1550 } |
| 1571 Sample* sample = sample_buffer->ReserveSample(); | 1551 Sample* sample = sample_buffer->ReserveSample(); |
| 1572 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); | 1552 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); |
| 1573 uword stack_lower = 0; | 1553 uword stack_lower = 0; |
| 1574 uword stack_upper = 0; | 1554 uword stack_upper = 0; |
| 1575 isolate->GetStackBounds(&stack_lower, &stack_upper); | 1555 isolate->GetStackBounds(&stack_lower, &stack_upper); |
| 1576 if ((stack_lower == 0) || (stack_upper == 0)) { | 1556 if ((stack_lower == 0) || (stack_upper == 0)) { |
| 1577 stack_lower = 0; | 1557 stack_lower = 0; |
| 1578 stack_upper = 0; | 1558 stack_upper = 0; |
| 1579 } | 1559 } |
| 1580 ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper, | 1560 ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper, |
| 1581 state.pc, state.fp, state.sp); | 1561 state.pc, state.fp, state.sp); |
| 1582 stackWalker.walk(isolate->heap(), isolate->vm_tag()); | 1562 stackWalker.walk(isolate->heap(), isolate->vm_tag()); |
| 1583 } | 1563 } |
| 1584 | 1564 |
| 1585 | |
| 1586 } // namespace dart | 1565 } // namespace dart |
| OLD | NEW |