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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 | 618 |
619 Handle<StackFrameInfo> NewStackFrameObject(FrameSummary& summ) { | 619 Handle<StackFrameInfo> NewStackFrameObject(FrameSummary& summ) { |
620 if (summ.IsJavaScript()) return NewStackFrameObject(summ.AsJavaScript()); | 620 if (summ.IsJavaScript()) return NewStackFrameObject(summ.AsJavaScript()); |
621 if (summ.IsWasm()) return NewStackFrameObject(summ.AsWasm()); | 621 if (summ.IsWasm()) return NewStackFrameObject(summ.AsWasm()); |
622 UNREACHABLE(); | 622 UNREACHABLE(); |
623 return factory()->NewStackFrameInfo(); | 623 return factory()->NewStackFrameInfo(); |
624 } | 624 } |
625 | 625 |
626 Handle<StackFrameInfo> NewStackFrameObject( | 626 Handle<StackFrameInfo> NewStackFrameObject( |
627 const FrameSummary::JavaScriptFrameSummary& summ) { | 627 const FrameSummary::JavaScriptFrameSummary& summ) { |
628 int code_offset = summ.code_offset(); | |
629 Handle<AbstractCode> code = summ.abstract_code(); | |
630 Object* maybe_cache = code->stack_frame_cache(); | |
631 Handle<UnseededNumberDictionary> cache; | |
632 if (maybe_cache->IsUnseededNumberDictionary()) { | |
633 cache = handle(UnseededNumberDictionary::cast(maybe_cache)); | |
634 } else { | |
635 cache = UnseededNumberDictionary::NewEmpty(isolate_); | |
636 code->set_stack_frame_cache(*cache); | |
637 } | |
638 int entry = cache->FindEntry(code_offset); | |
639 if (entry != UnseededNumberDictionary::kNotFound) { | |
640 return handle(StackFrameInfo::cast(cache->ValueAt(entry)), isolate_); | |
641 } | |
rmcilroy
2017/04/04 09:22:49
Rather than requiring a new field in both code and
Yang
2017/04/04 13:51:58
+1 for a side table. If you use code objects as ha
kozy
2017/04/04 19:11:07
Done.
kozy
2017/04/04 19:11:07
Done.
| |
628 Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); | 642 Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); |
629 Handle<Script> script = Handle<Script>::cast(summ.script()); | 643 Handle<Script> script = Handle<Script>::cast(summ.script()); |
630 if (options_ & StackTrace::kLineNumber) { | 644 if (options_ & StackTrace::kLineNumber) { |
631 Script::PositionInfo info; | 645 Script::PositionInfo info; |
632 bool valid_pos = Script::GetPositionInfo(script, summ.SourcePosition(), | 646 bool valid_pos = Script::GetPositionInfo(script, summ.SourcePosition(), |
633 &info, Script::WITH_OFFSET); | 647 &info, Script::WITH_OFFSET); |
634 if (valid_pos) { | 648 if (valid_pos) { |
635 frame->set_line_number(info.line + 1); | 649 frame->set_line_number(info.line + 1); |
636 if (options_ & StackTrace::kColumnOffset) { | 650 if (options_ & StackTrace::kColumnOffset) { |
637 frame->set_column_number(info.column + 1); | 651 frame->set_column_number(info.column + 1); |
(...skipping 12 matching lines...) Expand all Loading... | |
650 frame->set_is_eval(script->compilation_type() == | 664 frame->set_is_eval(script->compilation_type() == |
651 Script::COMPILATION_TYPE_EVAL); | 665 Script::COMPILATION_TYPE_EVAL); |
652 } | 666 } |
653 if (options_ & StackTrace::kFunctionName) { | 667 if (options_ & StackTrace::kFunctionName) { |
654 Handle<String> name = summ.FunctionName(); | 668 Handle<String> name = summ.FunctionName(); |
655 frame->set_function_name(*name); | 669 frame->set_function_name(*name); |
656 } | 670 } |
657 if (options_ & StackTrace::kIsConstructor) { | 671 if (options_ & StackTrace::kIsConstructor) { |
658 frame->set_is_constructor(summ.is_constructor()); | 672 frame->set_is_constructor(summ.is_constructor()); |
659 } | 673 } |
674 auto new_cache = | |
675 UnseededNumberDictionary::AtNumberPut(cache, code_offset, frame); | |
676 if (*new_cache != *cache) code->set_stack_frame_cache(*new_cache); | |
660 return frame; | 677 return frame; |
661 } | 678 } |
662 | 679 |
663 Handle<StackFrameInfo> NewStackFrameObject( | 680 Handle<StackFrameInfo> NewStackFrameObject( |
664 const FrameSummary::WasmFrameSummary& summ) { | 681 const FrameSummary::WasmFrameSummary& summ) { |
665 Handle<StackFrameInfo> info = factory()->NewStackFrameInfo(); | 682 Handle<StackFrameInfo> info = factory()->NewStackFrameInfo(); |
666 | 683 |
667 if (options_ & StackTrace::kFunctionName) { | 684 if (options_ & StackTrace::kFunctionName) { |
668 Handle<WasmCompiledModule> compiled_module( | 685 Handle<WasmCompiledModule> compiled_module( |
669 summ.wasm_instance()->compiled_module(), isolate_); | 686 summ.wasm_instance()->compiled_module(), isolate_); |
(...skipping 2986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3656 // Then check whether this scope intercepts. | 3673 // Then check whether this scope intercepts. |
3657 if ((flag & intercept_mask_)) { | 3674 if ((flag & intercept_mask_)) { |
3658 intercepted_flags_ |= flag; | 3675 intercepted_flags_ |= flag; |
3659 return true; | 3676 return true; |
3660 } | 3677 } |
3661 return false; | 3678 return false; |
3662 } | 3679 } |
3663 | 3680 |
3664 } // namespace internal | 3681 } // namespace internal |
3665 } // namespace v8 | 3682 } // namespace v8 |
OLD | NEW |