Ver código fonte

Updated to AngelScript 2.23.1.
Removed link time code generation from the release build as it greatly increases compile time, but does not seem to provide observable performance benefit.

Lasse Öörni 13 anos atrás
pai
commit
a84ed27df9

+ 3 - 3
CMakeLists.txt

@@ -43,16 +43,16 @@ if (MSVC)
     add_definitions (-D_CRT_SECURE_NO_WARNINGS)
     set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
     set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT /fp:fast /Zi /GS-")
-    set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELWITHDEBINFO} /GL")
+    set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
     set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
     set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} /MT /fp:fast /Zi /GS- /D _SECURE_SCL=0")
-    set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL")
+    set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
     if (ENABLE_SSE)
         set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE")
         set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
     endif ()
     set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF /DEBUG")
-    set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF /LTCG")
+    set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF")
 else ()
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -m32")

+ 1 - 1
Docs/Urho3D.dox

@@ -61,7 +61,7 @@ Urho3D is greatly inspired by OGRE (http://www.ogre3d.org/) and Horde3D (http://
 
 Urho3D uses the following third-party libraries:
 
-- AngelScript 2.23.1 WIP (http://www.angelcode.com/angelscript/)
+- AngelScript 2.23.1 (http://www.angelcode.com/angelscript/)
 - Bullet 2.80 (http://www.bulletphysics.org/)
 - FreeType 2.3.12 (http://www.freetype.org/)
 - GLee 5.4 (http://elf-stone.com/)

+ 1 - 1
Readme.txt

@@ -36,7 +36,7 @@ Urho3D is greatly inspired by OGRE (http://www.ogre3d.org) and Horde3D
   http://timothylottes.blogspot.com/2011/04/nvidia-fxaa-ii-for-console.html
 
 Urho3D uses the following third-party libraries:
-- AngelScript 2.23.1 WIP (http://www.angelcode.com/angelscript/)
+- AngelScript 2.23.1 (http://www.angelcode.com/angelscript/)
 - Bullet 2.80 (http://www.bulletphysics.org/)
 - FreeType 2.3.12 (http://www.freetype.org/)
 - GLee 5.4 (http://elf-stone.com/)

+ 1 - 1
ThirdParty/AngelScript/include/angelscript.h

@@ -60,7 +60,7 @@ BEGIN_AS_NAMESPACE
 // AngelScript version
 
 #define ANGELSCRIPT_VERSION        22301
-#define ANGELSCRIPT_VERSION_STRING "2.23.1 WIP"
+#define ANGELSCRIPT_VERSION_STRING "2.23.1"
 
 // Data types
 

+ 3 - 3
ThirdParty/AngelScript/source/as_builder.cpp

@@ -3276,15 +3276,15 @@ int asCBuilder::RegisterVirtualProperty(asCScriptNode *node, asCScriptCode *file
 	asCString emulatedName;
 	asCDataType emulatedType;
 	
+	asCScriptNode *mainNode = node;
+	node = node->firstChild;
+
 	if( !isGlobalFunction && node->tokenType == ttPrivate )
 	{
 		isPrivate = true;
 		node = node->next;
 	}
 
-	asCScriptNode *mainNode = node;
-	node = node->firstChild;
-
 	// TODO: namespace: Use correct implicit namespace
 	emulatedType = CreateDataTypeFromNode(node, file, "");
 	emulatedType = ModifyDataTypeFromNode(emulatedType, node->next, file, 0, 0);

+ 58 - 64
ThirdParty/AngelScript/source/as_callfunc_x64_gcc.cpp

@@ -57,62 +57,50 @@ typedef asQWORD ( *funcptr_t )( void );
 // Note to self: Always remember to inform the used registers on the clobber line, 
 // so that the gcc optimizer doesn't try to use them for other things
 
-#define PUSH_LONG( val )                         \
-	__asm__ __volatile__ (                       \
-		"movq   %0, %%rax\n"                     \
-		"pushq  %%rax"                           \
-		:                                        \
-		: "m" ( val )                            \
-		: "%rax"                                 \
-	)
-
-#define ASM_GET_REG( name, dest )                \
-	__asm__ __volatile__ (                       \
-		"movq %" name ", %0\n"                   \
-		:                                        \
-		: "m" ( dest )                           \
-		: name                                   \
-	)
-
-static void __attribute__((noinline)) GetReturnedXmm0Xmm1(asQWORD &a, asQWORD &b)
+static asQWORD __attribute__((noinline)) X64_CallFunction(const asQWORD *args, int cnt, funcptr_t func, asQWORD &retQW2, bool returnFloat) 
 {
-	__asm__ __volatile__ (
-		"lea     %0, %%rax\n"
-		"movq  %%xmm0, (%%rax)\n"
-		"lea     %1, %%rdx\n"
-		"movq  %%xmm1, (%%rdx)\n" 
-		: // no optput
-		: "m" (a), "m" (b)
-		: "%rax", "%rdx", "%xmm0", "%xmm1"
-	);
-}
+	asQWORD   retQW1;
 
-static asQWORD __attribute__((noinline)) X64_CallFunction( const asQWORD *args, int cnt, funcptr_t func ) 
-{
-	asQWORD   retval;
-	funcptr_t call    = func;
-	int       i       = 0;
+	// Reference: http://www.x86-64.org/documentation/abi.pdf
 
-	// Backup the stack pointer and then align it to 16 bytes.
-	// The R15 register is guaranteed to maintain its value over function
-	// calls, so it is safe for us to keep the original stack pointer here.
 	__asm__ __volatile__ (
+
+		"  movq %0, %%rcx \n" 	// rcx = cnt
+		"  movq %1, %%r10 \n"	// r10 = args
+		"  movq %2, %%r11 \n"	// r11 = func
+
+	// Backup stack pointer in R15 that is guaranteed to maintain its value over function calls
 		"  movq %%rsp, %%r15 \n"
+
+	// Skip the first 128 bytes on the stack frame, called "red zone",  
+	// that might be used by the compiler to store temporary values
+		"  sub $128, %%rsp \n"
+
+	// Make sure the stack pointer will be aligned to 16 bytes when the function is called
+		"  movq %%rcx, %%rdx \n"
+		"  salq $3, %%rdx \n"
 		"  movq %%rsp, %%rax \n"
-		"  sub %0, %%rax \n"
+		"  sub %%rdx, %%rax \n"
 		"  and $15, %%rax \n"
 		"  sub %%rax, %%rsp \n"
-		: : "r" ((asQWORD)cnt*8) 
-		// Tell the compiler that we're using the RAX and R15.
-		// This will make sure these registers are backed up by the compiler.
-		: "%rax", "%r15", "%rsp");
 
-	// Push the stack parameters
-	for( i = MAX_CALL_INT_REGISTERS + MAX_CALL_SSE_REGISTERS; cnt-- > 0; i++ )
-		PUSH_LONG( args[i] );
+	// Push the stack parameters, i.e. the arguments that won't be loaded into registers
+		"  movq %%rcx, %%rsi \n"
+		"  testl %%esi, %%esi \n"
+		"  jle endstack \n"
+		"  subl $1, %%esi \n"
+		"  xorl %%edx, %%edx \n"
+		"  leaq	8(, %%rsi, 8), %%rcx \n"
+		"loopstack: \n"
+		"  movq 112(%%r10, %%rdx), %%rax \n"
+		"  pushq %%rax \n"
+		"  addq $8, %%rdx \n"
+		"  cmpq %%rcx, %%rdx \n"
+		"  jne loopstack \n"
+		"endstack: \n"
 
 	// Populate integer and floating point parameters
-	__asm__ __volatile__ (
+		"  movq %%r10, %%rax \n"
 		"  mov     (%%rax), %%rdi \n"
 		"  mov    8(%%rax), %%rsi \n"
 		"  mov   16(%%rax), %%rdx \n"
@@ -128,21 +116,32 @@ static asQWORD __attribute__((noinline)) X64_CallFunction( const asQWORD *args,
 		"  movsd 40(%%rax), %%xmm5 \n"
 		"  movsd 48(%%rax), %%xmm6 \n"
 		"  movsd 56(%%rax), %%xmm7 \n"
-		: 
-		: "a" (args) // Pass args in rax
+
+	// Call the function
+		"  call	*%%r11 \n"
+
+	// Restore stack pointer
+		"  mov %%r15, %%rsp \n"
+
+	// Put return value in retQW1 and retQW2, using either RAX:RDX or XMM0:XMM1 depending on type of return value
+		"  movl %5, %%ecx \n"
+		"  testb %%cl, %%cl \n"
+		"  je intret \n"
+		"  lea %3, %%rax \n"
+		"  movq %%xmm0, (%%rax) \n"
+		"  lea %4, %%rdx \n"
+		"  movq %%xmm1, (%%rdx) \n"
+		"  jmp endcall \n"
+		"intret: \n"
+		"  movq %%rax, %3 \n"
+		"  movq %%rdx, %4 \n"
+		"endcall: \n"
+
+		: : "r" ((asQWORD)cnt), "r" (args), "r" (func), "m" (retQW1), "m" (retQW2), "m" (returnFloat)
 		: "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", 
-		  "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", 
-		  // rsp and r15 is added too so the compiler doesn't try to use
-		  // them to store anything over this piece of assembly
-		  "%rsp", "%r15"); 
+		  "%rdi", "%rsi", "%rax", "%rdx", "%rcx", "%r8", "%r9", "%r10", "%r11", "%r15");
 		
-	// call the function with the arguments
-	retval = call();
-
-	// Restore the stack pointer
-	__asm__ __volatile__ ("  mov %%r15, %%rsp \n" : : : "%r15", "%rsp");
-
-	return retval;
+	return retQW1;
 }
 
 // returns true if the given parameter is a 'variable argument'
@@ -394,12 +393,7 @@ asQWORD CallSystemFunctionNative(asCContext *context, asCScriptFunction *descr,
 		}
 	}
 
-	retQW = X64_CallFunction( tempBuff, used_stack_args, func );
-	ASM_GET_REG( "%rdx", retQW2 );
-
-	// If the return is a float value we need to get the value from the FP register
-	if( sysFunc->hostReturnFloat )
-		GetReturnedXmm0Xmm1(retQW, retQW2);
+	retQW = X64_CallFunction( tempBuff, used_stack_args, func, retQW2, sysFunc->hostReturnFloat );
 
 	return retQW;
 }

+ 8 - 0
ThirdParty/AngelScript/source/as_compiler.cpp

@@ -10960,6 +10960,14 @@ void asCCompiler::CompileOperatorOnHandles(asCScriptNode *node, asSExprContext *
 	to.MakeHandle(true);
 	to.MakeReference(false);
 
+	if( !to.IsObjectHandle() )
+	{
+		// Compiler error, don't continue
+		Error(TXT_OPERANDS_MUST_BE_HANDLES, node);
+		ctx->type.SetConstantDW(asCDataType::CreatePrimitive(ttBool, true), true);
+		return;
+	}
+
 	// Do the conversion
 	ImplicitConversion(lctx, to, node, asIC_IMPLICIT_CONV);
 	ImplicitConversion(rctx, to, node, asIC_IMPLICIT_CONV);

+ 1 - 1
ThirdParty/AngelScript/source/as_config.h

@@ -663,7 +663,7 @@
 		#define AS_WINDOWS_THREADS
 
 	// Linux
-	#elif defined(__linux__)
+	#elif defined(__linux__) && !defined(ANDROID)
 		#if defined(i386) && !defined(__LP64__)
 			#define THISCALL_RETURN_SIMPLE_IN_MEMORY
 			#define CDECL_RETURN_SIMPLE_IN_MEMORY

+ 26 - 0
ThirdParty/AngelScript/source/as_context.cpp

@@ -3317,6 +3317,19 @@ void asCContext::ExecuteNext()
 			// PshVPtr 0
 			asPWORD tmp = *(asPWORD*)l_fp;
 
+			// Make sure the pointer is not null
+			if( tmp == 0 )
+			{
+				// Need to move the values back to the context
+				regs.programPointer = l_bc;
+				regs.stackPointer = l_sp;
+				regs.stackFramePointer = l_fp;
+
+				// Raise exception
+				SetInternalException(TXT_NULL_POINTER_ACCESS);
+				return;
+			}
+
 			// ADDSi
 			tmp = tmp + asBC_SWORDARG0(l_bc);
 
@@ -3414,6 +3427,19 @@ void asCContext::ExecuteNext()
 			// PshVPtr x
 			asPWORD tmp = *(asPWORD*)(l_fp - asBC_SWORDARG0(l_bc)); 
 
+			// Make sure the pointer is not null
+			if( tmp == 0 )
+			{
+				// Need to move the values back to the context
+				regs.programPointer = l_bc;
+				regs.stackPointer = l_sp;
+				regs.stackFramePointer = l_fp;
+
+				// Raise exception
+				SetInternalException(TXT_NULL_POINTER_ACCESS);
+				return;
+			}
+
 			// ADDSi y
 			tmp = tmp + asBC_SWORDARG1(l_bc);