Skip to content

Commit

Permalink
[1.7>master] [1.6>1.7] [MERGE #3457 @curtisman] Cleanup: Remove unuse…
Browse files Browse the repository at this point in the history
…d field in JavascriptLibrary and avoid casting in functionObjectTypesList

Merge pull request #3457 from curtisman:clean

FuncitonObjectTypesList in FunctionBody always store RecyclerWeakReference<ScriptFunctionType> instead of RecyclerWeakReference<DynamicType>
Upgrade the type to avoid casting.

The JavascriptLibrary::dyanmicFunctionReference is already referenced by the JavascriptLibrary, so no need to bind reference.

Also typedArrayType field is not used in JavascriptLibaray. Remove it.
curtisman committed Jul 31, 2017
2 parents 4fdf333 + 0eabffe commit f33039c
Showing 4 changed files with 14 additions and 21 deletions.
29 changes: 12 additions & 17 deletions lib/Runtime/Base/FunctionBody.cpp
Original file line number Diff line number Diff line change
@@ -948,11 +948,10 @@ namespace Js
Js::ParseableFunctionInfo::NewDeferredFunctionFromFunctionBody(this);
FunctionInfo * functionInfo = this->GetFunctionInfo();

this->MapFunctionObjectTypes([&](DynamicType* type)
this->MapFunctionObjectTypes([&](ScriptFunctionType* functionType)
{
Assert(type->GetTypeId() == TypeIds_Function);

ScriptFunctionType* functionType = (ScriptFunctionType*)type;
Assert(functionType->GetTypeId() == TypeIds_Function);

if (!CrossSite::IsThunk(functionType->GetEntryPoint()))
{
functionType->SetEntryPoint(GetScriptContext()->DeferredParsingThunk);
@@ -2050,7 +2049,7 @@ namespace Js
{
if (typeWeakRef)
{
DynamicType* type = typeWeakRef->Get();
ScriptFunctionType* type = typeWeakRef->Get();
if (type)
{
func(type);
@@ -2078,7 +2077,7 @@ namespace Js
return functionObjectTypeList;
}

void FunctionProxy::RegisterFunctionObjectType(DynamicType* functionType)
void FunctionProxy::RegisterFunctionObjectType(ScriptFunctionType* functionType)
{
FunctionTypeWeakRefList* typeList = EnsureFunctionObjectTypeList();

@@ -9716,11 +9715,9 @@ namespace Js
#if ENABLE_NATIVE_CODEGEN
void FunctionEntryPointInfo::ResetOnNativeCodeInstallFailure()
{
this->functionProxy->MapFunctionObjectTypes([&](DynamicType* type)
this->functionProxy->MapFunctionObjectTypes([&](ScriptFunctionType* functionType)
{
Assert(type->GetTypeId() == TypeIds_Function);

ScriptFunctionType* functionType = (ScriptFunctionType*)type;
Assert(functionType->GetTypeId() == TypeIds_Function);
if (functionType->GetEntryPointInfo() == this)
{
if (!this->GetIsAsmJSFunction())
@@ -9791,11 +9788,10 @@ namespace Js
autoCleanup.Done();

}
this->functionProxy->MapFunctionObjectTypes([&](DynamicType* type)
this->functionProxy->MapFunctionObjectTypes([&](ScriptFunctionType* functionType)
{
Assert(type->GetTypeId() == TypeIds_Function);

ScriptFunctionType* functionType = (ScriptFunctionType*)type;
Assert(functionType->GetTypeId() == TypeIds_Function);

if (functionType->GetEntryPointInfo() == this)
{
functionType->SetEntryPointInfo(entryPoint);
@@ -9874,11 +9870,10 @@ namespace Js
}

OUTPUT_TRACE(Js::ExpirableCollectPhase, _u("Expiring 0x%p\n"), this);
this->functionProxy->MapFunctionObjectTypes([&] (DynamicType* type)
this->functionProxy->MapFunctionObjectTypes([&] (ScriptFunctionType* functionType)
{
Assert(type->GetTypeId() == TypeIds_Function);
Assert(functionType->GetTypeId() == TypeIds_Function);

ScriptFunctionType* functionType = (ScriptFunctionType*) type;
if (functionType->GetEntryPointInfo() == this)
{
OUTPUT_TRACE(Js::ExpirableCollectPhase, _u("Type 0x%p uses this entry point- switching to default entry point\n"), this);
4 changes: 2 additions & 2 deletions lib/Runtime/Base/FunctionBody.h
Original file line number Diff line number Diff line change
@@ -1327,7 +1327,7 @@ namespace Js
class FunctionProxy : public FinalizableObject
{
public:
typedef RecyclerWeakReference<DynamicType> FunctionTypeWeakRef;
typedef RecyclerWeakReference<ScriptFunctionType> FunctionTypeWeakRef;
typedef JsUtil::List<FunctionTypeWeakRef*, Recycler, false, WeakRefFreeListedRemovePolicy> FunctionTypeWeakRefList;

protected:
@@ -1465,7 +1465,7 @@ namespace Js
FunctionTypeWeakRefList* EnsureFunctionObjectTypeList();
FunctionTypeWeakRefList* GetFunctionObjectTypeList() const;
void SetFunctionObjectTypeList(FunctionTypeWeakRefList* list);
void RegisterFunctionObjectType(DynamicType* functionType);
void RegisterFunctionObjectType(ScriptFunctionType* functionType);
template <typename Fn>
void MapFunctionObjectTypes(Fn func);

1 change: 0 additions & 1 deletion lib/Runtime/Library/JavascriptLibrary.cpp
Original file line number Diff line number Diff line change
@@ -7329,7 +7329,6 @@ namespace Js
if (this->dynamicFunctionReference == nullptr)
{
this->dynamicFunctionReference = RecyclerNew(this->recycler, FunctionReferenceList, this->recycler);
this->BindReference(this->dynamicFunctionReference);
this->dynamicFunctionReferenceDepth = 0;
}

1 change: 0 additions & 1 deletion lib/Runtime/Library/JavascriptLibrary.h
Original file line number Diff line number Diff line change
@@ -257,7 +257,6 @@ namespace Js
Field(DynamicType *) arrayBufferType;
Field(DynamicType *) sharedArrayBufferType;
Field(DynamicType *) dataViewType;
Field(DynamicType *) typedArrayType;
Field(DynamicType *) int8ArrayType;
Field(DynamicType *) uint8ArrayType;
Field(DynamicType *) uint8ClampedArrayType;

0 comments on commit f33039c

Please sign in to comment.