@@ -230,62 +230,70 @@ namespace TTD
230230 AssertMsg (!Js::JavascriptProxy::Is (obj), " I didn't think proxies could have real properties directly on them." );
231231
232232 Js::PropertyId pid = handler->PropertyInfoArray [i].PropertyRecordId ;
233- TTDVar ttdVal = snpObject->VarArray [i];
234- Js::Var pVal = inflator->InflateTTDVar (ttdVal);
235233
236- if (handler->PropertyInfoArray [i].DataKind == NSSnapType::SnapEntryDataKindTag::Data )
234+ if (handler->PropertyInfoArray [i].DataKind == NSSnapType::SnapEntryDataKindTag::Uninitialized )
237235 {
238- BOOL success = FALSE ;
239- if (!obj->HasOwnProperty (pid))
240- {
241- // easy case just set the property
242- success = obj->SetProperty (pid, pVal, Js::PropertyOperationFlags::PropertyOperation_Force, nullptr );
243- }
244- else
236+ AssertMsg (!obj->HasOwnProperty (pid), " Shouldn't have this defined, or we should have cleared it, and nothing more to do." );
237+
238+ BOOL success = obj->EnsureProperty (pid);
239+
240+ AssertMsg (success, " Failed to set property during restore!!!" );
241+ }
242+ else
243+ {
244+ TTDVar ttdVal = snpObject->VarArray [i];
245+ Js::Var pVal = (ttdVal != nullptr ) ? inflator->InflateTTDVar (ttdVal) : nullptr ;
246+
247+ if (handler->PropertyInfoArray [i].DataKind == NSSnapType::SnapEntryDataKindTag::Data)
245248 {
246- if (obj->IsWritable (pid))
249+ BOOL success = FALSE ;
250+ if (!obj->HasOwnProperty (pid))
247251 {
248- // also easy just write the property
252+ // easy case just set the property
249253 success = obj->SetProperty (pid, pVal, Js::PropertyOperationFlags::PropertyOperation_Force, nullptr );
250254 }
251255 else
252256 {
253- // get the value to see if it is alreay ok
254- Js::Var currentValue = nullptr ;
255- Js::JavascriptOperators::GetProperty (obj, pid, obj->GetScriptContext (), nullptr );
256-
257- if (currentValue == pVal)
257+ if (obj->IsWritable (pid))
258258 {
259- // the right value is already there -- easy
260- success = TRUE ;
259+ // also easy just write the property
260+ success = obj-> SetProperty (pid, pVal, Js::PropertyOperationFlags::PropertyOperation_Force, nullptr ) ;
261261 }
262262 else
263263 {
264- // Ok so now we force set the property
265- success = obj->SetPropertyWithAttributes (pid, pVal, PropertyDynamicTypeDefaults, nullptr );
264+ // get the value to see if it is alreay ok
265+ Js::Var currentValue = nullptr ;
266+ Js::JavascriptOperators::GetProperty (obj, pid, obj->GetScriptContext (), nullptr );
267+
268+ if (currentValue == pVal)
269+ {
270+ // the right value is already there -- easy
271+ success = TRUE ;
272+ }
273+ else
274+ {
275+ // Ok so now we force set the property
276+ success = obj->SetPropertyWithAttributes (pid, pVal, PropertyDynamicTypeDefaults, nullptr );
277+ }
266278 }
267279 }
268- }
269- AssertMsg (success, " Failed to set property during restore!!!" );
270- }
271- else
272- {
273- //
274- // TODO: we could have a problem if we set a getter (and make it not writable say) then what happens with the setter -- or maybe set accessors just ignores this?
275- //
276-
277- NSSnapType::SnapEntryDataKindTag ttag = handler->PropertyInfoArray [i].DataKind ;
278- if (ttag == NSSnapType::SnapEntryDataKindTag::Getter)
279- {
280- obj->SetAccessors (pid, pVal, nullptr );
281- }
282- else if (ttag == NSSnapType::SnapEntryDataKindTag::Setter)
283- {
284- obj->SetAccessors (pid, nullptr , pVal);
280+ AssertMsg (success, " Failed to set property during restore!!!" );
285281 }
286282 else
287283 {
288- AssertMsg (false , " Don't know how to restore this accesstag!!" );
284+ NSSnapType::SnapEntryDataKindTag ttag = handler->PropertyInfoArray [i].DataKind ;
285+ if (ttag == NSSnapType::SnapEntryDataKindTag::Getter)
286+ {
287+ obj->SetAccessors (pid, pVal, nullptr );
288+ }
289+ else if (ttag == NSSnapType::SnapEntryDataKindTag::Setter)
290+ {
291+ obj->SetAccessors (pid, nullptr , pVal);
292+ }
293+ else
294+ {
295+ AssertMsg (false , " Don't know how to restore this accesstag!!" );
296+ }
289297 }
290298 }
291299
@@ -550,7 +558,7 @@ namespace TTD
550558 for (uint32 i = 0 ; i < handler2->MaxPropertyIndex ; ++i)
551559 {
552560 const NSSnapType::SnapHandlerPropertyEntry spe = handler2->PropertyInfoArray [i];
553- if (spe.DataKind != NSSnapType::SnapEntryDataKindTag::Clear)
561+ if (spe.DataKind != NSSnapType::SnapEntryDataKindTag::Clear && spe. DataKind != NSSnapType::SnapEntryDataKindTag::Uninitialized )
554562 {
555563 int64 locationTag = ComputeLocationTagForAssertCompare (spe);
556564
@@ -1285,7 +1293,7 @@ namespace TTD
12851293 const double * dateInfo1 = SnapObjectGetAddtlInfoAs<double *, SnapObjectType::SnapDateObject>(sobj1);
12861294 const double * dateInfo2 = SnapObjectGetAddtlInfoAs<double *, SnapObjectType::SnapDateObject>(sobj2);
12871295
1288- compareMap.DiagnosticAssert (*dateInfo1 == *dateInfo2);
1296+ compareMap.DiagnosticAssert (NSSnapValues ::CheckSnapEquivTTDDouble ( *dateInfo1, *dateInfo2) );
12891297 }
12901298#endif
12911299
@@ -1435,13 +1443,18 @@ namespace TTD
14351443
14361444 arrayObj->SetItemAttributes (entry->Index , entry->Attributes );
14371445 }
1446+
1447+ // do length writable as needed
1448+ Js::JavascriptLibrary::SetLengthWritableES5Array_TTD (arrayObj, es5Info->IsLengthWritable );
14381449 }
14391450
14401451 void EmitAddtlInfo_SnapES5ArrayInfo (const SnapObject* snpObject, FileWriter* writer)
14411452 {
14421453 SnapES5ArrayInfo* es5Info = SnapObjectGetAddtlInfoAs<SnapES5ArrayInfo*, SnapObjectType::SnapES5ArrayObject>(snpObject);
14431454
14441455 writer->WriteLengthValue (es5Info->GetterSetterCount , NSTokens::Separator::CommaSeparator);
1456+ writer->WriteBool (NSTokens::Key::boolVal, es5Info->IsLengthWritable , NSTokens::Separator::CommaSeparator);
1457+
14451458 writer->WriteSequenceStart_DefaultKey (NSTokens::Separator::CommaSeparator);
14461459 for (uint32 i = 0 ; i < es5Info->GetterSetterCount ; ++i)
14471460 {
@@ -1471,6 +1484,8 @@ namespace TTD
14711484 SnapES5ArrayInfo* es5Info = alloc.SlabAllocateStruct <SnapES5ArrayInfo>();
14721485
14731486 es5Info->GetterSetterCount = reader->ReadLengthValue (true );
1487+ es5Info->IsLengthWritable = reader->ReadBool (NSTokens::Key::boolVal, true );
1488+
14741489 if (es5Info->GetterSetterCount == 0 )
14751490 {
14761491 es5Info->GetterSetterEntries = nullptr ;
@@ -1512,6 +1527,8 @@ namespace TTD
15121527 SnapES5ArrayInfo* es5Info2 = SnapObjectGetAddtlInfoAs<SnapES5ArrayInfo*, SnapObjectType::SnapES5ArrayObject>(sobj2);
15131528
15141529 compareMap.DiagnosticAssert (es5Info1->GetterSetterCount == es5Info2->GetterSetterCount );
1530+ compareMap.DiagnosticAssert (es5Info1->IsLengthWritable == es5Info2->IsLengthWritable );
1531+
15151532 for (uint32 i = 0 ; i < es5Info1->GetterSetterCount ; ++i)
15161533 {
15171534 const SnapES5ArrayGetterSetterEntry* entry1 = es5Info1->GetterSetterEntries + i;
@@ -1524,7 +1541,9 @@ namespace TTD
15241541 NSSnapValues::AssertSnapEquivTTDVar_SpecialArray (entry1->Setter, entry2->Setter, compareMap, _u(" es5Setter" ), entry1->Index);
15251542 }
15261543
1527- AssertSnapEquiv_SnapArrayInfoCore<TTDVar>(es5Info1->BasicArrayData , es5Info2->BasicArrayData , compareMap);
1544+ compareMap.DiagnosticAssert (es5Info1->BasicArrayData ->Length == es5Info2->BasicArrayData ->Length );
1545+
1546+ AssertSnapEquiv_SnapArrayInfoCore<TTDVar>(es5Info1->BasicArrayData ->Data , es5Info2->BasicArrayData ->Data , compareMap);
15281547 }
15291548#endif
15301549
0 commit comments