Bug 152706

Summary: [ES6] Arrays should be subclassable.
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: JavaScriptCoreAssignee: Keith Miller <keith_miller>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, mark.lam, msaboff, nvasilyev, saam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 152695    
Bug Blocks: 142591    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
benjamin: review+
Benchmark results none

Description Keith Miller 2016-01-04 12:14:49 PST
This patch allows for subclassing JS Arrays with the correct prototype chain on the created objects.
Comment 1 Keith Miller 2016-01-04 13:01:32 PST
Created attachment 268225 [details]
Patch
Comment 2 Geoffrey Garen 2016-01-04 15:16:47 PST
Last 500 characters of output:

  "__ZN3JSC12PrototypeMap12addPrototypeEPNS_8JSObjectE", referenced from:
      __ZNK3JSC14JSGlobalObject45arrayStructureForIndexingTypeDuringAllocationERNS_2VMEhNS_7JSValueE in IDBBindingUtilities.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 3 Keith Miller 2016-01-04 17:07:13 PST
Created attachment 268250 [details]
Patch
Comment 4 Keith Miller 2016-01-05 12:03:20 PST
Created attachment 268301 [details]
Patch
Comment 5 Geoffrey Garen 2016-01-05 12:45:28 PST
  JSCBuiltins.cpp
     Creating library C:/cygwin/home/buildbot/WebKit/WebKitBuild/Release/lib32/JavaScriptCore.lib and object C:/cygwin/home/buildbot/WebKit/WebKitBuild/Release/lib32/JavaScriptCore.exp
AdaptiveInferredPropertyValueWatchpointBase.obj : error LNK2019: unresolved external symbol "public: __thiscall JSC::JSValue::operator bool(void)const " (??BJSValue@JSC@@QBE_NXZ) referenced in function "public: static class JSC::Structure * __cdecl JSC::Structure::createSubclassStructure(class JSC::VM &,class JSC::Structure *,class JSC::JSValue)" (?createSubclassStructure@Structure@JSC@@SAPAV12@AAVVM@2@PAV12@VJSValue@2@@Z) [C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\Source\JavaScriptCore\JavaScriptCore.vcxproj]
AdaptiveInferredPropertyValueWatchpointBase.obj : error LNK2019: unresolved external symbol "public: class JSC::JSObject * __thiscall JSC::JSValue::getObject(void)const " (?getObject@JSValue@JSC@@QBEPAVJSObject@2@XZ) referenced in function "public: static class JSC::Structure * __cdecl JSC::Structure::createSubclassStructure(class JSC::VM &,class JSC::Structure *,class JSC::JSValue)" (?createSubclassStructure@Structure@JSC@@SAPAV12@AAVVM@2@PAV12@VJSValue@2@@Z) [C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\Source\JavaScriptCore\JavaScriptCore.vcxproj]
C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\bin32\JavaScriptCore.dll : fatal error LNK1120: 2 unresolved externals [C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\Source\JavaScriptCore\JavaScriptCore.vcxproj]
  Generating ../../DerivedSources/WebKit/autoversion.h
Comment 6 Keith Miller 2016-01-05 12:53:05 PST
Created attachment 268314 [details]
Patch
Comment 7 Keith Miller 2016-01-05 12:54:09 PST
Hopefully, including JSCJSValueInlines.h fixes the problem but the patch should be done other than the windows build issue.
Comment 8 Keith Miller 2016-01-05 14:12:55 PST
Created attachment 268324 [details]
Benchmark results
Comment 9 Benjamin Poulain 2016-01-05 14:14:42 PST
Comment on attachment 268314 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSGlobalObject.h:732
> +    return ArrayAllocationProfile::updateLastAllocationFor(profile, JSArray::create(vm, initialLength >= MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH ? globalObject->arrayStructureForIndexingTypeDuringAllocation(vm, ArrayWithArrayStorage, prototype) : globalObject->arrayStructureForProfileDuringAllocation(vm, profile, prototype), initialLength));

Please split this over multiple lines. The ternary operator is a bit messy on this line.
Comment 10 Keith Miller 2016-01-05 14:15:35 PST
Comment on attachment 268314 [details]
Patch

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

>> Source/JavaScriptCore/runtime/JSGlobalObject.h:732
>> +    return ArrayAllocationProfile::updateLastAllocationFor(profile, JSArray::create(vm, initialLength >= MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH ? globalObject->arrayStructureForIndexingTypeDuringAllocation(vm, ArrayWithArrayStorage, prototype) : globalObject->arrayStructureForProfileDuringAllocation(vm, profile, prototype), initialLength));
> 
> Please split this over multiple lines. The ternary operator is a bit messy on this line.

Fair point. Fixed.
Comment 11 Keith Miller 2016-01-05 14:50:05 PST
Committed r194612: <http://trac.webkit.org/changeset/194612>
Comment 12 Alexey Shvayka 2020-03-10 15:31:31 PDT
*** Bug 145155 has been marked as a duplicate of this bug. ***