[wasm-gc] Omit null checks for array.len when possible

Null checks were not optimized out for non-nullable arrays for array.len.
This CL brings array.len in line with the rest of the gc operations.

Bug: v8:7748
Change-Id: I8d4d5f159ed220f6e64cb812079e15d6e92de68b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2567690
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71529}
This commit is contained in:
Manos Koukoutos 2020-12-01 06:41:36 +00:00 committed by Commit Bot
parent 20236145af
commit f46383809a
3 changed files with 12 additions and 5 deletions

View File

@ -5937,10 +5937,12 @@ Node* WasmGraphBuilder::ArraySet(Node* array_object,
type->element_type());
}
Node* WasmGraphBuilder::ArrayLen(Node* array_object,
Node* WasmGraphBuilder::ArrayLen(Node* array_object, CheckForNull null_check,
wasm::WasmCodePosition position) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(array_object, RefNull()), position);
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(array_object, RefNull()), position);
}
return gasm_->LoadWasmArrayLength(array_object);
}

View File

@ -425,7 +425,8 @@ class WasmGraphBuilder {
Node* ArraySet(Node* array_object, const wasm::ArrayType* type, Node* index,
Node* value, CheckForNull null_check,
wasm::WasmCodePosition position);
Node* ArrayLen(Node* array_object, wasm::WasmCodePosition position);
Node* ArrayLen(Node* array_object, CheckForNull null_check,
wasm::WasmCodePosition position);
Node* I31New(Node* input);
Node* I31GetS(Node* input);
Node* I31GetU(Node* input);

View File

@ -775,7 +775,11 @@ class WasmGraphBuildingInterface {
}
void ArrayLen(FullDecoder* decoder, const Value& array_obj, Value* result) {
result->node = BUILD(ArrayLen, array_obj.node, decoder->position());
CheckForNull null_check = array_obj.type.is_nullable()
? CheckForNull::kWithNullCheck
: CheckForNull::kWithoutNullCheck;
result->node =
BUILD(ArrayLen, array_obj.node, null_check, decoder->position());
}
void I31New(FullDecoder* decoder, const Value& input, Value* result) {