Оберон-клуб «ВЄДАsoft»

Твердыня модульных языков
Текущее время: 28 мар 2024, 14:38

Часовой пояс: UTC + 2 часа




Начать новую тему Ответить на тему  [ Сообщений: 4 ] 
Автор Сообщение
 Заголовок сообщения: Bug in floating point functions
СообщениеДобавлено: 17 сен 2015, 18:35 
Не в сети
Администратор
Аватара пользователя

Сообщения: 189
Вот такой код работает только для операторов '*' и '-'

Код: "OBERON"
  1. MODULE A;
  2. (*$CONSOLE*)
  3.  
  4. IMPORT
  5. Console;
  6.  
  7. VAR
  8. R: REAL;
  9. BEGIN
  10. R :=1.0*1.2;
  11. Console.WriteReal(R); Console.WriteString(' <- *'); Console.WriteLn;
  12.  
  13. R :=1.0/1.2;
  14. Console.WriteReal(R); Console.WriteString(' <- /'); Console.WriteLn;
  15.  
  16. R :=1.0+1.2;
  17. Console.WriteReal(R); Console.WriteString(' <- +'); Console.WriteLn;
  18.  
  19. R :=1.0-1.2;
  20. Console.WriteReal(R); Console.WriteString(' <- -'); Console.WriteLn;
  21. END A.


На выходе:

1.2e0 <- *
<- /
2.2e0 <- +
<- -


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Bug in floating point functions
СообщениеДобавлено: 19 сен 2015, 17:04 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Ответ на баг-репорт:
Đặng Minh Công писал(а):
Thanks. The floating-point is the least used part, so bug is common :)

After getting used with garbage collection in Oberon/Component Pascal, programming without garbage collection feels so awkward. I am currently reading on Active Oberon garbage collection, which is suitable for multiprocessor systems.


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: Bug in floating point functions
СообщениеДобавлено: 23 дек 2016, 02:13 
Не в сети
Администратор
Аватара пользователя

Сообщения: 189
В новой версии тест...

Если код в Module2 вот такой

Код: "OBERON"
  1. PROCEDURE P*(msg,title: ARRAY OF CHAR);

То все работает нормально, но если скрыть процедуру, то компилится без вопросов и ошибок, но не работает. Даже трап не выскакивает :cry:
Код: "OBERON"
  1. PROCEDURE P(msg,title: ARRAY OF CHAR);

В архиве тест и компилятор...


Вложения:
AyaCompiler-0.8.zip [51.98 КБ]
Скачиваний: 426
Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Re: Bug in floating point functions
СообщениеДобавлено: 24 дек 2016, 00:13 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Đặng Minh Công писал(а):
Dear Oleg N. Cher,

Thanks for the error reporting.
Actually, I already encountered this error before and understand why it happened, but didn't document about it yet.

In the previous version, the code generated by compiler accessed its global variables by RIP relative addressing, that meant there was no need for changing base register between module boundary, like in ProjectOberon.

However, in this version, I switch to the method of N. Wirth, the benefit is that the number of address fixups during compile process is reduced dramatically. However, it also cause the error which S. Atan encountered.

The procedure P is not exported, so in its code, there is no loading of RBX, because it assumed that RBX would always point to the base of Module2 when it was called. However, P was exported indirectly by procedure variable TT.P When P was called by Module1, RBX was still pointing to Module1 base, hence the crash happened. For more detail, you can check the code of PROCEDURE Procedure in Generator.mod

The moral of this is that adding more "features" or "tweaks" to the products may not be a good thing, because they could interact in an unexpected way (a case of this dialectical statement: the whole is not equal to the sum of its parts).

There are two solutions to this error:

    1. Require every procedure must be exported before assignment to procedure variable
    2. Saving and Loading of RBX should be mandatory for all procedures, exported or not

I believe solution 2 is less disruptive and more conforming to the spirit of N. Wirth.
Anyway, thank you very much for the report of this error.

P.S.
In Project Oberon, N. Wirth just let the caller load the base register for the callee, and use the module loader to perform fixup, which was a better solution, but we need more code in module loading phase (which was already complex enough, due to the design of Windows)

Đặng Minh Công

AyaCompiler 0.8b
    • Better error message for runtime errors.
    • Fix the bug when assigning non-export procedure to exported variable


Вернуться к началу
 Профиль  
Ответить с цитатой  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 4 ] 

Часовой пояс: UTC + 2 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Создано на основе phpBB® Forum Software © phpBB Group
© VEDAsoft Oberon Club