Skip to content

Commit 4efd113

Browse files
committed
PR feedback. Removed redundant GetDefaultPropertyDescriptor
1 parent 95c1c89 commit 4efd113

File tree

5 files changed

+9
-36
lines changed

5 files changed

+9
-36
lines changed

lib/Runtime/Library/JavascriptObject.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,12 @@ using namespace Js;
674674
if (obj->IsExternal())
675675
{
676676
isPropertyDescriptorDefined = obj->HasOwnProperty(propertyId) ?
677-
JavascriptOperators::GetOwnPropertyDescriptor(obj, propertyId, scriptContext, &propertyDescriptor) : obj->GetDefaultPropertyDescriptor(propertyDescriptor);
677+
JavascriptOperators::GetOwnPropertyDescriptor(obj, propertyId, scriptContext, &propertyDescriptor) :
678+
FALSE;
678679
}
679680
else
680681
{
681-
isPropertyDescriptorDefined = JavascriptOperators::GetOwnPropertyDescriptor(obj, propertyId, scriptContext, &propertyDescriptor) ||
682-
obj->GetDefaultPropertyDescriptor(propertyDescriptor);
682+
isPropertyDescriptorDefined = JavascriptOperators::GetOwnPropertyDescriptor(obj, propertyId, scriptContext, &propertyDescriptor);
683683
}
684684
return isPropertyDescriptorDefined;
685685
}

lib/Runtime/Library/JavascriptProxy.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ namespace Js
195195
target = nullptr;
196196
}
197197

198-
template <class Fn>
199-
BOOL JavascriptProxy::GetPropertyDescriptorTrap(Var originalInstance, Fn fn, PropertyId propertyId, PropertyDescriptor* resultDescriptor, ScriptContext* requestContext)
198+
BOOL JavascriptProxy::GetPropertyDescriptorTrap(PropertyId propertyId, PropertyDescriptor* resultDescriptor, ScriptContext* requestContext)
200199
{
201200
PROBE_STACK(GetScriptContext(), Js::Constants::MinStackDefault);
202201

@@ -223,14 +222,15 @@ namespace Js
223222

224223
Assert((static_cast<DynamicType*>(GetType()))->GetTypeHandler()->GetPropertyCount() == 0 ||
225224
(static_cast<DynamicType*>(GetType()))->GetTypeHandler()->GetPropertyId(GetScriptContext(), 0) == InternalPropertyIds::WeakMapKeyMap);
225+
226226
JavascriptFunction* gOPDMethod = GetMethodHelper(PropertyIds::getOwnPropertyDescriptor, requestContext);
227227

228228
//7. If trap is undefined, then
229229
// a.Return the result of calling the[[GetOwnProperty]] internal method of target with argument P.
230230
if (nullptr == gOPDMethod || GetScriptContext()->IsHeapEnumInProgress())
231231
{
232232
resultDescriptor->SetFromProxy(false);
233-
return fn(targetObj);
233+
return JavascriptOperators::GetOwnPropertyDescriptor(targetObj, propertyId, requestContext, resultDescriptor);
234234
}
235235

236236
Var propertyName = GetName(requestContext, propertyId);
@@ -276,6 +276,7 @@ namespace Js
276276
{
277277
JavascriptError::ThrowTypeError(requestContext, JSERR_InconsistentTrapResult, _u("getOwnPropertyDescriptor"));
278278
}
279+
279280
return FALSE;
280281
}
281282

@@ -1244,19 +1245,6 @@ namespace Js
12441245
return trapResult;
12451246
}
12461247

1247-
BOOL JavascriptProxy::GetDefaultPropertyDescriptor(PropertyDescriptor& descriptor)
1248-
{
1249-
if (target == nullptr)
1250-
{
1251-
// We only can get here through GetOwnPropertyDescriptor, which would check that proxy is not revoked and throw if necessary.
1252-
// It may still be possible for the `target` to become null after the validation, for example if a trap handler revokes the proxy.
1253-
// Just return FALSE in such cases.
1254-
return FALSE;
1255-
}
1256-
1257-
return target->GetDefaultPropertyDescriptor(descriptor);
1258-
}
1259-
12601248
// 7.3.12 in ES 2015. While this should have been no observable behavior change. Till there is obvious change warrant this
12611249
// to be moved to JavascriptOperators, let's keep it in proxy only first.
12621250
BOOL JavascriptProxy::TestIntegrityLevel(IntegrityLevel integrityLevel, RecyclableObject* obj, ScriptContext* scriptContext)
@@ -1673,12 +1661,7 @@ namespace Js
16731661
BOOL JavascriptProxy::GetOwnPropertyDescriptor(RecyclableObject* obj, PropertyId propertyId, ScriptContext* requestContext, PropertyDescriptor* propertyDescriptor)
16741662
{
16751663
JavascriptProxy* proxy = JavascriptProxy::FromVar(obj);
1676-
auto fn = [&](RecyclableObject *targetObj)-> BOOL {
1677-
return JavascriptOperators::GetOwnPropertyDescriptor(targetObj, propertyId, requestContext, propertyDescriptor);
1678-
};
1679-
1680-
BOOL foundProperty = proxy->GetPropertyDescriptorTrap(obj, fn, propertyId, propertyDescriptor, requestContext);
1681-
return foundProperty;
1664+
return proxy->GetPropertyDescriptorTrap(propertyId, propertyDescriptor, requestContext);
16821665
}
16831666

16841667

lib/Runtime/Library/JavascriptProxy.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ namespace Js
116116
virtual BOOL IsExtensible() override;
117117
virtual BOOL PreventExtensions() override;
118118
virtual void ThrowIfCannotDefineProperty(PropertyId propId, const PropertyDescriptor& descriptor) { }
119-
virtual BOOL GetDefaultPropertyDescriptor(PropertyDescriptor& descriptor) override;
120119
virtual BOOL Seal() override;
121120
virtual BOOL Freeze() override;
122121
virtual BOOL IsSealed() override;
@@ -231,8 +230,7 @@ namespace Js
231230
template <class Fn, class GetPropertyIdFunc>
232231
BOOL GetPropertyTrap(Var instance, PropertyDescriptor* propertyDescriptor, Fn fn, GetPropertyIdFunc getPropertyId, ScriptContext* requestContext);
233232

234-
template <class Fn>
235-
BOOL GetPropertyDescriptorTrap(Var originalInstance, Fn fn, PropertyId propertyId, PropertyDescriptor* resultDescriptor, ScriptContext* requestContext);
233+
BOOL GetPropertyDescriptorTrap(PropertyId propertyId, PropertyDescriptor* resultDescriptor, ScriptContext* requestContext);
236234

237235
#if ENABLE_TTD
238236
public:

lib/Runtime/Types/RecyclableObject.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,6 @@ namespace Js
313313
// Do nothing
314314
}
315315

316-
BOOL RecyclableObject::GetDefaultPropertyDescriptor(PropertyDescriptor& descriptor)
317-
{
318-
// By default, when GetOwnPropertyDescriptor is called for a nonexistent property,
319-
// return undefined.
320-
return false;
321-
}
322-
323316
HRESULT RecyclableObject::QueryObjectInterface(REFIID riid, void **ppvObj)
324317
{
325318
Assert(!this->GetScriptContext()->GetThreadContext()->IsScriptActive());

lib/Runtime/Types/RecyclableObject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ namespace Js {
340340
virtual BOOL IsProtoImmutable() const { return false; }
341341
virtual BOOL PreventExtensions() { return false; }; // Sets [[Extensible]] flag of instance to false
342342
virtual void ThrowIfCannotDefineProperty(PropertyId propId, const PropertyDescriptor& descriptor);
343-
virtual BOOL GetDefaultPropertyDescriptor(PropertyDescriptor& descriptor);
344343
virtual BOOL Seal() { return false; } // Seals the instance, no additional property can be added or deleted
345344
virtual BOOL Freeze() { return false; } // Freezes the instance, no additional property can be added or deleted or written
346345
virtual BOOL IsSealed() { return false; }

0 commit comments

Comments
 (0)