Commit 3935d6f6 authored by Adam Klein's avatar Adam Klein Committed by V8 LUCI CQ

Add MAYBE_RETURN_ON_EXCEPTION_VALUE macro and use it in Temporal

This is useful for cases where we're calling a Maybe-returning
function only for its side effects and possible exception-throwing.

Change-Id: I64e73598d40b3565d83cb17166c762d8affd7a84
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3708022Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81201}
parent 2506d6ca
......@@ -406,6 +406,14 @@ class StackMemory;
#define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
#define MAYBE_RETURN_ON_EXCEPTION_VALUE(isolate, call, value) \
do { \
if ((call).IsNothing()) { \
DCHECK((isolate)->has_pending_exception()); \
return value; \
} \
} while (false)
#define MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \
do { \
if (!(call).To(&dst)) { \
......
......@@ -1985,14 +1985,14 @@ Maybe<ShowOverflow> ToTemporalOverflow(Isolate* isolate, Handle<Object> options,
ShowOverflow::kConstrain);
}
// TODO(adamk): Remove this and replace with direct usage of
// MAYBE_RETURN_ON_EXCEPTION_VALUE().
Maybe<bool> ToTemporalOverflowForSideEffects(Isolate* isolate,
Handle<Object> options,
const char* method_name) {
ShowOverflow overflow;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, overflow, ToTemporalOverflow(isolate, options, method_name),
MAYBE_RETURN_ON_EXCEPTION_VALUE(
isolate, ToTemporalOverflow(isolate, options, method_name),
Nothing<bool>());
USE(overflow);
return Just(true);
}
......@@ -9916,11 +9916,9 @@ MaybeHandle<JSTemporalPlainMonthDay> ToTemporalMonthDay(
return MonthDayFromFields(isolate, calendar, fields, options);
}
// 4. Perform ? ToTemporalOverflow(options).
ShowOverflow overflow;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, overflow, ToTemporalOverflow(isolate, options, method_name),
MAYBE_RETURN_ON_EXCEPTION_VALUE(
isolate, ToTemporalOverflow(isolate, options, method_name),
Handle<JSTemporalPlainMonthDay>());
USE(overflow);
// 5. Let string be ? ToString(item).
Handle<String> string;
......@@ -9996,11 +9994,9 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainMonthDay::From(
// internal slot, then
if (item->IsJSTemporalPlainMonthDay()) {
// a. Perform ? ToTemporalOverflow(options).
ShowOverflow overflow;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, overflow, ToTemporalOverflow(isolate, options, method_name),
MAYBE_RETURN_ON_EXCEPTION_VALUE(
isolate, ToTemporalOverflow(isolate, options, method_name),
Handle<JSTemporalPlainMonthDay>());
USE(overflow);
// b. Return ? CreateTemporalMonthDay(item.[[ISOMonth]], item.[[ISODay]],
// item.[[Calendar]], item.[[ISOYear]]).
Handle<JSTemporalPlainMonthDay> month_day =
......
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