| OLD | NEW |
| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 while (true) { | 327 while (true) { |
| 328 SafeJavaScriptFrameIterator::Advance(); | 328 SafeJavaScriptFrameIterator::Advance(); |
| 329 if (done()) return; | 329 if (done()) return; |
| 330 if (frame()->is_java_script()) return; | 330 if (frame()->is_java_script()) return; |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 #endif | 333 #endif |
| 334 | 334 |
| 335 | 335 |
| 336 Code* StackFrame::GetSafepointData(Address pc, | 336 Code* StackFrame::GetSafepointData(Address pc, |
| 337 uint8_t** safepoint_entry, | 337 SafepointEntry* safepoint_entry, |
| 338 unsigned* stack_slots) { | 338 unsigned* stack_slots) { |
| 339 Isolate* isolate = Isolate::Current(); | 339 Isolate* isolate = Isolate::Current(); |
| 340 PcToCodeCache::PcToCodeCacheEntry* entry = | 340 PcToCodeCache::PcToCodeCacheEntry* entry = |
| 341 isolate->pc_to_code_cache()->GetCacheEntry(pc); | 341 isolate->pc_to_code_cache()->GetCacheEntry(pc); |
| 342 uint8_t* cached_safepoint_entry = entry->safepoint_entry; | 342 SafepointEntry cached_safepoint_entry = entry->safepoint_entry; |
| 343 if (cached_safepoint_entry == NULL) { | 343 if (!entry->safepoint_entry.is_valid()) { |
| 344 cached_safepoint_entry = entry->code->GetSafepointEntry(pc); | 344 entry->safepoint_entry = entry->code->GetSafepointEntry(pc); |
| 345 ASSERT(cached_safepoint_entry != NULL); // No safepoint found. | 345 ASSERT(entry->safepoint_entry.is_valid()); |
| 346 entry->safepoint_entry = cached_safepoint_entry; | |
| 347 } else { | 346 } else { |
| 348 ASSERT(cached_safepoint_entry == entry->code->GetSafepointEntry(pc)); | 347 ASSERT(entry->safepoint_entry.Equals(entry->code->GetSafepointEntry(pc))); |
| 349 } | 348 } |
| 350 | 349 |
| 351 // Fill in the results and return the code. | 350 // Fill in the results and return the code. |
| 352 Code* code = entry->code; | 351 Code* code = entry->code; |
| 353 *safepoint_entry = cached_safepoint_entry; | 352 *safepoint_entry = entry->safepoint_entry; |
| 354 *stack_slots = code->stack_slots(); | 353 *stack_slots = code->stack_slots(); |
| 355 return code; | 354 return code; |
| 356 } | 355 } |
| 357 | 356 |
| 358 | 357 |
| 359 bool StackFrame::HasHandler() const { | 358 bool StackFrame::HasHandler() const { |
| 360 StackHandlerIterator it(this, top_handler()); | 359 StackHandlerIterator it(this, top_handler()); |
| 361 return !it.done(); | 360 return !it.done(); |
| 362 } | 361 } |
| 363 | 362 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 StackHandlerIterator it(this, top_handler()); | 536 StackHandlerIterator it(this, top_handler()); |
| 538 ASSERT(it.done()); | 537 ASSERT(it.done()); |
| 539 #endif | 538 #endif |
| 540 | 539 |
| 541 // Make sure that we're not doing "safe" stack frame iteration. We cannot | 540 // Make sure that we're not doing "safe" stack frame iteration. We cannot |
| 542 // possibly find pointers in optimized frames in that state. | 541 // possibly find pointers in optimized frames in that state. |
| 543 ASSERT(!SafeStackFrameIterator::is_active()); | 542 ASSERT(!SafeStackFrameIterator::is_active()); |
| 544 | 543 |
| 545 // Compute the safepoint information. | 544 // Compute the safepoint information. |
| 546 unsigned stack_slots = 0; | 545 unsigned stack_slots = 0; |
| 547 uint8_t* safepoint_entry = NULL; | 546 SafepointEntry safepoint_entry; |
| 548 Code* code = StackFrame::GetSafepointData( | 547 Code* code = StackFrame::GetSafepointData( |
| 549 pc(), &safepoint_entry, &stack_slots); | 548 pc(), &safepoint_entry, &stack_slots); |
| 550 unsigned slot_space = stack_slots * kPointerSize; | 549 unsigned slot_space = stack_slots * kPointerSize; |
| 551 | 550 |
| 552 // Visit the outgoing parameters. This is usually dealt with by the | 551 // Visit the outgoing parameters. This is usually dealt with by the |
| 553 // callee, but while GC'ing we artificially lower the number of | 552 // callee, but while GC'ing we artificially lower the number of |
| 554 // arguments to zero and let the caller deal with it. | 553 // arguments to zero and let the caller deal with it. |
| 555 Object** parameters_base = &Memory::Object_at(sp()); | 554 Object** parameters_base = &Memory::Object_at(sp()); |
| 556 Object** parameters_limit = &Memory::Object_at( | 555 Object** parameters_limit = &Memory::Object_at( |
| 557 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); | 556 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); |
| 558 | 557 |
| 558 // Visit the parameters that may be on top of the saved registers. |
| 559 if (safepoint_entry.argument_count() > 0) { |
| 560 v->VisitPointers(parameters_base, |
| 561 parameters_base + safepoint_entry.argument_count()); |
| 562 parameters_base += safepoint_entry.argument_count(); |
| 563 } |
| 564 |
| 559 // Visit the registers that contain pointers if any. | 565 // Visit the registers that contain pointers if any. |
| 560 if (SafepointTable::HasRegisters(safepoint_entry)) { | 566 if (safepoint_entry.HasRegisters()) { |
| 561 for (int i = kNumSafepointRegisters - 1; i >=0; i--) { | 567 for (int i = kNumSafepointRegisters - 1; i >=0; i--) { |
| 562 if (SafepointTable::HasRegisterAt(safepoint_entry, i)) { | 568 if (safepoint_entry.HasRegisterAt(i)) { |
| 563 int reg_stack_index = MacroAssembler::SafepointRegisterStackIndex(i); | 569 int reg_stack_index = MacroAssembler::SafepointRegisterStackIndex(i); |
| 564 v->VisitPointer(parameters_base + reg_stack_index); | 570 v->VisitPointer(parameters_base + reg_stack_index); |
| 565 } | 571 } |
| 566 } | 572 } |
| 567 // Skip the words containing the register values. | 573 // Skip the words containing the register values. |
| 568 parameters_base += kNumSafepointRegisters; | 574 parameters_base += kNumSafepointRegisters; |
| 569 } | 575 } |
| 570 | 576 |
| 571 // We're done dealing with the register bits. | 577 // We're done dealing with the register bits. |
| 572 safepoint_entry += kNumSafepointRegisters >> kBitsPerByteLog2; | 578 uint8_t* safepoint_bits = safepoint_entry.bits(); |
| 579 safepoint_bits += kNumSafepointRegisters >> kBitsPerByteLog2; |
| 573 | 580 |
| 574 // Visit the rest of the parameters. | 581 // Visit the rest of the parameters. |
| 575 v->VisitPointers(parameters_base, parameters_limit); | 582 v->VisitPointers(parameters_base, parameters_limit); |
| 576 | 583 |
| 577 // Visit pointer spill slots and locals. | 584 // Visit pointer spill slots and locals. |
| 578 for (unsigned index = 0; index < stack_slots; index++) { | 585 for (unsigned index = 0; index < stack_slots; index++) { |
| 579 int byte_index = index >> kBitsPerByteLog2; | 586 int byte_index = index >> kBitsPerByteLog2; |
| 580 int bit_index = index & (kBitsPerByte - 1); | 587 int bit_index = index & (kBitsPerByte - 1); |
| 581 if ((safepoint_entry[byte_index] & (1U << bit_index)) != 0) { | 588 if ((safepoint_bits[byte_index] & (1U << bit_index)) != 0) { |
| 582 v->VisitPointer(parameters_limit + index); | 589 v->VisitPointer(parameters_limit + index); |
| 583 } | 590 } |
| 584 } | 591 } |
| 585 | 592 |
| 586 // Visit the context and the function. | 593 // Visit the context and the function. |
| 587 Object** fixed_base = &Memory::Object_at( | 594 Object** fixed_base = &Memory::Object_at( |
| 588 fp() + JavaScriptFrameConstants::kFunctionOffset); | 595 fp() + JavaScriptFrameConstants::kFunctionOffset); |
| 589 Object** fixed_limit = &Memory::Object_at(fp()); | 596 Object** fixed_limit = &Memory::Object_at(fp()); |
| 590 v->VisitPointers(fixed_base, fixed_limit); | 597 v->VisitPointers(fixed_base, fixed_limit); |
| 591 | 598 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 786 |
| 780 // The code object may have been replaced by lazy deoptimization. Fall | 787 // The code object may have been replaced by lazy deoptimization. Fall |
| 781 // back to a slow search in this case to find the original optimized | 788 // back to a slow search in this case to find the original optimized |
| 782 // code object. | 789 // code object. |
| 783 if (!code->contains(pc())) { | 790 if (!code->contains(pc())) { |
| 784 code = Isolate::Current()->pc_to_code_cache()->GcSafeFindCodeForPc(pc()); | 791 code = Isolate::Current()->pc_to_code_cache()->GcSafeFindCodeForPc(pc()); |
| 785 } | 792 } |
| 786 ASSERT(code != NULL); | 793 ASSERT(code != NULL); |
| 787 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 794 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 788 | 795 |
| 789 SafepointTable table(code); | 796 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); |
| 790 unsigned pc_offset = static_cast<unsigned>(pc() - code->instruction_start()); | 797 *deopt_index = safepoint_entry.deoptimization_index(); |
| 791 for (unsigned i = 0; i < table.length(); i++) { | |
| 792 if (table.GetPcOffset(i) == pc_offset) { | |
| 793 *deopt_index = table.GetDeoptimizationIndex(i); | |
| 794 break; | |
| 795 } | |
| 796 } | |
| 797 ASSERT(*deopt_index != AstNode::kNoNumber); | 798 ASSERT(*deopt_index != AstNode::kNoNumber); |
| 798 | 799 |
| 799 return DeoptimizationInputData::cast(code->deoptimization_data()); | 800 return DeoptimizationInputData::cast(code->deoptimization_data()); |
| 800 } | 801 } |
| 801 | 802 |
| 802 | 803 |
| 803 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { | 804 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { |
| 804 ASSERT(functions->length() == 0); | 805 ASSERT(functions->length() == 0); |
| 805 ASSERT(is_optimized()); | 806 ASSERT(is_optimized()); |
| 806 | 807 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 PcToCodeCacheEntry* entry = cache(index); | 1154 PcToCodeCacheEntry* entry = cache(index); |
| 1154 if (entry->pc == pc) { | 1155 if (entry->pc == pc) { |
| 1155 COUNTERS->pc_to_code_cached()->Increment(); | 1156 COUNTERS->pc_to_code_cached()->Increment(); |
| 1156 ASSERT(entry->code == GcSafeFindCodeForPc(pc)); | 1157 ASSERT(entry->code == GcSafeFindCodeForPc(pc)); |
| 1157 } else { | 1158 } else { |
| 1158 // Because this code may be interrupted by a profiling signal that | 1159 // Because this code may be interrupted by a profiling signal that |
| 1159 // also queries the cache, we cannot update pc before the code has | 1160 // also queries the cache, we cannot update pc before the code has |
| 1160 // been set. Otherwise, we risk trying to use a cache entry before | 1161 // been set. Otherwise, we risk trying to use a cache entry before |
| 1161 // the code has been computed. | 1162 // the code has been computed. |
| 1162 entry->code = GcSafeFindCodeForPc(pc); | 1163 entry->code = GcSafeFindCodeForPc(pc); |
| 1163 entry->safepoint_entry = NULL; | 1164 entry->safepoint_entry.Reset(); |
| 1164 entry->pc = pc; | 1165 entry->pc = pc; |
| 1165 } | 1166 } |
| 1166 return entry; | 1167 return entry; |
| 1167 } | 1168 } |
| 1168 | 1169 |
| 1169 | 1170 |
| 1170 // ------------------------------------------------------------------------- | 1171 // ------------------------------------------------------------------------- |
| 1171 | 1172 |
| 1172 int NumRegs(RegList reglist) { | 1173 int NumRegs(RegList reglist) { |
| 1173 int n = 0; | 1174 int n = 0; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 ZoneList<StackFrame*> list(10); | 1232 ZoneList<StackFrame*> list(10); |
| 1232 for (StackFrameIterator it; !it.done(); it.Advance()) { | 1233 for (StackFrameIterator it; !it.done(); it.Advance()) { |
| 1233 StackFrame* frame = AllocateFrameCopy(it.frame()); | 1234 StackFrame* frame = AllocateFrameCopy(it.frame()); |
| 1234 list.Add(frame); | 1235 list.Add(frame); |
| 1235 } | 1236 } |
| 1236 return list.ToVector(); | 1237 return list.ToVector(); |
| 1237 } | 1238 } |
| 1238 | 1239 |
| 1239 | 1240 |
| 1240 } } // namespace v8::internal | 1241 } } // namespace v8::internal |
| OLD | NEW |