Index: src/runtime/runtime-internal.cc |
diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc |
index 18b9481afc4d1f0a2299ace32cd9340c7e18aa29..90d5532af37a2e981bf3626a22bbf78392cc3f70 100644 |
--- a/src/runtime/runtime-internal.cc |
+++ b/src/runtime/runtime-internal.cc |
@@ -11,6 +11,8 @@ |
#include "src/frames-inl.h" |
#include "src/isolate-inl.h" |
#include "src/messages.h" |
+#include "src/parser.h" |
+#include "src/prettyprinter.h" |
namespace v8 { |
namespace internal { |
@@ -409,5 +411,39 @@ RUNTIME_FUNCTION(Runtime_GetCodeStubExportsObject) { |
return isolate->heap()->code_stub_exports_object(); |
} |
+ |
+namespace { |
+ |
+Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) { |
+ MessageLocation location; |
+ if (isolate->ComputeLocation(&location)) { |
+ Zone zone; |
+ base::SmartPointer<ParseInfo> info( |
+ location.function()->shared()->is_function() |
+ ? new ParseInfo(&zone, location.function()) |
+ : new ParseInfo(&zone, location.script())); |
+ if (Parser::ParseStatic(info.get())) { |
+ CallPrinter printer(isolate, &zone); |
+ const char* string = printer.Print(info->literal(), location.start_pos()); |
+ return isolate->factory()->NewStringFromAsciiChecked(string); |
+ } else { |
+ isolate->clear_pending_exception(); |
+ } |
+ } |
+ return Object::TypeOf(isolate, object); |
+} |
+ |
+} // namespace |
+ |
+ |
+RUNTIME_FUNCTION(Runtime_ThrowCalledNonCallable) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(1, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
+ Handle<String> callsite = RenderCallSite(isolate, object); |
+ THROW_NEW_ERROR_RETURN_FAILURE( |
+ isolate, NewTypeError(MessageTemplate::kCalledNonCallable, callsite)); |
+} |
+ |
} // namespace internal |
} // namespace v8 |