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

Side by Side Diff: src/frames.cc

Issue 16917004: Simplify stack iterators implementation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use iterator_.frame() instead of frame() to avoid assertion failure Created 7 years, 6 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 return result; 196 return result;
197 197
198 #undef FRAME_TYPE_CASE 198 #undef FRAME_TYPE_CASE
199 } 199 }
200 200
201 201
202 // ------------------------------------------------------------------------- 202 // -------------------------------------------------------------------------
203 203
204 204
205 JavaScriptFrameIterator::JavaScriptFrameIterator(
206 Isolate* isolate, StackFrame::Id id)
207 : iterator_(isolate) {
208 while (!done()) {
209 Advance();
210 if (frame()->id() == id) return;
211 }
212 }
213
214
215 void JavaScriptFrameIterator::Advance() {
216 do {
217 iterator_.Advance();
218 } while (!iterator_.done() && !iterator_.frame()->is_java_script());
219 }
220
221
222 void JavaScriptFrameIterator::AdvanceToArgumentsFrame() {
223 if (!frame()->has_adapted_arguments()) return;
224 iterator_.Advance();
225 ASSERT(iterator_.frame()->is_arguments_adaptor());
226 }
227
228
229 // -------------------------------------------------------------------------
230
231
205 StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate) 232 StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate)
206 : JavaScriptFrameIterator(isolate) { 233 : JavaScriptFrameIterator(isolate) {
207 if (!done() && !IsValidFrame()) Advance(); 234 if (!done() && !IsValidFrame()) Advance();
208 } 235 }
209 236
210 237
211 void StackTraceFrameIterator::Advance() { 238 void StackTraceFrameIterator::Advance() {
212 while (true) { 239 while (true) {
213 JavaScriptFrameIterator::Advance(); 240 JavaScriptFrameIterator::Advance();
214 if (done()) return; 241 if (done()) return;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if (!number_of_args->IsSmi()) { 361 if (!number_of_args->IsSmi()) {
335 return false; 362 return false;
336 } 363 }
337 } 364 }
338 frame->ComputeCallerState(&state); 365 frame->ComputeCallerState(&state);
339 return IsValidStackAddress(state.sp) && IsValidStackAddress(state.fp) && 366 return IsValidStackAddress(state.sp) && IsValidStackAddress(state.fp) &&
340 iterator_.SingletonFor(frame->GetCallerState(&state)) != NULL; 367 iterator_.SingletonFor(frame->GetCallerState(&state)) != NULL;
341 } 368 }
342 369
343 370
344 void SafeStackFrameIterator::Reset() {
345 if (is_working_iterator_) {
346 iterator_.Reset();
347 iteration_done_ = false;
348 }
349 }
350
351
352 // ------------------------------------------------------------------------- 371 // -------------------------------------------------------------------------
353 372
354 373
355 SafeStackTraceFrameIterator::SafeStackTraceFrameIterator( 374 SafeStackTraceFrameIterator::SafeStackTraceFrameIterator(
356 Isolate* isolate, 375 Isolate* isolate,
357 Address fp, Address sp, Address low_bound, Address high_bound) : 376 Address fp, Address sp, Address low_bound, Address high_bound)
358 SafeJavaScriptFrameIterator(isolate, fp, sp, low_bound, high_bound) { 377 : iterator_(isolate, fp, sp, low_bound, high_bound) {
359 if (!done() && !frame()->is_java_script()) Advance(); 378 if (!done()) Advance();
360 } 379 }
361 380
362 381
363 void SafeStackTraceFrameIterator::Advance() { 382 void SafeStackTraceFrameIterator::Advance() {
364 while (true) { 383 while (true) {
365 SafeJavaScriptFrameIterator::Advance(); 384 iterator_.Advance();
366 if (done()) return; 385 if (iterator_.done()) return;
367 if (frame()->is_java_script()) return; 386 if (iterator_.frame()->is_java_script()) return;
368 } 387 }
369 } 388 }
370 389
371 390
372 Code* StackFrame::GetSafepointData(Isolate* isolate, 391 Code* StackFrame::GetSafepointData(Isolate* isolate,
373 Address inner_pointer, 392 Address inner_pointer,
374 SafepointEntry* safepoint_entry, 393 SafepointEntry* safepoint_entry,
375 unsigned* stack_slots) { 394 unsigned* stack_slots) {
376 InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry = 395 InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry =
377 isolate->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer); 396 isolate->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer);
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 ZoneList<StackFrame*> list(10, zone); 1633 ZoneList<StackFrame*> list(10, zone);
1615 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1634 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1616 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1635 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1617 list.Add(frame, zone); 1636 list.Add(frame, zone);
1618 } 1637 }
1619 return list.ToVector(); 1638 return list.ToVector();
1620 } 1639 }
1621 1640
1622 1641
1623 } } // namespace v8::internal 1642 } } // 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