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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 659 |
660 Handle<StackFrameInfo> NewStackFrameObject(FrameSummary& summ) { | 660 Handle<StackFrameInfo> NewStackFrameObject(FrameSummary& summ) { |
661 if (summ.IsJavaScript()) return NewStackFrameObject(summ.AsJavaScript()); | 661 if (summ.IsJavaScript()) return NewStackFrameObject(summ.AsJavaScript()); |
662 if (summ.IsWasm()) return NewStackFrameObject(summ.AsWasm()); | 662 if (summ.IsWasm()) return NewStackFrameObject(summ.AsWasm()); |
663 UNREACHABLE(); | 663 UNREACHABLE(); |
664 return factory()->NewStackFrameInfo(); | 664 return factory()->NewStackFrameInfo(); |
665 } | 665 } |
666 | 666 |
667 Handle<StackFrameInfo> NewStackFrameObject( | 667 Handle<StackFrameInfo> NewStackFrameObject( |
668 const FrameSummary::JavaScriptFrameSummary& summ) { | 668 const FrameSummary::JavaScriptFrameSummary& summ) { |
| 669 int code_offset; |
| 670 Handle<ByteArray> source_position_table; |
| 671 Object* maybe_cache; |
| 672 Handle<UnseededNumberDictionary> cache; |
| 673 if (!FLAG_optimize_for_size) { |
| 674 code_offset = summ.code_offset(); |
| 675 source_position_table = |
| 676 handle(summ.abstract_code()->source_position_table(), isolate_); |
| 677 maybe_cache = summ.abstract_code()->stack_frame_cache(); |
| 678 if (maybe_cache->IsUnseededNumberDictionary()) { |
| 679 cache = handle(UnseededNumberDictionary::cast(maybe_cache)); |
| 680 } else { |
| 681 cache = UnseededNumberDictionary::New(isolate_, 1); |
| 682 } |
| 683 int entry = cache->FindEntry(code_offset); |
| 684 if (entry != UnseededNumberDictionary::kNotFound) { |
| 685 Handle<StackFrameInfo> frame( |
| 686 StackFrameInfo::cast(cache->ValueAt(entry))); |
| 687 DCHECK(frame->function_name()->IsString()); |
| 688 Handle<String> function_name = summ.FunctionName(); |
| 689 if (function_name->Equals(String::cast(frame->function_name()))) { |
| 690 return frame; |
| 691 } |
| 692 } |
| 693 } |
| 694 |
669 Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); | 695 Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); |
670 Handle<Script> script = Handle<Script>::cast(summ.script()); | 696 Handle<Script> script = Handle<Script>::cast(summ.script()); |
671 Script::PositionInfo info; | 697 Script::PositionInfo info; |
672 bool valid_pos = Script::GetPositionInfo(script, summ.SourcePosition(), | 698 bool valid_pos = Script::GetPositionInfo(script, summ.SourcePosition(), |
673 &info, Script::WITH_OFFSET); | 699 &info, Script::WITH_OFFSET); |
674 if (valid_pos) { | 700 if (valid_pos) { |
675 frame->set_line_number(info.line + 1); | 701 frame->set_line_number(info.line + 1); |
676 frame->set_column_number(info.column + 1); | 702 frame->set_column_number(info.column + 1); |
677 } | 703 } |
678 frame->set_script_id(script->id()); | 704 frame->set_script_id(script->id()); |
679 frame->set_script_name(script->name()); | 705 frame->set_script_name(script->name()); |
680 frame->set_script_name_or_source_url(script->GetNameOrSourceURL()); | 706 frame->set_script_name_or_source_url(script->GetNameOrSourceURL()); |
681 frame->set_is_eval(script->compilation_type() == | 707 frame->set_is_eval(script->compilation_type() == |
682 Script::COMPILATION_TYPE_EVAL); | 708 Script::COMPILATION_TYPE_EVAL); |
683 Handle<String> function_name = summ.FunctionName(); | 709 Handle<String> function_name = summ.FunctionName(); |
684 frame->set_function_name(*function_name); | 710 frame->set_function_name(*function_name); |
685 frame->set_is_constructor(summ.is_constructor()); | 711 frame->set_is_constructor(summ.is_constructor()); |
686 frame->set_is_wasm(false); | 712 frame->set_is_wasm(false); |
| 713 if (!FLAG_optimize_for_size) { |
| 714 auto new_cache = |
| 715 UnseededNumberDictionary::AtNumberPut(cache, code_offset, frame); |
| 716 if (*new_cache != *cache || !maybe_cache->IsUnseededNumberDictionary()) { |
| 717 AbstractCode::SetStackFrameCache(summ.abstract_code(), new_cache); |
| 718 } |
| 719 } |
687 return frame; | 720 return frame; |
688 } | 721 } |
689 | 722 |
690 Handle<StackFrameInfo> NewStackFrameObject( | 723 Handle<StackFrameInfo> NewStackFrameObject( |
691 const FrameSummary::WasmFrameSummary& summ) { | 724 const FrameSummary::WasmFrameSummary& summ) { |
692 Handle<StackFrameInfo> info = factory()->NewStackFrameInfo(); | 725 Handle<StackFrameInfo> info = factory()->NewStackFrameInfo(); |
693 | 726 |
694 Handle<WasmCompiledModule> compiled_module( | 727 Handle<WasmCompiledModule> compiled_module( |
695 summ.wasm_instance()->compiled_module(), isolate_); | 728 summ.wasm_instance()->compiled_module(), isolate_); |
696 Handle<String> name = WasmCompiledModule::GetFunctionName( | 729 Handle<String> name = WasmCompiledModule::GetFunctionName( |
(...skipping 3017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3714 // Then check whether this scope intercepts. | 3747 // Then check whether this scope intercepts. |
3715 if ((flag & intercept_mask_)) { | 3748 if ((flag & intercept_mask_)) { |
3716 intercepted_flags_ |= flag; | 3749 intercepted_flags_ |= flag; |
3717 return true; | 3750 return true; |
3718 } | 3751 } |
3719 return false; | 3752 return false; |
3720 } | 3753 } |
3721 | 3754 |
3722 } // namespace internal | 3755 } // namespace internal |
3723 } // namespace v8 | 3756 } // namespace v8 |
OLD | NEW |