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

Unified Diff: src/runtime/runtime-internal.cc

Issue 1360793002: [builtins] Refactor Invoke to deal with any kind of callable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698