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

Unified Diff: src/messages.cc

Issue 1122973002: Move more parts of stack trace formatting to runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.cc
diff --git a/src/messages.cc b/src/messages.cc
index 7dc5f64f00c9e3ee9966e8105dfc6a0a64970728..b3570f3f5eb1fb1c80467baae31a6c9d6fecfb31 100644
--- a/src/messages.cc
+++ b/src/messages.cc
@@ -197,6 +197,53 @@ Handle<Object> CallSite::GetScriptNameOrSourceUrl(Isolate* isolate) {
}
+bool CheckMethodName(Handle<JSObject> obj, Handle<Name> name,
+ Handle<JSFunction> fun) {
Igor Sheludko 2015/05/05 10:30:49 Maybe it's better to use LookupIterator here.
+ if (obj->IsAccessCheckNeeded()) return false;
+ if (JSObject::GetDataProperty(obj, name).is_identical_to(fun)) return true;
+ Handle<Object> getter =
+ JSObject::GetAccessor(obj, name, ACCESSOR_GETTER).ToHandleChecked();
+ if (getter.is_identical_to(fun)) return true;
+ Handle<Object> setter =
+ JSObject::GetAccessor(obj, name, ACCESSOR_SETTER).ToHandleChecked();
+ return setter.is_identical_to(fun);
+}
+
+
+Handle<Object> CallSite::GetMethodName(Isolate* isolate) {
+ MaybeHandle<JSReceiver> maybe = Object::ToObject(isolate, receiver_);
+ Handle<JSReceiver> receiver;
+ if (!maybe.ToHandle(&receiver) || !receiver->IsJSObject()) {
+ return isolate->factory()->null_value();
+ }
+
+ Handle<JSObject> obj = Handle<JSObject>::cast(receiver);
+ Handle<Object> function_name(fun_->shared()->name(), isolate);
+ if (function_name->IsName()) {
+ Handle<Name> name = Handle<Name>::cast(function_name);
+ if (CheckMethodName(obj, name, fun_)) return function_name;
+ }
+
+ HandleScope scope(isolate);
+ Handle<Object> name;
+ for (PrototypeIterator iter(isolate, obj,
+ PrototypeIterator::START_AT_RECEIVER);
+ !iter.IsAtEnd(); iter.Advance()) {
+ Handle<JSObject> current =
+ Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
+ if (current->IsAccessCheckNeeded()) break;
+ Handle<Object> lookup(current->SlowReverseLookup(*fun_), isolate);
Igor Sheludko 2015/05/05 10:30:49 SlowReverseLookup() does not look into accessor pa
+ if (lookup->IsName()) {
+ if (!name.is_null()) break;
Igor Sheludko 2015/05/05 10:30:49 You probably wanted to return null at this point t
+ name = lookup;
+ }
+ }
+
+ if (!name.is_null()) return scope.CloseAndEscape(name);
+ return isolate->factory()->null_value();
+}
+
+
int CallSite::GetLineNumber(Isolate* isolate) {
if (pos_ >= 0) {
Handle<Object> script_obj(fun_->shared()->script(), isolate);
@@ -242,6 +289,15 @@ bool CallSite::IsEval(Isolate* isolate) {
}
+bool CallSite::IsConstructor(Isolate* isolate) {
+ if (!receiver_->IsJSObject()) return false;
+ Handle<Object> constructor =
+ JSObject::GetDataProperty(Handle<JSObject>::cast(receiver_),
+ isolate->factory()->constructor_string());
+ return constructor.is_identical_to(fun_);
+}
+
+
MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
Handle<String> arg0,
Handle<String> arg1,
« no previous file with comments | « src/messages.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698