Commit 0a3e0cc6 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] Fix crash when no map is passed to extern class constructor

This CL adds a check and a more descriptive error message when no "map"
is passed when constructing an extern class:

extern class Foo extends HeapObject {...}
const f = new Foo {};

R=sigurds@chromium.org

Bug: v8:7793
Change-Id: I0dfa6d5976e98d572bafcf7a87f701ea97cd6a73
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1611804
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61537}
parent 0fbc34d5
......@@ -1471,8 +1471,13 @@ VisitResult ImplementationVisitor::Visit(NewExpression* expr) {
ReportError(
"external classes initializers must have a map as first parameter");
}
VisitResult object_map =
initializer_results.field_value_map[map_field.name_and_type.name];
NameValueMap initializer_fields = initializer_results.field_value_map;
if (initializer_fields.find(map_field.name_and_type.name) ==
initializer_fields.end()) {
ReportError("Constructor for ", class_type->name(),
" needs Map argument!");
}
VisitResult object_map = initializer_fields[map_field.name_and_type.name];
Arguments size_arguments;
size_arguments.parameters.push_back(object_map);
VisitResult object_size = GenerateCall("%GetAllocationBaseSize",
......
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