Skip to content

Commit c648792

Browse files
committed
implement Array.prototype.filter in javascript
1 parent 0730b1f commit c648792

18 files changed

+5614
-4814
lines changed

RegenAllByteCodeNoBuild.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ setlocal
3232
call GenByteCode.cmd
3333
call GenByteCode.cmd -nojit
3434
popd
35+
36+
pushd %_reporoot%\lib\Runtime\Library\JsBuiltIn
37+
call GenByteCode.cmd
38+
call GenByteCode.cmd -nojit
39+
popd
3540
endlocal

lib/Runtime/Base/JnDirectFields.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ ENTRY(registerChakraLibraryFunction)
605605
ENTRY(registerFunction)
606606
ENTRY(toLength)
607607
ENTRY(toInteger)
608+
ENTRY(arraySpeciesCreate)
609+
ENTRY(arrayCreateDataPropertyOrThrow)
608610

609611
// EngineInterfaceObject built-ins
610612
ENTRY(builtInGlobalObjectEntryIsFinite)
@@ -666,6 +668,7 @@ ENTRY(raiseObjectIsNonExtensible)
666668
ENTRY(raiseOptionValueOutOfRange_3)
667669
ENTRY(raiseOptionValueOutOfRange)
668670
ENTRY(raiseThis_NullOrUndefined)
671+
ENTRY(raiseFunctionArgument_NeedFunction)
669672

670673
// Promise (ChakraFull)
671674
ENTRY(Promise)

lib/Runtime/ByteCode/ByteCodeCacheReleaseFileVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
// NOTE: If there is a merge conflict the correct fix is to make a new GUID.
66

7-
// {9F2ABB67-7351-401E-911C-9919B54F761C}
7+
// {9B3A48D4-C8EF-46CF-A473-14CB0DA3244F}
88
const GUID byteCodeCacheReleaseFileVersion =
9-
{ 0x9F2ABB67, 0x7351, 0x401E, { 0x91, 0x1C, 0x99, 0x19, 0xB5, 0x4F, 0x76, 0x1C } };
9+
{ 0x9B3A48D4, 0xC8EF, 0x46CF, { 0xA4, 0x73, 0x14, 0xCB, 0x0D, 0xA3, 0x24, 0x4F } };

lib/Runtime/Library/EngineInterfaceObjectBuiltIns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ GlobalBuiltIn(JavascriptArray, EntryPush)
2929
GlobalBuiltIn(JavascriptArray, EntryJoin)
3030
GlobalBuiltIn(JavascriptArray, EntryMap)
3131
GlobalBuiltIn(JavascriptArray, EntryReduce)
32-
GlobalBuiltIn(JavascriptArray, EntryFilter)
3332
GlobalBuiltIn(JavascriptArray, EntrySlice)
3433
GlobalBuiltIn(JavascriptArray, EntryConcat)
3534

@@ -63,3 +62,4 @@ BuiltInRaiseException2(TypeError, NeedObjectOfType)
6362
BuiltInRaiseException1(RangeError, InvalidCurrencyCode)
6463
BuiltInRaiseException(TypeError, MissingCurrencyCode)
6564
BuiltInRaiseException(RangeError, InvalidDate)
65+
BuiltInRaiseException1(TypeError, FunctionArgument_NeedFunction)

lib/Runtime/Library/InJavascript/Intl.js.bc.32b.h

Lines changed: 798 additions & 798 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/InJavascript/Intl.js.bc.64b.h

Lines changed: 805 additions & 805 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.32b.h

Lines changed: 809 additions & 809 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.64b.h

Lines changed: 801 additions & 801 deletions
Large diffs are not rendered by default.

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,20 @@ namespace Js
30323032
}
30333033
}
30343034

3035+
void JavascriptArray::CreateDataPropertyOrThrow(RecyclableObject * obj, BigIndex index, Var item, ScriptContext * scriptContext)
3036+
{
3037+
JS_REENTRANCY_LOCK(jsReentLock, scriptContext->GetThreadContext());
3038+
JavascriptArray * arr = JavascriptOperators::TryFromVar<JavascriptArray>(obj);
3039+
if (arr != nullptr)
3040+
{
3041+
arr->GenericDirectSetItemAt(index, item);
3042+
}
3043+
else
3044+
{
3045+
JS_REENTRANT(jsReentLock, ThrowErrorOnFailure(SetArrayLikeObjects(obj, index, item), scriptContext, index));
3046+
}
3047+
}
3048+
30353049
BOOL JavascriptArray::SetArrayLikeObjects(RecyclableObject* pDestObj, uint32 idxDest, Var aItem)
30363050
{
30373051
return pDestObj->SetItem(idxDest, aItem, Js::PropertyOperation_ThrowIfNotExtensible);

lib/Runtime/Library/JavascriptArray.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,11 @@ namespace Js
862862
static bool PromoteToBigIndex(BigIndex lhs, BigIndex rhs);
863863
static bool PromoteToBigIndex(BigIndex lhs, uint32 rhs);
864864
static JavascriptArray* ConcatFloatArgs(JavascriptNativeFloatArray* pDestArray, TypeId* remoteTypeIds, Js::Arguments& args, ScriptContext* scriptContext);
865-
private:
865+
866866
template<typename T=uint32>
867867
static RecyclableObject* ArraySpeciesCreate(Var pThisArray, T length, ScriptContext* scriptContext, bool *pIsIntArray = nullptr, bool *pIsFloatArray = nullptr, bool *pIsBuiltinArrayCtor = nullptr);
868+
static void CreateDataPropertyOrThrow(RecyclableObject * obj, BigIndex index, Var item, ScriptContext * scriptContext);
869+
private:
868870
template <typename T, typename R> static R ConvertToIndex(T idxDest, ScriptContext* scriptContext) { Throw::InternalError(); return 0; }
869871
static BOOL SetArrayLikeObjects(RecyclableObject* pDestObj, uint32 idxDest, Var aItem);
870872
static BOOL SetArrayLikeObjects(RecyclableObject* pDestObj, BigIndex idxDest, Var aItem);

0 commit comments

Comments
 (0)