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

Unified Diff: src/isolate.cc

Issue 1510153002: Revert of Support intriscDefaultProto for Error functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/bootstrapper.cc ('k') | src/js/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index a3456c4600212a99cd1ec0eb3b9320f3e303b2ae..d5cda54a1859fac6cccb6b7e8bad31c340fb03d5 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1348,14 +1348,21 @@
}
-// Use stack_trace_symbol as proxy for [[ErrorData]].
-bool Isolate::IsErrorObject(Handle<Object> object) {
- Handle<Name> symbol = factory()->stack_trace_symbol();
- if (!object->IsJSObject()) return false;
- Maybe<bool> has_stack_trace =
- JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), symbol);
- DCHECK(!has_stack_trace.IsNothing());
- return has_stack_trace.FromJust();
+// Traverse prototype chain to find out whether the object is derived from
+// the Error object.
+bool Isolate::IsErrorObject(Handle<Object> obj) {
+ if (!obj->IsJSObject()) return false;
+ Handle<Object> error_constructor = error_function();
+ DisallowHeapAllocation no_gc;
+ for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER);
+ !iter.IsAtEnd(); iter.Advance()) {
+ if (iter.GetCurrent()->IsJSProxy()) return false;
+ if (iter.GetCurrent<JSObject>()->map()->GetConstructor() ==
+ *error_constructor) {
+ return true;
+ }
+ }
+ return false;
}
« no previous file with comments | « src/bootstrapper.cc ('k') | src/js/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698