Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index d1dd44c139d8ad8100b5e859ef9307d7e30fd76d..9f70fd443ef2ad2537eb670c8b11762c60093895 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -13142,6 +13142,616 @@ Script::Iterator::Iterator(Isolate* isolate) |
Script* Script::Iterator::Next() { return iterator_.Next<Script>(); } |
+namespace { |
+ |
+int JSSTGetPosition(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ return frame->abstract_code()->SourcePosition(frame->offset()); |
+} |
+ |
+Handle<Object> JSSTGetFileName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Object* script = frame->function()->shared()->script(); |
+ if (!script->IsScript()) return isolate->factory()->null_value(); |
+ return Handle<Object>(Script::cast(script)->name(), isolate); |
+} |
+ |
+Handle<Object> JSSTGetFunctionName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ |
+ Handle<JSFunction> function = handle(frame->function()); |
+ Handle<String> result = JSFunction::GetName(function); |
+ if (result->length() != 0) return result; |
+ |
+ Handle<Object> script(function->shared()->script(), isolate); |
+ if (script->IsScript() && |
+ Handle<Script>::cast(script)->compilation_type() == |
+ Script::COMPILATION_TYPE_EVAL) { |
+ return isolate->factory()->eval_string(); |
+ } |
+ |
+ return isolate->factory()->null_value(); |
+} |
+ |
+Handle<Object> JSSTGetScriptNameOrSourceUrl(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ |
+ Object* script_obj = frame->function()->shared()->script(); |
+ if (!script_obj->IsScript()) return isolate->factory()->null_value(); |
+ |
+ Handle<Script> script(Script::cast(script_obj), isolate); |
+ Object* source_url = script->source_url(); |
+ if (source_url->IsString()) return Handle<Object>(source_url, isolate); |
+ |
+ return Handle<Object>(script->name(), isolate); |
+} |
+ |
+bool CheckMethodName(Isolate* isolate, Handle<JSObject> obj, Handle<Name> name, |
+ Handle<JSFunction> fun, |
+ LookupIterator::Configuration config) { |
+ LookupIterator iter = |
+ LookupIterator::PropertyOrElement(isolate, obj, name, config); |
+ if (iter.state() == LookupIterator::DATA) { |
+ return iter.GetDataValue().is_identical_to(fun); |
+ } else if (iter.state() == LookupIterator::ACCESSOR) { |
+ Handle<Object> accessors = iter.GetAccessors(); |
+ if (accessors->IsAccessorPair()) { |
+ Handle<AccessorPair> pair = Handle<AccessorPair>::cast(accessors); |
+ return pair->getter() == *fun || pair->setter() == *fun; |
+ } |
+ } |
+ return false; |
+} |
+ |
+Handle<Object> JSSTGetMethodName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Handle<JSFunction> fun = handle(frame->function()); |
+ Handle<Object> recv_obj = handle(frame->receiver(), isolate); |
+ |
+ if (recv_obj->IsNull(isolate) || recv_obj->IsUndefined(isolate)) { |
+ return isolate->factory()->null_value(); |
+ } |
+ |
+ Handle<JSReceiver> recv = |
+ Object::ToObject(isolate, recv_obj).ToHandleChecked(); |
+ if (!recv->IsJSObject()) { |
+ return isolate->factory()->null_value(); |
+ } |
+ |
+ Handle<JSObject> obj = Handle<JSObject>::cast(recv); |
+ Handle<Object> function_name(fun->shared()->name(), isolate); |
+ if (function_name->IsString()) { |
+ Handle<String> name = Handle<String>::cast(function_name); |
+ // ES2015 gives getters and setters name prefixes which must |
+ // be stripped to find the property name. |
+ if (name->IsUtf8EqualTo(CStrVector("get "), true) || |
+ name->IsUtf8EqualTo(CStrVector("set "), true)) { |
+ name = isolate->factory()->NewProperSubString(name, 4, name->length()); |
+ } |
+ if (CheckMethodName(isolate, obj, name, fun, |
+ LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR)) { |
+ return name; |
+ } |
+ } |
+ |
+ HandleScope outer_scope(isolate); |
+ Handle<Object> result; |
+ for (PrototypeIterator iter(isolate, obj, kStartAtReceiver); !iter.IsAtEnd(); |
+ iter.Advance()) { |
+ Handle<Object> current = PrototypeIterator::GetCurrent(iter); |
+ if (!current->IsJSObject()) break; |
+ Handle<JSObject> current_obj = Handle<JSObject>::cast(current); |
+ if (current_obj->IsAccessCheckNeeded()) break; |
+ Handle<FixedArray> keys = |
+ KeyAccumulator::GetOwnEnumPropertyKeys(isolate, current_obj); |
+ for (int i = 0; i < keys->length(); i++) { |
+ HandleScope inner_scope(isolate); |
+ if (!keys->get(i)->IsName()) continue; |
+ Handle<Name> name_key(Name::cast(keys->get(i)), isolate); |
+ if (!CheckMethodName(isolate, current_obj, name_key, fun, |
+ LookupIterator::OWN_SKIP_INTERCEPTOR)) { |
+ continue; |
+ } |
+ // Return null in case of duplicates to avoid confusion. |
+ if (!result.is_null()) return isolate->factory()->null_value(); |
+ result = inner_scope.CloseAndEscape(name_key); |
+ } |
+ } |
+ |
+ if (!result.is_null()) return outer_scope.CloseAndEscape(result); |
+ return isolate->factory()->null_value(); |
+} |
+ |
+Handle<Object> JSSTGetTypeName(Handle<StackTraceFrame> frame) { |
+ // TODO(jgruber): Check for strict/constructor here as in |
+ // CallSitePrototypeGetThis. |
+ |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Handle<Object> recv = handle(frame->receiver(), isolate); |
+ |
+ if (recv->IsNull(isolate) || recv->IsUndefined(isolate)) |
+ return isolate->factory()->null_value(); |
+ |
+ if (recv->IsJSProxy()) return isolate->factory()->Proxy_string(); |
+ |
+ Handle<JSReceiver> receiver_object = |
+ Object::ToObject(isolate, recv).ToHandleChecked(); |
+ return JSReceiver::GetConstructorName(receiver_object); |
+} |
+ |
+Object* EvalFromFunctionName(Isolate* isolate, Handle<Script> script) { |
+ if (script->eval_from_shared()->IsUndefined(isolate)) |
+ return *isolate->factory()->undefined_value(); |
+ |
+ Handle<SharedFunctionInfo> shared( |
+ SharedFunctionInfo::cast(script->eval_from_shared())); |
+ // Find the name of the function calling eval. |
+ if (shared->name()->BooleanValue()) { |
+ return shared->name(); |
+ } |
+ |
+ return shared->inferred_name(); |
+} |
+ |
+Object* EvalFromScript(Isolate* isolate, Handle<Script> script) { |
+ if (script->eval_from_shared()->IsUndefined(isolate)) |
+ return *isolate->factory()->undefined_value(); |
+ |
+ Handle<SharedFunctionInfo> eval_from_shared( |
+ SharedFunctionInfo::cast(script->eval_from_shared())); |
+ return eval_from_shared->script()->IsScript() |
+ ? eval_from_shared->script() |
+ : *isolate->factory()->undefined_value(); |
+} |
+ |
+MaybeHandle<String> FormatEvalOrigin(Isolate* isolate, Handle<Script> script) { |
+ Handle<Object> sourceURL = Script::GetNameOrSourceURL(script); |
+ if (!sourceURL->IsUndefined(isolate)) { |
+ DCHECK(sourceURL->IsString()); |
+ return Handle<String>::cast(sourceURL); |
+ } |
+ |
+ IncrementalStringBuilder builder(isolate); |
+ builder.AppendCString("eval at "); |
+ |
+ Handle<Object> eval_from_function_name = |
+ handle(EvalFromFunctionName(isolate, script), isolate); |
+ if (eval_from_function_name->BooleanValue()) { |
+ Handle<String> str; |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, str, Object::ToString(isolate, eval_from_function_name), |
+ String); |
+ builder.AppendString(str); |
+ } else { |
+ builder.AppendCString("<anonymous>"); |
+ } |
+ |
+ Handle<Object> eval_from_script_obj = |
+ handle(EvalFromScript(isolate, script), isolate); |
+ if (eval_from_script_obj->IsScript()) { |
+ Handle<Script> eval_from_script = |
+ Handle<Script>::cast(eval_from_script_obj); |
+ builder.AppendCString(" ("); |
+ if (eval_from_script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { |
+ // Eval script originated from another eval. |
+ Handle<String> str; |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, str, FormatEvalOrigin(isolate, eval_from_script), String); |
+ builder.AppendString(str); |
+ } else { |
+ DCHECK(eval_from_script->compilation_type() != |
+ Script::COMPILATION_TYPE_EVAL); |
+ // eval script originated from "real" source. |
+ Handle<Object> name_obj = handle(eval_from_script->name(), isolate); |
+ if (eval_from_script->name()->IsString()) { |
+ builder.AppendString(Handle<String>::cast(name_obj)); |
+ |
+ Script::PositionInfo info; |
+ if (eval_from_script->GetPositionInfo(script->GetEvalPosition(), &info, |
+ Script::NO_OFFSET)) { |
+ builder.AppendCString(":"); |
+ |
+ Handle<String> str = isolate->factory()->NumberToString( |
+ handle(Smi::FromInt(info.line + 1), isolate)); |
+ builder.AppendString(str); |
+ |
+ builder.AppendCString(":"); |
+ |
+ str = isolate->factory()->NumberToString( |
+ handle(Smi::FromInt(info.column + 1), isolate)); |
+ builder.AppendString(str); |
+ } |
+ } else { |
+ DCHECK(!eval_from_script->name()->IsString()); |
+ builder.AppendCString("unknown source"); |
+ } |
+ } |
+ builder.AppendCString(")"); |
+ } |
+ |
+ Handle<String> result; |
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, result, builder.Finish(), String); |
+ return result; |
+} |
+ |
+Handle<Object> JSSTGetEvalOrigin(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ |
+ Handle<Object> script = |
+ handle(frame->function()->shared()->script(), isolate); |
+ if (!script->IsScript()) return isolate->factory()->undefined_value(); |
+ |
+ return FormatEvalOrigin(isolate, Handle<Script>::cast(script)) |
+ .ToHandleChecked(); |
+} |
+ |
+// Return 1-based line number, including line offset. |
+int JSSTGetLineNumber(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ const int pos = frame->GetPosition(); |
+ if (pos >= 0) { |
+ Handle<Object> script_obj(frame->function()->shared()->script(), isolate); |
+ if (script_obj->IsScript()) { |
+ Handle<Script> script = Handle<Script>::cast(script_obj); |
+ return Script::GetLineNumber(script, pos) + 1; |
+ } |
+ } |
+ return -1; |
+} |
+ |
+// Return 1-based column number, including column offset if first line. |
+int JSSTGetColumnNumber(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ const int pos = frame->GetPosition(); |
+ if (pos >= 0) { |
+ Handle<Object> script_obj(frame->function()->shared()->script(), isolate); |
+ if (script_obj->IsScript()) { |
+ Handle<Script> script = Handle<Script>::cast(script_obj); |
+ return Script::GetColumnNumber(script, pos) + 1; |
+ } |
+ } |
+ return -1; |
+} |
+ |
+bool JSSTIsNative(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Handle<Object> script(frame->function()->shared()->script(), isolate); |
+ return script->IsScript() && |
+ Handle<Script>::cast(script)->type() == Script::TYPE_NATIVE; |
+} |
+ |
+bool JSSTIsToplevel(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Object* recv = frame->receiver(); |
+ return recv->IsJSGlobalProxy() || recv->IsNull(isolate) || |
+ recv->IsUndefined(isolate); |
+} |
+ |
+bool JSSTIsEval(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Handle<Object> script(frame->function()->shared()->script(), isolate); |
+ return script->IsScript() && |
+ Handle<Script>::cast(script)->compilation_type() == |
+ Script::COMPILATION_TYPE_EVAL; |
+} |
+ |
+bool JSSTIsConstructor(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ Object* recv = frame->receiver(); |
+ |
+ if (frame->ForceConstructor()) return true; |
+ if (!recv->IsJSObject()) return false; |
+ Handle<Object> constructor = |
+ JSReceiver::GetDataProperty(Handle<JSObject>::cast(handle(recv, isolate)), |
+ isolate->factory()->constructor_string()); |
+ return constructor.is_identical_to(handle(frame->function())); |
+} |
+ |
+bool IsNonEmptyString(Handle<Object> object) { |
+ return (object->IsString() && String::cast(*object)->length() > 0); |
+} |
+ |
+int StringIndexOf(Isolate* isolate, Handle<String> subject, |
+ Handle<String> pattern) { |
+ if (pattern->length() > subject->length()) return -1; |
+ return String::IndexOf(isolate, subject, pattern, 0); |
+} |
+ |
+// Returns true iff |
+// 1. the subject ends with '.' + pattern, or |
+// 2. subject == pattern. |
+bool StringEndsWithMethodName(Isolate* isolate, Handle<String> subject, |
+ Handle<String> pattern) { |
+ if (String::Equals(subject, pattern)) return true; |
+ |
+ FlatStringReader subject_reader(isolate, String::Flatten(subject)); |
+ FlatStringReader pattern_reader(isolate, String::Flatten(pattern)); |
+ |
+ int pattern_index = pattern_reader.length() - 1; |
+ int subject_index = subject_reader.length() - 1; |
+ for (int i = 0; i <= pattern_reader.length(); i++) { // Iterate over len + 1. |
+ if (subject_index < 0) { |
+ return false; |
+ } |
+ |
+ const uc32 subject_char = subject_reader.Get(subject_index); |
+ if (i == pattern_reader.length()) { |
+ if (subject_char != '.') return false; |
+ } else if (subject_char != pattern_reader.Get(pattern_index)) { |
+ return false; |
+ } |
+ |
+ pattern_index--; |
+ subject_index--; |
+ } |
+ |
+ return true; |
+} |
+ |
+void AppendMethodCall(Isolate* isolate, Handle<StackTraceFrame> frame, |
+ IncrementalStringBuilder* builder) { |
+ Handle<Object> type_name = frame->GetTypeName(); |
+ Handle<Object> method_name = frame->GetMethodName(); |
+ Handle<Object> function_name = frame->GetFunctionName(); |
+ |
+ if (IsNonEmptyString(function_name)) { |
+ Handle<String> function_string = Handle<String>::cast(function_name); |
+ if (IsNonEmptyString(type_name)) { |
+ Handle<String> type_string = Handle<String>::cast(type_name); |
+ bool starts_with_type_name = |
+ (StringIndexOf(isolate, function_string, type_string) == 0); |
+ if (!starts_with_type_name) { |
+ builder->AppendString(type_string); |
+ builder->AppendCharacter('.'); |
+ } |
+ } |
+ builder->AppendString(function_string); |
+ |
+ if (IsNonEmptyString(method_name)) { |
+ Handle<String> method_string = Handle<String>::cast(method_name); |
+ if (!StringEndsWithMethodName(isolate, function_string, method_string)) { |
+ builder->AppendCString(" [as "); |
+ builder->AppendString(method_string); |
+ builder->AppendCharacter(']'); |
+ } |
+ } |
+ } else { |
+ builder->AppendString(Handle<String>::cast(type_name)); |
+ builder->AppendCharacter('.'); |
+ if (IsNonEmptyString(method_name)) { |
+ builder->AppendString(Handle<String>::cast(method_name)); |
+ } else { |
+ builder->AppendCString("<anonymous>"); |
+ } |
+ } |
+} |
+ |
+void AppendFileLocation(Isolate* isolate, Handle<StackTraceFrame> frame, |
+ IncrementalStringBuilder* builder) { |
+ if (frame->IsNative()) { |
+ builder->AppendCString("native"); |
+ return; |
+ } |
+ |
+ Handle<Object> file_name = frame->GetScriptNameOrSourceUrl(); |
+ if (!file_name->IsString() && frame->IsEval()) { |
+ Handle<Object> eval_origin = frame->GetEvalOrigin(); |
+ DCHECK(eval_origin->IsString()); |
+ builder->AppendString(Handle<String>::cast(eval_origin)); |
+ builder->AppendCString(", "); // Expecting source position to follow. |
+ } |
+ |
+ if (IsNonEmptyString(file_name)) { |
+ builder->AppendString(Handle<String>::cast(file_name)); |
+ } else { |
+ // Source code does not originate from a file and is not native, but we |
+ // can still get the source position inside the source string, e.g. in |
+ // an eval string. |
+ builder->AppendCString("<anonymous>"); |
+ } |
+ |
+ int line_number = frame->GetLineNumber(); |
+ if (line_number != -1) { |
+ builder->AppendCharacter(':'); |
+ Handle<String> line_string = isolate->factory()->NumberToString( |
+ handle(Smi::FromInt(line_number), isolate), isolate); |
+ builder->AppendString(line_string); |
+ |
+ int column_number = frame->GetColumnNumber(); |
+ if (column_number != -1) { |
+ builder->AppendCharacter(':'); |
+ Handle<String> column_string = isolate->factory()->NumberToString( |
+ handle(Smi::FromInt(column_number), isolate), isolate); |
+ builder->AppendString(column_string); |
+ } |
+ } |
+} |
+ |
+Handle<String> JSSTToString(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsJavaScriptFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ IncrementalStringBuilder builder(isolate); |
+ |
+ Handle<Object> function_name = frame->GetFunctionName(); |
+ |
+ const bool is_toplevel = frame->IsToplevel(); |
+ const bool is_constructor = frame->IsConstructor(); |
+ const bool is_method_call = !(is_toplevel || is_constructor); |
+ |
+ if (is_method_call) { |
+ AppendMethodCall(isolate, frame, &builder); |
+ } else if (is_constructor) { |
+ builder.AppendCString("new "); |
+ if (IsNonEmptyString(function_name)) { |
+ builder.AppendString(Handle<String>::cast(function_name)); |
+ } else { |
+ builder.AppendCString("<anonymous>"); |
+ } |
+ } else if (IsNonEmptyString(function_name)) { |
+ builder.AppendString(Handle<String>::cast(function_name)); |
+ } else { |
+ AppendFileLocation(isolate, frame, &builder); |
+ return builder.Finish().ToHandleChecked(); |
+ } |
+ |
+ builder.AppendCString(" ("); |
+ AppendFileLocation(isolate, frame, &builder); |
+ builder.AppendCString(")"); |
+ |
+ return builder.Finish().ToHandleChecked(); |
+} |
+ |
+int WasmSTGetPosition(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ const int off = frame->offset(); |
+ return (off < 0) ? -1 - off : frame->abstract_code()->SourcePosition(off); |
+} |
+ |
+Handle<Object> WasmSTGetFileName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ return isolate->factory()->null_value(); |
+} |
+ |
+Handle<Object> WasmSTGetFunctionName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ |
+ Isolate* isolate = frame->GetIsolate(); |
+ |
+ return wasm::GetWasmFunctionNameOrNull(isolate, |
+ handle(frame->wasm_object(), isolate), |
+ frame->wasm_function_index()); |
+} |
+ |
+Handle<Object> WasmSTGetScriptNameOrSourceUrl(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ return isolate->factory()->null_value(); |
+} |
+ |
+Handle<Object> WasmSTGetMethodName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ return isolate->factory()->null_value(); |
+} |
+ |
+Handle<Object> WasmSTGetTypeName(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ |
+ Isolate* isolate = frame->GetIsolate(); |
+ Handle<Object> recv = handle(frame->wasm_object(), isolate); |
+ |
+ if (recv->IsUndefined(isolate)) return isolate->factory()->null_value(); |
+ |
+ DCHECK(wasm::IsWasmObject(*recv)); |
+ Handle<JSReceiver> receiver_object = |
+ Object::ToObject(isolate, recv).ToHandleChecked(); |
+ return JSReceiver::GetConstructorName(receiver_object); |
+} |
+ |
+Handle<Object> WasmSTGetEvalOrigin(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ return isolate->factory()->null_value(); |
+} |
+ |
+int WasmSTGetLineNumber(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ return frame->wasm_function_index(); |
+} |
+ |
+int WasmSTGetColumnNumber(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ return -1; |
+} |
+ |
+bool WasmSTIsNative(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ return false; |
+} |
+ |
+bool WasmSTIsToplevel(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ return false; |
+} |
+ |
+bool WasmSTIsEval(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ return false; |
+} |
+ |
+bool WasmSTIsConstructor(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ return false; |
+} |
+ |
+Handle<String> WasmSTToString(Handle<StackTraceFrame> frame) { |
+ DCHECK(frame->IsWasmFrame()); |
+ Isolate* isolate = frame->GetIsolate(); |
+ IncrementalStringBuilder builder(isolate); |
+ |
+ Handle<Object> name = frame->GetFunctionName(); |
+ if (name->IsNull(isolate)) { |
+ builder.AppendCString("<WASM UNNAMED>"); |
+ } else { |
+ DCHECK(name->IsString()); |
+ builder.AppendString(Handle<String>::cast(name)); |
+ } |
+ |
+ builder.AppendCString(" (<WASM>["); |
+ |
+ Handle<String> ix = isolate->factory()->NumberToString( |
+ handle(Smi::FromInt(frame->wasm_function_index()), isolate)); |
+ builder.AppendString(ix); |
+ |
+ builder.AppendCString("]+"); |
+ |
+ Handle<Object> pos = handle(Smi::FromInt(frame->GetPosition()), isolate); |
+ builder.AppendString(isolate->factory()->NumberToString(pos)); |
+ builder.AppendCString(")"); |
+ |
+ return builder.Finish().ToHandleChecked(); |
+} |
+ |
+} // namespace |
+ |
+#define STACK_TRACE_FRAME_DISPATCH(return_type, name) \ |
+ return_type StackTraceFrame::name() { \ |
+ if (IsJavaScriptFrame()) { \ |
+ return JSST##name(handle(this)); \ |
+ } else { \ |
+ DCHECK(IsWasmFrame()); \ |
+ return WasmST##name(handle(this)); \ |
+ } \ |
+ } |
+ |
+STACK_TRACE_FRAME_DISPATCH(int, GetPosition) |
+STACK_TRACE_FRAME_DISPATCH(Handle<Object>, GetFileName) |
+STACK_TRACE_FRAME_DISPATCH(Handle<Object>, GetFunctionName) |
+STACK_TRACE_FRAME_DISPATCH(Handle<Object>, GetScriptNameOrSourceUrl) |
+STACK_TRACE_FRAME_DISPATCH(Handle<Object>, GetMethodName) |
+STACK_TRACE_FRAME_DISPATCH(Handle<Object>, GetTypeName) |
+STACK_TRACE_FRAME_DISPATCH(Handle<Object>, GetEvalOrigin) |
+STACK_TRACE_FRAME_DISPATCH(int, GetLineNumber) |
+STACK_TRACE_FRAME_DISPATCH(int, GetColumnNumber) |
+STACK_TRACE_FRAME_DISPATCH(bool, IsNative) |
+STACK_TRACE_FRAME_DISPATCH(bool, IsToplevel) |
+STACK_TRACE_FRAME_DISPATCH(bool, IsEval) |
+STACK_TRACE_FRAME_DISPATCH(bool, IsConstructor) |
+STACK_TRACE_FRAME_DISPATCH(Handle<String>, ToString) |
+#undef STACK_TRACE_FRAME_DISPATCH |
SharedFunctionInfo::Iterator::Iterator(Isolate* isolate) |
: script_iterator_(isolate), |