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

Side by Side Diff: src/frames.cc

Issue 6125007: Allow arguments in safepoints with registers. (Closed)
Patch Set: Created 9 years, 11 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
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 while (true) { 322 while (true) {
323 SafeJavaScriptFrameIterator::Advance(); 323 SafeJavaScriptFrameIterator::Advance();
324 if (done()) return; 324 if (done()) return;
325 if (frame()->is_java_script()) return; 325 if (frame()->is_java_script()) return;
326 } 326 }
327 } 327 }
328 #endif 328 #endif
329 329
330 330
331 Code* StackFrame::GetSafepointData(Address pc, 331 Code* StackFrame::GetSafepointData(Address pc,
332 uint8_t** safepoint_entry, 332 SafepointEntry* safepoint_entry,
333 unsigned* stack_slots) { 333 unsigned* stack_slots) {
334 PcToCodeCache::PcToCodeCacheEntry* entry = PcToCodeCache::GetCacheEntry(pc); 334 PcToCodeCache::PcToCodeCacheEntry* entry = PcToCodeCache::GetCacheEntry(pc);
335 uint8_t* cached_safepoint_entry = entry->safepoint_entry; 335 SafepointEntry cached_safepoint_entry = entry->safepoint_entry;
336 if (cached_safepoint_entry == NULL) { 336 if (!entry->safepoint_entry.is_valid()) {
337 cached_safepoint_entry = entry->code->GetSafepointEntry(pc); 337 entry->safepoint_entry = entry->code->GetSafepointEntry(pc);
338 ASSERT(cached_safepoint_entry != NULL); // No safepoint found. 338 ASSERT(entry->safepoint_entry.is_valid());
339 entry->safepoint_entry = cached_safepoint_entry;
340 } else { 339 } else {
341 ASSERT(cached_safepoint_entry == entry->code->GetSafepointEntry(pc)); 340 ASSERT(entry->safepoint_entry.Equals(entry->code->GetSafepointEntry(pc)));
342 } 341 }
343 342
344 // Fill in the results and return the code. 343 // Fill in the results and return the code.
345 Code* code = entry->code; 344 Code* code = entry->code;
346 *safepoint_entry = cached_safepoint_entry; 345 *safepoint_entry = entry->safepoint_entry;
347 *stack_slots = code->stack_slots(); 346 *stack_slots = code->stack_slots();
348 return code; 347 return code;
349 } 348 }
350 349
351 350
352 bool StackFrame::HasHandler() const { 351 bool StackFrame::HasHandler() const {
353 StackHandlerIterator it(this, top_handler()); 352 StackHandlerIterator it(this, top_handler());
354 return !it.done(); 353 return !it.done();
355 } 354 }
356 355
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 StackHandlerIterator it(this, top_handler()); 528 StackHandlerIterator it(this, top_handler());
530 ASSERT(it.done()); 529 ASSERT(it.done());
531 #endif 530 #endif
532 531
533 // Make sure that we're not doing "safe" stack frame iteration. We cannot 532 // Make sure that we're not doing "safe" stack frame iteration. We cannot
534 // possibly find pointers in optimized frames in that state. 533 // possibly find pointers in optimized frames in that state.
535 ASSERT(!SafeStackFrameIterator::is_active()); 534 ASSERT(!SafeStackFrameIterator::is_active());
536 535
537 // Compute the safepoint information. 536 // Compute the safepoint information.
538 unsigned stack_slots = 0; 537 unsigned stack_slots = 0;
539 uint8_t* safepoint_entry = NULL; 538 SafepointEntry safepoint_entry;
540 Code* code = StackFrame::GetSafepointData( 539 Code* code = StackFrame::GetSafepointData(
541 pc(), &safepoint_entry, &stack_slots); 540 pc(), &safepoint_entry, &stack_slots);
542 unsigned slot_space = stack_slots * kPointerSize; 541 unsigned slot_space = stack_slots * kPointerSize;
543 542
544 // Visit the outgoing parameters. This is usually dealt with by the 543 // Visit the outgoing parameters. This is usually dealt with by the
545 // callee, but while GC'ing we artificially lower the number of 544 // callee, but while GC'ing we artificially lower the number of
546 // arguments to zero and let the caller deal with it. 545 // arguments to zero and let the caller deal with it.
547 Object** parameters_base = &Memory::Object_at(sp()); 546 Object** parameters_base = &Memory::Object_at(sp());
548 Object** parameters_limit = &Memory::Object_at( 547 Object** parameters_limit = &Memory::Object_at(
549 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); 548 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space);
550 549
550 // Visit the parameters that may be on top of the saved registers.
551 if (safepoint_entry.argument_count() > 0) {
552 v->VisitPointers(parameters_base,
553 parameters_base + safepoint_entry.argument_count());
554 parameters_base += safepoint_entry.argument_count();
555 }
556
551 // Visit the registers that contain pointers if any. 557 // Visit the registers that contain pointers if any.
552 if (SafepointTable::HasRegisters(safepoint_entry)) { 558 if (safepoint_entry.HasRegisters()) {
553 for (int i = kNumSafepointRegisters - 1; i >=0; i--) { 559 for (int i = kNumSafepointRegisters - 1; i >=0; i--) {
554 if (SafepointTable::HasRegisterAt(safepoint_entry, i)) { 560 if (safepoint_entry.HasRegisterAt(i)) {
555 int reg_stack_index = MacroAssembler::SafepointRegisterStackIndex(i); 561 int reg_stack_index = MacroAssembler::SafepointRegisterStackIndex(i);
556 v->VisitPointer(parameters_base + reg_stack_index); 562 v->VisitPointer(parameters_base + reg_stack_index);
557 } 563 }
558 } 564 }
559 // Skip the words containing the register values. 565 // Skip the words containing the register values.
560 parameters_base += kNumSafepointRegisters; 566 parameters_base += kNumSafepointRegisters;
561 } 567 }
562 568
563 // We're done dealing with the register bits. 569 // We're done dealing with the register bits.
564 safepoint_entry += kNumSafepointRegisters >> kBitsPerByteLog2; 570 uint8_t* safepoint_bits = safepoint_entry.bits();
571 safepoint_bits += kNumSafepointRegisters >> kBitsPerByteLog2;
565 572
566 // Visit the rest of the parameters. 573 // Visit the rest of the parameters.
567 v->VisitPointers(parameters_base, parameters_limit); 574 v->VisitPointers(parameters_base, parameters_limit);
568 575
569 // Visit pointer spill slots and locals. 576 // Visit pointer spill slots and locals.
570 for (unsigned index = 0; index < stack_slots; index++) { 577 for (unsigned index = 0; index < stack_slots; index++) {
571 int byte_index = index >> kBitsPerByteLog2; 578 int byte_index = index >> kBitsPerByteLog2;
572 int bit_index = index & (kBitsPerByte - 1); 579 int bit_index = index & (kBitsPerByte - 1);
573 if ((safepoint_entry[byte_index] & (1U << bit_index)) != 0) { 580 if ((safepoint_bits[byte_index] & (1U << bit_index)) != 0) {
574 v->VisitPointer(parameters_limit + index); 581 v->VisitPointer(parameters_limit + index);
575 } 582 }
576 } 583 }
577 584
578 // Visit the context and the function. 585 // Visit the context and the function.
579 Object** fixed_base = &Memory::Object_at( 586 Object** fixed_base = &Memory::Object_at(
580 fp() + JavaScriptFrameConstants::kFunctionOffset); 587 fp() + JavaScriptFrameConstants::kFunctionOffset);
581 Object** fixed_limit = &Memory::Object_at(fp()); 588 Object** fixed_limit = &Memory::Object_at(fp());
582 v->VisitPointers(fixed_base, fixed_limit); 589 v->VisitPointers(fixed_base, fixed_limit);
583 590
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 778
772 // The code object may have been replaced by lazy deoptimization. Fall 779 // The code object may have been replaced by lazy deoptimization. Fall
773 // back to a slow search in this case to find the original optimized 780 // back to a slow search in this case to find the original optimized
774 // code object. 781 // code object.
775 if (!code->contains(pc())) { 782 if (!code->contains(pc())) {
776 code = PcToCodeCache::GcSafeFindCodeForPc(pc()); 783 code = PcToCodeCache::GcSafeFindCodeForPc(pc());
777 } 784 }
778 ASSERT(code != NULL); 785 ASSERT(code != NULL);
779 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); 786 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION);
780 787
781 SafepointTable table(code); 788 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc());
782 unsigned pc_offset = static_cast<unsigned>(pc() - code->instruction_start()); 789 *deopt_index = safepoint_entry.deoptimization_index();
783 for (unsigned i = 0; i < table.length(); i++) {
784 if (table.GetPcOffset(i) == pc_offset) {
785 *deopt_index = table.GetDeoptimizationIndex(i);
786 break;
787 }
788 }
789 ASSERT(*deopt_index != AstNode::kNoNumber); 790 ASSERT(*deopt_index != AstNode::kNoNumber);
790 791
791 return DeoptimizationInputData::cast(code->deoptimization_data()); 792 return DeoptimizationInputData::cast(code->deoptimization_data());
792 } 793 }
793 794
794 795
795 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { 796 void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) {
796 ASSERT(functions->length() == 0); 797 ASSERT(functions->length() == 0);
797 ASSERT(is_optimized()); 798 ASSERT(is_optimized());
798 799
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 PcToCodeCacheEntry* entry = cache(index); 1144 PcToCodeCacheEntry* entry = cache(index);
1144 if (entry->pc == pc) { 1145 if (entry->pc == pc) {
1145 Counters::pc_to_code_cached.Increment(); 1146 Counters::pc_to_code_cached.Increment();
1146 ASSERT(entry->code == GcSafeFindCodeForPc(pc)); 1147 ASSERT(entry->code == GcSafeFindCodeForPc(pc));
1147 } else { 1148 } else {
1148 // Because this code may be interrupted by a profiling signal that 1149 // Because this code may be interrupted by a profiling signal that
1149 // also queries the cache, we cannot update pc before the code has 1150 // also queries the cache, we cannot update pc before the code has
1150 // been set. Otherwise, we risk trying to use a cache entry before 1151 // been set. Otherwise, we risk trying to use a cache entry before
1151 // the code has been computed. 1152 // the code has been computed.
1152 entry->code = GcSafeFindCodeForPc(pc); 1153 entry->code = GcSafeFindCodeForPc(pc);
1153 entry->safepoint_entry = NULL; 1154 entry->safepoint_entry.Reset();
1154 entry->pc = pc; 1155 entry->pc = pc;
1155 } 1156 }
1156 return entry; 1157 return entry;
1157 } 1158 }
1158 1159
1159 1160
1160 // ------------------------------------------------------------------------- 1161 // -------------------------------------------------------------------------
1161 1162
1162 int NumRegs(RegList reglist) { 1163 int NumRegs(RegList reglist) {
1163 int n = 0; 1164 int n = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 ZoneList<StackFrame*> list(10); 1217 ZoneList<StackFrame*> list(10);
1217 for (StackFrameIterator it; !it.done(); it.Advance()) { 1218 for (StackFrameIterator it; !it.done(); it.Advance()) {
1218 StackFrame* frame = AllocateFrameCopy(it.frame()); 1219 StackFrame* frame = AllocateFrameCopy(it.frame());
1219 list.Add(frame); 1220 list.Add(frame);
1220 } 1221 }
1221 return list.ToVector(); 1222 return list.ToVector();
1222 } 1223 }
1223 1224
1224 1225
1225 } } // namespace v8::internal 1226 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | src/ia32/deoptimizer-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698