Throw when attaching a stack trace to an object fails.

R=jarin@chromium.org
BUG=chromium:478011
LOG=N

Review URL: https://codereview.chromium.org/1077153003

Cr-Commit-Position: refs/heads/master@{#27941}
This commit is contained in:
yangguo 2015-04-20 07:41:00 -07:00 committed by Commit bot
parent f66a31282a
commit 8cf289ca4f
4 changed files with 27 additions and 10 deletions

View File

@ -414,24 +414,31 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
}
void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) {
MaybeHandle<JSObject> Isolate::CaptureAndSetDetailedStackTrace(
Handle<JSObject> error_object) {
if (capture_stack_trace_for_uncaught_exceptions_) {
// Capture stack trace for a detailed exception message.
Handle<Name> key = factory()->detailed_stack_trace_symbol();
Handle<JSArray> stack_trace = CaptureCurrentStackTrace(
stack_trace_for_uncaught_exceptions_frame_limit_,
stack_trace_for_uncaught_exceptions_options_);
JSObject::SetProperty(error_object, key, stack_trace, STRICT).Assert();
RETURN_ON_EXCEPTION(
this, JSObject::SetProperty(error_object, key, stack_trace, STRICT),
JSObject);
}
return error_object;
}
void Isolate::CaptureAndSetSimpleStackTrace(Handle<JSObject> error_object,
Handle<Object> caller) {
MaybeHandle<JSObject> Isolate::CaptureAndSetSimpleStackTrace(
Handle<JSObject> error_object, Handle<Object> caller) {
// Capture stack trace for simple stack trace string formatting.
Handle<Name> key = factory()->stack_trace_symbol();
Handle<Object> stack_trace = CaptureSimpleStackTrace(error_object, caller);
JSObject::SetProperty(error_object, key, stack_trace, STRICT).Assert();
RETURN_ON_EXCEPTION(
this, JSObject::SetProperty(error_object, key, stack_trace, STRICT),
JSObject);
return error_object;
}

View File

@ -725,9 +725,10 @@ class Isolate {
StackTrace::StackTraceOptions options);
Handle<Object> CaptureSimpleStackTrace(Handle<JSObject> error_object,
Handle<Object> caller);
void CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object);
void CaptureAndSetSimpleStackTrace(Handle<JSObject> error_object,
Handle<Object> caller);
MaybeHandle<JSObject> CaptureAndSetDetailedStackTrace(
Handle<JSObject> error_object);
MaybeHandle<JSObject> CaptureAndSetSimpleStackTrace(
Handle<JSObject> error_object, Handle<Object> caller);
Handle<JSArray> GetDetailedStackTrace(Handle<JSObject> error_object);
Handle<JSArray> GetDetailedFromSimpleStackTrace(
Handle<JSObject> error_object);

View File

@ -163,9 +163,11 @@ RUNTIME_FUNCTION(Runtime_CollectStackTrace) {
if (!isolate->bootstrapper()->IsActive()) {
// Optionally capture a more detailed stack trace for the message.
isolate->CaptureAndSetDetailedStackTrace(error_object);
RETURN_FAILURE_ON_EXCEPTION(
isolate, isolate->CaptureAndSetDetailedStackTrace(error_object));
// Capture a simple stack trace for the stack property.
isolate->CaptureAndSetSimpleStackTrace(error_object, caller);
RETURN_FAILURE_ON_EXCEPTION(
isolate, isolate->CaptureAndSetSimpleStackTrace(error_object, caller));
}
return isolate->heap()->undefined_value();
}

View File

@ -0,0 +1,7 @@
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var e = {};
Object.preventExtensions(e);
assertThrows(function() { Error.captureStackTrace(e) });