OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 return code; | 386 return code; |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 bool StackFrame::HasHandler() const { | 390 bool StackFrame::HasHandler() const { |
391 StackHandlerIterator it(this, top_handler()); | 391 StackHandlerIterator it(this, top_handler()); |
392 return !it.done(); | 392 return !it.done(); |
393 } | 393 } |
394 | 394 |
395 | 395 |
| 396 #ifdef DEBUG |
| 397 static bool GcSafeCodeContains(HeapObject* object, Address addr); |
| 398 #endif |
| 399 |
| 400 |
396 void StackFrame::IteratePc(ObjectVisitor* v, | 401 void StackFrame::IteratePc(ObjectVisitor* v, |
397 Address* pc_address, | 402 Address* pc_address, |
398 Code* holder) { | 403 Code* holder) { |
399 Address pc = *pc_address; | 404 Address pc = *pc_address; |
400 ASSERT(holder->contains(pc)); | 405 ASSERT(GcSafeCodeContains(holder, pc)); |
401 unsigned pc_offset = static_cast<unsigned>(pc - holder->instruction_start()); | 406 unsigned pc_offset = static_cast<unsigned>(pc - holder->instruction_start()); |
402 Object* code = holder; | 407 Object* code = holder; |
403 v->VisitPointer(&code); | 408 v->VisitPointer(&code); |
404 if (code != holder) { | 409 if (code != holder) { |
405 holder = reinterpret_cast<Code*>(code); | 410 holder = reinterpret_cast<Code*>(code); |
406 pc = holder->instruction_start() + pc_offset; | 411 pc = holder->instruction_start() + pc_offset; |
407 *pc_address = pc; | 412 *pc_address = pc; |
408 } | 413 } |
409 } | 414 } |
410 | 415 |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 iterator_.Advance(); | 1155 iterator_.Advance(); |
1151 } | 1156 } |
1152 UNREACHABLE(); | 1157 UNREACHABLE(); |
1153 return NULL; | 1158 return NULL; |
1154 } | 1159 } |
1155 | 1160 |
1156 | 1161 |
1157 // ------------------------------------------------------------------------- | 1162 // ------------------------------------------------------------------------- |
1158 | 1163 |
1159 | 1164 |
| 1165 static Map* GcSafeMapOfCodeSpaceObject(HeapObject* object) { |
| 1166 MapWord map_word = object->map_word(); |
| 1167 return map_word.IsForwardingAddress() ? |
| 1168 map_word.ToForwardingAddress()->map() : map_word.ToMap(); |
| 1169 } |
| 1170 |
| 1171 |
| 1172 static int GcSafeSizeOfCodeSpaceObject(HeapObject* object) { |
| 1173 return object->SizeFromMap(GcSafeMapOfCodeSpaceObject(object)); |
| 1174 } |
| 1175 |
| 1176 |
| 1177 #ifdef DEBUG |
| 1178 static bool GcSafeCodeContains(HeapObject* code, Address addr) { |
| 1179 Map* map = GcSafeMapOfCodeSpaceObject(code); |
| 1180 ASSERT(map == code->GetHeap()->code_map()); |
| 1181 Address start = code->address(); |
| 1182 Address end = code->address() + code->SizeFromMap(map); |
| 1183 return start <= addr && addr < end; |
| 1184 } |
| 1185 #endif |
| 1186 |
| 1187 |
1160 Code* InnerPointerToCodeCache::GcSafeCastToCode(HeapObject* object, | 1188 Code* InnerPointerToCodeCache::GcSafeCastToCode(HeapObject* object, |
1161 Address inner_pointer) { | 1189 Address inner_pointer) { |
1162 Code* code = reinterpret_cast<Code*>(object); | 1190 Code* code = reinterpret_cast<Code*>(object); |
1163 ASSERT(code != NULL && code->contains(inner_pointer)); | 1191 ASSERT(code != NULL && GcSafeCodeContains(code, inner_pointer)); |
1164 return code; | 1192 return code; |
1165 } | 1193 } |
1166 | 1194 |
1167 | 1195 |
1168 static int GcSafeSizeOfCodeSpaceObject(HeapObject* object) { | |
1169 MapWord map_word = object->map_word(); | |
1170 Map* map = map_word.IsForwardingAddress() ? | |
1171 map_word.ToForwardingAddress()->map() : map_word.ToMap(); | |
1172 return object->SizeFromMap(map); | |
1173 } | |
1174 | |
1175 | |
1176 Code* InnerPointerToCodeCache::GcSafeFindCodeForInnerPointer( | 1196 Code* InnerPointerToCodeCache::GcSafeFindCodeForInnerPointer( |
1177 Address inner_pointer) { | 1197 Address inner_pointer) { |
1178 Heap* heap = isolate_->heap(); | 1198 Heap* heap = isolate_->heap(); |
1179 // Check if the inner pointer points into a large object chunk. | 1199 // Check if the inner pointer points into a large object chunk. |
1180 LargePage* large_page = heap->lo_space()->FindPageContainingPc(inner_pointer); | 1200 LargePage* large_page = heap->lo_space()->FindPageContainingPc(inner_pointer); |
1181 if (large_page != NULL) { | 1201 if (large_page != NULL) { |
1182 return GcSafeCastToCode(large_page->GetObject(), inner_pointer); | 1202 return GcSafeCastToCode(large_page->GetObject(), inner_pointer); |
1183 } | 1203 } |
1184 | 1204 |
1185 // Iterate through the page until we reach the end or find an object starting | 1205 // Iterate through the page until we reach the end or find an object starting |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 ZoneList<StackFrame*> list(10); | 1314 ZoneList<StackFrame*> list(10); |
1295 for (StackFrameIterator it; !it.done(); it.Advance()) { | 1315 for (StackFrameIterator it; !it.done(); it.Advance()) { |
1296 StackFrame* frame = AllocateFrameCopy(it.frame()); | 1316 StackFrame* frame = AllocateFrameCopy(it.frame()); |
1297 list.Add(frame); | 1317 list.Add(frame); |
1298 } | 1318 } |
1299 return list.ToVector(); | 1319 return list.ToVector(); |
1300 } | 1320 } |
1301 | 1321 |
1302 | 1322 |
1303 } } // namespace v8::internal | 1323 } } // namespace v8::internal |
OLD | NEW |