Commit 1d00b785 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[runtime] Fix source location for CallWithSpread with errors

Unify error handling for errors in CallWithSpread Bytecode and thus
fix source location mismatches.

Bug: v8:10378
Change-Id: If224cd34f1306492059dbedd8d2ca5c0feee5658
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2162856Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67365}
parent e0df158b
......@@ -317,7 +317,9 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
BIND(&if_generic);
{
Label if_iterator_fn_not_callable(this, Label::kDeferred),
if_iterator_is_null_or_undefined(this, Label::kDeferred);
if_iterator_is_null_or_undefined(this, Label::kDeferred),
throw_spread_error(this, Label::kDeferred);
TVARIABLE(Smi, message_id);
GotoIf(IsNullOrUndefined(spread), &if_iterator_is_null_or_undefined);
......@@ -336,10 +338,18 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
&if_smiorobject, &if_double);
BIND(&if_iterator_fn_not_callable);
ThrowTypeError(context, MessageTemplate::kIteratorSymbolNonCallable);
message_id = SmiConstant(
static_cast<int>(MessageTemplate::kIteratorSymbolNonCallable)),
Goto(&throw_spread_error);
BIND(&if_iterator_is_null_or_undefined);
CallRuntime(Runtime::kThrowSpreadArgIsNullOrUndefined, context, spread);
message_id = SmiConstant(
static_cast<int>(MessageTemplate::kNotIterableNoSymbolLoad));
Goto(&throw_spread_error);
BIND(&throw_spread_error);
CallRuntime(Runtime::kThrowSpreadArgError, context, message_id.value(),
spread);
Unreachable();
}
......
......@@ -2241,12 +2241,14 @@ void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
os << "\n - break_points: ";
break_points().FixedArrayPrint(os);
os << "\n - coverage_info: " << Brief(coverage_info());
os << "\n";
}
void WasmValue::WasmValuePrint(std::ostream& os) { // NOLINT
PrintHeader(os, "WasmValue");
os << "\n - value_type: " << value_type();
os << "\n - bytes: " << Brief(bytes());
os << "\n";
}
void StackTraceFrame::StackTraceFramePrint(std::ostream& os) { // NOLINT
......@@ -2254,6 +2256,7 @@ void StackTraceFrame::StackTraceFramePrint(std::ostream& os) { // NOLINT
os << "\n - frame_index: " << frame_index();
os << "\n - id: " << id();
os << "\n - frame_info: " << Brief(frame_info());
os << "\n";
}
void StackFrameInfo::StackFrameInfoPrint(std::ostream& os) { // NOLINT
......
......@@ -622,8 +622,9 @@ class FrameArrayBuilder {
if (is_constructor) flags |= FrameArray::kIsConstructor;
Handle<FixedArray> parameters = isolate_->factory()->empty_fixed_array();
if (V8_UNLIKELY(FLAG_detailed_error_stack_trace))
if (V8_UNLIKELY(FLAG_detailed_error_stack_trace)) {
parameters = summary.parameters();
}
elements_ = FrameArray::AppendJSFrame(
elements_, TheHoleToUndefined(isolate_, summary.receiver()), function,
......
......@@ -1308,8 +1308,8 @@ Handle<Object> ErrorUtils::NewIteratorError(Isolate* isolate,
return isolate->factory()->NewTypeError(id, callsite);
}
Object ErrorUtils::ThrowSpreadArgIsNullOrUndefinedError(Isolate* isolate,
Handle<Object> object) {
Object ErrorUtils::ThrowSpreadArgError(Isolate* isolate, MessageTemplate id,
Handle<Object> object) {
MessageLocation location;
Handle<String> callsite;
if (ComputeLocation(isolate, &location)) {
......@@ -1337,7 +1337,6 @@ Object ErrorUtils::ThrowSpreadArgIsNullOrUndefinedError(Isolate* isolate,
}
}
MessageTemplate id = MessageTemplate::kNotIterableNoSymbolLoad;
Handle<Object> exception =
isolate->factory()->NewTypeError(id, callsite, object);
return isolate->Throw(*exception, &location);
......
......@@ -297,8 +297,8 @@ class ErrorUtils : public AllStatic {
Handle<Object> source);
static Handle<Object> NewConstructedNonConstructable(Isolate* isolate,
Handle<Object> source);
static Object ThrowSpreadArgIsNullOrUndefinedError(Isolate* isolate,
Handle<Object> object);
static Object ThrowSpreadArgError(Isolate* isolate, MessageTemplate id,
Handle<Object> object);
static Object ThrowLoadFromNullOrUndefined(Isolate* isolate,
Handle<Object> object);
static Object ThrowLoadFromNullOrUndefined(Isolate* isolate,
......
......@@ -427,11 +427,13 @@ RUNTIME_FUNCTION(Runtime_ThrowIteratorError) {
return isolate->Throw(*ErrorUtils::NewIteratorError(isolate, object));
}
RUNTIME_FUNCTION(Runtime_ThrowSpreadArgIsNullOrUndefined) {
RUNTIME_FUNCTION(Runtime_ThrowSpreadArgError) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
return ErrorUtils::ThrowSpreadArgIsNullOrUndefinedError(isolate, object);
DCHECK_EQ(2, args.length());
CONVERT_SMI_ARG_CHECKED(message_id_smi, 0);
MessageTemplate message_id = MessageTemplateFromInt(message_id_smi);
CONVERT_ARG_HANDLE_CHECKED(Object, object, 1);
return ErrorUtils::ThrowSpreadArgError(isolate, message_id, object);
}
RUNTIME_FUNCTION(Runtime_ThrowCalledNonCallable) {
......
......@@ -239,7 +239,7 @@ namespace internal {
F(ThrowInvalidStringLength, 0, 1) \
F(ThrowInvalidTypedArrayAlignment, 2, 1) \
F(ThrowIteratorError, 1, 1) \
F(ThrowSpreadArgIsNullOrUndefined, 1, 1) \
F(ThrowSpreadArgError, 2, 1) \
F(ThrowIteratorResultNotAnObject, 1, 1) \
F(ThrowNotConstructor, 1, 1) \
F(ThrowPatternAssignmentNonCoercible, 1, 1) \
......
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