@@ -5253,63 +5253,7 @@ namespace Js
5253
5253
#endif
5254
5254
return function;
5255
5255
}
5256
-
5257
- void JavascriptLibrary::EnsureStringTemplateCallsiteObjectList ()
5258
- {
5259
- if (this ->stringTemplateCallsiteObjectList == nullptr )
5260
- {
5261
- this ->stringTemplateCallsiteObjectList = RecyclerNew (GetRecycler (), StringTemplateCallsiteObjectList, GetRecycler ());
5262
- }
5263
- }
5264
-
5265
- void JavascriptLibrary::AddStringTemplateCallsiteObject (RecyclableObject* callsite)
5266
- {
5267
- this ->EnsureStringTemplateCallsiteObjectList ();
5268
-
5269
- RecyclerWeakReference<RecyclableObject>* callsiteRef = this ->GetRecycler ()->CreateWeakReferenceHandle <RecyclableObject>(callsite);
5270
-
5271
- this ->stringTemplateCallsiteObjectList ->Item (callsiteRef);
5272
- }
5273
-
5274
- RecyclableObject* JavascriptLibrary::TryGetStringTemplateCallsiteObject (ParseNodePtr pnode)
5275
- {
5276
- this ->EnsureStringTemplateCallsiteObjectList ();
5277
-
5278
- RecyclerWeakReference<RecyclableObject>* callsiteRef = this ->stringTemplateCallsiteObjectList ->LookupWithKey (pnode);
5279
-
5280
- if (callsiteRef)
5281
- {
5282
- RecyclableObject* callsite = callsiteRef->Get ();
5283
-
5284
- if (callsite)
5285
- {
5286
- return callsite;
5287
- }
5288
- }
5289
-
5290
- return nullptr ;
5291
- }
5292
-
5293
- RecyclableObject* JavascriptLibrary::TryGetStringTemplateCallsiteObject (RecyclableObject* callsite)
5294
- {
5295
- this ->EnsureStringTemplateCallsiteObjectList ();
5296
-
5297
- RecyclerWeakReference<RecyclableObject>* callsiteRef = this ->GetRecycler ()->CreateWeakReferenceHandle <RecyclableObject>(callsite);
5298
- RecyclerWeakReference<RecyclableObject>* existingCallsiteRef = this ->stringTemplateCallsiteObjectList ->LookupWithKey (callsiteRef);
5299
-
5300
- if (existingCallsiteRef)
5301
- {
5302
- RecyclableObject* existingCallsite = existingCallsiteRef->Get ();
5303
-
5304
- if (existingCallsite)
5305
- {
5306
- return existingCallsite;
5307
- }
5308
- }
5309
-
5310
- return nullptr ;
5311
- }
5312
-
5256
+
5313
5257
#if DBG_DUMP
5314
5258
const char16* JavascriptLibrary::GetStringTemplateCallsiteObjectKey (Var callsite)
5315
5259
{
@@ -5374,290 +5318,7 @@ namespace Js
5374
5318
}
5375
5319
#endif
5376
5320
5377
- bool StringTemplateCallsiteObjectComparer<ParseNodePtr>::Equals(ParseNodePtr x, RecyclerWeakReference<Js::RecyclableObject>* y)
5378
- {
5379
- Assert (x != nullptr );
5380
- Assert (x->nop == knopStrTemplate);
5381
-
5382
- Js::RecyclableObject* obj = y->Get ();
5383
-
5384
- // If the weak reference is dead, we can't be equal.
5385
- if (obj == nullptr )
5386
- {
5387
- return false ;
5388
- }
5389
-
5390
- Js::ES5Array* callsite = Js::ES5Array::FromVar (obj);
5391
- uint32 length = callsite->GetLength ();
5392
- Js::Var element;
5393
- Js::JavascriptString* str;
5394
- IdentPtr pid;
5395
-
5396
- // If the length of string literals is different, these callsite objects are not equal.
5397
- if (x->AsParseNodeStrTemplate ()->countStringLiterals != length)
5398
- {
5399
- return false ;
5400
- }
5401
-
5402
- JS_REENTRANCY_LOCK (reentrancyLock, callsite->GetScriptContext ()->GetThreadContext ());
5403
- Unused (reentrancyLock);
5404
-
5405
- element = Js::JavascriptOperators::OP_GetProperty (callsite, Js::PropertyIds::raw, callsite->GetScriptContext ());
5406
- Js::ES5Array* rawArray = Js::ES5Array::FromVar (element);
5407
-
5408
- // Length of the raw strings should be the same as the cooked string literals.
5409
- AssertOrFailFast (length != 0 && length == rawArray->GetLength ());
5410
-
5411
- x = x->AsParseNodeStrTemplate ()->pnodeStringRawLiterals ;
5412
-
5413
- for (uint32 i = 0 ; i < length - 1 ; i++)
5414
- {
5415
- BOOL hasElem = rawArray->DirectGetItemAt (i, &element);
5416
- AssertOrFailFast (hasElem);
5417
- str = Js::JavascriptString::FromVar (element);
5418
-
5419
- Assert (x->nop == knopList);
5420
- Assert (x->AsParseNodeBin ()->pnode1 ->nop == knopStr);
5421
-
5422
- pid = x->AsParseNodeBin ()->pnode1 ->AsParseNodeStr ()->pid ;
5423
-
5424
- // If strings have different length, they aren't equal
5425
- if (pid->Cch () != str->GetLength ())
5426
- {
5427
- return false ;
5428
- }
5429
-
5430
- // If the strings at this index are not equal, the callsite objects are not equal.
5431
- if (!JsUtil::CharacterBuffer<char16>::StaticEquals (pid->Psz (), str->GetString (), str->GetLength ()))
5432
- {
5433
- return false ;
5434
- }
5435
-
5436
- x = x->AsParseNodeBin ()->pnode2 ;
5437
- }
5438
-
5439
- // There should be one more string in the callsite array - and the final string in the ParseNode
5440
-
5441
- BOOL hasLastElem = rawArray->DirectGetItemAt (length - 1 , &element);
5442
- AssertOrFailFast (hasLastElem);
5443
- str = Js::JavascriptString::FromVar (element);
5444
-
5445
- Assert (x->nop == knopStr);
5446
- pid = x->AsParseNodeStr ()->pid ;
5447
-
5448
- // If strings have different length, they aren't equal
5449
- if (pid->Cch () != str->GetLength ())
5450
- {
5451
- return false ;
5452
- }
5453
-
5454
- // If the strings at this index are not equal, the callsite objects are not equal.
5455
- if (!JsUtil::CharacterBuffer<char16>::StaticEquals (pid->Psz (), str->GetString (), str->GetLength ()))
5456
- {
5457
- return false ;
5458
- }
5459
-
5460
- return true ;
5461
- }
5462
-
5463
- bool StringTemplateCallsiteObjectComparer<ParseNodePtr>::Equals(ParseNodePtr x, ParseNodePtr y)
5464
- {
5465
- Assert (x != nullptr && y != nullptr );
5466
- Assert (x->nop == knopStrTemplate && y->nop == knopStrTemplate);
5467
-
5468
- // If the ParseNode is the same, they are equal.
5469
- if (x == y)
5470
- {
5471
- return true ;
5472
- }
5473
-
5474
- x = x->AsParseNodeStrTemplate ()->pnodeStringRawLiterals ;
5475
- y = y->AsParseNodeStrTemplate ()->pnodeStringRawLiterals ;
5476
-
5477
- // If one of the templates only includes one string value, the raw literals ParseNode will
5478
- // be a knopStr instead of knopList.
5479
- if (x->nop != y->nop )
5480
- {
5481
- return false ;
5482
- }
5483
-
5484
- const char16* pid_x;
5485
- const char16* pid_y;
5486
-
5487
- while (x->nop == knopList)
5488
- {
5489
- // If y is knopStr here, that means x has more strings in the list than y does.
5490
- if (y->nop != knopList)
5491
- {
5492
- return false ;
5493
- }
5494
-
5495
- Assert (x->AsParseNodeBin ()->pnode1 ->nop == knopStr);
5496
- Assert (y->AsParseNodeBin ()->pnode1 ->nop == knopStr);
5497
-
5498
- pid_x = x->AsParseNodeBin ()->pnode1 ->AsParseNodeStr ()->pid ->Psz ();
5499
- pid_y = y->AsParseNodeBin ()->pnode1 ->AsParseNodeStr ()->pid ->Psz ();
5500
-
5501
- // If the pid values of each raw string don't match each other, these are different.
5502
- if (!DefaultComparer<const char16*>::Equals (pid_x, pid_y))
5503
- {
5504
- return false ;
5505
- }
5506
-
5507
- x = x->AsParseNodeBin ()->pnode2 ;
5508
- y = y->AsParseNodeBin ()->pnode2 ;
5509
- }
5510
-
5511
- // If y is still knopList here, that means y has more strings in the list than x does.
5512
- if (y->nop != knopStr)
5513
- {
5514
- return false ;
5515
- }
5516
-
5517
- Assert (x->nop == knopStr);
5518
-
5519
- pid_x = x->AsParseNodeStr ()->pid ->Psz ();
5520
- pid_y = y->AsParseNodeStr ()->pid ->Psz ();
5521
-
5522
- // This is the final string in the raw literals list. Return true if they are equal.
5523
- return DefaultComparer<const char16*>::Equals (pid_x, pid_y);
5524
- }
5525
-
5526
- hash_t StringTemplateCallsiteObjectComparer<ParseNodePtr>::GetHashCode(ParseNodePtr i)
5527
- {
5528
- hash_t hash = 0 ;
5529
-
5530
- Assert (i != nullptr );
5531
- Assert (i->nop == knopStrTemplate);
5532
-
5533
- i = i->AsParseNodeStrTemplate ()->pnodeStringRawLiterals ;
5534
-
5535
- const char16* pid;
5536
-
5537
- while (i->nop == knopList)
5538
- {
5539
- Assert (i->AsParseNodeBin ()->pnode1 ->nop == knopStr);
5540
-
5541
- pid = i->AsParseNodeBin ()->pnode1 ->AsParseNodeStr ()->pid ->Psz ();
5542
-
5543
- hash ^= DefaultComparer<const char16*>::GetHashCode (pid);
5544
- hash ^= DefaultComparer<const char16*>::GetHashCode (_u (" ${}" ));
5545
-
5546
- i = i->AsParseNodeBin ()->pnode2 ;
5547
- }
5548
-
5549
- Assert (i->nop == knopStr);
5550
-
5551
- pid = i->AsParseNodeStr ()->pid ->Psz ();
5552
-
5553
- hash ^= DefaultComparer<const char16*>::GetHashCode (pid);
5554
-
5555
- return hash;
5556
- }
5557
-
5558
- bool StringTemplateCallsiteObjectComparer<RecyclerWeakReference<Js::RecyclableObject>*>::Equals(RecyclerWeakReference<Js::RecyclableObject>* x, ParseNodePtr y)
5559
- {
5560
- return StringTemplateCallsiteObjectComparer<ParseNodePtr>::Equals (y, x);
5561
- }
5562
-
5563
- bool StringTemplateCallsiteObjectComparer<RecyclerWeakReference<Js::RecyclableObject>*>::Equals(RecyclerWeakReference<Js::RecyclableObject>* x, RecyclerWeakReference<Js::RecyclableObject>* y)
5564
- {
5565
- Js::RecyclableObject* objLeft = x->Get ();
5566
- Js::RecyclableObject* objRight = y->Get ();
5567
-
5568
- // If either WeakReference is dead, we can't be equal to anything.
5569
- if (objLeft == nullptr || objRight == nullptr )
5570
- {
5571
- return false ;
5572
- }
5573
-
5574
- // If the Var pointers are the same, they are equal.
5575
- if (objLeft == objRight)
5576
- {
5577
- return true ;
5578
- }
5579
-
5580
- Js::ES5Array* arrayLeft = Js::ES5Array::FromVar (objLeft);
5581
- Js::ES5Array* arrayRight = Js::ES5Array::FromVar (objRight);
5582
- uint32 lengthLeft = arrayLeft->GetLength ();
5583
- uint32 lengthRight = arrayRight->GetLength ();
5584
- Js::Var varLeft;
5585
- Js::Var varRight;
5586
-
5587
- // If the length of string literals is different, these callsite objects are not equal.
5588
- if (lengthLeft != lengthRight)
5589
- {
5590
- return false ;
5591
- }
5592
-
5593
- AssertOrFailFast (lengthLeft != 0 && lengthRight != 0 );
5594
-
5595
- JS_REENTRANCY_LOCK (reentrancyLock, arrayLeft->GetScriptContext ()->GetThreadContext ());
5596
- Unused (reentrancyLock);
5597
-
5598
- // Change to the set of raw strings.
5599
- varLeft = Js::JavascriptOperators::OP_GetProperty (arrayLeft, Js::PropertyIds::raw, arrayLeft->GetScriptContext ());
5600
- arrayLeft = Js::ES5Array::FromVar (varLeft);
5601
-
5602
- varRight = Js::JavascriptOperators::OP_GetProperty (arrayRight, Js::PropertyIds::raw, arrayRight->GetScriptContext ());
5603
- arrayRight = Js::ES5Array::FromVar (varRight);
5604
-
5605
- // Length of the raw strings should be the same as the cooked string literals.
5606
- AssertOrFailFast (lengthLeft == arrayLeft->GetLength ());
5607
- AssertOrFailFast (lengthRight == arrayRight->GetLength ());
5608
-
5609
- for (uint32 i = 0 ; i < lengthLeft; i++)
5610
- {
5611
- BOOL hasLeft = arrayLeft->DirectGetItemAt (i, &varLeft);
5612
- AssertOrFailFast (hasLeft);
5613
- BOOL hasRight = arrayRight->DirectGetItemAt (i, &varRight);
5614
- AssertOrFailFast (hasRight);
5615
-
5616
- // If the strings at this index are not equal, the callsite objects are not equal.
5617
- if (!Js::JavascriptString::Equals (JavascriptString::FromVar (varLeft), JavascriptString::FromVar (varRight)))
5618
- {
5619
- return false ;
5620
- }
5621
- }
5622
-
5623
- return true ;
5624
- }
5625
-
5626
- hash_t StringTemplateCallsiteObjectComparer<RecyclerWeakReference<Js::RecyclableObject>*>::GetHashCode(RecyclerWeakReference<Js::RecyclableObject>* o)
5627
- {
5628
- hash_t hash = 0 ;
5629
-
5630
- Js::RecyclableObject* obj = o->Get ();
5631
-
5632
- if (obj == nullptr )
5633
- {
5634
- return hash;
5635
- }
5636
- JS_REENTRANCY_LOCK (reentrancyLock, obj->GetScriptContext ()->GetThreadContext ());
5637
- Unused (reentrancyLock);
5638
-
5639
- Js::ES5Array* callsite = Js::ES5Array::FromVar (obj);
5640
- Js::Var var = Js::JavascriptOperators::OP_GetProperty (callsite, Js::PropertyIds::raw, callsite->GetScriptContext ());
5641
- Js::ES5Array* rawArray = Js::ES5Array::FromVar (var);
5642
-
5643
- AssertOrFailFast (rawArray->GetLength () > 0 );
5644
-
5645
- rawArray->DirectGetItemAt (0 , &var);
5646
- Js::JavascriptString* str = Js::JavascriptString::FromVar (var);
5647
- hash ^= DefaultComparer<const char16*>::GetHashCode (str->GetSz ());
5648
-
5649
- for (uint32 i = 1 ; i < rawArray->GetLength (); i++)
5650
- {
5651
- hash ^= DefaultComparer<const char16*>::GetHashCode (_u (" ${}" ));
5652
-
5653
- BOOL hasItem = rawArray->DirectGetItemAt (i, &var);
5654
- AssertOrFailFast (hasItem);
5655
- str = Js::JavascriptString::FromVar (var);
5656
- hash ^= DefaultComparer<const char16*>::GetHashCode (str->GetSz ());
5657
- }
5658
-
5659
- return hash;
5660
- }
5321
+
5661
5322
5662
5323
DynamicType * JavascriptLibrary::GetObjectLiteralType (uint16 requestedInlineSlotCapacity)
5663
5324
{
0 commit comments