Bug 185476 - [JSC] Fix ArraySpeciesCreate to return a new Array when the given object is not an array
Summary: [JSC] Fix ArraySpeciesCreate to return a new Array when the given object is n...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-09 09:29 PDT by Leo Balter
Modified: 2018-05-09 16:11 PDT (History)
9 users (show)

See Also:


Attachments
Patch (2.23 KB, patch)
2018-05-09 09:31 PDT, Leo Balter
no flags Details | Formatted Diff | Diff
Patch (1.98 KB, patch)
2018-05-09 10:06 PDT, Leo Balter
no flags Details | Formatted Diff | Diff
Patch (1.98 KB, patch)
2018-05-09 10:13 PDT, Leo Balter
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Balter 2018-05-09 09:29:05 PDT
[JSC] Fix ArraySpeciesCreate to return a new Array when the given object is not an array
Comment 1 Leo Balter 2018-05-09 09:31:11 PDT
Created attachment 339969 [details]
Patch
Comment 2 Yusuke Suzuki 2018-05-09 09:55:54 PDT
Comment on attachment 339969 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339969&action=review

> Source/JavaScriptCore/runtime/ArrayPrototype.cpp:256
> +        // If isArray is false, return ? ArrayCreate(length).
> +        JSGlobalObject* globalObject = thisObject->globalObject();
> +        JSValue newValue = constructArrayWithSizeQuirk(exec, nullptr, globalObject, jsNumber(length), exec->newTarget());
> +        JSObject* newObject = newValue.toObject(exec);
>          RETURN_IF_EXCEPTION(scope, exceptionResult());
> +        return std::make_pair(SpeciesConstructResult::CreatedObject, newObject);

Let's return `std::make_pair(SpeciesConstructResult::FastPath, nullptr)` since it creates an Array(length), it is fast path case.
Comment 3 Leo Balter 2018-05-09 10:06:47 PDT
Created attachment 339974 [details]
Patch
Comment 4 Leo Balter 2018-05-09 10:13:17 PDT
Created attachment 339977 [details]
Patch
Comment 5 Yusuke Suzuki 2018-05-09 10:14:13 PDT
Comment on attachment 339977 [details]
Patch

r=me
Comment 6 WebKit Commit Bot 2018-05-09 10:29:45 PDT
Comment on attachment 339977 [details]
Patch

Clearing flags on attachment: 339977

Committed r231572: <https://trac.webkit.org/changeset/231572>
Comment 7 WebKit Commit Bot 2018-05-09 10:29:46 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2018-05-09 10:30:28 PDT
<rdar://problem/40096808>