小编Ect*_*cto的帖子

Dynamic branch prediction miss count - incorrect

I was looking over internet for some exaples about dbp and I found this one. Source: http://faculty.cse.tamu.edu/djimenez/614-spring14/bpexample.html (including solution)

Code:

main:
        leal    4(%esp), %ecx       ; function overhead
        andl    $-16, %esp
        pushl   -4(%ecx)
        pushl   %ecx         ; gcc stack alignment at the top of main

        xorl    %ecx, %ecx      ; i = 0 (%ecx)
.L2:                                       ; top of outer loop
        xorl    %edx, %edx      ; j = 0 (%edx)
.L3:                                             ; top of inner loop
        movl    c, %eax             ; %eax = c
        addl    $1, …
Run Code Online (Sandbox Code Playgroud)

c assembly branch prediction

5
推荐指数
1
解决办法
62
查看次数

集合的 toString() 方法中的 StackOverflowError 是错误吗?

我写了这段代码来演示:

List<Object> list1 = new ArrayList<>();
List<Object> list2 = new ArrayList<>();
list2.add(list1);
list1.add(list2);
list1.toString();
Run Code Online (Sandbox Code Playgroud)

此代码将导致StackOverflowError.

但是我知道在java的集合中有一些努力来防止这种情况,例如这段代码可以正常工作:

List<Object> list1 = new ArrayList<>();
list1.add(list1);
list1.toString();
Run Code Online (Sandbox Code Playgroud)

其他一些语言似乎也能处理它(两种情况)。第一个例子没有“消毒”而第二个例子是有原因的吗?这是一个错误吗?

java stack-overflow collections

2
推荐指数
1
解决办法
61
查看次数

标签 统计

assembly ×1

branch ×1

c ×1

collections ×1

java ×1

prediction ×1

stack-overflow ×1