OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 | 662 |
663 Handle<StackFrameInfo> NewStackFrameObject(FrameSummary& summ) { | 663 Handle<StackFrameInfo> NewStackFrameObject(FrameSummary& summ) { |
664 if (summ.IsJavaScript()) return NewStackFrameObject(summ.AsJavaScript()); | 664 if (summ.IsJavaScript()) return NewStackFrameObject(summ.AsJavaScript()); |
665 if (summ.IsWasm()) return NewStackFrameObject(summ.AsWasm()); | 665 if (summ.IsWasm()) return NewStackFrameObject(summ.AsWasm()); |
666 UNREACHABLE(); | 666 UNREACHABLE(); |
667 return factory()->NewStackFrameInfo(); | 667 return factory()->NewStackFrameInfo(); |
668 } | 668 } |
669 | 669 |
670 Handle<StackFrameInfo> NewStackFrameObject( | 670 Handle<StackFrameInfo> NewStackFrameObject( |
671 const FrameSummary::JavaScriptFrameSummary& summ) { | 671 const FrameSummary::JavaScriptFrameSummary& summ) { |
| 672 int code_offset; |
| 673 Handle<ByteArray> source_position_table; |
| 674 Object* maybe_cache; |
| 675 Handle<UnseededNumberDictionary> cache; |
| 676 if (!FLAG_optimize_for_size) { |
| 677 code_offset = summ.code_offset(); |
| 678 source_position_table = |
| 679 handle(summ.abstract_code()->source_position_table(), isolate_); |
| 680 maybe_cache = summ.abstract_code()->stack_frame_cache(); |
| 681 if (maybe_cache->IsUnseededNumberDictionary()) { |
| 682 cache = handle(UnseededNumberDictionary::cast(maybe_cache)); |
| 683 } else { |
| 684 cache = UnseededNumberDictionary::New(isolate_, 1); |
| 685 } |
| 686 int entry = cache->FindEntry(code_offset); |
| 687 if (entry != UnseededNumberDictionary::kNotFound) { |
| 688 Handle<StackFrameInfo> frame( |
| 689 StackFrameInfo::cast(cache->ValueAt(entry))); |
| 690 if (!frame->function_name()->IsString() && |
| 691 !(options_ & StackTrace::kFunctionName)) { |
| 692 return frame; |
| 693 } |
| 694 if (frame->function_name()->IsString()) { |
| 695 Handle<String> function_name = summ.FunctionName(); |
| 696 if (function_name->Equals(String::cast(frame->function_name()))) { |
| 697 return frame; |
| 698 } |
| 699 } |
| 700 } |
| 701 } |
| 702 |
672 Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); | 703 Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); |
673 Handle<Script> script = Handle<Script>::cast(summ.script()); | 704 Handle<Script> script = Handle<Script>::cast(summ.script()); |
674 if (options_ & StackTrace::kLineNumber) { | 705 if (options_ & StackTrace::kLineNumber) { |
675 Script::PositionInfo info; | 706 Script::PositionInfo info; |
676 bool valid_pos = Script::GetPositionInfo(script, summ.SourcePosition(), | 707 bool valid_pos = Script::GetPositionInfo(script, summ.SourcePosition(), |
677 &info, Script::WITH_OFFSET); | 708 &info, Script::WITH_OFFSET); |
678 if (valid_pos) { | 709 if (valid_pos) { |
679 frame->set_line_number(info.line + 1); | 710 frame->set_line_number(info.line + 1); |
680 if (options_ & StackTrace::kColumnOffset) { | 711 if (options_ & StackTrace::kColumnOffset) { |
681 frame->set_column_number(info.column + 1); | 712 frame->set_column_number(info.column + 1); |
(...skipping 13 matching lines...) Expand all Loading... |
695 Script::COMPILATION_TYPE_EVAL); | 726 Script::COMPILATION_TYPE_EVAL); |
696 } | 727 } |
697 if (options_ & StackTrace::kFunctionName) { | 728 if (options_ & StackTrace::kFunctionName) { |
698 Handle<String> name = summ.FunctionName(); | 729 Handle<String> name = summ.FunctionName(); |
699 frame->set_function_name(*name); | 730 frame->set_function_name(*name); |
700 } | 731 } |
701 if (options_ & StackTrace::kIsConstructor) { | 732 if (options_ & StackTrace::kIsConstructor) { |
702 frame->set_is_constructor(summ.is_constructor()); | 733 frame->set_is_constructor(summ.is_constructor()); |
703 } | 734 } |
704 frame->set_is_wasm(false); | 735 frame->set_is_wasm(false); |
| 736 if (!FLAG_optimize_for_size) { |
| 737 auto new_cache = |
| 738 UnseededNumberDictionary::AtNumberPut(cache, code_offset, frame); |
| 739 if (*new_cache != *cache || !maybe_cache->IsUnseededNumberDictionary()) { |
| 740 AbstractCode::SetStackFrameCache(summ.abstract_code(), new_cache); |
| 741 } |
| 742 } |
705 return frame; | 743 return frame; |
706 } | 744 } |
707 | 745 |
708 Handle<StackFrameInfo> NewStackFrameObject( | 746 Handle<StackFrameInfo> NewStackFrameObject( |
709 const FrameSummary::WasmFrameSummary& summ) { | 747 const FrameSummary::WasmFrameSummary& summ) { |
710 Handle<StackFrameInfo> info = factory()->NewStackFrameInfo(); | 748 Handle<StackFrameInfo> info = factory()->NewStackFrameInfo(); |
711 | 749 |
712 if (options_ & StackTrace::kFunctionName) { | 750 if (options_ & StackTrace::kFunctionName) { |
713 Handle<WasmCompiledModule> compiled_module( | 751 Handle<WasmCompiledModule> compiled_module( |
714 summ.wasm_instance()->compiled_module(), isolate_); | 752 summ.wasm_instance()->compiled_module(), isolate_); |
(...skipping 3025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3740 // Then check whether this scope intercepts. | 3778 // Then check whether this scope intercepts. |
3741 if ((flag & intercept_mask_)) { | 3779 if ((flag & intercept_mask_)) { |
3742 intercepted_flags_ |= flag; | 3780 intercepted_flags_ |= flag; |
3743 return true; | 3781 return true; |
3744 } | 3782 } |
3745 return false; | 3783 return false; |
3746 } | 3784 } |
3747 | 3785 |
3748 } // namespace internal | 3786 } // namespace internal |
3749 } // namespace v8 | 3787 } // namespace v8 |
OLD | NEW |