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

Side by Side Diff: src/isolate.cc

Issue 1496333002: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 int pos = PositionFromStackTrace(elements, i); 1349 int pos = PositionFromStackTrace(elements, i);
1350 Handle<Script> casted_script(Script::cast(script)); 1350 Handle<Script> casted_script(Script::cast(script));
1351 *target = MessageLocation(casted_script, pos, pos + 1); 1351 *target = MessageLocation(casted_script, pos, pos + 1);
1352 return true; 1352 return true;
1353 } 1353 }
1354 } 1354 }
1355 return false; 1355 return false;
1356 } 1356 }
1357 1357
1358 1358
1359 // Traverse prototype chain to find out whether the object is derived from 1359 // Use stack_trace_symbol as proxy for [[ErrorData]].
1360 // the Error object. 1360 bool Isolate::IsErrorObject(Handle<Object> object) {
1361 bool Isolate::IsErrorObject(Handle<Object> obj) { 1361 Handle<Name> symbol = factory()->stack_trace_symbol();
1362 if (!obj->IsJSObject()) return false; 1362 if (!object->IsJSObject()) return false;
1363 Handle<Object> error_constructor = error_function(); 1363 Maybe<bool> has_stack_trace =
1364 DisallowHeapAllocation no_gc; 1364 JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), symbol);
1365 for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); 1365 DCHECK(!has_stack_trace.IsNothing());
1366 !iter.IsAtEnd(); iter.Advance()) { 1366 return has_stack_trace.FromJust();
1367 if (iter.GetCurrent()->IsJSProxy()) return false;
1368 if (iter.GetCurrent<JSObject>()->map()->GetConstructor() ==
1369 *error_constructor) {
1370 return true;
1371 }
1372 }
1373 return false;
1374 } 1367 }
1375 1368
1376 1369
1377 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, 1370 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception,
1378 MessageLocation* location) { 1371 MessageLocation* location) {
1379 Handle<JSArray> stack_trace_object; 1372 Handle<JSArray> stack_trace_object;
1380 if (capture_stack_trace_for_uncaught_exceptions_) { 1373 if (capture_stack_trace_for_uncaught_exceptions_) {
1381 if (IsErrorObject(exception)) { 1374 if (IsErrorObject(exception)) {
1382 // We fetch the stack trace that corresponds to this error object. 1375 // We fetch the stack trace that corresponds to this error object.
1383 // If the lookup fails, the exception is probably not a valid Error 1376 // If the lookup fails, the exception is probably not a valid Error
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 // Then check whether this scope intercepts. 2831 // Then check whether this scope intercepts.
2839 if ((flag & intercept_mask_)) { 2832 if ((flag & intercept_mask_)) {
2840 intercepted_flags_ |= flag; 2833 intercepted_flags_ |= flag;
2841 return true; 2834 return true;
2842 } 2835 }
2843 return false; 2836 return false;
2844 } 2837 }
2845 2838
2846 } // namespace internal 2839 } // namespace internal
2847 } // namespace v8 2840 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/js/messages.js » ('j') | test/mjsunit/error-constructors.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698