OLD | NEW |
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 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 int pos = PositionFromStackTrace(elements, i); | 1341 int pos = PositionFromStackTrace(elements, i); |
1342 Handle<Script> casted_script(Script::cast(script)); | 1342 Handle<Script> casted_script(Script::cast(script)); |
1343 *target = MessageLocation(casted_script, pos, pos + 1); | 1343 *target = MessageLocation(casted_script, pos, pos + 1); |
1344 return true; | 1344 return true; |
1345 } | 1345 } |
1346 } | 1346 } |
1347 return false; | 1347 return false; |
1348 } | 1348 } |
1349 | 1349 |
1350 | 1350 |
1351 // Use stack_trace_symbol as proxy for [[ErrorData]]. | 1351 // Traverse prototype chain to find out whether the object is derived from |
1352 bool Isolate::IsErrorObject(Handle<Object> object) { | 1352 // the Error object. |
1353 Handle<Name> symbol = factory()->stack_trace_symbol(); | 1353 bool Isolate::IsErrorObject(Handle<Object> obj) { |
1354 if (!object->IsJSObject()) return false; | 1354 if (!obj->IsJSObject()) return false; |
1355 Maybe<bool> has_stack_trace = | 1355 Handle<Object> error_constructor = error_function(); |
1356 JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), symbol); | 1356 DisallowHeapAllocation no_gc; |
1357 DCHECK(!has_stack_trace.IsNothing()); | 1357 for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); |
1358 return has_stack_trace.FromJust(); | 1358 !iter.IsAtEnd(); iter.Advance()) { |
| 1359 if (iter.GetCurrent()->IsJSProxy()) return false; |
| 1360 if (iter.GetCurrent<JSObject>()->map()->GetConstructor() == |
| 1361 *error_constructor) { |
| 1362 return true; |
| 1363 } |
| 1364 } |
| 1365 return false; |
1359 } | 1366 } |
1360 | 1367 |
1361 | 1368 |
1362 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, | 1369 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, |
1363 MessageLocation* location) { | 1370 MessageLocation* location) { |
1364 Handle<JSArray> stack_trace_object; | 1371 Handle<JSArray> stack_trace_object; |
1365 if (capture_stack_trace_for_uncaught_exceptions_) { | 1372 if (capture_stack_trace_for_uncaught_exceptions_) { |
1366 if (IsErrorObject(exception)) { | 1373 if (IsErrorObject(exception)) { |
1367 // We fetch the stack trace that corresponds to this error object. | 1374 // We fetch the stack trace that corresponds to this error object. |
1368 // If the lookup fails, the exception is probably not a valid Error | 1375 // If the lookup fails, the exception is probably not a valid Error |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 // Then check whether this scope intercepts. | 2830 // Then check whether this scope intercepts. |
2824 if ((flag & intercept_mask_)) { | 2831 if ((flag & intercept_mask_)) { |
2825 intercepted_flags_ |= flag; | 2832 intercepted_flags_ |= flag; |
2826 return true; | 2833 return true; |
2827 } | 2834 } |
2828 return false; | 2835 return false; |
2829 } | 2836 } |
2830 | 2837 |
2831 } // namespace internal | 2838 } // namespace internal |
2832 } // namespace v8 | 2839 } // namespace v8 |
OLD | NEW |