|
|
Chromium Code Reviews
DescriptionMove Oddball/String to %Typearray%.prototype.fill fast path
ToNumber for Oddball/String has no side-effect, no need to go
through %Typearray%.prototype.fill slow path.
BUG=v8:5929, chromium:702902
Review-Url: https://codereview.chromium.org/2769673002
Cr-Commit-Position: refs/heads/master@{#44129}
Committed: https://chromium.googlesource.com/v8/v8/+/a1f2239e0b7daff6bbf728d4f744ef6ee52f5299
Patch Set 1 #
Total comments: 5
Patch Set 2 : minor changes #Patch Set 3 : beautify test #
Total comments: 2
Patch Set 4 : Oddball and String #Messages
Total messages: 18 (7 generated)
loorongjie@gmail.com changed reviewers: + bmeurer@chromium.org, caitp@igalia.com, cbruni@chromium.org
Description was changed from ========== Move Boolean/null/undefined to TA.p.fill fast path ToNumber for Boolean/null/undefined has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ========== to ========== Move Boolean/null/undefined to TA.p.fill fast path ToNumber for Boolean/null/undefined has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ==========
I think it would be fine to only handle undefined on the fast path. Maybe `null` too, but I'm not sure using "true"/"false" as parameters to TA.p.fill makes a whole lot of sense. I'd even be fine with restricting the fast path to numbers that are Smis. But, that's just my opinion.
https://codereview.chromium.org/2769673002/diff/1/src/elements.cc File src/elements.cc (right): https://codereview.chromium.org/2769673002/diff/1/src/elements.cc#newcode2869 src/elements.cc:2869: } else if (obj_value->IsHeapNumber()) { Oh nvm, I thought we had a fast path in CSA. This is fine
almost :) https://codereview.chromium.org/2769673002/diff/1/src/elements.cc File src/elements.cc (right): https://codereview.chromium.org/2769673002/diff/1/src/elements.cc#newcode2869 src/elements.cc:2869: } else if (obj_value->IsHeapNumber()) { Given that we now perform additional checks, let's avoid the additional implied IsHeapObject() tests further down by casting obj_value: if (obj_value->IsSmi()) { ... } else { Handle<HeapObject> heap_obj_value = Handle<HeapObject>::cast(obj_value); if (heap_obj_value->IsHeapNumber()) { ... } else if (heap_obj_value->IsNull(isolate) { .. } ... } https://codereview.chromium.org/2769673002/diff/1/test/mjsunit/es6/typedarray... File test/mjsunit/es6/typedarray-fill.js (right): https://codereview.chromium.org/2769673002/diff/1/test/mjsunit/es6/typedarray... test/mjsunit/es6/typedarray-fill.js:45: assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(null)); please add the same for undefined :)
https://codereview.chromium.org/2769673002/diff/1/src/elements.cc File src/elements.cc (right): https://codereview.chromium.org/2769673002/diff/1/src/elements.cc#newcode2869 src/elements.cc:2869: } else if (obj_value->IsHeapNumber()) { On 2017/03/22 21:26:50, Camillo Bruni wrote: > Given that we now perform additional checks, let's avoid the additional implied > IsHeapObject() tests further down by casting obj_value: > > if (obj_value->IsSmi()) { > ... > } else { > Handle<HeapObject> heap_obj_value = Handle<HeapObject>::cast(obj_value); > if (heap_obj_value->IsHeapNumber()) { ... } > else if (heap_obj_value->IsNull(isolate) { .. } > ... > > } Done. https://codereview.chromium.org/2769673002/diff/1/test/mjsunit/es6/typedarray... File test/mjsunit/es6/typedarray-fill.js (right): https://codereview.chromium.org/2769673002/diff/1/test/mjsunit/es6/typedarray... test/mjsunit/es6/typedarray-fill.js:45: assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(null)); On 2017/03/22 21:26:50, Camillo Bruni wrote: > please add the same for undefined :) Done.
sorry.. another comment https://codereview.chromium.org/2769673002/diff/40001/src/elements.cc File src/elements.cc (right): https://codereview.chromium.org/2769673002/diff/40001/src/elements.cc#newcode... src/elements.cc:2876: BackingStore::from_double(std::numeric_limits<double>::quiet_NaN()); I just realized that we do already have a number cache on the oddball objects (True, false, undefined). So you can do, the following (and reuse some more code): if (input->IsOddball()) { value = BackingStore::from_double( Oddball::ToNumber(Handle<Oddball>::cast(input)->Number()); } else if (input->IsString()) { value = BackingStore::from_double( String::ToNumber(Handle<String>::cast(input))->Number()); }
https://codereview.chromium.org/2769673002/diff/40001/src/elements.cc File src/elements.cc (right): https://codereview.chromium.org/2769673002/diff/40001/src/elements.cc#newcode... src/elements.cc:2876: BackingStore::from_double(std::numeric_limits<double>::quiet_NaN()); On 2017/03/23 10:56:43, Camillo Bruni wrote: > I just realized that we do already have a number cache on the oddball objects > (True, false, undefined). > So you can do, the following (and reuse some more code): > > if (input->IsOddball()) { > value = BackingStore::from_double( > Oddball::ToNumber(Handle<Oddball>::cast(input)->Number()); > } else if (input->IsString()) { > value = BackingStore::from_double( > String::ToNumber(Handle<String>::cast(input))->Number()); > } Done.
Description was changed from ========== Move Boolean/null/undefined to TA.p.fill fast path ToNumber for Boolean/null/undefined has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ========== to ========== ToNumber for Oddball/String has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ==========
Description was changed from ========== ToNumber for Oddball/String has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ========== to ========== Move Oddball/String to %Typearray%.prototype.fill fast path ToNumber for Oddball/String has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ==========
LGTM, please wait for lgtm from bmeurer
lgtm
The CQ bit was checked by loorongjie@gmail.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1490393865975840,
"parent_rev": "2beb56137fe4194a69686abdad4c9246cbc93fea", "commit_rev":
"a1f2239e0b7daff6bbf728d4f744ef6ee52f5299"}
Message was sent while issue was closed.
Description was changed from ========== Move Oddball/String to %Typearray%.prototype.fill fast path ToNumber for Oddball/String has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 ========== to ========== Move Oddball/String to %Typearray%.prototype.fill fast path ToNumber for Oddball/String has no side-effect, no need to go through %Typearray%.prototype.fill slow path. BUG=v8:5929,chromium:702902 Review-Url: https://codereview.chromium.org/2769673002 Cr-Commit-Position: refs/heads/master@{#44129} Committed: https://chromium.googlesource.com/v8/v8/+/a1f2239e0b7daff6bbf728d4f744ef6ee52... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/v8/v8/+/a1f2239e0b7daff6bbf728d4f744ef6ee52... |
