| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/basic-block-instrumentor.h" | 5 #include "src/compiler/basic-block-instrumentor.h" |
| 6 |
| 7 #include <sstream> |
| 8 |
| 6 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 7 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| 8 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 9 #include "src/compiler/operator-properties-inl.h" | 12 #include "src/compiler/operator-properties-inl.h" |
| 10 #include "src/compiler/schedule.h" | 13 #include "src/compiler/schedule.h" |
| 11 | 14 |
| 12 namespace v8 { | 15 namespace v8 { |
| 13 namespace internal { | 16 namespace internal { |
| 14 namespace compiler { | 17 namespace compiler { |
| 15 | 18 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 45 BasicBlockProfiler::Data* BasicBlockInstrumentor::Instrument( | 48 BasicBlockProfiler::Data* BasicBlockInstrumentor::Instrument( |
| 46 CompilationInfo* info, Graph* graph, Schedule* schedule) { | 49 CompilationInfo* info, Graph* graph, Schedule* schedule) { |
| 47 // Skip the exit block in profiles, since the register allocator can't handle | 50 // Skip the exit block in profiles, since the register allocator can't handle |
| 48 // it and entry into it means falling off the end of the function anyway. | 51 // it and entry into it means falling off the end of the function anyway. |
| 49 size_t n_blocks = static_cast<size_t>(schedule->RpoBlockCount()) - 1; | 52 size_t n_blocks = static_cast<size_t>(schedule->RpoBlockCount()) - 1; |
| 50 BasicBlockProfiler::Data* data = | 53 BasicBlockProfiler::Data* data = |
| 51 info->isolate()->GetOrCreateBasicBlockProfiler()->NewData(n_blocks); | 54 info->isolate()->GetOrCreateBasicBlockProfiler()->NewData(n_blocks); |
| 52 // Set the function name. | 55 // Set the function name. |
| 53 if (!info->shared_info().is_null() && | 56 if (!info->shared_info().is_null() && |
| 54 info->shared_info()->name()->IsString()) { | 57 info->shared_info()->name()->IsString()) { |
| 55 OStringStream os; | 58 std::ostringstream os; |
| 56 String::cast(info->shared_info()->name())->PrintUC16(os); | 59 String::cast(info->shared_info()->name())->PrintUC16(os); |
| 57 data->SetFunctionName(&os); | 60 data->SetFunctionName(&os); |
| 58 } | 61 } |
| 59 // Capture the schedule string before instrumentation. | 62 // Capture the schedule string before instrumentation. |
| 60 { | 63 { |
| 61 OStringStream os; | 64 std::ostringstream os; |
| 62 os << *schedule; | 65 os << *schedule; |
| 63 data->SetSchedule(&os); | 66 data->SetSchedule(&os); |
| 64 } | 67 } |
| 65 // Add the increment instructions to the start of every block. | 68 // Add the increment instructions to the start of every block. |
| 66 CommonOperatorBuilder common(graph->zone()); | 69 CommonOperatorBuilder common(graph->zone()); |
| 67 Node* zero = graph->NewNode(common.Int32Constant(0)); | 70 Node* zero = graph->NewNode(common.Int32Constant(0)); |
| 68 Node* one = graph->NewNode(common.Int32Constant(1)); | 71 Node* one = graph->NewNode(common.Int32Constant(1)); |
| 69 MachineOperatorBuilder machine; | 72 MachineOperatorBuilder machine; |
| 70 BasicBlockVector* blocks = schedule->rpo_order(); | 73 BasicBlockVector* blocks = schedule->rpo_order(); |
| 71 size_t block_number = 0; | 74 size_t block_number = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 93 for (int i = insertion_start; i < kArraySize; ++i) { | 96 for (int i = insertion_start; i < kArraySize; ++i) { |
| 94 schedule->SetBlockForNode(block, to_insert[i]); | 97 schedule->SetBlockForNode(block, to_insert[i]); |
| 95 } | 98 } |
| 96 } | 99 } |
| 97 return data; | 100 return data; |
| 98 } | 101 } |
| 99 | 102 |
| 100 } // namespace compiler | 103 } // namespace compiler |
| 101 } // namespace internal | 104 } // namespace internal |
| 102 } // namespace v8 | 105 } // namespace v8 |
| OLD | NEW |