| 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 "vm/deopt_instructions.h" | 5 #include "vm/deopt_instructions.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 MaterializeObjectInstr* mat) const { | 1011 MaterializeObjectInstr* mat) const { |
| 1012 for (intptr_t i = 0; i < materializations_.length(); i++) { | 1012 for (intptr_t i = 0; i < materializations_.length(); i++) { |
| 1013 if (materializations_[i] == mat) { | 1013 if (materializations_[i] == mat) { |
| 1014 return i; | 1014 return i; |
| 1015 } | 1015 } |
| 1016 } | 1016 } |
| 1017 return -1; | 1017 return -1; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 | 1020 |
| 1021 RawDeoptInfo* DeoptInfoBuilder::CreateDeoptInfo() { | 1021 RawDeoptInfo* DeoptInfoBuilder::CreateDeoptInfo(const Array& deopt_table) { |
| 1022 // TODO(vegorov): enable compression of deoptimization info containing object | 1022 // TODO(vegorov): enable compression of deoptimization info containing object |
| 1023 // materialization instructions. | 1023 // materialization instructions. |
| 1024 const bool disable_compression = | 1024 const bool disable_compression = |
| 1025 (instructions_[0]->kind() == DeoptInstr::kMaterializeObject); | 1025 (instructions_[0]->kind() == DeoptInstr::kMaterializeObject); |
| 1026 | 1026 |
| 1027 intptr_t length = instructions_.length(); | 1027 intptr_t length = instructions_.length(); |
| 1028 | 1028 |
| 1029 // Count the number of instructions that are a shared suffix of some deopt | 1029 // Count the number of instructions that are a shared suffix of some deopt |
| 1030 // info already written. | 1030 // info already written. |
| 1031 TrieNode* suffix = trie_root_; | 1031 TrieNode* suffix = trie_root_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1047 // Write the unshared instructions and build their sub-tree. | 1047 // Write the unshared instructions and build their sub-tree. |
| 1048 TrieNode* node = NULL; | 1048 TrieNode* node = NULL; |
| 1049 intptr_t write_count = (suffix_length > 1) ? length - 1 : length; | 1049 intptr_t write_count = (suffix_length > 1) ? length - 1 : length; |
| 1050 for (intptr_t i = 0; i < write_count; ++i) { | 1050 for (intptr_t i = 0; i < write_count; ++i) { |
| 1051 DeoptInstr* instr = instructions_[i]; | 1051 DeoptInstr* instr = instructions_[i]; |
| 1052 deopt_info.SetAt(i, instr->kind(), instr->from_index()); | 1052 deopt_info.SetAt(i, instr->kind(), instr->from_index()); |
| 1053 TrieNode* child = node; | 1053 TrieNode* child = node; |
| 1054 node = new TrieNode(instr, current_info_number_); | 1054 node = new TrieNode(instr, current_info_number_); |
| 1055 node->AddChild(child); | 1055 node->AddChild(child); |
| 1056 } | 1056 } |
| 1057 suffix->AddChild(node); | |
| 1058 | 1057 |
| 1059 if (suffix_length > 1) { | 1058 if (suffix_length > 1) { |
| 1059 suffix->AddChild(node); |
| 1060 DeoptInstr* instr = | 1060 DeoptInstr* instr = |
| 1061 new DeoptSuffixInstr(suffix->info_number(), suffix_length); | 1061 new DeoptSuffixInstr(suffix->info_number(), suffix_length); |
| 1062 deopt_info.SetAt(length - 1, instr->kind(), instr->from_index()); | 1062 deopt_info.SetAt(length - 1, instr->kind(), instr->from_index()); |
| 1063 } else { |
| 1064 trie_root_->AddChild(node); |
| 1063 } | 1065 } |
| 1064 | 1066 |
| 1067 ASSERT(deopt_info.VerifyDecompression(instructions_, deopt_table)); |
| 1065 instructions_.Clear(); | 1068 instructions_.Clear(); |
| 1066 materializations_.Clear(); | 1069 materializations_.Clear(); |
| 1067 frame_start_ = -1; | 1070 frame_start_ = -1; |
| 1068 | 1071 |
| 1069 ++current_info_number_; | 1072 ++current_info_number_; |
| 1070 return deopt_info.raw(); | 1073 return deopt_info.raw(); |
| 1071 } | 1074 } |
| 1072 | 1075 |
| 1073 | 1076 |
| 1074 intptr_t DeoptTable::SizeFor(intptr_t length) { | 1077 intptr_t DeoptTable::SizeFor(intptr_t length) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1099 Smi* offset, | 1102 Smi* offset, |
| 1100 DeoptInfo* info, | 1103 DeoptInfo* info, |
| 1101 Smi* reason) { | 1104 Smi* reason) { |
| 1102 intptr_t i = index * kEntrySize; | 1105 intptr_t i = index * kEntrySize; |
| 1103 *offset ^= table.At(i); | 1106 *offset ^= table.At(i); |
| 1104 *info ^= table.At(i + 1); | 1107 *info ^= table.At(i + 1); |
| 1105 *reason ^= table.At(i + 2); | 1108 *reason ^= table.At(i + 2); |
| 1106 } | 1109 } |
| 1107 | 1110 |
| 1108 } // namespace dart | 1111 } // namespace dart |
| OLD | NEW |