Selaa lähdekoodia

Fix ChakraCore retail build

Mostly just fixing link errors by explicitly instantiating templatized functions.
Hello world works on Linux retail builds now.
Hitesh Kanwathirtha 10 vuotta sitten
vanhempi
sitoutus
1552054536

+ 10 - 12
bin/ch/WScriptJsrt.cpp

@@ -188,10 +188,9 @@ JsValueRef WScriptJsrt::LoadScriptHelper(JsValueRef callee, bool isConstructCall
     else
     {
         const wchar_t *fileContent;
-        char *fileName;
+        char *fileName = (char*) "script.js";
         const wchar_t *scriptInjectType = _u("self");
         size_t fileContentLength;
-        size_t fileNameLength;
         size_t scriptInjectTypeLength;
         bool freeFileName = false;
 
@@ -200,18 +199,17 @@ JsValueRef WScriptJsrt::LoadScriptHelper(JsValueRef callee, bool isConstructCall
         if (argumentCount > 2)
         {
             IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointer(arguments[2], &scriptInjectType, &scriptInjectTypeLength));
-        }
 
-        fileName = "script.js";
-        fileNameLength = strlen(fileName);
-        if (argumentCount > 3)
-        {
-            size_t fileNameWideLength = 0;
-            const wchar_t* fileNameWide = nullptr;
-            IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointer(arguments[3], &fileNameWide, &fileNameWideLength));
-            IfFailGo(Helpers::WideStringToNarrowDynamic(fileNameWide, &fileName));
-            freeFileName = true;
+            if (argumentCount > 3)
+            {
+                size_t fileNameWideLength = 0;
+                const wchar_t* fileNameWide = nullptr;
+                IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointer(arguments[3], &fileNameWide, &fileNameWideLength));
+                IfFailGo(Helpers::WideStringToNarrowDynamic(fileNameWide, &fileName));
+                freeFileName = true;
+            }
         }
+        
         returnValue = LoadScript(callee, fileName, fileContent, scriptInjectType, isSourceModule);
 
         if (freeFileName)

+ 3 - 0
lib/Common/Memory/Recycler.cpp

@@ -8220,3 +8220,6 @@ RecyclerHeapObjectInfo::GetSize() const
 #endif
     return size;
 }
+
+template char* Recycler::AllocWithAttributesInlined<(Memory::ObjectInfoBits)32, false>(size_t);
+

+ 8 - 0
lib/Parser/CharClassifier.cpp

@@ -665,3 +665,11 @@ PlatformAgnostic::UnicodeText::CharacterTypeFlags Js::CharClassifier::GetCharFla
 #endif
 }
 #endif
+
+// Explicit instantiation
+template bool Js::CharClassifier::IsIdStartFast<true>(codepoint_t) const;
+template bool Js::CharClassifier::IsIdStartFast<false>(codepoint_t) const;
+template bool Js::CharClassifier::IsIdContinueFast<true>(codepoint_t) const;
+template bool Js::CharClassifier::IsIdContinueFast<false>(codepoint_t) const;
+template bool Js::CharClassifier::IsWhiteSpaceFast<true>(codepoint_t) const;
+template bool Js::CharClassifier::IsWhiteSpaceFast<false>(codepoint_t) const;

+ 0 - 12
lib/Parser/Parse.cpp

@@ -686,18 +686,6 @@ void Parser::InitNode(OpCode nop,ParseNodePtr pnode) {
 }
 
 // Create nodes using Arena
-template <OpCode nop>
-ParseNodePtr Parser::StaticCreateNodeT(ArenaAllocator* alloc, charcount_t ichMin, charcount_t ichLim)
-{
-    ParseNodePtr pnode = StaticAllocNode<nop>(alloc);
-    InitNode(nop,pnode);
-    // default - may be changed
-    pnode->ichMin = ichMin;
-    pnode->ichLim = ichLim;
-
-    return pnode;
-}
-
 ParseNodePtr
 Parser::StaticCreateBlockNode(ArenaAllocator* alloc, charcount_t ichMin , charcount_t ichLim, int blockId, PnodeBlockType blockType)
 {

+ 11 - 1
lib/Parser/Parse.h

@@ -240,7 +240,17 @@ public:
 
     // create nodes using arena allocator; used by AST transformation
     template <OpCode nop>
-    static ParseNodePtr StaticCreateNodeT(ArenaAllocator* alloc, charcount_t ichMin = 0, charcount_t ichLim = 0);
+    static ParseNodePtr StaticCreateNodeT(ArenaAllocator* alloc, charcount_t ichMin = 0, charcount_t ichLim = 0)
+    {
+        ParseNodePtr pnode = StaticAllocNode<nop>(alloc);
+        InitNode(nop,pnode);
+        // default - may be changed
+        pnode->ichMin = ichMin;
+        pnode->ichLim = ichLim;
+
+        return pnode;
+    }
+
     static ParseNodePtr StaticCreateBinNode(OpCode nop, ParseNodePtr pnode1,ParseNodePtr pnode2,ArenaAllocator* alloc);
     static ParseNodePtr StaticCreateBlockNode(ArenaAllocator* alloc, charcount_t ichMin = 0, charcount_t ichLim = 0, int blockId = -1, PnodeBlockType blockType = PnodeBlockType::Regular);
     ParseNodePtr CreateNode(OpCode nop, charcount_t ichMin,charcount_t ichLim);

+ 4 - 0
lib/Parser/RegexRuntime.cpp

@@ -5063,6 +5063,10 @@ namespace UnifiedRegex
     }
 #endif
 
+    // Template parameter here is the max number of cases
+    template void UnifiedRegex::SwitchMixin<10>::AddCase(char16, unsigned int);
+    template void UnifiedRegex::SwitchMixin<20>::AddCase(char16, unsigned int);
+
 #define M(...)
 #define MTemplate(TagName, TemplateDeclaration, GenericClassName, SpecializedClassName) template struct SpecializedClassName;
 #include "RegexOpCodes.h"

+ 1 - 1
lib/Runtime/Base/CrossSite.cpp

@@ -123,7 +123,7 @@ namespace Js
     }
 
     // static
-    inline Var CrossSite::MarshalVar(ScriptContext* scriptContext, Var value, bool fRequestWrapper)
+    Var CrossSite::MarshalVar(ScriptContext* scriptContext, Var value, bool fRequestWrapper)
     {
         // value might be null from disable implicit call
         if (value == nullptr || Js::TaggedNumber::Is(value))

+ 5 - 4
lib/Runtime/Base/FunctionBody.cpp

@@ -73,12 +73,12 @@ namespace Js
         PERF_COUNTER_INC(Code, TotalFunction);
     }
 
-    inline Recycler* FunctionProxy::GetRecycler() const
+    Recycler* FunctionProxy::GetRecycler() const
     {
         return m_scriptContext->GetRecycler();
     }
 
-    inline void* FunctionProxy::GetAuxPtr(AuxPointerType e) const
+    void* FunctionProxy::GetAuxPtr(AuxPointerType e) const
     {
         if (this->auxPtrs == nullptr)
         {
@@ -89,7 +89,8 @@ namespace Js
         Assert(ThreadContext::GetContextForCurrentThread() || ThreadContext::GetCriticalSection()->IsLocked());
         return AuxPtrsT::GetAuxPtr(this, e);
     }
-    inline void* FunctionProxy::GetAuxPtrWithLock(AuxPointerType e) const
+
+    void* FunctionProxy::GetAuxPtrWithLock(AuxPointerType e) const
     {
         if (this->auxPtrs == nullptr)
         {
@@ -99,7 +100,7 @@ namespace Js
         return AuxPtrsT::GetAuxPtr(this, e);
     }
 
-    inline void FunctionProxy::SetAuxPtr(AuxPointerType e, void* ptr)
+    void FunctionProxy::SetAuxPtr(AuxPointerType e, void* ptr)
     {
         // On process detach this can be called from another thread but the ThreadContext should be locked
         Assert(ThreadContext::GetContextForCurrentThread() || ThreadContext::GetCriticalSection()->IsLocked());

+ 2 - 2
lib/Runtime/Base/ThreadContextTlsEntry.cpp

@@ -127,7 +127,7 @@ void ThreadContextTLSEntry::Delete(ThreadContextTLSEntry * entry)
     HeapDelete(entry);
 }
 
-inline ThreadContextTLSEntry * ThreadContextTLSEntry::GetEntryForCurrentThread()
+ThreadContextTLSEntry * ThreadContextTLSEntry::GetEntryForCurrentThread()
 {
     Assert(s_tlsSlot != TLS_OUT_OF_INDEXES);
     return reinterpret_cast<ThreadContextTLSEntry *>(TlsGetValue(s_tlsSlot));
@@ -146,7 +146,7 @@ ThreadContextTLSEntry * ThreadContextTLSEntry::CreateEntryForCurrentThread()
     return entry;
 }
 
-inline ThreadContext * ThreadContextTLSEntry::GetThreadContext()
+ThreadContext * ThreadContextTLSEntry::GetThreadContext()
 {
     return this->threadContext;
 }

+ 3 - 0
lib/Runtime/ByteCode/ByteCodeReader.cpp

@@ -248,6 +248,9 @@ namespace Js
     template AuxArray<uint32> const * ByteCodeReader::ReadAuxArrayWithLock<uint32>(uint offset, FunctionBody * functionBody);
     template AuxArray<double> const * ByteCodeReader::ReadAuxArrayWithLock<double>(uint offset, FunctionBody * functionBody);
     template AuxArray<FuncInfoEntry> const * ByteCodeReader::ReadAuxArrayWithLock<FuncInfoEntry>(uint offset, FunctionBody * functionBody);
+    template const unaligned Js::OpLayoutT_Unsigned1<Js::LayoutSizePolicy<(Js::LayoutSize)0> >* Js::ByteCodeReader::GetLayout<Js::OpLayoutT_Unsigned1<Js::LayoutSizePolicy<(Js::LayoutSize)0> > >(const byte*&);
+    template const unaligned Js::OpLayoutT_Unsigned1<Js::LayoutSizePolicy<(Js::LayoutSize)1> >* Js::ByteCodeReader::GetLayout<Js::OpLayoutT_Unsigned1<Js::LayoutSizePolicy<(Js::LayoutSize)1> > >(const byte*&);
+    template const unaligned Js::OpLayoutT_Unsigned1<Js::LayoutSizePolicy<(Js::LayoutSize)2> >* Js::ByteCodeReader::GetLayout<Js::OpLayoutT_Unsigned1<Js::LayoutSizePolicy<(Js::LayoutSize)2> > >(const byte*&);
 
     const Js::PropertyIdArray * ByteCodeReader::ReadPropertyIdArray(uint offset, FunctionBody * functionBody, uint extraSlots)
     {

+ 3 - 0
lib/Runtime/Language/InterpreterStackFrame.cpp

@@ -8352,6 +8352,9 @@ const byte * InterpreterStackFrame::OP_ProfiledLoopBodyStart(const byte * ip)
         AssertMsg(allocationToFree == previousAllocation, "Memory locations should match");
         AssertMsg(false, "This function should never actually be called");
     }
+
+    template void* Js::InterpreterStackFrame::GetReg<unsigned int>(unsigned int) const;
+    template void Js::InterpreterStackFrame::SetReg<unsigned int>(unsigned int, void*);
 } // namespace Js
 
 // Make sure the macro and the layout for the op is consistent

+ 1 - 1
lib/Runtime/Library/CompoundString.cpp

@@ -146,7 +146,7 @@ namespace Js
 
     #endif
 
-    inline CharCount CompoundString::Block::PointerLengthFromCharLength(const CharCount charLength)
+    CharCount CompoundString::Block::PointerLengthFromCharLength(const CharCount charLength)
     {
         return PointerAlign(charLength) / (sizeof(void *) / sizeof(char16));
     }

+ 6 - 0
lib/Runtime/Library/JavascriptArray.cpp

@@ -12204,4 +12204,10 @@ Case0:
 
         return static_cast<JavascriptNativeFloatArray *>(RecyclableObject::FromVar(aValue));
     }
+
+    template int   Js::JavascriptArray::GetParamForIndexOf<unsigned int>(unsigned int, Js::Arguments const&, void*&, unsigned int&, Js::ScriptContext*);
+    template bool  Js::JavascriptArray::ArrayElementEnumerator::MoveNext<void*>();
+    template void  Js::JavascriptArray::SetArrayLiteralItem<void*>(unsigned int, void*);
+    template void* Js::JavascriptArray::TemplatedIndexOfHelper<false, Js::TypedArrayBase, unsigned int>(Js::TypedArrayBase*, void*, unsigned int, unsigned int, Js::ScriptContext*);
+    template void* Js::JavascriptArray::TemplatedIndexOfHelper<true, Js::TypedArrayBase, unsigned int>(Js::TypedArrayBase*, void*, unsigned int, unsigned int, Js::ScriptContext*);
 } //namespace Js

+ 1 - 1
lib/Runtime/Library/JavascriptObject.cpp

@@ -791,7 +791,7 @@ namespace Js
         return JavascriptOperators::FromPropertyDescriptor(propertyDescriptor, scriptContext);
     }
 
-    inline BOOL JavascriptObject::GetOwnPropertyDescriptorHelper(RecyclableObject* obj, PropertyId propertyId, ScriptContext* scriptContext, PropertyDescriptor& propertyDescriptor)
+    BOOL JavascriptObject::GetOwnPropertyDescriptorHelper(RecyclableObject* obj, PropertyId propertyId, ScriptContext* scriptContext, PropertyDescriptor& propertyDescriptor)
     {
         BOOL isPropertyDescriptorDefined;
         if (obj->CanHaveInterceptors())

+ 1 - 1
lib/Runtime/Library/JavascriptProxy.cpp

@@ -7,7 +7,7 @@
 
 namespace Js
 {
-    inline BOOL JavascriptProxy::Is(Var obj)
+    BOOL JavascriptProxy::Is(Var obj)
     {
         return JavascriptOperators::GetTypeId(obj) == TypeIds_Proxy;
     }

+ 0 - 10
lib/Runtime/Library/JavascriptRegularExpression.cpp

@@ -100,16 +100,6 @@ namespace Js
         return static_cast<JavascriptRegExp *>(RecyclableObject::FromVar(aValue));
     }
 
-    void JavascriptRegExp::SetPattern(UnifiedRegex::RegexPattern* pattern)
-    {
-        this->pattern = pattern;
-    }
-
-    void JavascriptRegExp::SetSplitPattern(UnifiedRegex::RegexPattern* splitPattern)
-    {
-        this->splitPattern = splitPattern;
-    }
-
     CharCount JavascriptRegExp::GetLastIndexProperty(RecyclableObject* instance, ScriptContext* scriptContext)
     {
         int64 lastIndex = JavascriptConversion::ToLength(

+ 9 - 2
lib/Runtime/Library/JavascriptRegularExpression.h

@@ -51,8 +51,15 @@ namespace Js
 
         Var GetOptions();
 
-        inline void SetPattern(UnifiedRegex::RegexPattern* pattern);
-        inline void SetSplitPattern(UnifiedRegex::RegexPattern* splitPattern);
+        void SetPattern(UnifiedRegex::RegexPattern* pattern)
+        {
+            this->pattern = pattern;
+        }
+
+        void SetSplitPattern(UnifiedRegex::RegexPattern* splitPattern)
+        {
+            this->splitPattern = splitPattern;
+        }
 
         static CharCount GetLastIndexProperty(RecyclableObject* instance, ScriptContext* scriptContext);
         static void SetLastIndexProperty(Var instance, CharCount lastIndex, ScriptContext* scriptContext);

+ 2 - 2
lib/Runtime/Library/JavascriptRegularExpressionResult.cpp

@@ -6,7 +6,7 @@
 
 namespace Js
 {
-    inline JavascriptArray* JavascriptRegularExpressionResult::Create(
+    JavascriptArray* JavascriptRegularExpressionResult::Create(
         void *const stackAllocationPointer,
         JavascriptString* input,
         ScriptContext* const scriptContext)
@@ -21,7 +21,7 @@ namespace Js
         return arr;
     }
 
-    inline JavascriptArray* JavascriptRegularExpressionResult::Create(
+    JavascriptArray* JavascriptRegularExpressionResult::Create(
         void *const stackAllocationPointer,
         const int numGroups,
         JavascriptString* input,

+ 2 - 2
lib/Runtime/Library/StringCopyInfo.cpp

@@ -33,14 +33,14 @@ namespace Js
     #endif
     }
 
-    inline JavascriptString *StringCopyInfo::SourceString() const
+    JavascriptString *StringCopyInfo::SourceString() const
     {
         Assert(isInitialized);
 
         return sourceString;
     }
 
-    inline char16 *StringCopyInfo::DestinationBuffer() const
+    char16 *StringCopyInfo::DestinationBuffer() const
     {
         Assert(isInitialized);
         return destinationBuffer;

+ 7 - 0
lib/Runtime/Types/SimpleDictionaryTypeHandler.cpp

@@ -3154,4 +3154,11 @@ namespace Js
     template class SimpleDictionaryTypeHandlerBase<PropertyIndex, JavascriptString*, true>;
     template class SimpleDictionaryTypeHandlerBase<BigPropertyIndex, JavascriptString*, false>;
     template class SimpleDictionaryTypeHandlerBase<BigPropertyIndex, JavascriptString*, true>;
+
+    template void Js::SimpleDictionaryTypeHandlerBase<unsigned short, Js::PropertyRecord const*, false>::Add<Js::PropertyRecord const*>(Js::PropertyRecord const*, unsigned char, bool, bool, bool, Js::ScriptContext* const);
+    template void Js::SimpleDictionaryTypeHandlerBase<unsigned short, Js::PropertyRecord const*, true>::Add<Js::PropertyRecord const*>(Js::PropertyRecord const*, unsigned char, bool, bool, bool, Js::ScriptContext* const);
+
+    // Instantiated here since this method is defined in this file
+    template void Js::PropertyIndexRangesBase<Js::PropertyIndexRanges<int> >::VerifySlotCapacity(int);
+    template void Js::PropertyIndexRangesBase<Js::PropertyIndexRanges<unsigned short> >::VerifySlotCapacity(int);
 }

+ 0 - 5
lib/Runtime/Types/Type.cpp

@@ -117,11 +117,6 @@ namespace Js
         return flags & TypeFlagMask_AreThisAndPrototypesEnsuredToHaveOnlyWritableDataProperties;
     }
 
-    BOOL Type::IsFalsy() const
-    {
-        return flags & TypeFlagMask_IsFalsy;
-    }
-
     void Type::SetIsFalsy(const bool truth)
     {
         if (truth)

+ 1 - 1
lib/Runtime/Types/Type.h

@@ -61,7 +61,7 @@ namespace Js
         inline BOOL IsExternal() const { return (this->flags & TypeFlagMask_External) != 0; }
         inline BOOL SkipsPrototype() const { return (this->flags & TypeFlagMask_SkipsPrototype) != 0 ; }
         inline BOOL CanHaveInterceptors() const { return (this->flags & TypeFlagMask_CanHaveInterceptors) != 0; }
-        inline BOOL IsFalsy() const;
+        inline BOOL IsFalsy() const { return flags & TypeFlagMask_IsFalsy; }
         void SetIsFalsy(const bool truth);
         void SetHasSpecialPrototype(const bool hasSpecialPrototype);
 

+ 1 - 1
lib/Runtime/Types/TypePath.cpp

@@ -40,7 +40,7 @@ namespace Js {
         return LookupInline(propId,typePathLength);
     }
 
-    inline PropertyIndex TypePath::LookupInline(PropertyId propId,int typePathLength)
+    PropertyIndex TypePath::LookupInline(PropertyId propId,int typePathLength)
     {
         if (propId == Constants::NoProperty) {
            return Constants::NoSlot;