Skip to content

Commit 6c17206

Browse files
committed
[MERGE chakra-core#2456 @MikeHolman] add missing copy on access conversion for GetItemSetter
Merge pull request chakra-core#2456 from MikeHolman:copyonaccessreflectset
2 parents 161b875 + f9d90a8 commit 6c17206

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,16 @@ namespace Js
28262826
return GetType()->GetLibrary()->GetUndefined();
28272827
}
28282828

2829+
DescriptorFlags JavascriptNativeIntArray::GetItemSetter(uint32 index, Var* setterValue, ScriptContext* requestContext)
2830+
{
2831+
#if ENABLE_COPYONACCESS_ARRAY
2832+
JavascriptLibrary::CheckAndConvertCopyOnAccessNativeIntArray<Var>(this);
2833+
#endif
2834+
int32 value = 0;
2835+
return this->DirectGetItemAt(index, &value) ? WritableData : None;
2836+
}
2837+
2838+
28292839
Var JavascriptNativeFloatArray::DirectGetItem(uint32 index)
28302840
{
28312841
SparseArraySegment<double> *seg = (SparseArraySegment<double>*)this->GetLastUsedSegment();

lib/Runtime/Library/JavascriptArray.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,7 @@ namespace Js
959959
virtual BOOL DirectGetVarItemAt(uint index, Var* outval, ScriptContext *scriptContext);
960960
virtual BOOL DirectGetItemAtFull(uint index, Var* outVal);
961961
virtual Var DirectGetItem(uint32 index);
962-
virtual DescriptorFlags GetItemSetter(uint32 index, Var* setterValue, ScriptContext* requestContext) override
963-
{
964-
int32 value = 0;
965-
return this->DirectGetItemAt(index, &value) ? WritableData : None;
966-
}
962+
virtual DescriptorFlags GetItemSetter(uint32 index, Var* setterValue, ScriptContext* requestContext) override;
967963

968964
virtual BOOL SetItem(uint32 index, Var value, PropertyOperationFlags flags) override;
969965
virtual BOOL DeleteItem(uint32 index, PropertyOperationFlags flags) override;

test/Array/CopyOnAccessArray_bugs.baseline

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ PASSED
3030
PASSED
3131
*** Running test #12 (11): Reflect.defineProperty
3232
PASSED
33-
*** Running test #13 (12): Array.of
33+
*** Running test #13 (12): Reflect.set
3434
PASSED
35-
Summary of tests: total executed: 13; passed: 13; failed: 0
35+
*** Running test #14 (13): Array.of
36+
PASSED
37+
Summary of tests: total executed: 14; passed: 14; failed: 0

test/Array/CopyOnAccessArray_bugs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ var tests = [
128128
assert.areEqual(b.length, 0, "Setting length property to 0");
129129
}
130130
},
131+
{
132+
name: "Reflect.set",
133+
body: function ()
134+
{
135+
assert.isTrue(Reflect.set([1950, 1960, 1970, 1980, 1990], "0", 1), "Should be able to set property on int array");
136+
assert.isTrue(Reflect.set([1950, 1960.1, 1970, 1980, 1990], "0", 1), "Should be able to set property on float array");
137+
}
138+
},
131139
{
132140
name: "Array.of",
133141
body: function ()

0 commit comments

Comments
 (0)