Index: src/isolate.cc |
diff --git a/src/isolate.cc b/src/isolate.cc |
index 823458544e59090126f1b88e78acd291aa63f098..34bd3831dcf317ec7ba3bf948866cabeead24f12 100644 |
--- a/src/isolate.cc |
+++ b/src/isolate.cc |
@@ -669,6 +669,37 @@ class CaptureStackTraceHelper { |
Handle<StackFrameInfo> NewStackFrameObject( |
const FrameSummary::JavaScriptFrameSummary& summ) { |
+ int code_offset; |
+ Handle<ByteArray> source_position_table; |
+ Object* maybe_cache; |
+ Handle<UnseededNumberDictionary> cache; |
+ if (!FLAG_optimize_for_size) { |
+ code_offset = summ.code_offset(); |
+ source_position_table = |
+ handle(summ.abstract_code()->source_position_table(), isolate_); |
+ maybe_cache = summ.abstract_code()->stack_frame_cache(); |
+ if (maybe_cache->IsUnseededNumberDictionary()) { |
+ cache = handle(UnseededNumberDictionary::cast(maybe_cache)); |
+ } else { |
+ cache = UnseededNumberDictionary::New(isolate_, 1); |
+ } |
+ int entry = cache->FindEntry(code_offset); |
+ if (entry != UnseededNumberDictionary::kNotFound) { |
+ Handle<StackFrameInfo> frame( |
+ StackFrameInfo::cast(cache->ValueAt(entry))); |
+ if (!frame->function_name()->IsString() && |
+ !(options_ & StackTrace::kFunctionName)) { |
+ return frame; |
+ } |
+ if (frame->function_name()->IsString()) { |
+ Handle<String> function_name = summ.FunctionName(); |
+ if (function_name->Equals(String::cast(frame->function_name()))) { |
+ return frame; |
+ } |
+ } |
+ } |
+ } |
+ |
Handle<StackFrameInfo> frame = factory()->NewStackFrameInfo(); |
Handle<Script> script = Handle<Script>::cast(summ.script()); |
if (options_ & StackTrace::kLineNumber) { |
@@ -702,6 +733,13 @@ class CaptureStackTraceHelper { |
frame->set_is_constructor(summ.is_constructor()); |
} |
frame->set_is_wasm(false); |
+ if (!FLAG_optimize_for_size) { |
+ auto new_cache = |
+ UnseededNumberDictionary::AtNumberPut(cache, code_offset, frame); |
+ if (*new_cache != *cache || !maybe_cache->IsUnseededNumberDictionary()) { |
+ AbstractCode::SetStackFrameCache(summ.abstract_code(), new_cache); |
+ } |
+ } |
return frame; |
} |