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

Unified Diff: src/runtime/runtime.cc

Issue 1752133004: [proxies] throw TypeError in [[Call]] if is_callable Map bit is unset (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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.cc
diff --git a/src/runtime/runtime.cc b/src/runtime/runtime.cc
index 151e240f2505c89d6db87b4ed3829533df6c3471..c4f4120c80cbac9493ffb42351f866a9702b869b 100644
--- a/src/runtime/runtime.cc
+++ b/src/runtime/runtime.cc
@@ -5,10 +5,14 @@
#include "src/runtime/runtime.h"
#include "src/assembler.h"
+#include "src/ast/prettyprinter.h"
#include "src/contexts.h"
+#include "src/frames-inl.h"
#include "src/handles-inl.h"
#include "src/heap/heap.h"
+#include "src/isolate-inl.h"
#include "src/isolate.h"
+#include "src/parsing/parser.h"
#include "src/runtime/runtime-utils.h"
namespace v8 {
@@ -125,6 +129,50 @@ const Runtime::Function* Runtime::RuntimeFunctionTable(Isolate* isolate) {
}
}
+bool Runtime::ComputeLocation(Isolate* isolate, MessageLocation* target) {
+ JavaScriptFrameIterator it(isolate);
+ if (!it.done()) {
+ JavaScriptFrame* frame = it.frame();
+ JSFunction* fun = frame->function();
+ Object* script = fun->shared()->script();
+ if (script->IsScript() &&
+ !(Script::cast(script)->source()->IsUndefined())) {
+ Handle<Script> casted_script(Script::cast(script));
+ // Compute the location from the function and the relocation info of the
+ // baseline code. For optimized code this will use the deoptimization
+ // information to get canonical location information.
+ List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+ it.frame()->Summarize(&frames);
+ FrameSummary& summary = frames.last();
+ int pos = summary.abstract_code()->SourcePosition(summary.code_offset());
+ *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
+ return true;
+ }
+ }
+ return false;
+}
+
+Handle<String> Runtime::RenderCallSite(Isolate* isolate,
+ Handle<Object> object) {
+ MessageLocation location;
+ if (ComputeLocation(isolate, &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, location.function()->shared()->IsBuiltin());
+ const char* string = printer.Print(info->literal(), location.start_pos());
+ if (strlen(string) > 0) {
+ return isolate->factory()->NewStringFromAsciiChecked(string);
+ }
+ } else {
+ isolate->clear_pending_exception();
+ }
+ }
+ return Object::TypeOf(isolate, object);
+}
std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) {
return os << Runtime::FunctionForId(id)->name;

Powered by Google App Engine
This is Rietveld 408576698