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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 isolate->factory()->NewFixedArrayWithHoles(new_capacity); | 348 isolate->factory()->NewFixedArrayWithHoles(new_capacity); |
349 for (int i = 0; i < cur_position; i++) { | 349 for (int i = 0; i < cur_position; i++) { |
350 new_elements->set(i, elements->get(i)); | 350 new_elements->set(i, elements->get(i)); |
351 } | 351 } |
352 elements = new_elements; | 352 elements = new_elements; |
353 } | 353 } |
354 DCHECK(new_size <= elements->length()); | 354 DCHECK(new_size <= elements->length()); |
355 return elements; | 355 return elements; |
356 } | 356 } |
357 | 357 |
358 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object, | 358 Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, |
359 Handle<Object> caller) { | 359 Handle<Object> caller) { |
360 // Get stack trace limit. | 360 // Get stack trace limit. |
361 Handle<JSObject> error = error_function(); | 361 Handle<JSObject> error = error_function(); |
362 Handle<String> stackTraceLimit = | 362 Handle<String> stackTraceLimit = |
363 factory()->InternalizeUtf8String("stackTraceLimit"); | 363 factory()->InternalizeUtf8String("stackTraceLimit"); |
364 DCHECK(!stackTraceLimit.is_null()); | 364 DCHECK(!stackTraceLimit.is_null()); |
365 Handle<Object> stack_trace_limit = | 365 Handle<Object> stack_trace_limit = |
366 JSReceiver::GetDataProperty(error, stackTraceLimit); | 366 JSReceiver::GetDataProperty(error, stackTraceLimit); |
367 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); | 367 if (!stack_trace_limit->IsNumber()) return factory()->undefined_value(); |
368 int limit = FastD2IChecked(stack_trace_limit->Number()); | 368 int limit = FastD2IChecked(stack_trace_limit->Number()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 449 } |
450 } | 450 } |
451 elements->set(0, Smi::FromInt(sloppy_frames)); | 451 elements->set(0, Smi::FromInt(sloppy_frames)); |
452 elements->Shrink(cursor); | 452 elements->Shrink(cursor); |
453 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); | 453 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); |
454 result->set_length(Smi::FromInt(cursor)); | 454 result->set_length(Smi::FromInt(cursor)); |
455 // TODO(yangguo): Queue this structured stack trace for preprocessing on GC. | 455 // TODO(yangguo): Queue this structured stack trace for preprocessing on GC. |
456 return result; | 456 return result; |
457 } | 457 } |
458 | 458 |
459 MaybeHandle<JSObject> Isolate::CaptureAndSetDetailedStackTrace( | 459 MaybeHandle<JSReceiver> Isolate::CaptureAndSetDetailedStackTrace( |
460 Handle<JSObject> error_object) { | 460 Handle<JSReceiver> error_object) { |
461 if (capture_stack_trace_for_uncaught_exceptions_) { | 461 if (capture_stack_trace_for_uncaught_exceptions_) { |
462 // Capture stack trace for a detailed exception message. | 462 // Capture stack trace for a detailed exception message. |
463 Handle<Name> key = factory()->detailed_stack_trace_symbol(); | 463 Handle<Name> key = factory()->detailed_stack_trace_symbol(); |
464 Handle<JSArray> stack_trace = CaptureCurrentStackTrace( | 464 Handle<JSArray> stack_trace = CaptureCurrentStackTrace( |
465 stack_trace_for_uncaught_exceptions_frame_limit_, | 465 stack_trace_for_uncaught_exceptions_frame_limit_, |
466 stack_trace_for_uncaught_exceptions_options_); | 466 stack_trace_for_uncaught_exceptions_options_); |
467 RETURN_ON_EXCEPTION( | 467 RETURN_ON_EXCEPTION( |
468 this, JSObject::SetProperty(error_object, key, stack_trace, STRICT), | 468 this, JSReceiver::SetProperty(error_object, key, stack_trace, STRICT), |
469 JSObject); | 469 JSReceiver); |
470 } | 470 } |
471 return error_object; | 471 return error_object; |
472 } | 472 } |
473 | 473 |
474 | 474 MaybeHandle<JSReceiver> Isolate::CaptureAndSetSimpleStackTrace( |
475 MaybeHandle<JSObject> Isolate::CaptureAndSetSimpleStackTrace( | 475 Handle<JSReceiver> error_object, Handle<Object> caller) { |
476 Handle<JSObject> error_object, Handle<Object> caller) { | |
477 // Capture stack trace for simple stack trace string formatting. | 476 // Capture stack trace for simple stack trace string formatting. |
478 Handle<Name> key = factory()->stack_trace_symbol(); | 477 Handle<Name> key = factory()->stack_trace_symbol(); |
479 Handle<Object> stack_trace = CaptureSimpleStackTrace(error_object, caller); | 478 Handle<Object> stack_trace = CaptureSimpleStackTrace(error_object, caller); |
480 RETURN_ON_EXCEPTION( | 479 RETURN_ON_EXCEPTION( |
481 this, JSObject::SetProperty(error_object, key, stack_trace, STRICT), | 480 this, JSReceiver::SetProperty(error_object, key, stack_trace, STRICT), |
482 JSObject); | 481 JSReceiver); |
483 return error_object; | 482 return error_object; |
484 } | 483 } |
485 | 484 |
486 | 485 |
487 Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) { | 486 Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) { |
488 Handle<Name> key_detailed = factory()->detailed_stack_trace_symbol(); | 487 Handle<Name> key_detailed = factory()->detailed_stack_trace_symbol(); |
489 Handle<Object> stack_trace = | 488 Handle<Object> stack_trace = |
490 JSReceiver::GetDataProperty(error_object, key_detailed); | 489 JSReceiver::GetDataProperty(error_object, key_detailed); |
491 if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace); | 490 if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace); |
492 | 491 |
(...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 // Then check whether this scope intercepts. | 2989 // Then check whether this scope intercepts. |
2991 if ((flag & intercept_mask_)) { | 2990 if ((flag & intercept_mask_)) { |
2992 intercepted_flags_ |= flag; | 2991 intercepted_flags_ |= flag; |
2993 return true; | 2992 return true; |
2994 } | 2993 } |
2995 return false; | 2994 return false; |
2996 } | 2995 } |
2997 | 2996 |
2998 } // namespace internal | 2997 } // namespace internal |
2999 } // namespace v8 | 2998 } // namespace v8 |
OLD | NEW |