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

Side by Side Diff: src/frames.cc

Issue 6800012: Version 3.2.8... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: 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/frames-inl.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 11 matching lines...) Expand all
66 const Address limit_; 63 const Address limit_;
67 StackHandler* handler_; 64 StackHandler* handler_;
68 }; 65 };
69 66
70 67
71 // ------------------------------------------------------------------------- 68 // -------------------------------------------------------------------------
72 69
73 70
74 #define INITIALIZE_SINGLETON(type, field) field##_(this), 71 #define INITIALIZE_SINGLETON(type, field) field##_(this),
75 StackFrameIterator::StackFrameIterator() 72 StackFrameIterator::StackFrameIterator()
76 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) 73 : isolate_(Isolate::Current()),
74 STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON)
77 frame_(NULL), handler_(NULL), 75 frame_(NULL), handler_(NULL),
78 thread_(Isolate::Current()->thread_local_top()), 76 thread_(isolate_->thread_local_top()),
79 fp_(NULL), sp_(NULL), advance_(&StackFrameIterator::AdvanceWithHandler) { 77 fp_(NULL), sp_(NULL), advance_(&StackFrameIterator::AdvanceWithHandler) {
80 Reset(); 78 Reset();
81 } 79 }
82 StackFrameIterator::StackFrameIterator(ThreadLocalTop* t) 80 StackFrameIterator::StackFrameIterator(Isolate* isolate)
83 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) 81 : isolate_(isolate),
82 STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON)
83 frame_(NULL), handler_(NULL),
84 thread_(isolate_->thread_local_top()),
85 fp_(NULL), sp_(NULL), advance_(&StackFrameIterator::AdvanceWithHandler) {
86 Reset();
87 }
88 StackFrameIterator::StackFrameIterator(Isolate* isolate, ThreadLocalTop* t)
89 : isolate_(isolate),
90 STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON)
84 frame_(NULL), handler_(NULL), thread_(t), 91 frame_(NULL), handler_(NULL), thread_(t),
85 fp_(NULL), sp_(NULL), advance_(&StackFrameIterator::AdvanceWithHandler) { 92 fp_(NULL), sp_(NULL), advance_(&StackFrameIterator::AdvanceWithHandler) {
86 Reset(); 93 Reset();
87 } 94 }
88 StackFrameIterator::StackFrameIterator(Isolate* isolate, 95 StackFrameIterator::StackFrameIterator(Isolate* isolate,
89 bool use_top, Address fp, Address sp) 96 bool use_top, Address fp, Address sp)
90 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) 97 : isolate_(isolate),
98 STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON)
91 frame_(NULL), handler_(NULL), 99 frame_(NULL), handler_(NULL),
92 thread_(use_top ? isolate->thread_local_top() : NULL), 100 thread_(use_top ? isolate_->thread_local_top() : NULL),
93 fp_(use_top ? NULL : fp), sp_(sp), 101 fp_(use_top ? NULL : fp), sp_(sp),
94 advance_(use_top ? &StackFrameIterator::AdvanceWithHandler : 102 advance_(use_top ? &StackFrameIterator::AdvanceWithHandler :
95 &StackFrameIterator::AdvanceWithoutHandler) { 103 &StackFrameIterator::AdvanceWithoutHandler) {
96 if (use_top || fp != NULL) { 104 if (use_top || fp != NULL) {
97 Reset(); 105 Reset();
98 } 106 }
99 } 107 }
100 108
101 #undef INITIALIZE_SINGLETON 109 #undef INITIALIZE_SINGLETON
102 110
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 type = ExitFrame::GetStateForFramePointer( 148 type = ExitFrame::GetStateForFramePointer(
141 Isolate::c_entry_fp(thread_), &state); 149 Isolate::c_entry_fp(thread_), &state);
142 handler_ = StackHandler::FromAddress( 150 handler_ = StackHandler::FromAddress(
143 Isolate::handler(thread_)); 151 Isolate::handler(thread_));
144 } else { 152 } else {
145 ASSERT(fp_ != NULL); 153 ASSERT(fp_ != NULL);
146 state.fp = fp_; 154 state.fp = fp_;
147 state.sp = sp_; 155 state.sp = sp_;
148 state.pc_address = 156 state.pc_address =
149 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp_)); 157 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp_));
150 type = StackFrame::ComputeType(&state); 158 type = StackFrame::ComputeType(isolate(), &state);
151 } 159 }
152 if (SingletonFor(type) == NULL) return; 160 if (SingletonFor(type) == NULL) return;
153 frame_ = SingletonFor(type, &state); 161 frame_ = SingletonFor(type, &state);
154 } 162 }
155 163
156 164
157 StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type, 165 StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type,
158 StackFrame::State* state) { 166 StackFrame::State* state) {
159 if (type == StackFrame::NONE) return NULL; 167 if (type == StackFrame::NONE) return NULL;
160 StackFrame* result = SingletonFor(type); 168 StackFrame* result = SingletonFor(type);
(...skipping 20 matching lines...) Expand all
181 189
182 190
183 // ------------------------------------------------------------------------- 191 // -------------------------------------------------------------------------
184 192
185 193
186 StackTraceFrameIterator::StackTraceFrameIterator() { 194 StackTraceFrameIterator::StackTraceFrameIterator() {
187 if (!done() && !IsValidFrame()) Advance(); 195 if (!done() && !IsValidFrame()) Advance();
188 } 196 }
189 197
190 198
199 StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate)
200 : JavaScriptFrameIterator(isolate) {
201 if (!done() && !IsValidFrame()) Advance();
202 }
203
204
191 void StackTraceFrameIterator::Advance() { 205 void StackTraceFrameIterator::Advance() {
192 while (true) { 206 while (true) {
193 JavaScriptFrameIterator::Advance(); 207 JavaScriptFrameIterator::Advance();
194 if (done()) return; 208 if (done()) return;
195 if (IsValidFrame()) return; 209 if (IsValidFrame()) return;
196 } 210 }
197 } 211 }
198 212
199 bool StackTraceFrameIterator::IsValidFrame() { 213 bool StackTraceFrameIterator::IsValidFrame() {
200 if (!frame()->function()->IsJSFunction()) return false; 214 if (!frame()->function()->IsJSFunction()) return false;
(...skipping 13 matching lines...) Expand all
214 if (!validator_.IsValid(sp)) return false; 228 if (!validator_.IsValid(sp)) return false;
215 StackFrame::State state; 229 StackFrame::State state;
216 ExitFrame::FillState(fp, sp, &state); 230 ExitFrame::FillState(fp, sp, &state);
217 if (!validator_.IsValid(reinterpret_cast<Address>(state.pc_address))) { 231 if (!validator_.IsValid(reinterpret_cast<Address>(state.pc_address))) {
218 return false; 232 return false;
219 } 233 }
220 return *state.pc_address != NULL; 234 return *state.pc_address != NULL;
221 } 235 }
222 236
223 237
238 SafeStackFrameIterator::ActiveCountMaintainer::ActiveCountMaintainer(
239 Isolate* isolate)
240 : isolate_(isolate) {
241 isolate_->set_safe_stack_iterator_counter(
242 isolate_->safe_stack_iterator_counter() + 1);
243 }
244
245
246 SafeStackFrameIterator::ActiveCountMaintainer::~ActiveCountMaintainer() {
247 isolate_->set_safe_stack_iterator_counter(
248 isolate_->safe_stack_iterator_counter() - 1);
249 }
250
251
224 SafeStackFrameIterator::SafeStackFrameIterator( 252 SafeStackFrameIterator::SafeStackFrameIterator(
225 Isolate* isolate, 253 Isolate* isolate,
226 Address fp, Address sp, Address low_bound, Address high_bound) : 254 Address fp, Address sp, Address low_bound, Address high_bound) :
227 maintainer_(), 255 maintainer_(isolate),
228 stack_validator_(low_bound, high_bound), 256 stack_validator_(low_bound, high_bound),
229 is_valid_top_(IsValidTop(isolate, low_bound, high_bound)), 257 is_valid_top_(IsValidTop(isolate, low_bound, high_bound)),
230 is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)), 258 is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)),
231 is_working_iterator_(is_valid_top_ || is_valid_fp_), 259 is_working_iterator_(is_valid_top_ || is_valid_fp_),
232 iteration_done_(!is_working_iterator_), 260 iteration_done_(!is_working_iterator_),
233 iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { 261 iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) {
234 } 262 }
235 263
264 bool SafeStackFrameIterator::is_active(Isolate* isolate) {
265 return isolate->safe_stack_iterator_counter() > 0;
266 }
267
236 268
237 bool SafeStackFrameIterator::IsValidTop(Isolate* isolate, 269 bool SafeStackFrameIterator::IsValidTop(Isolate* isolate,
238 Address low_bound, Address high_bound) { 270 Address low_bound, Address high_bound) {
239 ThreadLocalTop* top = isolate->thread_local_top(); 271 ThreadLocalTop* top = isolate->thread_local_top();
240 Address fp = Isolate::c_entry_fp(top); 272 Address fp = Isolate::c_entry_fp(top);
241 ExitFrameValidator validator(low_bound, high_bound); 273 ExitFrameValidator validator(low_bound, high_bound);
242 if (!validator.IsValidFP(fp)) return false; 274 if (!validator.IsValidFP(fp)) return false;
243 return Isolate::handler(top) != NULL; 275 return Isolate::handler(top) != NULL;
244 } 276 }
245 277
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 void SafeStackTraceFrameIterator::Advance() { 358 void SafeStackTraceFrameIterator::Advance() {
327 while (true) { 359 while (true) {
328 SafeJavaScriptFrameIterator::Advance(); 360 SafeJavaScriptFrameIterator::Advance();
329 if (done()) return; 361 if (done()) return;
330 if (frame()->is_java_script()) return; 362 if (frame()->is_java_script()) return;
331 } 363 }
332 } 364 }
333 #endif 365 #endif
334 366
335 367
336 Code* StackFrame::GetSafepointData(Address pc, 368 Code* StackFrame::GetSafepointData(Isolate* isolate,
369 Address pc,
337 SafepointEntry* safepoint_entry, 370 SafepointEntry* safepoint_entry,
338 unsigned* stack_slots) { 371 unsigned* stack_slots) {
339 Isolate* isolate = Isolate::Current();
340 PcToCodeCache::PcToCodeCacheEntry* entry = 372 PcToCodeCache::PcToCodeCacheEntry* entry =
341 isolate->pc_to_code_cache()->GetCacheEntry(pc); 373 isolate->pc_to_code_cache()->GetCacheEntry(pc);
342 SafepointEntry cached_safepoint_entry = entry->safepoint_entry; 374 SafepointEntry cached_safepoint_entry = entry->safepoint_entry;
343 if (!entry->safepoint_entry.is_valid()) { 375 if (!entry->safepoint_entry.is_valid()) {
344 entry->safepoint_entry = entry->code->GetSafepointEntry(pc); 376 entry->safepoint_entry = entry->code->GetSafepointEntry(pc);
345 ASSERT(entry->safepoint_entry.is_valid()); 377 ASSERT(entry->safepoint_entry.is_valid());
346 } else { 378 } else {
347 ASSERT(entry->safepoint_entry.Equals(entry->code->GetSafepointEntry(pc))); 379 ASSERT(entry->safepoint_entry.Equals(entry->code->GetSafepointEntry(pc)));
348 } 380 }
349 381
(...skipping 20 matching lines...) Expand all
370 Object* code = holder; 402 Object* code = holder;
371 v->VisitPointer(&code); 403 v->VisitPointer(&code);
372 if (code != holder) { 404 if (code != holder) {
373 holder = reinterpret_cast<Code*>(code); 405 holder = reinterpret_cast<Code*>(code);
374 pc = holder->instruction_start() + pc_offset; 406 pc = holder->instruction_start() + pc_offset;
375 *pc_address = pc; 407 *pc_address = pc;
376 } 408 }
377 } 409 }
378 410
379 411
380 StackFrame::Type StackFrame::ComputeType(State* state) { 412 StackFrame::Type StackFrame::ComputeType(Isolate* isolate, State* state) {
381 ASSERT(state->fp != NULL); 413 ASSERT(state->fp != NULL);
382 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { 414 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) {
383 return ARGUMENTS_ADAPTOR; 415 return ARGUMENTS_ADAPTOR;
384 } 416 }
385 // The marker and function offsets overlap. If the marker isn't a 417 // 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 418 // smi then the frame is a JavaScript frame -- and the marker is
387 // really the function. 419 // really the function.
388 const int offset = StandardFrameConstants::kMarkerOffset; 420 const int offset = StandardFrameConstants::kMarkerOffset;
389 Object* marker = Memory::Object_at(state->fp + offset); 421 Object* marker = Memory::Object_at(state->fp + offset);
390 if (!marker->IsSmi()) { 422 if (!marker->IsSmi()) {
391 // If we're using a "safe" stack iterator, we treat optimized 423 // If we're using a "safe" stack iterator, we treat optimized
392 // frames as normal JavaScript frames to avoid having to look 424 // frames as normal JavaScript frames to avoid having to look
393 // into the heap to determine the state. This is safe as long 425 // into the heap to determine the state. This is safe as long
394 // as nobody tries to GC... 426 // as nobody tries to GC...
395 if (SafeStackFrameIterator::is_active()) return JAVA_SCRIPT; 427 if (SafeStackFrameIterator::is_active(isolate)) return JAVA_SCRIPT;
396 Code::Kind kind = GetContainingCode(Isolate::Current(), 428 Code::Kind kind = GetContainingCode(isolate, *(state->pc_address))->kind();
397 *(state->pc_address))->kind();
398 ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION); 429 ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION);
399 return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT; 430 return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT;
400 } 431 }
401 return static_cast<StackFrame::Type>(Smi::cast(marker)->value()); 432 return static_cast<StackFrame::Type>(Smi::cast(marker)->value());
402 } 433 }
403 434
404 435
405 436
406 StackFrame::Type StackFrame::GetCallerState(State* state) const { 437 StackFrame::Type StackFrame::GetCallerState(State* state) const {
407 ComputeCallerState(state); 438 ComputeCallerState(state);
408 return ComputeType(state); 439 return ComputeType(isolate(), state);
409 } 440 }
410 441
411 442
412 Code* EntryFrame::unchecked_code() const { 443 Code* EntryFrame::unchecked_code() const {
413 return HEAP->raw_unchecked_js_entry_code(); 444 return HEAP->raw_unchecked_js_entry_code();
414 } 445 }
415 446
416 447
417 void EntryFrame::ComputeCallerState(State* state) const { 448 void EntryFrame::ComputeCallerState(State* state) const {
418 GetCallerState(state); 449 GetCallerState(state);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 489
459 490
460 void ExitFrame::SetCallerFp(Address caller_fp) { 491 void ExitFrame::SetCallerFp(Address caller_fp) {
461 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; 492 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp;
462 } 493 }
463 494
464 495
465 void ExitFrame::Iterate(ObjectVisitor* v) const { 496 void ExitFrame::Iterate(ObjectVisitor* v) const {
466 // The arguments are traversed as part of the expression stack of 497 // The arguments are traversed as part of the expression stack of
467 // the calling frame. 498 // the calling frame.
468 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); 499 IteratePc(v, pc_address(), LookupCode());
469 v->VisitPointer(&code_slot()); 500 v->VisitPointer(&code_slot());
470 } 501 }
471 502
472 503
473 Address ExitFrame::GetCallerStackPointer() const { 504 Address ExitFrame::GetCallerStackPointer() const {
474 return fp() + ExitFrameConstants::kCallerSPDisplacement; 505 return fp() + ExitFrameConstants::kCallerSPDisplacement;
475 } 506 }
476 507
477 508
478 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { 509 StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 563
533 void OptimizedFrame::Iterate(ObjectVisitor* v) const { 564 void OptimizedFrame::Iterate(ObjectVisitor* v) const {
534 #ifdef DEBUG 565 #ifdef DEBUG
535 // Make sure that optimized frames do not contain any stack handlers. 566 // Make sure that optimized frames do not contain any stack handlers.
536 StackHandlerIterator it(this, top_handler()); 567 StackHandlerIterator it(this, top_handler());
537 ASSERT(it.done()); 568 ASSERT(it.done());
538 #endif 569 #endif
539 570
540 // Make sure that we're not doing "safe" stack frame iteration. We cannot 571 // Make sure that we're not doing "safe" stack frame iteration. We cannot
541 // possibly find pointers in optimized frames in that state. 572 // possibly find pointers in optimized frames in that state.
542 ASSERT(!SafeStackFrameIterator::is_active()); 573 ASSERT(!SafeStackFrameIterator::is_active(isolate()));
543 574
544 // Compute the safepoint information. 575 // Compute the safepoint information.
545 unsigned stack_slots = 0; 576 unsigned stack_slots = 0;
546 SafepointEntry safepoint_entry; 577 SafepointEntry safepoint_entry;
547 Code* code = StackFrame::GetSafepointData( 578 Code* code = StackFrame::GetSafepointData(
548 pc(), &safepoint_entry, &stack_slots); 579 isolate(), pc(), &safepoint_entry, &stack_slots);
549 unsigned slot_space = stack_slots * kPointerSize; 580 unsigned slot_space = stack_slots * kPointerSize;
550 581
551 // Visit the outgoing parameters. This is usually dealt with by the 582 // Visit the outgoing parameters. This is usually dealt with by the
552 // callee, but while GC'ing we artificially lower the number of 583 // callee, but while GC'ing we artificially lower the number of
553 // arguments to zero and let the caller deal with it. 584 // arguments to zero and let the caller deal with it.
554 Object** parameters_base = &Memory::Object_at(sp()); 585 Object** parameters_base = &Memory::Object_at(sp());
555 Object** parameters_limit = &Memory::Object_at( 586 Object** parameters_limit = &Memory::Object_at(
556 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); 587 fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space);
557 588
558 // Visit the parameters that may be on top of the saved registers. 589 // Visit the parameters that may be on top of the saved registers.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 664
634 665
635 Code* JavaScriptFrame::unchecked_code() const { 666 Code* JavaScriptFrame::unchecked_code() const {
636 JSFunction* function = JSFunction::cast(this->function()); 667 JSFunction* function = JSFunction::cast(this->function());
637 return function->unchecked_code(); 668 return function->unchecked_code();
638 } 669 }
639 670
640 671
641 Address JavaScriptFrame::GetCallerStackPointer() const { 672 Address JavaScriptFrame::GetCallerStackPointer() const {
642 int arguments; 673 int arguments;
643 if (SafeStackFrameIterator::is_active() || 674 if (SafeStackFrameIterator::is_active(isolate()) ||
644 HEAP->gc_state() != Heap::NOT_IN_GC) { 675 isolate()->heap()->gc_state() != Heap::NOT_IN_GC) {
645 // If the we are currently iterating the safe stack the 676 // If the we are currently iterating the safe stack the
646 // arguments for frames are traversed as if they were 677 // arguments for frames are traversed as if they were
647 // expression stack elements of the calling frame. The reason for 678 // expression stack elements of the calling frame. The reason for
648 // this rather strange decision is that we cannot access the 679 // this rather strange decision is that we cannot access the
649 // function during mark-compact GCs when objects may have been marked. 680 // function during mark-compact GCs when objects may have been marked.
650 // In fact accessing heap objects (like function->shared() below) 681 // In fact accessing heap objects (like function->shared() below)
651 // at all during GC is problematic. 682 // at all during GC is problematic.
652 arguments = 0; 683 arguments = 0;
653 } else { 684 } else {
654 // Compute the number of arguments by getting the number of formal 685 // Compute the number of arguments by getting the number of formal
655 // parameters of the function. We must remember to take the 686 // parameters of the function. We must remember to take the
656 // receiver into account (+1). 687 // receiver into account (+1).
657 JSFunction* function = JSFunction::cast(this->function()); 688 JSFunction* function = JSFunction::cast(this->function());
658 arguments = function->shared()->formal_parameter_count() + 1; 689 arguments = function->shared()->formal_parameter_count() + 1;
659 } 690 }
660 const int offset = StandardFrameConstants::kCallerSPOffset; 691 const int offset = StandardFrameConstants::kCallerSPOffset;
661 return fp() + offset + (arguments * kPointerSize); 692 return fp() + offset + (arguments * kPointerSize);
662 } 693 }
663 694
664 695
665 void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) { 696 void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) {
666 ASSERT(functions->length() == 0); 697 ASSERT(functions->length() == 0);
667 functions->Add(JSFunction::cast(function())); 698 functions->Add(JSFunction::cast(function()));
668 } 699 }
669 700
670 701
671 void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { 702 void JavaScriptFrame::Summarize(List<FrameSummary>* functions) {
672 ASSERT(functions->length() == 0); 703 ASSERT(functions->length() == 0);
673 Code* code_pointer = LookupCode(Isolate::Current()); 704 Code* code_pointer = LookupCode();
674 int offset = static_cast<int>(pc() - code_pointer->address()); 705 int offset = static_cast<int>(pc() - code_pointer->address());
675 FrameSummary summary(receiver(), 706 FrameSummary summary(receiver(),
676 JSFunction::cast(function()), 707 JSFunction::cast(function()),
677 code_pointer, 708 code_pointer,
678 offset, 709 offset,
679 IsConstructor()); 710 IsConstructor());
680 functions->Add(summary); 711 functions->Add(summary);
681 } 712 }
682 713
683 714
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 int* deopt_index) { 813 int* deopt_index) {
783 ASSERT(is_optimized()); 814 ASSERT(is_optimized());
784 815
785 JSFunction* opt_function = JSFunction::cast(function()); 816 JSFunction* opt_function = JSFunction::cast(function());
786 Code* code = opt_function->code(); 817 Code* code = opt_function->code();
787 818
788 // The code object may have been replaced by lazy deoptimization. Fall 819 // The code object may have been replaced by lazy deoptimization. Fall
789 // back to a slow search in this case to find the original optimized 820 // back to a slow search in this case to find the original optimized
790 // code object. 821 // code object.
791 if (!code->contains(pc())) { 822 if (!code->contains(pc())) {
792 code = Isolate::Current()->pc_to_code_cache()->GcSafeFindCodeForPc(pc()); 823 code = isolate()->pc_to_code_cache()->GcSafeFindCodeForPc(pc());
793 } 824 }
794 ASSERT(code != NULL); 825 ASSERT(code != NULL);
795 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); 826 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION);
796 827
797 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); 828 SafepointEntry safepoint_entry = code->GetSafepointEntry(pc());
798 *deopt_index = safepoint_entry.deoptimization_index(); 829 *deopt_index = safepoint_entry.deoptimization_index();
799 ASSERT(*deopt_index != Safepoint::kNoDeoptimizationIndex); 830 ASSERT(*deopt_index != Safepoint::kNoDeoptimizationIndex);
800 831
801 return DeoptimizationInputData::cast(code->deoptimization_data()); 832 return DeoptimizationInputData::cast(code->deoptimization_data());
802 } 833 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 874
844 875
845 Address InternalFrame::GetCallerStackPointer() const { 876 Address InternalFrame::GetCallerStackPointer() const {
846 // Internal frames have no arguments. The stack pointer of the 877 // Internal frames have no arguments. The stack pointer of the
847 // caller is at a fixed offset from the frame pointer. 878 // caller is at a fixed offset from the frame pointer.
848 return fp() + StandardFrameConstants::kCallerSPOffset; 879 return fp() + StandardFrameConstants::kCallerSPOffset;
849 } 880 }
850 881
851 882
852 Code* ArgumentsAdaptorFrame::unchecked_code() const { 883 Code* ArgumentsAdaptorFrame::unchecked_code() const {
853 return Isolate::Current()->builtins()->builtin( 884 return isolate()->builtins()->builtin(
854 Builtins::kArgumentsAdaptorTrampoline); 885 Builtins::kArgumentsAdaptorTrampoline);
855 } 886 }
856 887
857 888
858 Code* InternalFrame::unchecked_code() const { 889 Code* InternalFrame::unchecked_code() const {
859 const int offset = InternalFrameConstants::kCodeOffset; 890 const int offset = InternalFrameConstants::kCodeOffset;
860 Object* code = Memory::Object_at(fp() + offset); 891 Object* code = Memory::Object_at(fp() + offset);
861 ASSERT(code != NULL); 892 ASSERT(code != NULL);
862 return reinterpret_cast<Code*>(code); 893 return reinterpret_cast<Code*>(code);
863 } 894 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1069
1039 accumulator->Add("}\n\n"); 1070 accumulator->Add("}\n\n");
1040 } 1071 }
1041 1072
1042 1073
1043 void EntryFrame::Iterate(ObjectVisitor* v) const { 1074 void EntryFrame::Iterate(ObjectVisitor* v) const {
1044 StackHandlerIterator it(this, top_handler()); 1075 StackHandlerIterator it(this, top_handler());
1045 ASSERT(!it.done()); 1076 ASSERT(!it.done());
1046 StackHandler* handler = it.handler(); 1077 StackHandler* handler = it.handler();
1047 ASSERT(handler->is_entry()); 1078 ASSERT(handler->is_entry());
1048 handler->Iterate(v, LookupCode(Isolate::Current())); 1079 handler->Iterate(v, LookupCode());
1049 #ifdef DEBUG 1080 #ifdef DEBUG
1050 // Make sure that the entry frame does not contain more than one 1081 // Make sure that the entry frame does not contain more than one
1051 // stack handler. 1082 // stack handler.
1052 it.Advance(); 1083 it.Advance();
1053 ASSERT(it.done()); 1084 ASSERT(it.done());
1054 #endif 1085 #endif
1055 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); 1086 IteratePc(v, pc_address(), LookupCode());
1056 } 1087 }
1057 1088
1058 1089
1059 void StandardFrame::IterateExpressions(ObjectVisitor* v) const { 1090 void StandardFrame::IterateExpressions(ObjectVisitor* v) const {
1060 const int offset = StandardFrameConstants::kContextOffset; 1091 const int offset = StandardFrameConstants::kContextOffset;
1061 Object** base = &Memory::Object_at(sp()); 1092 Object** base = &Memory::Object_at(sp());
1062 Object** limit = &Memory::Object_at(fp() + offset) + 1; 1093 Object** limit = &Memory::Object_at(fp() + offset) + 1;
1063 for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) { 1094 for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) {
1064 StackHandler* handler = it.handler(); 1095 StackHandler* handler = it.handler();
1065 // Traverse pointers down to - but not including - the next 1096 // Traverse pointers down to - but not including - the next
1066 // handler in the handler chain. Update the base to skip the 1097 // handler in the handler chain. Update the base to skip the
1067 // handler and allow the handler to traverse its own pointers. 1098 // handler and allow the handler to traverse its own pointers.
1068 const Address address = handler->address(); 1099 const Address address = handler->address();
1069 v->VisitPointers(base, reinterpret_cast<Object**>(address)); 1100 v->VisitPointers(base, reinterpret_cast<Object**>(address));
1070 base = reinterpret_cast<Object**>(address + StackHandlerConstants::kSize); 1101 base = reinterpret_cast<Object**>(address + StackHandlerConstants::kSize);
1071 // Traverse the pointers in the handler itself. 1102 // Traverse the pointers in the handler itself.
1072 handler->Iterate(v, LookupCode(Isolate::Current())); 1103 handler->Iterate(v, LookupCode());
1073 } 1104 }
1074 v->VisitPointers(base, limit); 1105 v->VisitPointers(base, limit);
1075 } 1106 }
1076 1107
1077 1108
1078 void JavaScriptFrame::Iterate(ObjectVisitor* v) const { 1109 void JavaScriptFrame::Iterate(ObjectVisitor* v) const {
1079 IterateExpressions(v); 1110 IterateExpressions(v);
1080 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); 1111 IteratePc(v, pc_address(), LookupCode());
1081 IterateArguments(v); 1112 IterateArguments(v);
1082 } 1113 }
1083 1114
1084 1115
1085 void JavaScriptFrame::IterateArguments(ObjectVisitor* v) const { 1116 void JavaScriptFrame::IterateArguments(ObjectVisitor* v) const {
1086 // Traverse callee-saved registers, receiver, and parameters. 1117 // Traverse callee-saved registers, receiver, and parameters.
1087 const int kBaseOffset = JavaScriptFrameConstants::kLastParameterOffset; 1118 const int kBaseOffset = JavaScriptFrameConstants::kLastParameterOffset;
1088 const int kLimitOffset = JavaScriptFrameConstants::kReceiverOffset; 1119 const int kLimitOffset = JavaScriptFrameConstants::kReceiverOffset;
1089 Object** base = &Memory::Object_at(fp() + kBaseOffset); 1120 Object** base = &Memory::Object_at(fp() + kBaseOffset);
1090 Object** limit = &Memory::Object_at(caller_sp() + kLimitOffset) + 1; 1121 Object** limit = &Memory::Object_at(caller_sp() + kLimitOffset) + 1;
1091 v->VisitPointers(base, limit); 1122 v->VisitPointers(base, limit);
1092 } 1123 }
1093 1124
1094 1125
1095 void InternalFrame::Iterate(ObjectVisitor* v) const { 1126 void InternalFrame::Iterate(ObjectVisitor* v) const {
1096 // Internal frames only have object pointers on the expression stack 1127 // Internal frames only have object pointers on the expression stack
1097 // as they never have any arguments. 1128 // as they never have any arguments.
1098 IterateExpressions(v); 1129 IterateExpressions(v);
1099 IteratePc(v, pc_address(), LookupCode(Isolate::Current())); 1130 IteratePc(v, pc_address(), LookupCode());
1100 } 1131 }
1101 1132
1102 1133
1103 // ------------------------------------------------------------------------- 1134 // -------------------------------------------------------------------------
1104 1135
1105 1136
1106 JavaScriptFrame* StackFrameLocator::FindJavaScriptFrame(int n) { 1137 JavaScriptFrame* StackFrameLocator::FindJavaScriptFrame(int n) {
1107 ASSERT(n >= 0); 1138 ASSERT(n >= 0);
1108 for (int i = 0; i <= n; i++) { 1139 for (int i = 0; i <= n; i++) {
1109 while (!iterator_.frame()->is_java_script()) iterator_.Advance(); 1140 while (!iterator_.frame()->is_java_script()) iterator_.Advance();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 ZoneList<StackFrame*> list(10); 1264 ZoneList<StackFrame*> list(10);
1234 for (StackFrameIterator it; !it.done(); it.Advance()) { 1265 for (StackFrameIterator it; !it.done(); it.Advance()) {
1235 StackFrame* frame = AllocateFrameCopy(it.frame()); 1266 StackFrame* frame = AllocateFrameCopy(it.frame());
1236 list.Add(frame); 1267 list.Add(frame);
1237 } 1268 }
1238 return list.ToVector(); 1269 return list.ToVector();
1239 } 1270 }
1240 1271
1241 1272
1242 } } // namespace v8::internal 1273 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/frames-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698