Browse Source

Makefile, build, and util trivia

* Makefile: more threads

* Util: longer debug buffer

* Add some misc dev test code (bitfield tests)

* Minor debugger web UI tweak
pull/2485/head
Sami Vaarala 3 years ago
parent
commit
bb6e4911b5
  1. 5
      Makefile
  2. 2
      debugger/static/index.html
  3. 64
      misc/bitfield_test.c
  4. 105
      misc/tval_return_test.c
  5. 2
      util/makeduk_base.yaml
  6. 2
      util/makeduk_debug.yaml

5
Makefile

@ -189,6 +189,7 @@ CCOPTS_SHARED += -I./extras/module-duktape
CCOPTS_NONDEBUG = $(CCOPTS_SHARED) $(CCOPTS_FEATURES)
CCOPTS_NONDEBUG += -Os -fomit-frame-pointer -fno-stack-protector
CCOPTS_NONDEBUG += -g -ggdb
#CCOPTS_NONDEBUG += -flto
#CCOPTS_NONDEBUG += -malign-double
CCOPTS_DEBUG = $(CCOPTS_SHARED) $(CCOPTS_FEATURES)
@ -662,11 +663,11 @@ runtests/node_modules:
.PHONY: ecmatest
ecmatest: runtestsdeps build/duk | tmp
@echo "### ecmatest"
"$(NODEJS)" runtests/runtests.js $(RUNTESTSOPTS) --run-duk --cmd-duk=$(shell pwd)/build/duk --num-threads 4 --log-file=tmp/duk-test.log tests/ecmascript/
"$(NODEJS)" runtests/runtests.js $(RUNTESTSOPTS) --run-duk --cmd-duk=$(shell pwd)/build/duk --num-threads 16 --log-file=tmp/duk-test.log tests/ecmascript/
.PHONY: ecmatest-comparison
ecmatest-comparison: runtestsdeps build/duk | tmp
@echo "### ecmatest"
"$(NODEJS)" runtests/runtests.js $(RUNTESTSOPTS) --run-duk --cmd-duk=$(shell pwd)/build/duk --report-diff-to-other --run-nodejs --run-rhino --num-threads 4 --log-file=tmp/duk-test.log tests/ecmascript/
"$(NODEJS)" runtests/runtests.js $(RUNTESTSOPTS) --run-duk --cmd-duk=$(shell pwd)/build/duk --report-diff-to-other --run-nodejs --run-rhino --num-threads 16 --log-file=tmp/duk-test.log tests/ecmascript/
.PHONY: apitest
ifeq ($(DETECTED_OS),Darwin)
apitest: runtestsdeps build/libduktape.1.0.0.so | tmp

2
debugger/static/index.html

@ -70,7 +70,7 @@
</div> <!-- #part-middle -->
<div id="part-footer">
<div>DUK_VERSION: <span id="duk-version">?</span>, DUK_GIT_DESCRIBE: <span id="duk-git-describe">?</span>, Target info: <span id="target-info">?</span>, Endianness: <span id="endianness">?</span><br />
<div>DUK_VERSION: <span id="duk-version">?</span> &#xB7; DUK_GIT_DESCRIBE: <span id="duk-git-describe">?</span> &#xB7; Target info: <span id="target-info">?</span> &#xB7; Endianness: <span id="endianness">?</span><br />
Debug protocol stats:
recv <span id="debug-rx-bytes">?</span> (<span id="debug-rx-kbrate">?</span> kB/s), <span id="debug-rx-dvalues">?</span> dvalues, <span id="debug-rx-messages">?</span> messages;
send <span id="debug-tx-bytes">?</span> (<span id="debug-tx-kbrate">?</span> kB/s), <span id="debug-tx-dvalues">?</span> dvalues, <span id="debug-tx-messages">?</span> messages

64
misc/bitfield_test.c

@ -0,0 +1,64 @@
/* Test bitfield patterns. */
/*
* 1050: 48 83 ec 08 sub $0x8,%rsp
* 1054: 8b 05 d6 2f 00 00 mov 0x2fd6(%rip),%eax # 4030 <val>
* 105a: f6 c4 01 test $0x1,%ah
* 105d: 75 4c jne 10ab <main+0x5b>
* 105f: 8b 05 cb 2f 00 00 mov 0x2fcb(%rip),%eax # 4030 <val>
* 1065: f6 c4 01 test $0x1,%ah
* 1068: 74 6b je 10d5 <main+0x85>
* 106a: 8b 05 c0 2f 00 00 mov 0x2fc0(%rip),%eax # 4030 <val>
* 1070: f6 c4 0f test $0xf,%ah
* 1073: 74 52 je 10c7 <main+0x77>
* 1075: 8b 05 b5 2f 00 00 mov 0x2fb5(%rip),%eax # 4030 <val>
* 107b: f6 c4 0f test $0xf,%ah
* 107e: 75 39 jne 10b9 <main+0x69>
* 1080: 8b 05 aa 2f 00 00 mov 0x2faa(%rip),%eax # 4030 <val>
* 1086: 25 00 0f 00 00 and $0xf00,%eax
* 108b: 3d 00 0f 00 00 cmp $0xf00,%eax
* 1090: 74 5f je 10f1 <main+0xa1>
* 1092: 8b 05 98 2f 00 00 mov 0x2f98(%rip),%eax # 4030 <val>
* 1098: 25 00 0f 00 00 and $0xf00,%eax
* 109d: 3d 00 0c 00 00 cmp $0xc00,%eax
* 10a2: 74 3f je 10e3 <main+0x93>
* 10a4: 31 c0 xor %eax,%eax
* 10a6: 48 83 c4 08 add $0x8,%rsp
* 10aa: c3 retq
*/
#include <stdio.h>
volatile int val = 0xdeadbeef;
int main(int argc, const char *argv[]) {
/* Single-bit test for 0 or 1: single TEST on x64. */
if ((val & 0x100) != 0) {
printf("1\n");
}
if ((val & 0x100) == 0) {
printf("2\n");
}
/* Multi-bit test for all zeroes: single TEST on x64. */
if ((val & 0xf00) == 0) {
printf("3\n");
}
/* Multi-bit test for not all zeroes (>= one-bit): single TEST on x64. */
if ((val & 0xf00) != 0) {
printf("3\n");
}
/* Multi-bit test for all ones: AND + CMP on x64. */
if ((val & 0xf00) == 0xf00) {
printf("4\n");
}
/* Multi-bit test for arbitrary value: AND + CMP on x64. */
if ((val & 0xf00) == 0xc00) {
printf("5\n");
}
return 0;
}

105
misc/tval_return_test.c

@ -0,0 +1,105 @@
/* Test return by value or write to out pointer. */
/* For gcc 9.4.0 -O2 (loop highlighted):
0000000000001170 <run1>:
1170: b8 00 e1 f5 05 mov $0x5f5e100,%eax
1175: 0f 1f 00 nopl (%rax)
===============================================================================
1178: c7 44 24 e8 7b 00 00 movl $0x7b,-0x18(%rsp)
117f: 00
1180: f2 0f 10 05 88 2e 00 movsd 0x2e88(%rip),%xmm0 # 4010 <dbl>
1187: 00
1188: f2 0f 11 44 24 f0 movsd %xmm0,-0x10(%rsp)
118e: 83 e8 01 sub $0x1,%eax
1191: 75 e5 jne 1178 <run1+0x8>
===============================================================================
1193: 8b 54 24 e8 mov -0x18(%rsp),%edx
1197: 48 8d 35 66 0e 00 00 lea 0xe66(%rip),%rsi # 2004 <_IO_stdin_used+0x4>
119e: bf 01 00 00 00 mov $0x1,%edi
11a3: 31 c0 xor %eax,%eax
11a5: e9 a6 fe ff ff jmpq 1050 <__printf_chk@plt>
11aa: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
00000000000011b0 <run2>:
11b0: 48 bf 00 00 00 00 ff movabs $0xffffffff00000000,%rdi
11b7: ff ff ff
11ba: be 00 e1 f5 05 mov $0x5f5e100,%esi
11bf: 90 nop
===============================================================================
11c0: 48 89 c1 mov %rax,%rcx
11c3: f2 0f 10 05 45 2e 00 movsd 0x2e45(%rip),%xmm0 # 4010 <dbl>
11ca: 00
11cb: 48 21 f9 and %rdi,%rcx
11ce: 48 83 c9 7b or $0x7b,%rcx
11d2: 48 89 4c 24 e8 mov %rcx,-0x18(%rsp)
11d7: 48 89 c8 mov %rcx,%rax
11da: 66 0f d6 44 24 f0 movq %xmm0,-0x10(%rsp)
11e0: 83 ee 01 sub $0x1,%esi
11e3: 75 db jne 11c0 <run2+0x10>
===============================================================================
11e5: 8b 54 24 e8 mov -0x18(%rsp),%edx
11e9: 48 8d 35 14 0e 00 00 lea 0xe14(%rip),%rsi # 2004 <_IO_stdin_used+0x4>
11f0: bf 01 00 00 00 mov $0x1,%edi
11f5: 31 c0 xor %eax,%eax
11f7: e9 54 fe ff ff jmpq 1050 <__printf_chk@plt>
11fc: 0f 1f 40 00 nopl 0x0(%rax)
*/
#include <stdio.h>
typedef struct {
int t;
union {
double d;
void *p;
} u;
} tval;
volatile double dbl = 123.0;
static void test1(volatile tval *out) {
out->t = 123;
out->u.d = dbl;
}
static tval test2(void) {
tval tv;
tv.t = 123;
tv.u.d = dbl;
return tv;
}
static __attribute__((noinline)) void run1(void) {
volatile tval tv1;
int i;
for (i = 0; i < 100000000; i++) {
#if 1
test1(&tv1);
#endif
}
printf("%d\n", tv1.t);
}
static __attribute__((noinline)) void run2(void) {
volatile tval tv2;
int i;
for (i = 0; i < 100000000; i++) {
#if 1
tv2 = test2();
#endif
}
printf("%d\n", tv2.t);
}
int main(int argc, const char *argv[]) {
(void) argc;
(void) argv;
run1();
run2();
return 0;
}

2
util/makeduk_base.yaml

@ -59,9 +59,7 @@ DUK_USE_DEBUGGER_INSPECT: true
#DUK_USE_NONSTD_GETTER_KEY_ARGUMENT: false
#DUK_USE_NONSTD_SETTER_KEY_ARGUMENT: false
#DUK_USE_NONSTD_FUNC_STMT: false
#DUK_USE_NONSTD_FUNC_CALLER_PROPERTY: true
#DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY: true
#DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT: false
#DUK_USE_NONSTD_JSON_ESC_U2028_U2029: false
#DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT: false
#DUK_USE_ES6_OBJECT_PROTO_PROPERTY: false

2
util/makeduk_debug.yaml

@ -1,6 +1,6 @@
# Additional options on top of makeduk_base.yaml to enable debug prints.
DUK_USE_DEBUG_BUFSIZE: 512
DUK_USE_DEBUG_BUFSIZE: 65536
DUK_USE_DEBUG: true
DUK_USE_DEBUG_LEVEL: 0
#DUK_USE_DEBUG_LEVEL: 1

Loading…
Cancel
Save