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

Side by Side Diff: src/isolate.cc

Issue 2788413004: [inspector] cache stack frame for call sites (Closed)
Patch Set: reverted v8-debugger change Created 3 years, 8 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
« no previous file with comments | « src/factory.cc ('k') | src/objects.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 // 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
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 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after
3740 // Then check whether this scope intercepts. 3773 // Then check whether this scope intercepts.
3741 if ((flag & intercept_mask_)) { 3774 if ((flag & intercept_mask_)) {
3742 intercepted_flags_ |= flag; 3775 intercepted_flags_ |= flag;
3743 return true; 3776 return true;
3744 } 3777 }
3745 return false; 3778 return false;
3746 } 3779 }
3747 3780
3748 } // namespace internal 3781 } // namespace internal
3749 } // namespace v8 3782 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698