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

Side by Side Diff: src/frames.cc

Issue 6771047: Move SafeStackFrameIterator::active_count_ into an isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moved variable to Isolate, as Vitaly has suggested Created 9 years, 8 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/frames.h ('k') | src/isolate.h » ('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 21 matching lines...) Expand all
32 #include "frames-inl.h" 32 #include "frames-inl.h"
33 #include "full-codegen.h" 33 #include "full-codegen.h"
34 #include "mark-compact.h" 34 #include "mark-compact.h"
35 #include "safepoint-table.h" 35 #include "safepoint-table.h"
36 #include "scopeinfo.h" 36 #include "scopeinfo.h"
37 #include "string-stream.h" 37 #include "string-stream.h"
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42
43 int SafeStackFrameIterator::active_count_ = 0;
44
45 // Iterator that supports traversing the stack handlers of a 42 // Iterator that supports traversing the stack handlers of a
46 // particular frame. Needs to know the top of the handler chain. 43 // particular frame. Needs to know the top of the handler chain.
47 class StackHandlerIterator BASE_EMBEDDED { 44 class StackHandlerIterator BASE_EMBEDDED {
48 public: 45 public:
49 StackHandlerIterator(const StackFrame* frame, StackHandler* handler) 46 StackHandlerIterator(const StackFrame* frame, StackHandler* handler)
50 : limit_(frame->fp()), handler_(handler) { 47 : limit_(frame->fp()), handler_(handler) {
51 // Make sure the handler has already been unwound to this frame. 48 // Make sure the handler has already been unwound to this frame.
52 ASSERT(frame->sp() <= handler->address()); 49 ASSERT(frame->sp() <= handler->address());
53 } 50 }
54 51
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (!validator_.IsValid(sp)) return false; 211 if (!validator_.IsValid(sp)) return false;
215 StackFrame::State state; 212 StackFrame::State state;
216 ExitFrame::FillState(fp, sp, &state); 213 ExitFrame::FillState(fp, sp, &state);
217 if (!validator_.IsValid(reinterpret_cast<Address>(state.pc_address))) { 214 if (!validator_.IsValid(reinterpret_cast<Address>(state.pc_address))) {
218 return false; 215 return false;
219 } 216 }
220 return *state.pc_address != NULL; 217 return *state.pc_address != NULL;
221 } 218 }
222 219
223 220
221 SafeStackFrameIterator::ActiveCountMaintainer::ActiveCountMaintainer(
222 Isolate* isolate)
223 : isolate_(isolate) {
224 isolate_->set_safe_stack_iterator_counter(
225 isolate_->safe_stack_iterator_counter() + 1);
226 }
227
228
229 SafeStackFrameIterator::ActiveCountMaintainer::~ActiveCountMaintainer() {
230 isolate_->set_safe_stack_iterator_counter(
231 isolate_->safe_stack_iterator_counter() - 1);
232 }
233
234
224 SafeStackFrameIterator::SafeStackFrameIterator( 235 SafeStackFrameIterator::SafeStackFrameIterator(
225 Isolate* isolate, 236 Isolate* isolate,
226 Address fp, Address sp, Address low_bound, Address high_bound) : 237 Address fp, Address sp, Address low_bound, Address high_bound) :
227 maintainer_(), 238 maintainer_(isolate),
228 stack_validator_(low_bound, high_bound), 239 stack_validator_(low_bound, high_bound),
229 is_valid_top_(IsValidTop(isolate, low_bound, high_bound)), 240 is_valid_top_(IsValidTop(isolate, low_bound, high_bound)),
230 is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)), 241 is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)),
231 is_working_iterator_(is_valid_top_ || is_valid_fp_), 242 is_working_iterator_(is_valid_top_ || is_valid_fp_),
232 iteration_done_(!is_working_iterator_), 243 iteration_done_(!is_working_iterator_),
233 iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { 244 iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) {
234 } 245 }
235 246
247 bool SafeStackFrameIterator::is_active(Isolate* isolate) {
248 return isolate->safe_stack_iterator_counter() > 0;
249 }
250
236 251
237 bool SafeStackFrameIterator::IsValidTop(Isolate* isolate, 252 bool SafeStackFrameIterator::IsValidTop(Isolate* isolate,
238 Address low_bound, Address high_bound) { 253 Address low_bound, Address high_bound) {
239 ThreadLocalTop* top = isolate->thread_local_top(); 254 ThreadLocalTop* top = isolate->thread_local_top();
240 Address fp = Isolate::c_entry_fp(top); 255 Address fp = Isolate::c_entry_fp(top);
241 ExitFrameValidator validator(low_bound, high_bound); 256 ExitFrameValidator validator(low_bound, high_bound);
242 if (!validator.IsValidFP(fp)) return false; 257 if (!validator.IsValidFP(fp)) return false;
243 return Isolate::handler(top) != NULL; 258 return Isolate::handler(top) != NULL;
244 } 259 }
245 260
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // The marker and function offsets overlap. If the marker isn't a 400 // The marker and function offsets overlap. If the marker isn't a
386 // smi then the frame is a JavaScript frame -- and the marker is 401 // smi then the frame is a JavaScript frame -- and the marker is
387 // really the function. 402 // really the function.
388 const int offset = StandardFrameConstants::kMarkerOffset; 403 const int offset = StandardFrameConstants::kMarkerOffset;
389 Object* marker = Memory::Object_at(state->fp + offset); 404 Object* marker = Memory::Object_at(state->fp + offset);
390 if (!marker->IsSmi()) { 405 if (!marker->IsSmi()) {
391 // If we're using a "safe" stack iterator, we treat optimized 406 // If we're using a "safe" stack iterator, we treat optimized
392 // frames as normal JavaScript frames to avoid having to look 407 // frames as normal JavaScript frames to avoid having to look
393 // into the heap to determine the state. This is safe as long 408 // into the heap to determine the state. This is safe as long
394 // as nobody tries to GC... 409 // as nobody tries to GC...
395 if (SafeStackFrameIterator::is_active()) return JAVA_SCRIPT; 410 if (SafeStackFrameIterator::is_active(Isolate::Current()))
Vitaly Repeshko 2011/04/01 15:16:37 Save result of Isolate::Current() as it's used mor
mnaganov (inactive) 2011/04/01 15:21:39 Done.
411 return JAVA_SCRIPT;
396 Code::Kind kind = GetContainingCode(Isolate::Current(), 412 Code::Kind kind = GetContainingCode(Isolate::Current(),
397 *(state->pc_address))->kind(); 413 *(state->pc_address))->kind();
398 ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION); 414 ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION);
399 return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT; 415 return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT;
400 } 416 }
401 return static_cast<StackFrame::Type>(Smi::cast(marker)->value()); 417 return static_cast<StackFrame::Type>(Smi::cast(marker)->value());
402 } 418 }
403 419
404 420
405 421
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 548
533 void OptimizedFrame::Iterate(ObjectVisitor* v) const { 549 void OptimizedFrame::Iterate(ObjectVisitor* v) const {
534 #ifdef DEBUG 550 #ifdef DEBUG
535 // Make sure that optimized frames do not contain any stack handlers. 551 // Make sure that optimized frames do not contain any stack handlers.
536 StackHandlerIterator it(this, top_handler()); 552 StackHandlerIterator it(this, top_handler());
537 ASSERT(it.done()); 553 ASSERT(it.done());
538 #endif 554 #endif
539 555
540 // Make sure that we're not doing "safe" stack frame iteration. We cannot 556 // Make sure that we're not doing "safe" stack frame iteration. We cannot
541 // possibly find pointers in optimized frames in that state. 557 // possibly find pointers in optimized frames in that state.
542 ASSERT(!SafeStackFrameIterator::is_active()); 558 ASSERT(!SafeStackFrameIterator::is_active(Isolate::Current()));
543 559
544 // Compute the safepoint information. 560 // Compute the safepoint information.
545 unsigned stack_slots = 0; 561 unsigned stack_slots = 0;
546 SafepointEntry safepoint_entry; 562 SafepointEntry safepoint_entry;
547 Code* code = StackFrame::GetSafepointData( 563 Code* code = StackFrame::GetSafepointData(
548 pc(), &safepoint_entry, &stack_slots); 564 pc(), &safepoint_entry, &stack_slots);
549 unsigned slot_space = stack_slots * kPointerSize; 565 unsigned slot_space = stack_slots * kPointerSize;
550 566
551 // Visit the outgoing parameters. This is usually dealt with by the 567 // Visit the outgoing parameters. This is usually dealt with by the
552 // callee, but while GC'ing we artificially lower the number of 568 // callee, but while GC'ing we artificially lower the number of
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 649
634 650
635 Code* JavaScriptFrame::unchecked_code() const { 651 Code* JavaScriptFrame::unchecked_code() const {
636 JSFunction* function = JSFunction::cast(this->function()); 652 JSFunction* function = JSFunction::cast(this->function());
637 return function->unchecked_code(); 653 return function->unchecked_code();
638 } 654 }
639 655
640 656
641 Address JavaScriptFrame::GetCallerStackPointer() const { 657 Address JavaScriptFrame::GetCallerStackPointer() const {
642 int arguments; 658 int arguments;
643 if (SafeStackFrameIterator::is_active() || 659 if (SafeStackFrameIterator::is_active(Isolate::Current()) ||
Vitaly Repeshko 2011/04/01 15:16:37 Same here. The second usage is in the HEAP macro.
mnaganov (inactive) 2011/04/01 15:21:39 Done.
644 HEAP->gc_state() != Heap::NOT_IN_GC) { 660 HEAP->gc_state() != Heap::NOT_IN_GC) {
645 // If the we are currently iterating the safe stack the 661 // If the we are currently iterating the safe stack the
646 // arguments for frames are traversed as if they were 662 // arguments for frames are traversed as if they were
647 // expression stack elements of the calling frame. The reason for 663 // expression stack elements of the calling frame. The reason for
648 // this rather strange decision is that we cannot access the 664 // this rather strange decision is that we cannot access the
649 // function during mark-compact GCs when objects may have been marked. 665 // function during mark-compact GCs when objects may have been marked.
650 // In fact accessing heap objects (like function->shared() below) 666 // In fact accessing heap objects (like function->shared() below)
651 // at all during GC is problematic. 667 // at all during GC is problematic.
652 arguments = 0; 668 arguments = 0;
653 } else { 669 } else {
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 ZoneList<StackFrame*> list(10); 1249 ZoneList<StackFrame*> list(10);
1234 for (StackFrameIterator it; !it.done(); it.Advance()) { 1250 for (StackFrameIterator it; !it.done(); it.Advance()) {
1235 StackFrame* frame = AllocateFrameCopy(it.frame()); 1251 StackFrame* frame = AllocateFrameCopy(it.frame());
1236 list.Add(frame); 1252 list.Add(frame);
1237 } 1253 }
1238 return list.ToVector(); 1254 return list.ToVector();
1239 } 1255 }
1240 1256
1241 1257
1242 } } // namespace v8::internal 1258 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698