Jump to content
  • Advertisement

rfonseca

Member
  • Content Count

    24
  • Joined

  • Last visited

Community Reputation

135 Neutral

About rfonseca

  • Rank
    Member
  1. rfonseca

    Compiling angelscript on ppc64

    It works! Good job.   And I have good news:   --------- MEMORY STATISTICS number of allocations                 : 628810 max allocated memory at any one time  : 4334820 max number of simultaneous allocations: 57210 total amount of allocated memory      : 89742757 medium size of allocations            : 142 -------------------------------------------- All of the tests passed with success.   :D
  2. rfonseca

    Compiling angelscript on ppc64

    Andreas,   sorry for the delay. It takes me some time to get around the compiler code.   So this is what's happening (line numbers might be a bit off because of my changes):   1) the string "2147483648" is parsed and converted to an asQWORD (0x80000000). Since the 31st bit is set, this value is saved as a signed int64       compiler.cpp:9037  ctx->type.SetConstantQW(asCDataType::CreatePrimitive(ttInt64, true), val); (gdb) n 9043                                            ctx->type.SetConstantQW(asCDataType::CreatePrimitive(ttInt64, true), val); (gdb) n 9030                            asCString value(&script->code[vnode->tokenPos], vnode->tokenLength); (gdb) p ctx->type.GetConstantQW() $28 = 2147483648 (gdb) p/x ctx->type.GetConstantQW() $29 = 0x80000000 2) the operator ttMinus is applied and the value is now 0xffffffff80000000       compiler.cpp:10661 ctx->type.SetConstantQW(-(asINT64)ctx->type.GetConstantQW()); 10666                                   else if( ctx->type.dataType.IsIntegerType() && ctx->type.dataType.GetSizeInMemoryDWords() == 2 ) (gdb)  10667                                           ctx->type.SetConstantQW(-(asINT64)ctx->type.GetConstantQW()); (gdb)  10678                                   return 0; (gdb) p ctx->type.GetConstantQW() $38 = 18446744071562067968 (gdb) p/x ctx->type.GetConstantQW() $39 = 0xffffffff80000000 3) the assignment is evaluated and the value is implicitly converted to ttInt32. For that, in  asCCompiler::ImplicitConversionConstant you just change the type from ttInt64 to ttInt. In a little endian system, nothing else needs to be done, since later, when you read the asDWORD from the union, you're going to read the right portion of the number. But in a big endian, you read the first half (0xffffffff).   What my patch tried to do, unsuccessfully, was to do the right conversion at ::ImplicitConversionConstant time, instead of just overwriting the variable type to the target's type right away.   Should I dig in deeper or do you think that's enough?
  3. rfonseca

    Compiling angelscript on ppc64

    Andreas,   the tests to check the division of -2147483648 by -1 were failing on PPC. That's because when the value (1<<31) is parsed, it's saved as an int64 (0xffffffff80000000). If we get a dword from that, we get the 0xffffffff part on big endians. So int values need to be properly downsized.   The attached patch fixes this problem BUT it's not the proper solution. Do you have any ideas how to better do this? Maybe we need to properly parse int32 vs int64 values?
  4. rfonseca

    Compiling angelscript on ppc64

    The attached patch fixes the previous mentioned error in test_compiler.cpp:1742    Next errors are now:   Failed on line 1851 in ../../source/test_compiler.cpp Failed on line 1857 in ../../source/test_compiler.cpp  
  5. rfonseca

    Compiling angelscript on ppc64

    What about the attached patch? With it, all tests up to test_compiler pass.   Failed on line 1742 in ../../source/test_compiler.cpp
  6. rfonseca

    Compiling angelscript on ppc64

    Andreas,   now test_namespace is the one failing. Particularly these lines:    606             "  assert(a::e1 == 1); \n"  607             "  assert(a::e::e1 == 1); \n"   The problem comes from the way the enum value is evaluated. In as_builder.cpp:2299, the following code   e->value = *(int*)&gvar->constantValue;   gives the wrong value in PPC because constantValue is an asQWORD with value 0x0000000000000001, so the 'int' portion is 0.     fprintf(stderr, "gvar->value is 0x%016lx and converted is 0x%08x\n", gvar->constantValue, *(int *)&gvar->constantValue); // as_builder.cpp:2300   results in     "gvar->value is 0x0000000000000001 and converted is 0x00000000".   This problem does not happen for all cases. For some, the right portion of the constantValue is evaluated, as we can see from the output below. I guess when we save a constant enum value we save the whole QWORD instead of saving only the 'int' portion in the gvar.   gvar->value is 0x00000000deadbeef and converted is 0x00000000 gvar->value is 0x00000001deadbeef and converted is 0x00000001 gvar->value is 0x00000002deadbeef and converted is 0x00000002 gvar->value is 0x00000000deadbeef and converted is 0x00000000 gvar->value is 0x00000001deadbeef and converted is 0x00000001 gvar->value is 0x00000002deadbeef and converted is 0x00000002 gvar->value is 0x00000000deadbeef and converted is 0x00000000 gvar->value is 0x00000000deadbeef and converted is 0x00000000 gvar->value is 0x0000000000000000 and converted is 0x00000000 gvar->value is 0x0000000000000001 and converted is 0x00000000
  7. rfonseca

    Compiling angelscript on ppc64

    Patch for enabling datetime test compilation on gcc.   Edit: missed a change on add_on/datetime/datetime.cpp. Another patch attached.
  8. rfonseca

    Compiling angelscript on ppc64

    Yes, it is working now!   I'll keep debugging the other issues. I'll come back with more things soon.
  9. rfonseca

    Compiling angelscript on ppc64

    Andreas, there is one problem.   --- Assert failed --- func: void main() mdle: test sect: test line: 11 --------------------- Failed on line 118 in ../../source/test_addon_dictionary.cpp   In that line, the assert is "    assert( bool(dict['value']) == true ); \n"   In CScriptDictValue::Set we memcpy 'size' bytes to m_valueInt. So this happens:   -> Memcpying 8 bytes from 2a (from an fprintf I added)   But then, on  CScriptDictValue::Get,    int size = engine->GetSizeOfPrimitiveType(typeId); // -> equals to 1.   When you memcmp one byte of 'm_valueInt' to 'zero', it does:   m_valueInt (big endian): 0x000000000000002a zero:                               0x0000000000000000                                            ^ first byte   Notice that the first byte is 0 in both, so the comparison to 'zero' will return true.   If you change size to 8, the test passes successfully. However, from my printf I noticed sometimes only 4 bytes are memcpy'ed. That's why in my original patch I replaced this line with:   *(bool*)value = !!m_valueInt;
  10. rfonseca

    Compiling angelscript on ppc64

    I was just busy with other stuff and it was hard to find the time to work on Angelscript.   So about the test_compiler.cpp failures, this is what the assembly code looks like:   void ExecuteString()   Temps: 2   Variables:  001: uint ui32     - 1,1 -     0   2 *    SUSPEND                VarDecl  0     1   2 *    SetV4    v1, 0x0          (i:0, f:0) - 1,27 -     3   2 *    SUSPEND     4   2 *    CMPIu    v1, -1     6   2 *    TZ     7   2 *    CpyRtoV4 v2     8   2 *    PshV4    v2     9   3 *    CALLSYS  19           (void assert(bool)) - 2,3 -    11   2 *    SUSPEND             0:    12   2 *    RET      0   So the problem is possibly in the SetV4 part when reading a dword from a saved qword. I tried a fix similar to what I did to SetV1, but them I broke test_pow :(
  11. rfonseca

    Compiling angelscript on ppc64

    After a long hiatus, I'm back with some results. The attached changes make the test pass until test_saveload. Note that it's not a patch, it just points out where the "faulty" parts possibly are.   With those changes, I get up to   Failed on line 499 in ../../source/test_saveload.cpp Failed on line 516 in ../../source/test_saveload.cpp config (49, 0) : Warning : Cannot register template callback without the actual implementation Failed on line 611 in ../../source/test_saveload.cpp   and if I comment out the saveload test   Test on line 987 in ../../source/test_compiler.cpp skipped --- Assert failed --- func: void ExecuteString() mdle: (null) sect: ExecuteString line: 1 --------------------- Failed on line 1216 in ../../source/test_compiler.cpp --- Assert failed --- func: void ExecuteString() mdle: (null) sect: ExecuteString line: 1 --------------------- Failed on line 1237 in ../../source/test_compiler.cpp Failed on line 1742 in ../../source/test_compiler.cpp Test on line 1755 in ../../source/test_compiler.cpp skipped Test on line 1792 in ../../source/test_compiler.cpp skipped Failed on line 1851 in ../../source/test_compiler.cpp Failed on line 1857 in ../../source/test_compiler.cpp Test on line 2059 in ../../source/test_compiler.cpp skipped Test on line 4564 in ../../source/test_compiler.cpp skipped Test on line 4827 in ../../source/test_compiler.cpp skipped -------------------------------------------- One of the tests failed, see details above.   I hope it helps.   
  12. rfonseca

    Compiling angelscript on ppc64

      This second problem is failing on the script statement "assert( b == 1 );", which is translated to the following bytecode sequence:   - 4,5 -     0  21 *    SUSPEND     1  21 *    SetV1    v1, 0x1     3  21 *    PshV4    v1     4  22 *    CALLSYS  150           (void assert(bool))   You can find this in the debug output file AS_DEBUG/__main.txt right after compiling the script (if the library is compiled with the flag AS_DEBUG defined).   Most like the problem is with the bytecode instruction asBC_SetV1 in as_context.cpp, which is not setting the byte in the correct position of the target DWORD. A similar problem would exist with SetV2 as well.     SetV[1,2,4] seem to be fine (regarding this test). The problem is the number being wrong in the bytecode itself.                    ppc64                                                          ppc64le Set 0 [0] at 0x1002e480420[-1]        | Set 0x1 [0x1] at 0x1002edf23c0[-1] Push 0 [0] from 0x1002e480420[-1] | Push 0x1 [0x1] from 0x1002edf23c0[-1]   I saved the generated bytecodes to a file and this is the result:                                                        ppc64                                                                                                                                  ppc64le 00000000: 0001 0666 6f6f 0400 0000 0400 0302 6100  ...foo........a.  |  00000000: 0001 0666 6f6f 0400 0000 0400 0302 6100  ...foo........a. 00000010: 0000 0002 6200 0000 0102 6300 0000 0200  ....b.....c.....  |  00000010: 0000 0002 6200 0000 0102 6300 0000 0200  ....b.....c..... 00000020: 0000 0003 6608 6d61 696e 0040 5000 0000  ....f.main.@P...  |  00000020: 0000 0003 6608 6d61 696e 0040 5000 0000  ....f.main.@P... 00000030: 0100 0000 4107 3f8e 0100 0301 3d00 3fbd  ....A.?.....=.?.  |  00000030: 0100 0000 4107 3f8e 0101 0301 3d00 3fbd  ....A.?.....=.?.                                  ^                                                                       ^  
  13. Maybe this is not important, but if you add -DSTREAM_TO_FILE when compiling the test_feature set, it fails with:   ../../source/test_saveload.cpp: In function ‘bool TestSaveLoad::Test()’: ../../source/test_saveload.cpp:880:40: error: ‘class CBytecodeStream’ has no member named ‘buffer’    asDWORD crc1 = ComputeCRC32(&stream2.buffer[0], asUINT(stream2.buffer.size()))                                         ^ ../../source/test_saveload.cpp:880:66: error: ‘class CBytecodeStream’ has no member named ‘buffer’    asDWORD crc1 = ComputeCRC32(&stream2.buffer[0], asUINT(stream2.buffer.size()))                                                                   ^ ../../source/test_saveload.cpp:907:40: error: ‘class CBytecodeStream’ has no member named ‘buffer’    asDWORD crc2 = ComputeCRC32(&stream4.buffer[0], asUINT(stream4.buffer.size()))                                         ^ ../../source/test_saveload.cpp:907:66: error: ‘class CBytecodeStream’ has no member named ‘buffer’    asDWORD crc2 = ComputeCRC32(&stream4.buffer[0], asUINT(stream4.buffer.size()))                                                                   ^ ../../source/test_saveload.cpp:912:15: error: ‘class CBytecodeStream’ has no member named ‘buffer’    if( stream4.buffer.size() == stream2.buffer.size() )                ^ ../../source/test_saveload.cpp:912:40: error: ‘class CBytecodeStream’ has no member named ‘buffer’    if( stream4.buffer.size() == stream2.buffer.size() )                                         ^ ../../source/test_saveload.cpp:914:35: error: ‘class CBytecodeStream’ has no member named ‘buffer’     for( size_t b = 0; b < stream4.buffer.size(); ++b )                                    ^ ../../source/test_saveload.cpp:915:17: error: ‘class CBytecodeStream’ has no member named ‘buffer’      if( stream4.buffer != stream2.buffer )                  ^ ../../source/test_saveload.cpp:915:38: error: ‘class CBytecodeStream’ has no member named ‘buffer’      if( stream4.buffer != stream2.buffer )                                       ^ makefile:203: recipe for target 'obj/test_saveload.o' failed
  14. rfonseca

    Compiling angelscript on ppc64

      It looks like the problem is that MAX_PORTABILITY is defined, so RegisterGlobalFunction returns NOT_SUPPORTED since the call is not registered as CALL_GENERIC.
  15. rfonseca

    Compiling angelscript on ppc64

    Andreas,   some progress update. My patch so far is attached.   * as of recent updates, I'm getting the following error on ppc64le:   -- TestEnumGlobVar passed  (0, 0) : Error   : Failed in call to function 'RegisterGlobalFunction' with 'void Print(const string& in s)' (Code: -7)  (0, 0) : Error   : Invalid configuration. Verify the registered application interface. Failed on line 63 in ../../source/test_configaccess.cpp -------------------------------------------- One of the tests failed, see details above.     * test_features pass on ppc64 up to test_addon_dictionary:    --- Assert failed --- func: void main() mdle: test sect: test line: 7 --------------------- Failed on line 119 in ../../source/test_addon_dictionary.cpp --- Assert failed --- func: void main() mdle: test sect: test line: 4 --------------------- func: void main() modl: test sect: test line: 4 desc: Assert failed --- call stack --- ExecuteString (1): void ExecuteString() Failed on line 430 in ../../source/test_addon_dictionary.cpp Test on line 531 in ../../source/test_addon_dictionary.cpp skipped -------------------------------------------- One of the tests failed, see details above.   Any tips on how I can debug it? I tried registering a print function to check the value stored in the dictionary, but I was not able to  (error similar to the one on ppc64le).
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!