Commit 8cf289ca authored by yangguo's avatar yangguo Committed by Commit bot

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}
parent f66a3128
...@@ -414,24 +414,31 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object, ...@@ -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_) { if (capture_stack_trace_for_uncaught_exceptions_) {
// Capture stack trace for a detailed exception message. // Capture stack trace for a detailed exception message.
Handle<Name> key = factory()->detailed_stack_trace_symbol(); Handle<Name> key = factory()->detailed_stack_trace_symbol();
Handle<JSArray> stack_trace = CaptureCurrentStackTrace( Handle<JSArray> stack_trace = CaptureCurrentStackTrace(
stack_trace_for_uncaught_exceptions_frame_limit_, stack_trace_for_uncaught_exceptions_frame_limit_,
stack_trace_for_uncaught_exceptions_options_); 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, MaybeHandle<JSObject> Isolate::CaptureAndSetSimpleStackTrace(
Handle<Object> caller) { Handle<JSObject> error_object, Handle<Object> caller) {
// Capture stack trace for simple stack trace string formatting. // Capture stack trace for simple stack trace string formatting.
Handle<Name> key = factory()->stack_trace_symbol(); Handle<Name> key = factory()->stack_trace_symbol();
Handle<Object> stack_trace = CaptureSimpleStackTrace(error_object, caller); 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;
} }
......
...@@ -725,9 +725,10 @@ class Isolate { ...@@ -725,9 +725,10 @@ class Isolate {
StackTrace::StackTraceOptions options); StackTrace::StackTraceOptions options);
Handle<Object> CaptureSimpleStackTrace(Handle<JSObject> error_object, Handle<Object> CaptureSimpleStackTrace(Handle<JSObject> error_object,
Handle<Object> caller); Handle<Object> caller);
void CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object); MaybeHandle<JSObject> CaptureAndSetDetailedStackTrace(
void CaptureAndSetSimpleStackTrace(Handle<JSObject> error_object, Handle<JSObject> error_object);
Handle<Object> caller); MaybeHandle<JSObject> CaptureAndSetSimpleStackTrace(
Handle<JSObject> error_object, Handle<Object> caller);
Handle<JSArray> GetDetailedStackTrace(Handle<JSObject> error_object); Handle<JSArray> GetDetailedStackTrace(Handle<JSObject> error_object);
Handle<JSArray> GetDetailedFromSimpleStackTrace( Handle<JSArray> GetDetailedFromSimpleStackTrace(
Handle<JSObject> error_object); Handle<JSObject> error_object);
......
...@@ -163,9 +163,11 @@ RUNTIME_FUNCTION(Runtime_CollectStackTrace) { ...@@ -163,9 +163,11 @@ RUNTIME_FUNCTION(Runtime_CollectStackTrace) {
if (!isolate->bootstrapper()->IsActive()) { if (!isolate->bootstrapper()->IsActive()) {
// Optionally capture a more detailed stack trace for the message. // 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. // 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(); return isolate->heap()->undefined_value();
} }
......
// 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) });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment