Commit ec411b5d authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[builtins] Fix assertion in %TypedArray%.prototype.map

The assertion was too strict, not matching the check in JSTypedArray::Create.
Delete the TODO because the code does not actually rely on the assertion for safety: EmitElementStore always performs a length check.
Drive-by-fix: KeyedAccessStoreMode::STANDARD_STORE is equally safe and does one comparison less.

Bug: chromium:724889
Change-Id: I988a4eb6ad36d35143a008f7289b075f5c05e7ed
Reviewed-on: https://chromium-review.googlesource.com/517102Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45617}
parent 6fb42018
...@@ -168,11 +168,10 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler { ...@@ -168,11 +168,10 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler {
// 6. Let A be ? TypedArraySpeciesCreate(O, len). // 6. Let A be ? TypedArraySpeciesCreate(O, len).
Node* a = TypedArraySpeciesCreateByLength(context(), o(), len_); Node* a = TypedArraySpeciesCreateByLength(context(), o(), len_);
// In the Spec and our current implementation, the length check is already // In the Spec and our current implementation, the length check is already
// performed in TypedArraySpeciesCreate. Repeating the check here to // performed in TypedArraySpeciesCreate.
// keep this invariant local. CSA_ASSERT(this,
// TODO(tebbi): Change this to a release mode check. SmiLessThanOrEqual(
CSA_ASSERT( len_, LoadObjectField(a, JSTypedArray::kLengthOffset)));
this, WordEqual(len_, LoadObjectField(a, JSTypedArray::kLengthOffset)));
fast_typed_array_target_ = Word32Equal(LoadInstanceType(LoadElements(o_)), fast_typed_array_target_ = Word32Equal(LoadInstanceType(LoadElements(o_)),
LoadInstanceType(LoadElements(a))); LoadInstanceType(LoadElements(a)));
a_.Bind(a); a_.Bind(a);
...@@ -269,10 +268,8 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler { ...@@ -269,10 +268,8 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler {
// #sec-integerindexedelementset 3. Let numValue be ? ToNumber(value). // #sec-integerindexedelementset 3. Let numValue be ? ToNumber(value).
Node* num_value = ToNumber(context(), mappedValue); Node* num_value = ToNumber(context(), mappedValue);
// The only way how this can bailout is because of a detached buffer. // The only way how this can bailout is because of a detached buffer.
EmitElementStore( EmitElementStore(a(), k, num_value, false, source_elements_kind_,
a(), k, num_value, false, source_elements_kind_, KeyedAccessStoreMode::STANDARD_STORE, &detached);
KeyedAccessStoreMode::STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS,
&detached);
Goto(&done); Goto(&done);
BIND(&slow); BIND(&slow);
......
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