Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: src/safepoint-table.cc

Issue 504493002: Fix deoptimization address patching in Turbofan to use safepoints. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Compilation fix. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/safepoint-table.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/safepoint-table.h" 7 #include "src/safepoint-table.h"
8 8
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/disasm.h" 10 #include "src/disasm.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 38
39 SafepointTable::SafepointTable(Code* code) { 39 SafepointTable::SafepointTable(Code* code) {
40 DCHECK(code->is_crankshafted()); 40 DCHECK(code->is_crankshafted());
41 code_ = code; 41 code_ = code;
42 Address header = code->instruction_start() + code->safepoint_table_offset(); 42 Address header = code->instruction_start() + code->safepoint_table_offset();
43 length_ = Memory::uint32_at(header + kLengthOffset); 43 length_ = Memory::uint32_at(header + kLengthOffset);
44 entry_size_ = Memory::uint32_at(header + kEntrySizeOffset); 44 entry_size_ = Memory::uint32_at(header + kEntrySizeOffset);
45 pc_and_deoptimization_indexes_ = header + kHeaderSize; 45 pc_and_deoptimization_indexes_ = header + kHeaderSize;
46 entries_ = pc_and_deoptimization_indexes_ + 46 entries_ =
47 (length_ * kPcAndDeoptimizationIndexSize); 47 pc_and_deoptimization_indexes_ + (length_ * kPcAndDeoptimizationInfoSize);
48 DCHECK(entry_size_ > 0); 48 DCHECK(entry_size_ > 0);
49 STATIC_ASSERT(SafepointEntry::DeoptimizationIndexField::kMax == 49 STATIC_ASSERT(SafepointEntry::DeoptimizationIndexField::kMax ==
50 Safepoint::kNoDeoptimizationIndex); 50 Safepoint::kNoDeoptimizationIndex);
51 } 51 }
52 52
53 53
54 SafepointEntry SafepointTable::FindEntry(Address pc) const { 54 SafepointEntry SafepointTable::FindEntry(Address pc) const {
55 unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start()); 55 unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start());
56 for (unsigned i = 0; i < length(); i++) { 56 for (unsigned i = 0; i < length(); i++) {
57 // TODO(kasperl): Replace the linear search with binary search. 57 // TODO(kasperl): Replace the linear search with binary search.
58 if (GetPcOffset(i) == pc_offset) return GetEntry(i); 58 if (GetPcOffset(i) == pc_offset) return GetEntry(i);
59 if (GetDeoptimizationPcOffset(i) == pc_offset) return GetEntry(i);
59 } 60 }
60 return SafepointEntry(); 61 return SafepointEntry();
61 } 62 }
62 63
63 64
64 void SafepointTable::PrintEntry(unsigned index, OStream& os) const { // NOLINT 65 void SafepointTable::PrintEntry(unsigned index, OStream& os) const { // NOLINT
65 disasm::NameConverter converter; 66 disasm::NameConverter converter;
66 SafepointEntry entry = GetEntry(index); 67 SafepointEntry entry = GetEntry(index);
67 uint8_t* bits = entry.bits(); 68 uint8_t* bits = entry.bits();
68 69
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 Safepoint SafepointTableBuilder::DefineSafepoint( 104 Safepoint SafepointTableBuilder::DefineSafepoint(
104 Assembler* assembler, 105 Assembler* assembler,
105 Safepoint::Kind kind, 106 Safepoint::Kind kind,
106 int arguments, 107 int arguments,
107 Safepoint::DeoptMode deopt_mode) { 108 Safepoint::DeoptMode deopt_mode) {
108 DCHECK(arguments >= 0); 109 DCHECK(arguments >= 0);
109 DeoptimizationInfo info; 110 DeoptimizationInfo info;
110 info.pc = assembler->pc_offset(); 111 info.pc = assembler->pc_offset();
111 info.arguments = arguments; 112 info.arguments = arguments;
112 info.has_doubles = (kind & Safepoint::kWithDoubles); 113 info.has_doubles = (kind & Safepoint::kWithDoubles);
114 info.deoptimization_pc = Safepoint::kNoDeoptimizationPc;
115 int safepoint_id = deoptimization_info_.length();
113 deoptimization_info_.Add(info, zone_); 116 deoptimization_info_.Add(info, zone_);
114 deopt_index_list_.Add(Safepoint::kNoDeoptimizationIndex, zone_); 117 deopt_index_list_.Add(Safepoint::kNoDeoptimizationIndex, zone_);
115 if (deopt_mode == Safepoint::kNoLazyDeopt) { 118 if (deopt_mode == Safepoint::kNoLazyDeopt) {
116 last_lazy_safepoint_ = deopt_index_list_.length(); 119 last_lazy_safepoint_ = deopt_index_list_.length();
117 } 120 }
118 indexes_.Add(new(zone_) ZoneList<int>(8, zone_), zone_); 121 indexes_.Add(new(zone_) ZoneList<int>(8, zone_), zone_);
119 registers_.Add((kind & Safepoint::kWithRegisters) 122 registers_.Add((kind & Safepoint::kWithRegisters)
120 ? new(zone_) ZoneList<int>(4, zone_) 123 ? new(zone_) ZoneList<int>(4, zone_)
121 : NULL, 124 : NULL,
122 zone_); 125 zone_);
123 return Safepoint(indexes_.last(), registers_.last()); 126 return Safepoint(safepoint_id, indexes_.last(), registers_.last());
124 } 127 }
125 128
126 129
127 void SafepointTableBuilder::RecordLazyDeoptimizationIndex(int index) { 130 void SafepointTableBuilder::RecordLazyDeoptimizationIndex(int index) {
128 while (last_lazy_safepoint_ < deopt_index_list_.length()) { 131 while (last_lazy_safepoint_ < deopt_index_list_.length()) {
129 deopt_index_list_[last_lazy_safepoint_++] = index; 132 deopt_index_list_[last_lazy_safepoint_++] = index;
130 } 133 }
131 } 134 }
132 135
133 unsigned SafepointTableBuilder::GetCodeOffset() const { 136 unsigned SafepointTableBuilder::GetCodeOffset() const {
(...skipping 18 matching lines...) Expand all
152 // Emit the table header. 155 // Emit the table header.
153 int length = deoptimization_info_.length(); 156 int length = deoptimization_info_.length();
154 assembler->dd(length); 157 assembler->dd(length);
155 assembler->dd(bytes_per_entry); 158 assembler->dd(bytes_per_entry);
156 159
157 // Emit sorted table of pc offsets together with deoptimization indexes. 160 // Emit sorted table of pc offsets together with deoptimization indexes.
158 for (int i = 0; i < length; i++) { 161 for (int i = 0; i < length; i++) {
159 assembler->dd(deoptimization_info_[i].pc); 162 assembler->dd(deoptimization_info_[i].pc);
160 assembler->dd(EncodeExceptPC(deoptimization_info_[i], 163 assembler->dd(EncodeExceptPC(deoptimization_info_[i],
161 deopt_index_list_[i])); 164 deopt_index_list_[i]));
165 assembler->dd(deoptimization_info_[i].deoptimization_pc);
162 } 166 }
163 167
164 // Emit table of bitmaps. 168 // Emit table of bitmaps.
165 ZoneList<uint8_t> bits(bytes_per_entry, zone_); 169 ZoneList<uint8_t> bits(bytes_per_entry, zone_);
166 for (int i = 0; i < length; i++) { 170 for (int i = 0; i < length; i++) {
167 ZoneList<int>* indexes = indexes_[i]; 171 ZoneList<int>* indexes = indexes_[i];
168 ZoneList<int>* registers = registers_[i]; 172 ZoneList<int>* registers = registers_[i];
169 bits.Clear(); 173 bits.Clear();
170 bits.AddBlock(0, bytes_per_entry, zone_); 174 bits.AddBlock(0, bytes_per_entry, zone_);
171 175
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 unsigned index) { 211 unsigned index) {
208 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index); 212 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index);
209 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments); 213 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments);
210 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles); 214 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles);
211 return encoding; 215 return encoding;
212 } 216 }
213 217
214 218
215 219
216 } } // namespace v8::internal 220 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/safepoint-table.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698