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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 return false; | 325 return false; |
326 } | 326 } |
327 } | 327 } |
328 return true; | 328 return true; |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object, | 332 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object, |
333 Handle<Object> caller) { | 333 Handle<Object> caller) { |
334 // Get stack trace limit. | 334 // Get stack trace limit. |
335 Handle<Object> error = Object::GetProperty( | 335 Handle<JSObject> error = error_function(); |
336 this, js_builtins_object(), "$Error").ToHandleChecked(); | |
337 if (!error->IsJSObject()) return factory()->undefined_value(); | |
338 | |
339 Handle<String> stackTraceLimit = | 336 Handle<String> stackTraceLimit = |
340 factory()->InternalizeUtf8String("stackTraceLimit"); | 337 factory()->InternalizeUtf8String("stackTraceLimit"); |
341 DCHECK(!stackTraceLimit.is_null()); | 338 DCHECK(!stackTraceLimit.is_null()); |
342 Handle<Object> stack_trace_limit = JSReceiver::GetDataProperty( | 339 Handle<Object> stack_trace_limit = |
343 Handle<JSObject>::cast(error), stackTraceLimit); | 340 JSReceiver::GetDataProperty(error, stackTraceLimit); |
344 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); | 341 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); |
345 int limit = FastD2IChecked(stack_trace_limit->Number()); | 342 int limit = FastD2IChecked(stack_trace_limit->Number()); |
346 limit = Max(limit, 0); // Ensure that limit is not negative. | 343 limit = Max(limit, 0); // Ensure that limit is not negative. |
347 | 344 |
348 int initial_size = Min(limit, 10); | 345 int initial_size = Min(limit, 10); |
349 Handle<FixedArray> elements = | 346 Handle<FixedArray> elements = |
350 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1); | 347 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1); |
351 | 348 |
352 // If the caller parameter is a function we skip frames until we're | 349 // If the caller parameter is a function we skip frames until we're |
353 // under it before starting to collect. | 350 // under it before starting to collect. |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 } | 1334 } |
1338 } | 1335 } |
1339 return false; | 1336 return false; |
1340 } | 1337 } |
1341 | 1338 |
1342 | 1339 |
1343 // Traverse prototype chain to find out whether the object is derived from | 1340 // Traverse prototype chain to find out whether the object is derived from |
1344 // the Error object. | 1341 // the Error object. |
1345 bool Isolate::IsErrorObject(Handle<Object> obj) { | 1342 bool Isolate::IsErrorObject(Handle<Object> obj) { |
1346 if (!obj->IsJSObject()) return false; | 1343 if (!obj->IsJSObject()) return false; |
1347 | 1344 Handle<Object> error_constructor = error_function(); |
1348 Handle<String> error_key = | |
1349 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("$Error")); | |
1350 Handle<Object> error_constructor = Object::GetProperty( | |
1351 js_builtins_object(), error_key).ToHandleChecked(); | |
1352 | |
1353 DisallowHeapAllocation no_gc; | 1345 DisallowHeapAllocation no_gc; |
1354 for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); | 1346 for (PrototypeIterator iter(this, *obj, PrototypeIterator::START_AT_RECEIVER); |
1355 !iter.IsAtEnd(); iter.Advance()) { | 1347 !iter.IsAtEnd(); iter.Advance()) { |
1356 if (iter.GetCurrent()->IsJSProxy()) return false; | 1348 if (iter.GetCurrent()->IsJSProxy()) return false; |
1357 if (JSObject::cast(iter.GetCurrent())->map()->GetConstructor() == | 1349 if (JSObject::cast(iter.GetCurrent())->map()->GetConstructor() == |
1358 *error_constructor) { | 1350 *error_constructor) { |
1359 return true; | 1351 return true; |
1360 } | 1352 } |
1361 } | 1353 } |
1362 return false; | 1354 return false; |
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2825 // Then check whether this scope intercepts. | 2817 // Then check whether this scope intercepts. |
2826 if ((flag & intercept_mask_)) { | 2818 if ((flag & intercept_mask_)) { |
2827 intercepted_flags_ |= flag; | 2819 intercepted_flags_ |= flag; |
2828 return true; | 2820 return true; |
2829 } | 2821 } |
2830 return false; | 2822 return false; |
2831 } | 2823 } |
2832 | 2824 |
2833 } // namespace internal | 2825 } // namespace internal |
2834 } // namespace v8 | 2826 } // namespace v8 |
OLD | NEW |