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

Side by Side Diff: src/ia32/assembler-ia32-inl.h

Issue 2732273003: Disentangle assembler from isolate. (Closed)
Patch Set: Address feedback. Created 3 years, 9 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
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/ia32/codegen-ia32.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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 110 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
111 return Handle<HeapObject>::cast(Memory::Object_Handle_at(pc_)); 111 return Handle<HeapObject>::cast(Memory::Object_Handle_at(pc_));
112 } 112 }
113 113
114 void RelocInfo::set_target_object(HeapObject* target, 114 void RelocInfo::set_target_object(HeapObject* target,
115 WriteBarrierMode write_barrier_mode, 115 WriteBarrierMode write_barrier_mode,
116 ICacheFlushMode icache_flush_mode) { 116 ICacheFlushMode icache_flush_mode) {
117 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 117 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
118 Memory::Object_at(pc_) = target; 118 Memory::Object_at(pc_) = target;
119 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { 119 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
120 Assembler::FlushICache(isolate_, pc_, sizeof(Address)); 120 Assembler::FlushICache(target->GetIsolate(), pc_, sizeof(Address));
121 } 121 }
122 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { 122 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
123 host()->GetHeap()->RecordWriteIntoCode(host(), this, target); 123 host()->GetHeap()->RecordWriteIntoCode(host(), this, target);
124 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, 124 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
125 target); 125 target);
126 } 126 }
127 } 127 }
128 128
129 129
130 Address RelocInfo::target_external_reference() { 130 Address RelocInfo::target_external_reference() {
(...skipping 12 matching lines...) Expand all
143 DCHECK(rmode_ == INTERNAL_REFERENCE); 143 DCHECK(rmode_ == INTERNAL_REFERENCE);
144 return reinterpret_cast<Address>(pc_); 144 return reinterpret_cast<Address>(pc_);
145 } 145 }
146 146
147 147
148 Address RelocInfo::target_runtime_entry(Assembler* origin) { 148 Address RelocInfo::target_runtime_entry(Assembler* origin) {
149 DCHECK(IsRuntimeEntry(rmode_)); 149 DCHECK(IsRuntimeEntry(rmode_));
150 return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_)); 150 return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_));
151 } 151 }
152 152
153 153 void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target,
154 void RelocInfo::set_target_runtime_entry(Address target,
155 WriteBarrierMode write_barrier_mode, 154 WriteBarrierMode write_barrier_mode,
156 ICacheFlushMode icache_flush_mode) { 155 ICacheFlushMode icache_flush_mode) {
157 DCHECK(IsRuntimeEntry(rmode_)); 156 DCHECK(IsRuntimeEntry(rmode_));
158 if (target_address() != target) { 157 if (target_address() != target) {
159 set_target_address(target, write_barrier_mode, icache_flush_mode); 158 set_target_address(isolate, target, write_barrier_mode, icache_flush_mode);
160 } 159 }
161 } 160 }
162 161
163 162
164 Handle<Cell> RelocInfo::target_cell_handle() { 163 Handle<Cell> RelocInfo::target_cell_handle() {
165 DCHECK(rmode_ == RelocInfo::CELL); 164 DCHECK(rmode_ == RelocInfo::CELL);
166 Address address = Memory::Address_at(pc_); 165 Address address = Memory::Address_at(pc_);
167 return Handle<Cell>(reinterpret_cast<Cell**>(address)); 166 return Handle<Cell>(reinterpret_cast<Cell**>(address));
168 } 167 }
169 168
170 169
171 Cell* RelocInfo::target_cell() { 170 Cell* RelocInfo::target_cell() {
172 DCHECK(rmode_ == RelocInfo::CELL); 171 DCHECK(rmode_ == RelocInfo::CELL);
173 return Cell::FromValueAddress(Memory::Address_at(pc_)); 172 return Cell::FromValueAddress(Memory::Address_at(pc_));
174 } 173 }
175 174
176 175
177 void RelocInfo::set_target_cell(Cell* cell, 176 void RelocInfo::set_target_cell(Cell* cell,
178 WriteBarrierMode write_barrier_mode, 177 WriteBarrierMode write_barrier_mode,
179 ICacheFlushMode icache_flush_mode) { 178 ICacheFlushMode icache_flush_mode) {
180 DCHECK(cell->IsCell()); 179 DCHECK(cell->IsCell());
181 DCHECK(rmode_ == RelocInfo::CELL); 180 DCHECK(rmode_ == RelocInfo::CELL);
182 Address address = cell->address() + Cell::kValueOffset; 181 Address address = cell->address() + Cell::kValueOffset;
183 Memory::Address_at(pc_) = address; 182 Memory::Address_at(pc_) = address;
184 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { 183 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
185 Assembler::FlushICache(isolate_, pc_, sizeof(Address)); 184 Assembler::FlushICache(cell->GetIsolate(), pc_, sizeof(Address));
186 } 185 }
187 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { 186 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
188 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, 187 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
189 cell); 188 cell);
190 } 189 }
191 } 190 }
192 191
193 Handle<Code> RelocInfo::code_age_stub_handle(Assembler* origin) { 192 Handle<Code> RelocInfo::code_age_stub_handle(Assembler* origin) {
194 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 193 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
195 DCHECK(*pc_ == kCallOpcode); 194 DCHECK(*pc_ == kCallOpcode);
196 return Handle<Code>::cast(Memory::Object_Handle_at(pc_ + 1)); 195 return Handle<Code>::cast(Memory::Object_Handle_at(pc_ + 1));
197 } 196 }
198 197
199 198
200 Code* RelocInfo::code_age_stub() { 199 Code* RelocInfo::code_age_stub() {
201 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 200 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
202 DCHECK(*pc_ == kCallOpcode); 201 DCHECK(*pc_ == kCallOpcode);
203 return Code::GetCodeFromTargetAddress( 202 return Code::GetCodeFromTargetAddress(
204 Assembler::target_address_at(pc_ + 1, host_)); 203 Assembler::target_address_at(pc_ + 1, host_));
205 } 204 }
206 205
207 206
208 void RelocInfo::set_code_age_stub(Code* stub, 207 void RelocInfo::set_code_age_stub(Code* stub,
209 ICacheFlushMode icache_flush_mode) { 208 ICacheFlushMode icache_flush_mode) {
210 DCHECK(*pc_ == kCallOpcode); 209 DCHECK(*pc_ == kCallOpcode);
211 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); 210 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
212 Assembler::set_target_address_at( 211 Assembler::set_target_address_at(stub->GetIsolate(), pc_ + 1, host_,
213 isolate_, pc_ + 1, host_, stub->instruction_start(), icache_flush_mode); 212 stub->instruction_start(),
213 icache_flush_mode);
214 } 214 }
215 215
216 216
217 Address RelocInfo::debug_call_address() { 217 Address RelocInfo::debug_call_address() {
218 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); 218 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
219 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset; 219 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset;
220 return Assembler::target_address_at(location, host_); 220 return Assembler::target_address_at(location, host_);
221 } 221 }
222 222
223 223 void RelocInfo::set_debug_call_address(Isolate* isolate, Address target) {
224 void RelocInfo::set_debug_call_address(Address target) {
225 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); 224 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
226 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset; 225 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset;
227 Assembler::set_target_address_at(isolate_, location, host_, target); 226 Assembler::set_target_address_at(isolate, location, host_, target);
228 if (host() != NULL) { 227 if (host() != NULL) {
229 Code* target_code = Code::GetCodeFromTargetAddress(target); 228 Code* target_code = Code::GetCodeFromTargetAddress(target);
230 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, 229 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
231 target_code); 230 target_code);
232 } 231 }
233 } 232 }
234 233
235 234 void RelocInfo::WipeOut(Isolate* isolate) {
236 void RelocInfo::WipeOut() {
237 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) || 235 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) ||
238 IsInternalReference(rmode_)) { 236 IsInternalReference(rmode_)) {
239 Memory::Address_at(pc_) = NULL; 237 Memory::Address_at(pc_) = NULL;
240 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { 238 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) {
241 // Effectively write zero into the relocation. 239 // Effectively write zero into the relocation.
242 Assembler::set_target_address_at(isolate_, pc_, host_, 240 Assembler::set_target_address_at(isolate, pc_, host_,
243 pc_ + sizeof(int32_t)); 241 pc_ + sizeof(int32_t));
244 } else { 242 } else {
245 UNREACHABLE(); 243 UNREACHABLE();
246 } 244 }
247 } 245 }
248 246
249 template <typename ObjectVisitor> 247 template <typename ObjectVisitor>
250 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { 248 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
251 RelocInfo::Mode mode = rmode(); 249 RelocInfo::Mode mode = rmode();
252 if (mode == RelocInfo::EMBEDDED_OBJECT) { 250 if (mode == RelocInfo::EMBEDDED_OBJECT) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 425
428 426
429 Address Assembler::target_address_at(Address pc, Address constant_pool) { 427 Address Assembler::target_address_at(Address pc, Address constant_pool) {
430 return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc); 428 return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc);
431 } 429 }
432 430
433 431
434 void Assembler::set_target_address_at(Isolate* isolate, Address pc, 432 void Assembler::set_target_address_at(Isolate* isolate, Address pc,
435 Address constant_pool, Address target, 433 Address constant_pool, Address target,
436 ICacheFlushMode icache_flush_mode) { 434 ICacheFlushMode icache_flush_mode) {
435 DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH);
437 int32_t* p = reinterpret_cast<int32_t*>(pc); 436 int32_t* p = reinterpret_cast<int32_t*>(pc);
438 *p = target - (pc + sizeof(int32_t)); 437 *p = target - (pc + sizeof(int32_t));
439 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { 438 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
440 Assembler::FlushICache(isolate, p, sizeof(int32_t)); 439 Assembler::FlushICache(isolate, p, sizeof(int32_t));
441 } 440 }
442 } 441 }
443 442
444 Address Assembler::target_address_at(Address pc, Code* code) { 443 Address Assembler::target_address_at(Address pc, Code* code) {
445 Address constant_pool = code ? code->constant_pool() : NULL; 444 Address constant_pool = code ? code->constant_pool() : NULL;
446 return target_address_at(pc, constant_pool); 445 return target_address_at(pc, constant_pool);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 544
546 Operand::Operand(Immediate imm) { 545 Operand::Operand(Immediate imm) {
547 // [disp/r] 546 // [disp/r]
548 set_modrm(0, ebp); 547 set_modrm(0, ebp);
549 set_dispr(imm.x_, imm.rmode_); 548 set_dispr(imm.x_, imm.rmode_);
550 } 549 }
551 } // namespace internal 550 } // namespace internal
552 } // namespace v8 551 } // namespace v8
553 552
554 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ 553 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698