| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/code_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 | 35 |
| 36 bool CodeGenerator::CanOptimize() { | 36 bool CodeGenerator::CanOptimize() { |
| 37 return | 37 return |
| 38 !FLAG_report_usage_count && | 38 !FLAG_report_usage_count && |
| 39 (FLAG_optimization_counter_threshold >= 0) && | 39 (FLAG_optimization_counter_threshold >= 0) && |
| 40 !Isolate::Current()->debugger()->IsActive(); | 40 !Isolate::Current()->debugger()->IsActive(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 void CodeGenerator::DescriptorList::AddDescriptor( | |
| 45 PcDescriptors::Kind kind, | |
| 46 intptr_t pc_offset, | |
| 47 intptr_t node_id, | |
| 48 intptr_t token_index, | |
| 49 intptr_t try_index) { | |
| 50 struct PcDesc data; | |
| 51 data.pc_offset = pc_offset; | |
| 52 data.kind = kind; | |
| 53 data.node_id = node_id; | |
| 54 data.token_index = token_index; | |
| 55 data.try_index = try_index; | |
| 56 list_.Add(data); | |
| 57 } | |
| 58 | |
| 59 | |
| 60 RawPcDescriptors* CodeGenerator::DescriptorList::FinalizePcDescriptors( | |
| 61 uword entry_point) { | |
| 62 intptr_t num_descriptors = Length(); | |
| 63 const PcDescriptors& descriptors = | |
| 64 PcDescriptors::Handle(PcDescriptors::New(num_descriptors)); | |
| 65 for (intptr_t i = 0; i < num_descriptors; i++) { | |
| 66 descriptors.AddDescriptor(i, | |
| 67 (entry_point + PcOffset(i)), | |
| 68 Kind(i), | |
| 69 NodeId(i), | |
| 70 TokenIndex(i), | |
| 71 TryIndex(i)); | |
| 72 } | |
| 73 return descriptors.raw(); | |
| 74 } | |
| 75 | |
| 76 | |
| 77 const Array& CodeGenerator::ArgumentsDescriptor( | 44 const Array& CodeGenerator::ArgumentsDescriptor( |
| 78 int num_arguments, | 45 int num_arguments, |
| 79 const Array& optional_arguments_names) { | 46 const Array& optional_arguments_names) { |
| 80 const intptr_t num_named_args = | 47 const intptr_t num_named_args = |
| 81 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length(); | 48 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length(); |
| 82 const intptr_t num_pos_args = num_arguments - num_named_args; | 49 const intptr_t num_pos_args = num_arguments - num_named_args; |
| 83 | 50 |
| 84 // Build the argument descriptor array, which consists of the total number of | 51 // Build the argument descriptor array, which consists of the total number of |
| 85 // arguments, the number of positional arguments, alphabetically sorted | 52 // arguments, the number of positional arguments, alphabetically sorted |
| 86 // pairs of name/position, and a terminating null. | 53 // pairs of name/position, and a terminating null. |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 } | 1413 } |
| 1447 } | 1414 } |
| 1448 } | 1415 } |
| 1449 // The cache is null terminated, therefore the loop above should never | 1416 // The cache is null terminated, therefore the loop above should never |
| 1450 // terminate by itself. | 1417 // terminate by itself. |
| 1451 UNREACHABLE(); | 1418 UNREACHABLE(); |
| 1452 return Code::null(); | 1419 return Code::null(); |
| 1453 } | 1420 } |
| 1454 | 1421 |
| 1455 } // namespace dart | 1422 } // namespace dart |
| OLD | NEW |