Bug 1651545 - Update jsparagus for bug 1642476. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D82874
This commit is contained in:
Tooru Fujisawa 2020-07-09 09:41:04 +00:00
Родитель cf209b6c53
Коммит be67ca2eb8
18 изменённых файлов: 784 добавлений и 421 удалений

Просмотреть файл

@ -30,7 +30,7 @@ rev = "61dcc364ac0d6d0816ab88a494bbf20d824b009b"
[source."https://github.com/mozilla-spidermonkey/jsparagus"]
git = "https://github.com/mozilla-spidermonkey/jsparagus"
replace-with = "vendored-sources"
rev = "90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
rev = "b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
[source."https://github.com/kvark/spirv_cross"]
branch = "wgpu3"

17
Cargo.lock сгенерированный
Просмотреть файл

@ -2356,7 +2356,7 @@ dependencies = [
[[package]]
name = "jsparagus"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"jsparagus-ast",
"jsparagus-emitter",
@ -2370,7 +2370,7 @@ dependencies = [
[[package]]
name = "jsparagus-ast"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"bumpalo",
"indexmap",
@ -2379,7 +2379,7 @@ dependencies = [
[[package]]
name = "jsparagus-emitter"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"bumpalo",
"byteorder",
@ -2392,7 +2392,7 @@ dependencies = [
[[package]]
name = "jsparagus-generated-parser"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"bumpalo",
"jsparagus-ast",
@ -2402,13 +2402,14 @@ dependencies = [
[[package]]
name = "jsparagus-json-log"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
[[package]]
name = "jsparagus-parser"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"arrayvec",
"bumpalo",
"jsparagus-ast",
"jsparagus-generated-parser",
@ -2418,7 +2419,7 @@ dependencies = [
[[package]]
name = "jsparagus-scope"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"indexmap",
"jsparagus-ast",
@ -2428,7 +2429,7 @@ dependencies = [
[[package]]
name = "jsparagus-stencil"
version = "0.1.0"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=90744b6c7bf9936174ab5fe62d1e17dde65bf64f#90744b6c7bf9936174ab5fe62d1e17dde65bf64f"
source = "git+https://github.com/mozilla-spidermonkey/jsparagus?rev=b987c8f4d4bc878dd79c58ad3917c0db3f7341b3#b987c8f4d4bc878dd79c58ad3917c0db3f7341b3"
dependencies = [
"jsparagus-ast",
]

Просмотреть файл

@ -12,12 +12,12 @@ log = "0.4"
# Disable regex feature for code size.
env_logger = {version = "0.6", default-features = false}
# For non-jsparagus developers.
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "90744b6c7bf9936174ab5fe62d1e17dde65bf64f" }
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "b987c8f4d4bc878dd79c58ad3917c0db3f7341b3" }
# For local development, replace above with
# jsparagus = { path = "{path to jsparagus}" }
[build-dependencies]
# For non-jsparagus developers.
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "90744b6c7bf9936174ab5fe62d1e17dde65bf64f" }
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "b987c8f4d4bc878dd79c58ad3917c0db3f7341b3" }
# For local development, replace above with
# jsparagus = { path = "{path to jsparagus}" }

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"00c740f44b5681e3277e519d2e143e6edfbff186ca31a07ddce2eb46b803ddd7","src/array_emitter.rs":"bbc6528321f1d11d7c86c4f2bfdcfc9dced8f0b8b1c30c9f0a5355f300d196b6","src/ast_emitter.rs":"43686d1c8a7af3af9715a831ede7442e8ec1d82b84efff08a910b908a3b0b114","src/block_emitter.rs":"78965260d87a66c5324d6f3bdfea0f1938f8037f70adde148dbb2db599d1b2c0","src/compilation_info.rs":"32ca7cdae514501de0d0d667ff2b27a3abf736ae207a23009c42eacbdffbd5b3","src/control_structures.rs":"bdb186e98c14fa4e769b23b3dee4376683e6c6530af0856d55c055aff4398b84","src/dis.rs":"4a335d813fa965482ca0f20a7b9295a55ce7625b577d42bd8b33b156b81c6306","src/emitter.rs":"e87189e2e078c58c03a4c92e25a48160e18796ea7eaa8e33e5f6b583182664ef","src/emitter_scope.rs":"07a904b6973bd2dbc1f9395022c15f11f6befc9b0fb4f2f251ccfc3f09aff380","src/expression_emitter.rs":"f8e02785dffb179bbe9fe58e45bbfccc08adc3ad0a071a0073bed0feedc8ed9a","src/function_declaration_emitter.rs":"c2bbfe2c27e97a345d34c6da056c7ac45b48af45b6216a8dec114673320abe7e","src/lib.rs":"271d385beb1a507a9bbb8671a11f3ab8f072348ac03eebcfd41364b82410ef1a","src/object_emitter.rs":"998423b3d6ef8797fadef6763803627df72fde292b1b34d6a41b2e66a331a181","src/reference_op_emitter.rs":"4ead96ef4424e3937c3f73e22b4e103f97cee522b9926345caeddcf4643ff843","src/script_emitter.rs":"44a6be5ecdcde3c32d78d100a205d38be2591c7c2cc109967579af7393e09fe8"},"package":null}
{"files":{"Cargo.toml":"00c740f44b5681e3277e519d2e143e6edfbff186ca31a07ddce2eb46b803ddd7","src/array_emitter.rs":"bbc6528321f1d11d7c86c4f2bfdcfc9dced8f0b8b1c30c9f0a5355f300d196b6","src/ast_emitter.rs":"43686d1c8a7af3af9715a831ede7442e8ec1d82b84efff08a910b908a3b0b114","src/block_emitter.rs":"78965260d87a66c5324d6f3bdfea0f1938f8037f70adde148dbb2db599d1b2c0","src/compilation_info.rs":"32ca7cdae514501de0d0d667ff2b27a3abf736ae207a23009c42eacbdffbd5b3","src/control_structures.rs":"bdb186e98c14fa4e769b23b3dee4376683e6c6530af0856d55c055aff4398b84","src/dis.rs":"4a335d813fa965482ca0f20a7b9295a55ce7625b577d42bd8b33b156b81c6306","src/emitter.rs":"1108fb14184ce4d2eaf8c1daeab36d10140bb529f97c6c62056fe46d1fbfa3d0","src/emitter_scope.rs":"07a904b6973bd2dbc1f9395022c15f11f6befc9b0fb4f2f251ccfc3f09aff380","src/expression_emitter.rs":"f8e02785dffb179bbe9fe58e45bbfccc08adc3ad0a071a0073bed0feedc8ed9a","src/function_declaration_emitter.rs":"c2bbfe2c27e97a345d34c6da056c7ac45b48af45b6216a8dec114673320abe7e","src/lib.rs":"271d385beb1a507a9bbb8671a11f3ab8f072348ac03eebcfd41364b82410ef1a","src/object_emitter.rs":"998423b3d6ef8797fadef6763803627df72fde292b1b34d6a41b2e66a331a181","src/reference_op_emitter.rs":"4ead96ef4424e3937c3f73e22b4e103f97cee522b9926345caeddcf4643ff843","src/script_emitter.rs":"44a6be5ecdcde3c32d78d100a205d38be2591c7c2cc109967579af7393e09fe8"},"package":null}

Просмотреть файл

@ -555,6 +555,10 @@ impl InstructionWriter {
self.emit_op(Opcode::InitHiddenElem);
}
pub fn init_private_elem(&mut self) {
self.emit_op(Opcode::InitPrivateElem);
}
pub fn init_prop_getter(&mut self, name_index: GCThingIndex) {
self.emit_op(Opcode::InitPropGetter);
self.write_g_c_thing_index(name_index);
@ -609,6 +613,10 @@ impl InstructionWriter {
self.emit_op(Opcode::CallElem);
}
pub fn get_private_elem(&mut self) {
self.emit_op(Opcode::GetPrivateElem);
}
pub fn length(&mut self, name_index: GCThingIndex) {
self.emit_op(Opcode::Length);
self.write_g_c_thing_index(name_index);
@ -632,6 +640,10 @@ impl InstructionWriter {
self.emit_op(Opcode::StrictSetElem);
}
pub fn set_private_elem(&mut self) {
self.emit_op(Opcode::SetPrivateElem);
}
pub fn del_prop(&mut self, name_index: GCThingIndex) {
self.emit_op(Opcode::DelProp);
self.write_g_c_thing_index(name_index);

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"553be3c198fe555913bbeb7473b24e0e1fff12e48890a2e399b311df8a97c814","src/ast_builder.rs":"8b10743ebbc3390d1158cb44ff5c87fbb653d62521f3e1274565d0061eebe095","src/context_stack.rs":"29331d03cd4c8ee9283cb426ebe893b7ba6ad6d8a69016399c4d92a81cb1363b","src/declaration_kind.rs":"fdfda2fe408cce1c637d17fee0813160619450472c6de9befc36ebeed892cc3c","src/early_error_checker.rs":"150a106a8f0901b72ae40581f0c12f785983514cbc9042404ed6cf4315693d60","src/early_errors.rs":"8674454af7ac5efe51eb6a8e2abe088aad5560e0a0bd88a3eae66c90f1527149","src/error.rs":"507e4dd9c66720f3da2db135c3024392d8aaac5ccdb90c7f7463ccb2eff7efa8","src/lib.rs":"b74105a84c4a141b880439f9ec724f7dc08224342be08a73490ac2c01410af08","src/parser_tables_generated.rs":"be923ff8f89edaf9b77f9f9b3cc8698cb4f54ff8531e8b008c3a0dc1838530a7","src/stack_value_generated.rs":"d8696a671368e2565d589922e3a46d20667ed3e17e29953e69b970470e9639ee","src/token.rs":"479f4cb97d2e6bc654a70634f3809817cc73eaf749c845643beb3556b9ead383","src/traits/mod.rs":"ba74c71f7218027f8188247bc64df243117613fbc9893d40799402ef1e6dbf59"},"package":null}
{"files":{"Cargo.toml":"553be3c198fe555913bbeb7473b24e0e1fff12e48890a2e399b311df8a97c814","src/ast_builder.rs":"8b10743ebbc3390d1158cb44ff5c87fbb653d62521f3e1274565d0061eebe095","src/context_stack.rs":"29331d03cd4c8ee9283cb426ebe893b7ba6ad6d8a69016399c4d92a81cb1363b","src/declaration_kind.rs":"fdfda2fe408cce1c637d17fee0813160619450472c6de9befc36ebeed892cc3c","src/early_error_checker.rs":"150a106a8f0901b72ae40581f0c12f785983514cbc9042404ed6cf4315693d60","src/early_errors.rs":"8674454af7ac5efe51eb6a8e2abe088aad5560e0a0bd88a3eae66c90f1527149","src/error.rs":"507e4dd9c66720f3da2db135c3024392d8aaac5ccdb90c7f7463ccb2eff7efa8","src/lib.rs":"b74105a84c4a141b880439f9ec724f7dc08224342be08a73490ac2c01410af08","src/parser_tables_generated.rs":"405a20fc84c79ebe84daae5f46c5c27f86958292991ac6420a86131c2e1031d8","src/stack_value_generated.rs":"d8696a671368e2565d589922e3a46d20667ed3e17e29953e69b970470e9639ee","src/token.rs":"479f4cb97d2e6bc654a70634f3809817cc73eaf749c845643beb3556b9ead383","src/traits/mod.rs":"ba74c71f7218027f8188247bc64df243117613fbc9893d40799402ef1e6dbf59"},"package":null}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"2a9ad06ba69e548f1add39f4e1fb66f884a23e995af2735d6aa07c74c2376a0e","benches/__finStreamer-proto.js":"44edc00a99a8904f8c6bb0c42c7ba4f96ad611e61191d2702ecb228ae6d7b35d","benches/parser.rs":"6cb13b135513e86b94e1bbe1470156f182355078c2e34bf8d9deba1c67daf4b9","benches/simple.js":"fbb50c1c49c0b1e3740a79407a834248c1f8ebdb1b72530c0fc6df57d079f252","src/lexer.rs":"fc641c9e320652c7f73bdf78080ba73b84a5afcea0fa88759039290ce659d2e0","src/lib.rs":"09e22a1e09eb1b3166842c8936f0d166594d5025d3079d7ed23eef948381bab9","src/numeric_value.rs":"f429c50640eb35a53aa5ffdf71de305da30747e568dc10219c54b766372f6eca","src/parser.rs":"d7e69fd548d3149bc2aa4ef8e0e35725c9188dcaab470c899c66ba485445625f","src/queue_stack.rs":"5abbcfd65c655507e0fad545242bbff24db523ae962b5d02aac4e7f1debba293","src/simulator.rs":"b49881dbfceff1ac67f53fac97fed876bae27215d67f2d0c255f7ece4c59b992","src/tests.rs":"ea5df36f73d74692a6f26f4148d3d0b541a9e4baae16479100d54d2898602c3f","src/unicode.rs":"0e5d77d4d6751c6441982ae3d4a8453233443376441c5c01da5c86a5a5051167","src/unicode_data.rs":"e7d6e1d819bf2696cbf78eaee8de21814191585fddb52a04f434ce7e348d5c00"},"package":null}
{"files":{"Cargo.toml":"46d6606172cefe2aab05105afdc8a1372c1c3f9dd8a610bfcc91993025ba9d2e","benches/__finStreamer-proto.js":"44edc00a99a8904f8c6bb0c42c7ba4f96ad611e61191d2702ecb228ae6d7b35d","benches/parser.rs":"6cb13b135513e86b94e1bbe1470156f182355078c2e34bf8d9deba1c67daf4b9","benches/simple.js":"fbb50c1c49c0b1e3740a79407a834248c1f8ebdb1b72530c0fc6df57d079f252","src/lexer.rs":"fc641c9e320652c7f73bdf78080ba73b84a5afcea0fa88759039290ce659d2e0","src/lib.rs":"12fb80fe5b0429f96540385ebfde861f98750ca629769f1bff47f22ab094e882","src/numeric_value.rs":"f429c50640eb35a53aa5ffdf71de305da30747e568dc10219c54b766372f6eca","src/parser.rs":"d7e69fd548d3149bc2aa4ef8e0e35725c9188dcaab470c899c66ba485445625f","src/queue_stack.rs":"5abbcfd65c655507e0fad545242bbff24db523ae962b5d02aac4e7f1debba293","src/simulator.rs":"8c23627a170f02ca5ae0c9f50c899c19a1b439546ad518d2c43d96f830fe567e","src/tests.rs":"ea5df36f73d74692a6f26f4148d3d0b541a9e4baae16479100d54d2898602c3f","src/unicode.rs":"0e5d77d4d6751c6441982ae3d4a8453233443376441c5c01da5c86a5a5051167","src/unicode_data.rs":"e7d6e1d819bf2696cbf78eaee8de21814191585fddb52a04f434ce7e348d5c00"},"package":null}

Просмотреть файл

@ -10,6 +10,7 @@ bumpalo = "3.4.0"
jsparagus-ast = { path = "../ast" }
jsparagus-json-log = { path = "../json-log" }
jsparagus-generated-parser = { path = "../generated_parser" }
arrayvec = "0.5.1"
[features]
logging = ["jsparagus-json-log/logging"]

Просмотреть файл

@ -11,6 +11,7 @@ mod unicode_data;
#[cfg(test)]
mod tests;
extern crate arrayvec;
extern crate jsparagus_ast as ast;
extern crate jsparagus_generated_parser as generated_parser;
extern crate jsparagus_json_log as json_log;

Просмотреть файл

@ -5,6 +5,7 @@
//! generated_parser::reduce, and stack bookkeeping, omitted.
use crate::parser::Parser;
use arrayvec::ArrayVec;
use ast::SourceLocation;
use generated_parser::{
noop_actions, ParseError, ParserTrait, Result, StackValue, TermValue, TerminalId, Token, TABLES,
@ -22,12 +23,22 @@ pub struct Simulator<'alloc, 'parser> {
node_stack: &'parser [TermValue<StackValue<'alloc>>],
/// Mutable state stack used by the simulator on top of the immutable
/// parser's state stack.
sim_state_stack: Vec<usize>,
///
/// Uses a fixed-size array as the number of lookahead is bounded to a lower
/// value, panics otherwise.
sim_state_stack: ArrayVec<[usize; 4]>,
/// Mutable term stack used by the simulator on top of the immutable
/// parser's term stack.
sim_node_stack: Vec<TermValue<()>>,
/// Mutable term stack used by the simulator for replaying terms when reducing non-terminals are replaying lookahead terminals.
replay_stack: Vec<TermValue<()>>,
///
/// Uses a fixed-size array as the number of lookahead is bounded to a lower
/// value, panics otherwise.
sim_node_stack: ArrayVec<[TermValue<()>; 4]>,
/// Mutable term stack used by the simulator for replaying terms when
/// reducing non-terminals are replaying lookahead terminals.
///
/// Uses a fixed-size array as the number of lookahead is bounded to a lower
/// value, panics otherwise.
replay_stack: ArrayVec<[TermValue<()>; 4]>,
}
impl<'alloc, 'parser> ParserTrait<'alloc, ()> for Simulator<'alloc, 'parser> {
@ -119,9 +130,9 @@ impl<'alloc, 'parser> Simulator<'alloc, 'parser> {
sp,
state_stack,
node_stack,
sim_state_stack: vec![],
sim_node_stack: vec![],
replay_stack: vec![],
sim_state_stack: ArrayVec::new(),
sim_node_stack: ArrayVec::new(),
replay_stack: ArrayVec::new(),
}
}

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"f5439990185662ab31de12c07ef0c842438e3207bdfecc4fa6a9e4d4bea8a0d3","src/bytecode_offset.rs":"2aa7ba8c3cfbbd832092e65b599ab1c5a28d784ccc65d9e351bba656421b9a69","src/copy/AsyncFunctionResolveKind.h":"3851ecbb4728257595dd6e900749d1d8e02558574c00424a7ff0e3ca007fa6ec","src/copy/BytecodeFormatFlags.h":"f495a25e113a92071514d17483fbd821c9e9b24b164cae1c6b5ad2dd7491a945","src/copy/CheckIsObjectKind.h":"8f0e112396d966c9221a743d353f62671e04cdace7dd49a59898d94ba0f621b7","src/copy/FunctionFlags.h":"e2578c5747f298d03d81fa2b248e4b36800ac8d42d9d6ef801ebb1bc13bc3960","src/copy/FunctionPrefixKind.h":"f540a5c646a519b2d61aa27e4be865e08a31438def00ad5ba4ba2982ad1f2275","src/copy/GeneratorAndAsyncKind.h":"301668ce705970a51abfa94f89fd5db29ef5f129525110860e9e9bf7586ef187","src/copy/GeneratorResumeKind.h":"9e3cd9dc9c7f50937c6c45d73ec092dbfd92c4b56818ae6d1504bcd77078d0a6","src/copy/Opcodes.h":"16665eaf6793fb86f35edd59b237c88f480b8bdfd3e5e33008ac6c520892095c","src/copy/SourceNotes.h":"1e467f4e63d6f40a428e257fecd210bd14664516adf75a45cb17ab02ccd65fd8","src/copy/StencilEnums.h":"e5a1db4af868fd65591ed97594f7aa9a4cde79194da0cabd62b34e950b3b10b4","src/copy/Symbol.h":"603985e8c92c94e021baf3a0114dd384035eda60827016d310f1507c8396a45e","src/copy/ThrowMsgKind.h":"da805756961d81a2b50aeb391a02fd59a0aa39a9e3eb6aae21b423b15875ab30","src/env_coord.rs":"0be36a1bd307f5586affe0f3046d8b2ab2f5382b41b7b7bfb364b97d16a7c410","src/frame_slot.rs":"b20c81d67c572f20d06d493b211cd3eaa0432a8294541583643b82df3af2f813","src/function.rs":"b841ba6f7ecee3a38a136ef9902fd1d4a3f6b0aa96d1e8d8340e7f26dead75d9","src/gcthings.rs":"e2cb24050e30f423d0fe7bdbf2295854c4b8d3d76a202d47ea4c4e5586c4db58","src/lib.rs":"b003e085344277d2987ef492dc513048e8ec83217850a22ba7ca06ac01bc9b5c","src/opcode.rs":"5d91235142ab63db14009d43cb8930ae1518885c63c27bb0ff236bc5bb9971b2","src/opcode_info.rs":"a27c6d5602f5ecdcc882a0167614bc7a7754d958124941b4c1c0cdc2b0a894f1","src/regexp.rs":"7436cf545b990bec7dcc51ff28d67deaca9d4ce894468fdad0dd44b25c571cf2","src/result.rs":"58a64e0619c4ba4c6b7d8834208698a8f1639ab1771f7ae22272f81fe3611d63","src/scope.rs":"f3898f6ce9dbe45f0d346dbc93fcd801c74445aa154640bb6071c964c4758cdc","src/scope_notes.rs":"9947ba5aba3097321c76adcb5648a478e4a67e088fdc1e01511e51c4ad41a9f3","src/script.rs":"77138bdd47afafb4e70125face41244bc2b3f681c2f41458833d26146c27b3ab"},"package":null}
{"files":{"Cargo.toml":"f5439990185662ab31de12c07ef0c842438e3207bdfecc4fa6a9e4d4bea8a0d3","src/bytecode_offset.rs":"2aa7ba8c3cfbbd832092e65b599ab1c5a28d784ccc65d9e351bba656421b9a69","src/copy/AsyncFunctionResolveKind.h":"3851ecbb4728257595dd6e900749d1d8e02558574c00424a7ff0e3ca007fa6ec","src/copy/BytecodeFormatFlags.h":"f495a25e113a92071514d17483fbd821c9e9b24b164cae1c6b5ad2dd7491a945","src/copy/CheckIsObjectKind.h":"8f0e112396d966c9221a743d353f62671e04cdace7dd49a59898d94ba0f621b7","src/copy/FunctionFlags.h":"e2578c5747f298d03d81fa2b248e4b36800ac8d42d9d6ef801ebb1bc13bc3960","src/copy/FunctionPrefixKind.h":"f540a5c646a519b2d61aa27e4be865e08a31438def00ad5ba4ba2982ad1f2275","src/copy/GeneratorAndAsyncKind.h":"301668ce705970a51abfa94f89fd5db29ef5f129525110860e9e9bf7586ef187","src/copy/GeneratorResumeKind.h":"9e3cd9dc9c7f50937c6c45d73ec092dbfd92c4b56818ae6d1504bcd77078d0a6","src/copy/Opcodes.h":"6663f2ae6251b341352c0f75bea2a2c27babd555768e74727ecf524b1e83563e","src/copy/SourceNotes.h":"1e467f4e63d6f40a428e257fecd210bd14664516adf75a45cb17ab02ccd65fd8","src/copy/StencilEnums.h":"e5a1db4af868fd65591ed97594f7aa9a4cde79194da0cabd62b34e950b3b10b4","src/copy/Symbol.h":"603985e8c92c94e021baf3a0114dd384035eda60827016d310f1507c8396a45e","src/copy/ThrowMsgKind.h":"da805756961d81a2b50aeb391a02fd59a0aa39a9e3eb6aae21b423b15875ab30","src/env_coord.rs":"0be36a1bd307f5586affe0f3046d8b2ab2f5382b41b7b7bfb364b97d16a7c410","src/frame_slot.rs":"b20c81d67c572f20d06d493b211cd3eaa0432a8294541583643b82df3af2f813","src/function.rs":"b841ba6f7ecee3a38a136ef9902fd1d4a3f6b0aa96d1e8d8340e7f26dead75d9","src/gcthings.rs":"e2cb24050e30f423d0fe7bdbf2295854c4b8d3d76a202d47ea4c4e5586c4db58","src/lib.rs":"b003e085344277d2987ef492dc513048e8ec83217850a22ba7ca06ac01bc9b5c","src/opcode.rs":"aabbeae9df11564d3275414497ff99499f3d297f6d062351180f77cb23e588a0","src/opcode_info.rs":"a27c6d5602f5ecdcc882a0167614bc7a7754d958124941b4c1c0cdc2b0a894f1","src/regexp.rs":"7436cf545b990bec7dcc51ff28d67deaca9d4ce894468fdad0dd44b25c571cf2","src/result.rs":"58a64e0619c4ba4c6b7d8834208698a8f1639ab1771f7ae22272f81fe3611d63","src/scope.rs":"f3898f6ce9dbe45f0d346dbc93fcd801c74445aa154640bb6071c964c4758cdc","src/scope_notes.rs":"9947ba5aba3097321c76adcb5648a478e4a67e088fdc1e01511e51c4ad41a9f3","src/script.rs":"77138bdd47afafb4e70125face41244bc2b3f681c2f41458833d26146c27b3ab"},"package":null}

Просмотреть файл

@ -934,6 +934,18 @@
*/ \
MACRO(InitElem, init_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \
MACRO(InitHiddenElem, init_hidden_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \
/*
* Define a private field on `obj` with property key `id` and value `val`.
*
* `obj` must be an object,
* `id` must be a private name.
*
* Category: Objects
* Type: Defining properties
* Operands:
* Stack: obj, id, val => obj
*/ \
MACRO(InitPrivateElem, init_private_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \
/*
* Define an accessor property on `obj` with the given `getter`.
* `nameIndex` gives the property name.
@ -1038,6 +1050,17 @@
*/ \
MACRO(GetElem, get_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC) \
MACRO(CallElem, call_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC) \
/*
* Get the value of the private field `obj.#key`.
*
* Throws a TypeError if #key isn't on obj.
*
* Category: Objects
* Type: Accessing properties
* Operands:
* Stack: obj, key => obj[key]
*/ \
MACRO(GetPrivateElem, get_private_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC) \
/*
* Push the value of `obj.length`.
*
@ -1102,6 +1125,14 @@
* Stack: obj, key, val => val
*/ \
MACRO(StrictSetElem, strict_set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \
/*
* Like `JSOp::SetStrictElem`, but for private names. throw a TypeError if the private name doesnt' exist.
* Category: Objects
* Type: Accessing properties
* Operands:
* Stack: obj, key, val => val
*/ \
MACRO(SetPrivateElem, set_private_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \
/*
* Delete a property from `obj`. Push true on success, false if the
* property existed but could not be deleted. This implements `delete
@ -3656,9 +3687,6 @@
* a power of two. Use this macro to do so.
*/
#define FOR_EACH_TRAILING_UNUSED_OPCODE(MACRO) \
MACRO(237) \
MACRO(238) \
MACRO(239) \
MACRO(240) \
MACRO(241) \
MACRO(242) \

Просмотреть файл

@ -71,6 +71,7 @@ macro_rules! using_opcode_database {
(InitLockedProp, init_locked_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_IC),
(InitElem, init_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC),
(InitHiddenElem, init_hidden_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC),
(InitPrivateElem, init_private_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC),
(InitPropGetter, init_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT),
(InitHiddenPropGetter, init_hidden_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT),
(InitElemGetter, init_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT),
@ -83,11 +84,13 @@ macro_rules! using_opcode_database {
(CallProp, call_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_TYPESET|JOF_IC),
(GetElem, get_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC),
(CallElem, call_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC),
(GetPrivateElem, get_private_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC),
(Length, length, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_TYPESET|JOF_IC),
(SetProp, set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC),
(StrictSetProp, strict_set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC),
(SetElem, set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC),
(StrictSetElem, strict_set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC),
(SetPrivateElem, set_private_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC),
(DelProp, del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_CHECKSLOPPY),
(StrictDelProp, strict_del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_CHECKSTRICT),
(DelElem, del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_CHECKSLOPPY),

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

1
third_party/rust/jsparagus/Cargo.lock сгенерированный поставляемый
Просмотреть файл

@ -448,6 +448,7 @@ dependencies = [
name = "jsparagus-parser"
version = "0.1.0"
dependencies = [
"arrayvec",
"bumpalo",
"criterion",
"jsparagus-ast",

Просмотреть файл

@ -0,0 +1,255 @@
// This script runs multipe parsers from a single engine.
"use strict";
// Directory where to find the list of JavaScript sources to be used for
// benchmarking.
var dir = ".";
if (scriptArgs && scriptArgs[0]) {
// If an argument is given on the command line, assume this is the path to
// one of real-js-samples directory containing thousabds of JS files,
// otherwise this is assumed to be the current working directory.
dir = scriptArgs[0]; // "~/real-js-samples/20190416"
}
// Execution mode of the parser, either "script" or "module".
var mode = "script";
// Number of times each JavaScript source is used for benchmarking.
var runs_per_script = 10;
// First parser
var name_1 = "SpiderMonkey parser";
function parse_1(path) {
var start = performance.now();
parse(path, { module: mode == "module", smoosh: false });
return performance.now() - start;
}
// Second parser
var name_2 = "SmooshMonkey parser";
function parse_2(path) {
var start = performance.now();
parse(path, { module: mode == "module", smoosh: true });
return performance.now() - start;
}
// For a given `parse` function, execute it with the content of each file in
// `dir`. This process is repeated `N` times and the results are added to the
// `result` argument using the `prefix` key for the filenames.
function for_all_files(parse, N = 1, prefix = "", result = {}) {
var path = "", content = "";
var t = 0;
var list = os.file.listDir(dir);
for (var file of list) {
try {
path = os.path.join(dir, file);
content = os.file.readRelativeToScript(path);
try {
t = 0;
for (var n = 0; n < N; n++)
t += parse(content);
result[prefix + path] = { time: t / N, bytes: content.length };
} catch (e) {
// ignore all errors for now.
result[prefix + path] = { time: null, bytes: content.length };
}
} catch (e) {
// ignore all read errors.
}
}
return result;
}
// Compare the results of 2 parser runs and compute the speed ratio between the
// 2 parsers. Results from both parsers are assuming to be comparing the same
// things if they have the same property name.
//
// The aggregated results is returned as an object, which reports the total time
// for each parser, the quantity of bytes parsed and skipped and an array of
// speed ratios for each file tested.
function compare(res1, res2) {
var result = {
time1: 0,
time2: 0,
parsed_files: 0,
parsed_bytes: 0,
skipped_files: 0,
skipped_bytes: 0,
ratios_2over1: [],
};
for (var path of Object.keys(res1)) {
if (!(path in res1 && path in res2)) {
continue;
}
var p1 = res1[path];
var p2 = res2[path];
if (p1.time !== null && p2.time !== null) {
result.time1 += p1.time;
result.time2 += p2.time;
result.parsed_files += 1;
result.parsed_bytes += p1.bytes;
result.ratios_2over1.push(p2.time / p1.time);
} else {
result.skipped_files += 1;
result.skipped_bytes += p1.bytes;
}
}
return result;
}
// Given a `table` of speed ratios, display a distribution chart of speed
// ratios. This is useful to check if the data is noisy, bimodal, and to easily
// eye-ball characteristics of the distribution.
function spread(table, min, max, step) {
// var chars = ["\xa0", "\u2591", "\u2592", "\u2593", "\u2588"];
var chars = ["\xa0", "\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
var s = ["\xa0", "\xa0", "" + min, "\xa0", "\xa0"];
var ending = ["\xa0", "\xa0", "" + max, "\xa0", "\xa0"];
var ranges = [];
var vmax = table.length / 10;
for (var i = min; i < max; i += step) {
ranges.push(0);
}
for (var x of table) {
if (x < min || max < x) continue;
var idx = ((x - min) / step)|0;
ranges[idx] += 1;
}
var max_index = chars.length * s.length;
var ratio = max_index / vmax;
for (i = 0; i < s.length; i++)
s[i] += "\xa0\u2595";
for (var v of ranges) {
var d = Math.min((v * ratio)|0, max_index - 1);
var offset = max_index;
for (i = 0; i < s.length; i++) {
offset -= chars.length;
var c = Math.max(0, Math.min(d - offset, chars.length - 1));
s[i] += chars[c];
}
}
for (i = 0; i < s.length; i++)
s[i] += "\u258f\xa0" + ending[i];
var res = "";
for (i = 0; i < s.length; i++)
res += "\n" + s[i];
return res;
}
// NOTE: We have multiple strategies depending whether we want to check the
// throughput of the parser assuming the parser is cold/hot in memory, the data is
// cold/hot in the cache, and the adaptive CPU throttle is low/high.
//
// Ideally we should be comparing comparable things, but due to the adaptive
// behavior of CPU and Disk, we can only approximate it while keeping results
// comparable to what users might see.
// Compare Hot-parsers on cold data.
function strategy_1() {
var res1 = for_all_files(parse_1, runs_per_script);
var res2 = for_all_files(parse_2, runs_per_script);
var result = compare(res1, res2);
print(name_1, "\t", result.time1, "ms\t", 1e6 * result.time1 / result.parsed_bytes, 'ns/byte\t', result.parsed_bytes / (1e6 * result.time1), 'bytes/ns\t');
print(name_2, "\t", result.time2, "ms\t", 1e6 * result.time2 / result.parsed_bytes, 'ns/byte\t', result.parsed_bytes / (1e6 * result.time2), 'bytes/ns\t');
print("Total parsed (scripts:", result.parsed_files, ", bytes:", result.parsed_bytes, ")");
print("Total skipped (scripts:", result.skipped_files, ", bytes:", result.skipped_bytes, ")");
print(name_2, "/", name_1, ":", result.time2 / result.time1);
print(name_2, "/", name_1, ":", spread(result.ratios_2over1, 0, 3, 0.05));
}
// Compare Hot-parsers on cold data, and swap parse order.
function strategy_2() {
var res2 = for_all_files(parse_2, runs_per_script);
var res1 = for_all_files(parse_1, runs_per_script);
var result = compare(res1, res2);
print(name_1, "\t", result.time1, "ms\t", 1e6 * result.time1 / result.parsed_bytes, 'ns/byte\t', result.parsed_bytes / (1e6 * result.time1), 'bytes/ns\t');
print(name_2, "\t", result.time2, "ms\t", 1e6 * result.time2 / result.parsed_bytes, 'ns/byte\t', result.parsed_bytes / (1e6 * result.time2), 'bytes/ns\t');
print("Total parsed (scripts:", result.parsed_files, ", bytes:", result.parsed_bytes, ")");
print("Total skipped (scripts:", result.skipped_files, ", bytes:", result.skipped_bytes, ")");
print(name_2, "/", name_1, ":", result.time2 / result.time1);
print(name_2, "/", name_1, ":", spread(result.ratios_2over1, 0, 3, 0.05));
}
// Interleaves N hot-parser results. (if N=1, then strategy_3 is identical to strategy_1)
//
// At the moment, this is assumed to be the best approach which might mimic how
// a helper-thread would behave if it was saturated with content to be parsed.
function strategy_3() {
var res1 = {};
var res2 = {};
var N = runs_per_script;
for (var n = 0; n < N; n++) {
for_all_files(parse_1, 1, "" + n, res1);
for_all_files(parse_2, 1, "" + n, res2);
}
var result = compare(res1, res2);
print(name_1, "\t", result.time1, "ms\t", 1e6 * result.time1 / result.parsed_bytes, 'ns/byte\t', result.parsed_bytes / (1e6 * result.time1), 'bytes/ns\t');
print(name_2, "\t", result.time2, "ms\t", 1e6 * result.time2 / result.parsed_bytes, 'ns/byte\t', result.parsed_bytes / (1e6 * result.time2), 'bytes/ns\t');
print("Total parsed (scripts:", result.parsed_files, ", bytes:", result.parsed_bytes, ")");
print("Total skipped (scripts:", result.skipped_files, ", bytes:", result.skipped_bytes, ")");
print(name_2, "/", name_1, ":", result.time2 / result.time1);
print(name_2, "/", name_1, ":", spread(result.ratios_2over1, 0, 5, 0.05));
}
// Compare cold parsers, with alternatetively cold/hot data.
//
// By swapping parser order of execution after each file, we expect that the
// previous parser execution would be enough to evict the other from the L2
// cache, and as such cause the other parser to hit cold instruction cache where
// the instruction have to be reloaded.
//
// At the moment, this is assumed to be the best approach which might mimic how
// parsers are effectively used on the main thread.
function strategy_0() {
var path = "", content = "";
var t_1= 0, t_2 = 0, time_1 = 0, time_2 = 0;
var count = 0, count_bytes = 0, skipped = 0, skipped_bytes = 0;
var parse1_first = false;
var list = os.file.listDir(dir);
var ratios_2over1 = [];
var parse1_first = true;
for (var file of list) {
path = os.path.join(dir, file);
content = "";
try {
// print(Math.round(100 * f / list.length), file);
content = os.file.readRelativeToScript(path);
parse1_first = !parse1_first; // Math.random() > 0.5;
for (var i = 0; i < runs_per_script; i++) {
// Randomize the order in which parsers are executed as they are
// executed in the same process and the parsed content might be
// faster to load for the second parser as it is already in memory.
if (parse1_first) {
t_1 = parse_1(content);
t_2 = parse_2(content);
} else {
t_2 = parse_2(content);
t_1 = parse_1(content);
}
time_1 += t_1;
time_2 += t_2;
ratios_2over1.push(t_2 / t_1);
}
count++;
count_bytes += content.length;
} catch (e) {
// ignore all errors for now.
skipped++;
skipped_bytes += content.length;
}
}
var total_bytes = count_bytes * runs_per_script;
print(name_1, "\t", time_1, "ms\t", 1e6 * time_1 / total_bytes, 'ns/byte\t', total_bytes / (1e6 * time_1), 'bytes/ns\t');
print(name_2, "\t", time_2, "ms\t", 1e6 * time_2 / total_bytes, 'ns/byte\t', total_bytes / (1e6 * time_2), 'bytes/ns\t');
print("Total parsed (scripts:", count * runs_per_script, ", bytes:", total_bytes, ")");
print("Total skipped (scripts:", skipped * runs_per_script, ", bytes:", skipped_bytes, ")");
print(name_2, "/", name_1, ":", time_2 / time_1);
print(name_2, "/", name_1, ":", spread(ratios_2over1, 0, 5, 0.05));
}
print("Main thread comparison:")
strategy_0();
print("")
print("Off-thread comparison:")
strategy_3();

Просмотреть файл

@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::env::{self, Args};
use std::fs::{File, create_dir_all};
use std::fs::{create_dir_all, File};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::process::{self, Command};
@ -20,6 +20,10 @@ COMMAND:
test [--opt] [MOZILLA_CENTRAL]
Run jstests/jit-test with SpiderMonkey JS shell binary built by
"build" command
bench [--opt] [--samples-dir=REAL_JS_SAMPLES/DATE] [MOZILLA_CENTRAL]
Compare SpiderMonkey parser performance against SmooshMonkey on a
collection of JavaScript files, using the JS shell binary built by
"build" command.
bump [MOZILLA_CENTRAL]
Bump jsparagus version referred by mozilla-central to the latest
"ci_generated" branch HEAD, and re-vendor jsparagus
@ -43,6 +47,8 @@ OPTIONS:
--concat-mozconfig For building mozilla-central, concatenates the content
of the MOZCONFIG environment variable with the content of
smoosh_tools mozconfig.
--samples-dir=DIR Directory containing thousands of JavaScripts to be used
for measuring the performance of SmooshMonkey.
"#;
macro_rules! try_finally {
@ -110,6 +116,7 @@ enum CommandType {
Build,
Shell,
Test,
Bench,
Bump,
Gen,
Try,
@ -130,6 +137,7 @@ struct SimpleArgs {
command: CommandType,
build_type: BuildType,
moz_path: String,
realjs_path: String,
remote: String,
concat_mozconfig: bool,
}
@ -144,6 +152,7 @@ impl SimpleArgs {
"build" => CommandType::Build,
"test" => CommandType::Test,
"shell" => CommandType::Shell,
"bench" => CommandType::Bench,
"bump" => CommandType::Bump,
"gen" => CommandType::Gen,
"try" => CommandType::Try,
@ -156,6 +165,7 @@ impl SimpleArgs {
let mut remote = "origin".to_string();
let mut moz_path = Self::guess_moz();
let mut realjs_path = Self::guess_realjs();
let mut build_type = BuildType::Debug;
let mut concat_mozconfig = false;
@ -176,6 +186,9 @@ impl SimpleArgs {
"--remote" => {
remote = value.to_string();
}
"--samples-dir" => {
realjs_path = value.to_string();
}
_ => {
Self::show_usage();
}
@ -210,6 +223,7 @@ impl SimpleArgs {
command,
build_type,
moz_path,
realjs_path,
remote,
concat_mozconfig,
}
@ -235,6 +249,10 @@ impl SimpleArgs {
return "../mozilla-central".to_string();
}
fn guess_realjs() -> String {
return "../real-js-samples/20190416".to_string();
}
}
#[derive(Debug)]
@ -314,6 +332,12 @@ impl JsparagusTree {
BuildType::Debug => "smoosh-debug",
})
}
fn compare_parsers_js(&self) -> PathBuf {
self.topsrcdir
.join("benchmarks")
.join("compare-spidermonkey-parsers.js")
}
}
struct ObjDir(String);
@ -327,13 +351,20 @@ impl FromStr for ObjDir {
false => return Err(Error::Generic("unexpected start".into())),
};
if Some(0) != s.find(char::is_whitespace) {
return Err(Error::Generic("expected whitespace after mk_add_options".into()));
return Err(Error::Generic(
"expected whitespace after mk_add_options".into(),
));
}
let s = s.trim_start();
let eq_idx = s.find('=').ok_or(Error::Generic("equal sign not found after mk_add_option".into()))?;
let eq_idx = s.find('=').ok_or(Error::Generic(
"equal sign not found after mk_add_option".into(),
))?;
let var_name = &s[..eq_idx];
if var_name != "MOZ_OBJDIR" {
return Err(Error::Generic(format!("{}: unexpected variable, expected MOZ_OBJDIR", var_name)))
return Err(Error::Generic(format!(
"{}: unexpected variable, expected MOZ_OBJDIR",
var_name
)));
}
let s = &s[(eq_idx + 1)..];
let s = s.trim();
@ -342,7 +373,6 @@ impl FromStr for ObjDir {
}
}
#[derive(Debug)]
struct BuildTree {
moz: MozillaTree,
@ -361,8 +391,7 @@ impl BuildTree {
// environmenet variable with the content provided by jsparagus.
// This is useful to add additional compilation variants for
// mozilla-central.
let env = env::var("MOZCONFIG")
.map_err(|e| Error::EnvVar("MOZCONFIG", e))?;
let env = env::var("MOZCONFIG").map_err(|e| Error::EnvVar("MOZCONFIG", e))?;
let env_config = read_file(&env.into())?;
let jsp_config = read_file(&jsp_mozconfig)?;
let config = env_config + &jsp_config;
@ -377,15 +406,19 @@ impl BuildTree {
}
}
let objdir = objdir.ok_or(Error::Generic("MOZ_OBJDIR must exists".into()))?;
let topsrcdir = moz.topsrcdir.to_str().ok_or(())
let topsrcdir = moz
.topsrcdir
.to_str()
.ok_or(())
.map_err(|_| Error::Generic("topsrcdir cannot be encoded in UTF-8.".into()))?;
let objdir = objdir.replace("@TOPSRCDIR@", topsrcdir);
// Create the object direcotry.
let objdir: PathBuf = objdir.into();
if !objdir.is_dir() {
create_dir_all(&objdir)
.map_err(|e| Error::IO(format!("Failed to create directory {:?}", objdir), e))?;
create_dir_all(&objdir).map_err(|e| {
Error::IO(format!("Failed to create directory {:?}", objdir), e)
})?;
}
// Create MOZCONFIG file.
@ -397,12 +430,14 @@ impl BuildTree {
jsp_mozconfig
};
Ok(Self { moz, jsp, mozconfig })
Ok(Self {
moz,
jsp,
mozconfig,
})
}
}
/// Run `command`, and check if the exit code is successful.
/// Returns Err if failed to run the command, or the exit code is non-zero.
fn check_command(command: &mut Command) -> Result<(), Error> {
@ -693,6 +728,20 @@ fn shell(args: &SimpleArgs) -> Result<(), Error> {
run_mach(&["run", "--smoosh"], args)
}
fn bench(args: &SimpleArgs) -> Result<(), Error> {
let jsparagus = JsparagusTree::try_new()?;
let cmp_parsers = jsparagus.compare_parsers_js();
let cmp_parsers: &str = cmp_parsers.to_str().ok_or(Error::Generic(
"Unable to serialize benchmark script path".into(),
))?;
let realjs_path = jsparagus.topsrcdir.join(&args.realjs_path);
let realjs_path: &str = realjs_path.to_str().ok_or(Error::Generic(
"Unable to serialize benchmark script path".into(),
))?;
run_mach(&["run", "-f", cmp_parsers, "--", "--", realjs_path], args)
}
fn test(args: &SimpleArgs) -> Result<(), Error> {
run_mach(&["jstests", "--args=-smoosh"], args)?;
run_mach(&["jit-test", "--args=-smoosh"], args)
@ -881,6 +930,7 @@ fn main() {
CommandType::Build => build(&args),
CommandType::Shell => shell(&args),
CommandType::Test => test(&args),
CommandType::Bench => bench(&args),
CommandType::Bump => bump(&args),
CommandType::Gen => gen_branch(&args),
CommandType::Try => push_try(&args),