| 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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 567 |
| 568 Handle<JSArray> Isolate::CaptureCurrentStackTrace( | 568 Handle<JSArray> Isolate::CaptureCurrentStackTrace( |
| 569 int frame_limit, StackTrace::StackTraceOptions options) { | 569 int frame_limit, StackTrace::StackTraceOptions options) { |
| 570 // Ensure no negative values. | 570 // Ensure no negative values. |
| 571 int limit = Max(frame_limit, 0); | 571 int limit = Max(frame_limit, 0); |
| 572 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 572 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
| 573 | 573 |
| 574 Handle<String> column_key = factory()->LookupAsciiSymbol("column"); | 574 Handle<String> column_key = factory()->LookupAsciiSymbol("column"); |
| 575 Handle<String> line_key = factory()->LookupAsciiSymbol("lineNumber"); | 575 Handle<String> line_key = factory()->LookupAsciiSymbol("lineNumber"); |
| 576 Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName"); | 576 Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName"); |
| 577 Handle<String> name_or_source_url_key = | |
| 578 factory()->LookupAsciiSymbol("nameOrSourceURL"); | |
| 579 Handle<String> script_name_or_source_url_key = | 577 Handle<String> script_name_or_source_url_key = |
| 580 factory()->LookupAsciiSymbol("scriptNameOrSourceURL"); | 578 factory()->LookupAsciiSymbol("scriptNameOrSourceURL"); |
| 581 Handle<String> function_key = factory()->LookupAsciiSymbol("functionName"); | 579 Handle<String> function_key = factory()->LookupAsciiSymbol("functionName"); |
| 582 Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval"); | 580 Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval"); |
| 583 Handle<String> constructor_key = | 581 Handle<String> constructor_key = |
| 584 factory()->LookupAsciiSymbol("isConstructor"); | 582 factory()->LookupAsciiSymbol("isConstructor"); |
| 585 | 583 |
| 586 StackTraceFrameIterator it(this); | 584 StackTraceFrameIterator it(this); |
| 587 int frames_seen = 0; | 585 int frames_seen = 0; |
| 588 while (!it.done() && (frames_seen < limit)) { | 586 while (!it.done() && (frames_seen < limit)) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 626 } |
| 629 | 627 |
| 630 if (options & StackTrace::kScriptName) { | 628 if (options & StackTrace::kScriptName) { |
| 631 Handle<Object> script_name(script->name(), this); | 629 Handle<Object> script_name(script->name(), this); |
| 632 CHECK_NOT_EMPTY_HANDLE(this, | 630 CHECK_NOT_EMPTY_HANDLE(this, |
| 633 JSObject::SetLocalPropertyIgnoreAttributes( | 631 JSObject::SetLocalPropertyIgnoreAttributes( |
| 634 stack_frame, script_key, script_name, NONE)); | 632 stack_frame, script_key, script_name, NONE)); |
| 635 } | 633 } |
| 636 | 634 |
| 637 if (options & StackTrace::kScriptNameOrSourceURL) { | 635 if (options & StackTrace::kScriptNameOrSourceURL) { |
| 638 Handle<Object> script_name(script->name(), this); | 636 Handle<Object> result = GetScriptNameOrSourceURL(script); |
| 639 Handle<JSValue> script_wrapper = GetScriptWrapper(script); | |
| 640 Handle<Object> property = GetProperty(script_wrapper, | |
| 641 name_or_source_url_key); | |
| 642 ASSERT(property->IsJSFunction()); | |
| 643 Handle<JSFunction> method = Handle<JSFunction>::cast(property); | |
| 644 bool caught_exception; | |
| 645 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, | |
| 646 NULL, &caught_exception); | |
| 647 if (caught_exception) { | |
| 648 result = factory()->undefined_value(); | |
| 649 } | |
| 650 CHECK_NOT_EMPTY_HANDLE(this, | 637 CHECK_NOT_EMPTY_HANDLE(this, |
| 651 JSObject::SetLocalPropertyIgnoreAttributes( | 638 JSObject::SetLocalPropertyIgnoreAttributes( |
| 652 stack_frame, script_name_or_source_url_key, | 639 stack_frame, script_name_or_source_url_key, |
| 653 result, NONE)); | 640 result, NONE)); |
| 654 } | 641 } |
| 655 | 642 |
| 656 if (options & StackTrace::kFunctionName) { | 643 if (options & StackTrace::kFunctionName) { |
| 657 Handle<Object> fun_name(fun->shared()->name(), this); | 644 Handle<Object> fun_name(fun->shared()->name(), this); |
| 658 if (fun_name->ToBoolean()->IsFalse()) { | 645 if (fun_name->ToBoolean()->IsFalse()) { |
| 659 fun_name = Handle<Object>(fun->shared()->inferred_name(), this); | 646 fun_name = Handle<Object>(fun->shared()->inferred_name(), this); |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 | 2053 |
| 2067 #ifdef DEBUG | 2054 #ifdef DEBUG |
| 2068 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2055 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2069 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2056 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2070 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2057 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2071 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2058 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2072 #undef ISOLATE_FIELD_OFFSET | 2059 #undef ISOLATE_FIELD_OFFSET |
| 2073 #endif | 2060 #endif |
| 2074 | 2061 |
| 2075 } } // namespace v8::internal | 2062 } } // namespace v8::internal |
| OLD | NEW |