OLD | NEW |
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 Handle<Object> caller, | 446 Handle<Object> caller, |
447 int limit) { | 447 int limit) { |
448 limit = Max(limit, 0); // Ensure that limit is not negative. | 448 limit = Max(limit, 0); // Ensure that limit is not negative. |
449 int initial_size = Min(limit, 10); | 449 int initial_size = Min(limit, 10); |
450 Handle<FixedArray> elements = | 450 Handle<FixedArray> elements = |
451 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1); | 451 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1); |
452 | 452 |
453 // If the caller parameter is a function we skip frames until we're | 453 // If the caller parameter is a function we skip frames until we're |
454 // under it before starting to collect. | 454 // under it before starting to collect. |
455 bool seen_caller = !caller->IsJSFunction(); | 455 bool seen_caller = !caller->IsJSFunction(); |
456 // First element is reserved to store the number of non-strict frames. | 456 // First element is reserved to store the number of sloppy frames. |
457 int cursor = 1; | 457 int cursor = 1; |
458 int frames_seen = 0; | 458 int frames_seen = 0; |
459 int non_strict_frames = 0; | 459 int sloppy_frames = 0; |
460 bool encountered_strict_function = false; | 460 bool encountered_strict_function = false; |
461 for (StackFrameIterator iter(this); | 461 for (StackFrameIterator iter(this); |
462 !iter.done() && frames_seen < limit; | 462 !iter.done() && frames_seen < limit; |
463 iter.Advance()) { | 463 iter.Advance()) { |
464 StackFrame* raw_frame = iter.frame(); | 464 StackFrame* raw_frame = iter.frame(); |
465 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) { | 465 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) { |
466 frames_seen++; | 466 frames_seen++; |
467 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 467 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
468 // Set initial size to the maximum inlining level + 1 for the outermost | 468 // Set initial size to the maximum inlining level + 1 for the outermost |
469 // function. | 469 // function. |
(...skipping 10 matching lines...) Expand all Loading... |
480 elements = new_elements; | 480 elements = new_elements; |
481 } | 481 } |
482 ASSERT(cursor + 4 <= elements->length()); | 482 ASSERT(cursor + 4 <= elements->length()); |
483 | 483 |
484 Handle<Object> recv = frames[i].receiver(); | 484 Handle<Object> recv = frames[i].receiver(); |
485 Handle<JSFunction> fun = frames[i].function(); | 485 Handle<JSFunction> fun = frames[i].function(); |
486 Handle<Code> code = frames[i].code(); | 486 Handle<Code> code = frames[i].code(); |
487 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); | 487 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); |
488 // The stack trace API should not expose receivers and function | 488 // The stack trace API should not expose receivers and function |
489 // objects on frames deeper than the top-most one with a strict | 489 // objects on frames deeper than the top-most one with a strict |
490 // mode function. The number of non-strict frames is stored as | 490 // mode function. The number of sloppy frames is stored as |
491 // first element in the result array. | 491 // first element in the result array. |
492 if (!encountered_strict_function) { | 492 if (!encountered_strict_function) { |
493 if (!fun->shared()->is_classic_mode()) { | 493 if (!fun->shared()->is_sloppy_mode()) { |
494 encountered_strict_function = true; | 494 encountered_strict_function = true; |
495 } else { | 495 } else { |
496 non_strict_frames++; | 496 sloppy_frames++; |
497 } | 497 } |
498 } | 498 } |
499 elements->set(cursor++, *recv); | 499 elements->set(cursor++, *recv); |
500 elements->set(cursor++, *fun); | 500 elements->set(cursor++, *fun); |
501 elements->set(cursor++, *code); | 501 elements->set(cursor++, *code); |
502 elements->set(cursor++, *offset); | 502 elements->set(cursor++, *offset); |
503 } | 503 } |
504 } | 504 } |
505 } | 505 } |
506 elements->set(0, Smi::FromInt(non_strict_frames)); | 506 elements->set(0, Smi::FromInt(sloppy_frames)); |
507 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); | 507 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); |
508 result->set_length(Smi::FromInt(cursor)); | 508 result->set_length(Smi::FromInt(cursor)); |
509 return result; | 509 return result; |
510 } | 510 } |
511 | 511 |
512 | 512 |
513 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) { | 513 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) { |
514 if (capture_stack_trace_for_uncaught_exceptions_) { | 514 if (capture_stack_trace_for_uncaught_exceptions_) { |
515 // Capture stack trace for a detailed exception message. | 515 // Capture stack trace for a detailed exception message. |
516 Handle<String> key = factory()->hidden_stack_trace_string(); | 516 Handle<String> key = factory()->hidden_stack_trace_string(); |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 | 2319 |
2320 #ifdef DEBUG | 2320 #ifdef DEBUG |
2321 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2321 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2322 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2322 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2323 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2323 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2324 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2324 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2325 #undef ISOLATE_FIELD_OFFSET | 2325 #undef ISOLATE_FIELD_OFFSET |
2326 #endif | 2326 #endif |
2327 | 2327 |
2328 } } // namespace v8::internal | 2328 } } // namespace v8::internal |
OLD | NEW |