Skip to content

Commit d93aabd

Browse files
committed
Only expand bigint on-demand instead of during page load
1 parent e442143 commit d93aabd

File tree

7 files changed

+73
-91
lines changed

7 files changed

+73
-91
lines changed

docs/index.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<style>
1010
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
1111
</style>
12-
<link rel="stylesheet" href="css/normalize.css?v=2.7.0">
13-
<link rel="stylesheet" href="css/layout.css?v=2.7.0">
14-
<link rel="stylesheet" href="css/theme.css?v=2.7.0">
12+
<link rel="stylesheet" href="css/normalize.css?v=2.8.0">
13+
<link rel="stylesheet" href="css/layout.css?v=2.8.0">
14+
<link rel="stylesheet" href="css/theme.css?v=2.8.0">
1515
<link rel="icon" type="image/png" href="favicon.png">
1616
<script>
17-
var BUILD_TS = 1663551945;
17+
var BUILD_TS = 1663559905;
1818
</script>
1919
<script async src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
2020
<script type="text/x-mathjax-config">
@@ -24,20 +24,20 @@
2424
extensions: ["MathMenu.js", "MathZoom.js"]
2525
});
2626
</script>
27-
<script src="js/BigInteger.min.js?v=2.7.0" type="text/javascript"></script>
28-
<script src="js/sha1.js?v=2.7.0" type="text/javascript"></script>
29-
<script src="js/data.js?ts=1663551945" type="text/javascript"></script>
30-
<script src="search/bkt_index.js?ts=1663551945" type="text/javascript"></script>
31-
<script src="js/ral.js?v=2.7.0" type="text/javascript"></script>
32-
<script src="js/main.js?v=2.7.0" type="text/javascript"></script>
33-
<script src="js/nav.js?v=2.7.0" type="text/javascript"></script>
34-
<script src="js/sidebar.js?v=2.7.0" type="text/javascript"></script>
35-
<script src="js/index_edit.js?v=2.7.0" type="text/javascript"></script>
36-
<script src="js/field_testers.js?v=2.7.0" type="text/javascript"></script>
37-
<script src="js/search.js?v=2.7.0" type="text/javascript"></script>
38-
<script src="js/address_search.js?v=2.7.0" type="text/javascript"></script>
39-
<script src="js/path_search.js?v=2.7.0" type="text/javascript"></script>
40-
<script src="js/content_search.js?v=2.7.0" type="text/javascript"></script>
27+
<script src="js/BigInteger.min.js?v=2.8.0" type="text/javascript"></script>
28+
<script src="js/sha1.js?v=2.8.0" type="text/javascript"></script>
29+
<script src="js/data.js?ts=1663559905" type="text/javascript"></script>
30+
<script src="search/bkt_index.js?ts=1663559905" type="text/javascript"></script>
31+
<script src="js/ral.js?v=2.8.0" type="text/javascript"></script>
32+
<script src="js/main.js?v=2.8.0" type="text/javascript"></script>
33+
<script src="js/nav.js?v=2.8.0" type="text/javascript"></script>
34+
<script src="js/sidebar.js?v=2.8.0" type="text/javascript"></script>
35+
<script src="js/index_edit.js?v=2.8.0" type="text/javascript"></script>
36+
<script src="js/field_testers.js?v=2.8.0" type="text/javascript"></script>
37+
<script src="js/search.js?v=2.8.0" type="text/javascript"></script>
38+
<script src="js/address_search.js?v=2.8.0" type="text/javascript"></script>
39+
<script src="js/path_search.js?v=2.8.0" type="text/javascript"></script>
40+
<script src="js/content_search.js?v=2.8.0" type="text/javascript"></script>
4141
</head>
4242

4343
<body class="pack-h" onload="onPageLoad()">
@@ -91,7 +91,7 @@
9191
<div class="main stretchy limit-h"></div>
9292
<footer class="main limit-h">
9393
<hr/>
94-
Generated by PeakRDL-html v2.7.0
94+
Generated by PeakRDL-html v2.8.0
9595
</footer>
9696
</div>
9797

docs/js/main.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,9 @@ function onPageLoad() {
6262
id = parsed_path[0];
6363
}
6464

65-
// Prepare content for initial page load
66-
ral_expand_all_bigint_pass1(id);
67-
Sidebar.init(id);
68-
6965
// Load content
70-
load_page_via_url().then(() => {
71-
// finish remaining initialization after page load
72-
// defer it to the next animation frame
73-
// TODO: Figure out a better way to defer these to after page rendering
74-
// requestAnimationFrame and other methods don't seem to work
75-
setTimeout(() => {
76-
ral_expand_all_bigint_pass2();
77-
}, 100);
78-
});
79-
66+
Sidebar.init(id);
67+
load_page_via_url();
8068
init_index_edit();
8169
userHooks.onPageLoad();
8270
}

docs/js/ral.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,37 @@
44
class RAL {
55

66
static get_node(id){
7-
return RALIndex[id];
7+
var node = RALIndex[id];
8+
this.#expand_bigint(node);
9+
return node;
10+
}
11+
12+
static #expand_bigint(node){
13+
// Check if RAL entry has been converted yet
14+
if(typeof node.offset !== 'string') return;
15+
16+
// Needs conversion from base-16 string --> bigInt object
17+
node.offset = bigInt(node.offset, 16);
18+
node.size = bigInt(node.size, 16);
19+
if('stride' in node) node.stride = bigInt(node.stride, 16);
20+
21+
if(RAL.is_register_node(node)) {
22+
for(var i=0; i<node.fields.length; i++){
23+
node.fields[i].reset = bigInt(node.fields[i].reset, 16);
24+
}
25+
}
826
}
927

1028
static number_of_ids(){
1129
return RALIndex.length;
1230
}
1331

1432
static is_register(id) {
15-
return("fields" in this.get_node(id));
33+
return(this.is_register_node(this.get_node(id)));
34+
}
35+
36+
static is_register_node(node) {
37+
return("fields" in node);
1638
}
1739

1840
static is_array(id) {
@@ -375,22 +397,3 @@ function ral_expand_bigint(id){
375397
}
376398
}
377399
}
378-
379-
function ral_expand_all_bigint_pass1(first_id){
380-
// RAL data contains strings that represent integers that need to be expanded
381-
// to bigInt objects
382-
383-
// To keep initial page load fast, only expand ids in the linage of first_id
384-
var ids = RAL.get_ancestors(first_id);
385-
ids.push(first_id);
386-
for(var i=0; i<ids.length; i++){
387-
ral_expand_bigint(ids[i]);
388-
}
389-
}
390-
391-
function ral_expand_all_bigint_pass2(){
392-
// Next, asynchronously process all others
393-
for(var id=0; id<RAL.number_of_ids(); id++){
394-
ral_expand_bigint(id);
395-
}
396-
}

example/large-test.rdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ addrmap top {
1212
<% } %>
1313
};
1414

15-
<% for( $i = 0; $i < 100; $i += 1 ) { %>
15+
<% for( $i = 0; $i < 1000; $i += 1 ) { %>
1616
thing thing<%=$i%>;
1717
<% } %>
1818
};

src/peakrdl_html/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.7.0"
1+
__version__ = "2.8.0"

src/peakrdl_html/static/js/main.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,9 @@ function onPageLoad() {
6262
id = parsed_path[0];
6363
}
6464

65-
// Prepare content for initial page load
66-
ral_expand_all_bigint_pass1(id);
67-
Sidebar.init(id);
68-
6965
// Load content
70-
load_page_via_url().then(() => {
71-
// finish remaining initialization after page load
72-
// defer it to the next animation frame
73-
// TODO: Figure out a better way to defer these to after page rendering
74-
// requestAnimationFrame and other methods don't seem to work
75-
setTimeout(() => {
76-
ral_expand_all_bigint_pass2();
77-
}, 100);
78-
});
79-
66+
Sidebar.init(id);
67+
load_page_via_url();
8068
init_index_edit();
8169
userHooks.onPageLoad();
8270
}

src/peakrdl_html/static/js/ral.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,37 @@
44
class RAL {
55

66
static get_node(id){
7-
return RALIndex[id];
7+
var node = RALIndex[id];
8+
this.#expand_bigint(node);
9+
return node;
10+
}
11+
12+
static #expand_bigint(node){
13+
// Check if RAL entry has been converted yet
14+
if(typeof node.offset !== 'string') return;
15+
16+
// Needs conversion from base-16 string --> bigInt object
17+
node.offset = bigInt(node.offset, 16);
18+
node.size = bigInt(node.size, 16);
19+
if('stride' in node) node.stride = bigInt(node.stride, 16);
20+
21+
if(RAL.is_register_node(node)) {
22+
for(var i=0; i<node.fields.length; i++){
23+
node.fields[i].reset = bigInt(node.fields[i].reset, 16);
24+
}
25+
}
826
}
927

1028
static number_of_ids(){
1129
return RALIndex.length;
1230
}
1331

1432
static is_register(id) {
15-
return("fields" in this.get_node(id));
33+
return(this.is_register_node(this.get_node(id)));
34+
}
35+
36+
static is_register_node(node) {
37+
return("fields" in node);
1638
}
1739

1840
static is_array(id) {
@@ -375,22 +397,3 @@ function ral_expand_bigint(id){
375397
}
376398
}
377399
}
378-
379-
function ral_expand_all_bigint_pass1(first_id){
380-
// RAL data contains strings that represent integers that need to be expanded
381-
// to bigInt objects
382-
383-
// To keep initial page load fast, only expand ids in the linage of first_id
384-
var ids = RAL.get_ancestors(first_id);
385-
ids.push(first_id);
386-
for(var i=0; i<ids.length; i++){
387-
ral_expand_bigint(ids[i]);
388-
}
389-
}
390-
391-
function ral_expand_all_bigint_pass2(){
392-
// Next, asynchronously process all others
393-
for(var id=0; id<RAL.number_of_ids(); id++){
394-
ral_expand_bigint(id);
395-
}
396-
}

0 commit comments

Comments
 (0)