-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
{Python,Ruby,JS}: Add
class_id
information to ExternalInstance valu…
…es; use for in-VM IsA checks (#1472) Create `Constants` type which wraps two HashMaps describing Symbol -> Term and ID -> Symbol relationships. This second ID -> Symbol index is populated by reading the optional `class_id` information in `ExternalInstance` and will be used to implement in-core IsA checks where present. Extend `vm#isa` to attempt an in-core check when the `ExternalInstance` value we're processing has the necessary `class_id` information declared. At time of commit Python is the only language which is capabale of passing this information to the core. * {JS,Python,Ruby} Format ExternalInstance values with user-provided class names if present (#1488) Co-authored-by: Gabe Jackson <17556281+gj@users.noreply.github.com>
- Loading branch information
Showing
21 changed files
with
280 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::terms::{Symbol, Term}; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Default, Debug)] | ||
pub(crate) struct Constants { | ||
// Symbol -> Term (populated by *all* constants) | ||
pub symbol_to_term: HashMap<Symbol, Term>, | ||
// Symbol -> class_id (populated by class constants) | ||
class_symbol_to_id: HashMap<Symbol, u64>, | ||
// class_id -> Symbol (populated by class constants) | ||
class_id_to_symbol: HashMap<u64, Symbol>, | ||
} | ||
|
||
impl Constants { | ||
pub(crate) fn insert(&mut self, name: Symbol, value: Term) { | ||
self.symbol_to_term.insert(name, value); | ||
} | ||
|
||
pub(crate) fn insert_class(&mut self, name: Symbol, value: Term, class_id: u64) { | ||
self.insert(name.clone(), value); | ||
self.class_symbol_to_id.insert(name.clone(), class_id); | ||
self.class_id_to_symbol.insert(class_id, name); | ||
} | ||
|
||
pub(crate) fn contains_key(&self, name: &Symbol) -> bool { | ||
self.symbol_to_term.contains_key(name) | ||
} | ||
|
||
pub(crate) fn get(&self, name: &Symbol) -> Option<&Term> { | ||
self.symbol_to_term.get(name) | ||
} | ||
|
||
pub(crate) fn get_class_id_for_symbol(&self, symbol: &Symbol) -> Option<&u64> { | ||
self.class_symbol_to_id.get(symbol) | ||
} | ||
|
||
pub(crate) fn get_symbol_for_class_id(&self, id: &u64) -> Option<&Symbol> { | ||
self.class_id_to_symbol.get(id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
2631806
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust Benchmark
rust_get_attribute
45959
ns/iter (± 1938
)46361
ns/iter (± 2641
)0.99
n_plus_one/100
2265843
ns/iter (± 5634
)2257978
ns/iter (± 34289
)1.00
n_plus_one/500
10861165
ns/iter (± 23233
)10905597
ns/iter (± 72665
)1.00
n_plus_one/1000
21548110
ns/iter (± 105892
)21830629
ns/iter (± 358299
)0.99
unify_once
1029
ns/iter (± 51
)1009
ns/iter (± 40
)1.02
unify_twice
2701
ns/iter (± 86
)2635
ns/iter (± 77
)1.03
many_rules
63917
ns/iter (± 1265
)65281
ns/iter (± 1647
)0.98
fib/5
536931
ns/iter (± 7263
)547190
ns/iter (± 9060
)0.98
prime/3
17987
ns/iter (± 698
)18347
ns/iter (± 1101
)0.98
prime/23
18013
ns/iter (± 699
)18427
ns/iter (± 930
)0.98
prime/43
17972
ns/iter (± 694
)18394
ns/iter (± 957
)0.98
prime/83
17953
ns/iter (± 704
)18365
ns/iter (± 1049
)0.98
prime/255
16390
ns/iter (± 598
)16801
ns/iter (± 834
)0.98
indexed/100
5981
ns/iter (± 657
)6481
ns/iter (± 839
)0.92
indexed/500
7450
ns/iter (± 1848
)8729
ns/iter (± 2935
)0.85
indexed/1000
9610
ns/iter (± 256
)10191
ns/iter (± 893
)0.94
indexed/10000
22950
ns/iter (± 1748
)42575
ns/iter (± 2176
)0.54
not
6005
ns/iter (± 92
)6252
ns/iter (± 152
)0.96
double_not
12418
ns/iter (± 223
)13117
ns/iter (± 382
)0.95
De_Morgan_not
8073
ns/iter (± 176
)8337
ns/iter (± 279
)0.97
load_policy
888231
ns/iter (± 7816
)888491
ns/iter (± 1213
)1.00
partial_and/1
32458
ns/iter (± 1389
)32803
ns/iter (± 1701
)0.99
partial_and/5
113933
ns/iter (± 2943
)111508
ns/iter (± 3408
)1.02
partial_and/10
216074
ns/iter (± 4378
)212796
ns/iter (± 5548
)1.02
partial_and/20
439151
ns/iter (± 5075
)431291
ns/iter (± 8586
)1.02
partial_and/40
932709
ns/iter (± 10636
)936419
ns/iter (± 12533
)1.00
partial_and/80
2098932
ns/iter (± 31396
)2090541
ns/iter (± 7359
)1.00
partial_and/100
2780242
ns/iter (± 5896
)2753202
ns/iter (± 10271
)1.01
partial_rule_depth/1
104837
ns/iter (± 3932
)105865
ns/iter (± 4185
)0.99
partial_rule_depth/5
338105
ns/iter (± 5372
)342655
ns/iter (± 7739
)0.99
partial_rule_depth/10
736127
ns/iter (± 18592
)743708
ns/iter (± 14226
)0.99
partial_rule_depth/20
2054771
ns/iter (± 3510
)2071291
ns/iter (± 6065
)0.99
partial_rule_depth/40
7520758
ns/iter (± 33517
)7691108
ns/iter (± 175483
)0.98
partial_rule_depth/80
45280136
ns/iter (± 290490
)47960363
ns/iter (± 364464
)0.94
partial_rule_depth/100
85153217
ns/iter (± 537303
)88405947
ns/iter (± 660868
)0.96
This comment was automatically generated by workflow using github-action-benchmark.