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

Side by Side Diff: src/mark-compact.cc

Issue 193111: Use GetCodeFromTargetAddress everywhere, uniformly. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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/assembler.cc ('k') | src/objects.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 273
274 void EndCodeIteration(Code* code) { 274 void EndCodeIteration(Code* code) {
275 // If this is a compacting collection, set ic targets 275 // If this is a compacting collection, set ic targets
276 // are pointing to object headers. 276 // are pointing to object headers.
277 if (IsCompacting()) code->set_ic_flag(Code::IC_TARGET_IS_OBJECT); 277 if (IsCompacting()) code->set_ic_flag(Code::IC_TARGET_IS_OBJECT);
278 } 278 }
279 279
280 void VisitCodeTarget(RelocInfo* rinfo) { 280 void VisitCodeTarget(RelocInfo* rinfo) {
281 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 281 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
282 Code* code = CodeFromDerivedPointer(rinfo->target_address()); 282 Code* code = Code::GetCodeFromTargetAddress(rinfo->target_address());
283 if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) { 283 if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) {
284 IC::Clear(rinfo->pc()); 284 IC::Clear(rinfo->pc());
285 // Please note targets for cleared inline cached do not have to be 285 // Please note targets for cleared inline cached do not have to be
286 // marked since they are contained in Heap::non_monomorphic_cache(). 286 // marked since they are contained in Heap::non_monomorphic_cache().
287 } else { 287 } else {
288 MarkCompactCollector::MarkObject(code); 288 MarkCompactCollector::MarkObject(code);
289 } 289 }
290 if (IsCompacting()) { 290 if (IsCompacting()) {
291 // When compacting we convert the target to a real object pointer. 291 // When compacting we convert the target to a real object pointer.
292 code = CodeFromDerivedPointer(rinfo->target_address()); 292 code = Code::GetCodeFromTargetAddress(rinfo->target_address());
293 rinfo->set_target_object(code); 293 rinfo->set_target_object(code);
294 } 294 }
295 } 295 }
296 296
297 void VisitDebugTarget(RelocInfo* rinfo) { 297 void VisitDebugTarget(RelocInfo* rinfo) {
298 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && 298 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) &&
299 rinfo->IsCallInstruction()); 299 rinfo->IsCallInstruction());
300 HeapObject* code = CodeFromDerivedPointer(rinfo->call_address()); 300 HeapObject* code = Code::GetCodeFromTargetAddress(rinfo->call_address());
301 MarkCompactCollector::MarkObject(code); 301 MarkCompactCollector::MarkObject(code);
302 // When compacting we convert the call to a real object pointer. 302 // When compacting we convert the call to a real object pointer.
303 if (IsCompacting()) rinfo->set_call_object(code); 303 if (IsCompacting()) rinfo->set_call_object(code);
304 } 304 }
305 305
306 private: 306 private:
307 // Mark object pointed to by p. 307 // Mark object pointed to by p.
308 void MarkObjectByPointer(Object** p) { 308 void MarkObjectByPointer(Object** p) {
309 if (!(*p)->IsHeapObject()) return; 309 if (!(*p)->IsHeapObject()) return;
310 HeapObject* object = ShortCircuitConsString(p); 310 HeapObject* object = ShortCircuitConsString(p);
311 MarkCompactCollector::MarkObject(object); 311 MarkCompactCollector::MarkObject(object);
312 } 312 }
313 313
314 // Tells whether the mark sweep collection will perform compaction. 314 // Tells whether the mark sweep collection will perform compaction.
315 bool IsCompacting() { return MarkCompactCollector::IsCompacting(); } 315 bool IsCompacting() { return MarkCompactCollector::IsCompacting(); }
316 316
317 // Retrieves the Code pointer from derived code entry.
318 Code* CodeFromDerivedPointer(Address addr) {
319 ASSERT(addr != NULL);
320 return reinterpret_cast<Code*>(
321 HeapObject::FromAddress(addr - Code::kHeaderSize));
322 }
323
324 // Visit an unmarked object. 317 // Visit an unmarked object.
325 void VisitUnmarkedObject(HeapObject* obj) { 318 void VisitUnmarkedObject(HeapObject* obj) {
326 #ifdef DEBUG 319 #ifdef DEBUG
327 ASSERT(Heap::Contains(obj)); 320 ASSERT(Heap::Contains(obj));
328 ASSERT(!obj->IsMarked()); 321 ASSERT(!obj->IsMarked());
329 #endif 322 #endif
330 Map* map = obj->map(); 323 Map* map = obj->map();
331 MarkCompactCollector::SetMark(obj); 324 MarkCompactCollector::SetMark(obj);
332 // Mark the map pointer and the body. 325 // Mark the map pointer and the body.
333 MarkCompactCollector::MarkObject(map); 326 MarkCompactCollector::MarkObject(map);
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1833
1841 void MarkCompactCollector::RebuildRSets() { 1834 void MarkCompactCollector::RebuildRSets() {
1842 #ifdef DEBUG 1835 #ifdef DEBUG
1843 ASSERT(state_ == RELOCATE_OBJECTS); 1836 ASSERT(state_ == RELOCATE_OBJECTS);
1844 state_ = REBUILD_RSETS; 1837 state_ = REBUILD_RSETS;
1845 #endif 1838 #endif
1846 Heap::RebuildRSets(); 1839 Heap::RebuildRSets();
1847 } 1840 }
1848 1841
1849 } } // namespace v8::internal 1842 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698