Skip to content

Commit

Permalink
Bump HHVM version
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 23, 2023
1 parent 997b782 commit b9eb8c0
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 146 deletions.
57 changes: 20 additions & 37 deletions hhvm-patch.diff
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ index e7f91b56e96..7be4f159ecf 100644

pub struct Names {
diff --git a/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs b/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs
index 384622926b5..54fa1671824 100644
index cfc3b81042c..e3e7a5b8fc0 100644
--- a/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs
+++ b/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs
@@ -2237,7 +2237,6 @@ impl<P: Params> Node<P> for Typedef<P::Ex, P::En> {
@@ -2247,7 +2247,6 @@ impl<P: Params> Node<P> for Typedef<P::Ex, P::En> {
self.file_attributes.accept(c, v)?;
self.mode.accept(c, v)?;
self.vis.accept(c, v)?;
Expand All @@ -189,43 +189,17 @@ index 384622926b5..54fa1671824 100644
self.emit_id.accept(c, v)?;
self.is_ctx.accept(c, v)?;
diff --git a/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs b/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs
index c6da9b503e4..64a8c2caf9a 100644
index 2df37947608..1943892a3e3 100644
--- a/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs
+++ b/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs
@@ -2237,7 +2237,6 @@ impl<P: Params> NodeMut<P> for Typedef<P::Ex, P::En> {
@@ -2247,7 +2247,6 @@ impl<P: Params> NodeMut<P> for Typedef<P::Ex, P::En> {
self.file_attributes.accept(c, v)?;
self.mode.accept(c, v)?;
self.vis.accept(c, v)?;
- self.namespace.accept(c, v)?;
self.span.accept(c, v)?;
self.emit_id.accept(c, v)?;
self.is_ctx.accept(c, v)?;
diff --git a/hphp/hack/src/oxidized/lib.rs b/hphp/hack/src/oxidized/lib.rs
index 6b89bf88bb8..00242f8bd3d 100644
--- a/hphp/hack/src/oxidized/lib.rs
+++ b/hphp/hack/src/oxidized/lib.rs
@@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
#![feature(box_patterns)]
-#![feature(drain_filter)]
+#![feature(extract_if)]

#[macro_use]
extern crate rust_to_ocaml_attr;
diff --git a/hphp/hack/src/oxidized/manual/custom_error_config_impl.rs b/hphp/hack/src/oxidized/manual/custom_error_config_impl.rs
index 30d98a66d71..d6914543ba2 100644
--- a/hphp/hack/src/oxidized/manual/custom_error_config_impl.rs
+++ b/hphp/hack/src/oxidized/manual/custom_error_config_impl.rs
@@ -39,7 +39,7 @@ use crate::validation_err::ValidationErr;
impl CustomErrorConfig {
pub fn new(mut errors: Vec<CustomError>) -> Self {
let invalid = errors
- .drain_filter(|e| {
+ .extract_if(|e| {
let mut env = ValidationEnv::default();
!e.validate(&mut env)
})
diff --git a/hphp/hack/src/oxidized_by_ref/Cargo.toml b/hphp/hack/src/oxidized_by_ref/Cargo.toml
index de0a509ccff..4b7bd0f2947 100644
--- a/hphp/hack/src/oxidized_by_ref/Cargo.toml
Expand Down Expand Up @@ -406,9 +380,18 @@ index 33ba4ae40cf..bebe6e2e909 100644
}
}
diff --git a/hphp/hack/src/parser/aast_parser.rs b/hphp/hack/src/parser/aast_parser.rs
index 01b39e624aa..8d04ce3b9ca 100644
index c0bba7f63f8..93d79e22298 100644
--- a/hphp/hack/src/parser/aast_parser.rs
+++ b/hphp/hack/src/parser/aast_parser.rs
@@ -5,7 +5,7 @@
// LICENSE file in the "hack" directory of this source tree.

use std::sync::Arc;
-use std::time::Instant;
+

use bumpalo::Bump;
use hash::HashSet;
@@ -85,11 +85,11 @@ impl<'src> AastParser {
indexed_source_text: &'src IndexedSourceText<'src>,
default_unstable_features: HashSet<rust_parser_errors::UnstableFeatures>,
Expand Down Expand Up @@ -443,7 +426,7 @@ index 01b39e624aa..8d04ce3b9ca 100644
match language {
Language::Hack => {}
_ => return Err(Error::NotAHackFile()),
@@ -166,14 +166,14 @@ impl<'src> AastParser {
@@ -165,14 +165,14 @@ impl<'src> AastParser {
);
stack_limit::reset();
let ret = lower(&mut lowerer_env, tree.root());
Expand All @@ -460,7 +443,7 @@ index 01b39e624aa..8d04ce3b9ca 100644
stack_limit::reset();
let syntax_errors = Self::check_syntax_error(
env,
@@ -186,7 +186,7 @@ impl<'src> AastParser {
@@ -185,7 +185,7 @@ impl<'src> AastParser {
let lowerer_parsing_errors = lowerer_env.parsing_errors().to_vec();
let errors = lowerer_env.hh_errors().to_vec();
let lint_errors = lowerer_env.lint_errors().to_vec();
Expand All @@ -469,7 +452,7 @@ index 01b39e624aa..8d04ce3b9ca 100644

Ok(ParserResult {
file_mode: mode,
@@ -198,9 +198,9 @@ impl<'src> AastParser {
@@ -197,9 +197,9 @@ impl<'src> AastParser {
lint_errors,
profile: ParserProfile {
lower_peak,
Expand All @@ -482,7 +465,7 @@ index 01b39e624aa..8d04ce3b9ca 100644
error_peak,
arena_bytes: arena.allocated_bytes() as u64,
..Default::default()
@@ -334,7 +334,7 @@ impl<'src> AastParser {
@@ -333,7 +333,7 @@ impl<'src> AastParser {
disable_hh_ignore_error: env.parser_options.po_disable_hh_ignore_error,
allowed_decl_fixme_codes: &env.parser_options.po_allowed_decl_fixme_codes,
};
Expand All @@ -505,10 +488,10 @@ index 8db2f3a3271..cadcc02dbbf 100644
}
_ => {
diff --git a/hphp/hack/src/parser/lowerer/lowerer.rs b/hphp/hack/src/parser/lowerer/lowerer.rs
index 2635de421ad..cc70f07f0e8 100644
index 978ee9dd0b7..1bf7e45930d 100644
--- a/hphp/hack/src/parser/lowerer/lowerer.rs
+++ b/hphp/hack/src/parser/lowerer/lowerer.rs
@@ -3648,12 +3648,12 @@ fn p_markup<'a>(node: S<'a>, env: &mut Env<'a>) -> Result<ast::Stmt> {
@@ -3491,12 +3491,12 @@ fn p_markup<'a>(node: S<'a>, env: &mut Env<'a>) -> Result<ast::Stmt> {
let markup_hashbang = &c.hashbang;
let markup_suffix = &c.suffix;
let pos = p_pos(node, env);
Expand Down
9 changes: 9 additions & 0 deletions src/analyzer/function_analysis_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct FunctionAnalysisData {
pub closures: FxHashMap<Pos, FunctionLikeInfo>,
pub closure_spans: Vec<(u32, u32)>,
pub replacements: BTreeMap<(u32, u32), Replacement>,
pub insertions: BTreeMap<u32, Vec<String>>,
pub current_stmt_offset: Option<StmtStart>,
pub expr_fixme_positions: FxHashMap<(u32, u32), StmtStart>,
pub symbol_references: SymbolReferences,
Expand Down Expand Up @@ -64,6 +65,7 @@ impl FunctionAnalysisData {
if_true_assertions: FxHashMap::default(),
if_false_assertions: FxHashMap::default(),
replacements: BTreeMap::new(),
insertions: BTreeMap::new(),
current_stmt_offset,
hh_fixmes: file_source.hh_fixmes.clone(),
symbol_references: SymbolReferences::new(),
Expand Down Expand Up @@ -558,6 +560,13 @@ impl FunctionAnalysisData {
self.replacements.insert(offsets, replacement);
true
}

pub fn insert_at(&mut self, insertion_point: u32, replacement: String) {
self.insertions
.entry(insertion_point)
.or_insert_with(Vec::new)
.push(replacement);
}
}

fn get_hakana_fixmes_and_ignores(
Expand Down
14 changes: 14 additions & 0 deletions src/analyzer/functionlike_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ impl<'a> FunctionLikeAnalyzer<'a> {
.extend(analysis_data.replacements);
}

if !analysis_data.insertions.is_empty() {
parent_analysis_data
.insertions
.extend(analysis_data.insertions);
}

for issue in analysis_data.issues_to_emit {
parent_analysis_data.maybe_add_issue(
issue,
Expand Down Expand Up @@ -1400,6 +1406,14 @@ pub(crate) fn update_analysis_result_with_tast(
.extend(analysis_data.replacements);
}

if !analysis_data.insertions.is_empty() {
analysis_result
.insertions
.entry(*file_path)
.or_insert_with(BTreeMap::new)
.extend(analysis_data.insertions);
}

let mut issues_to_emit = analysis_data.issues_to_emit;

issues_to_emit.sort_by(|a, b| a.pos.start_offset.partial_cmp(&b.pos.start_offset).unwrap());
Expand Down
64 changes: 52 additions & 12 deletions src/analyzer/stmt/control_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,25 +415,32 @@ pub(crate) fn get_control_actions(
control_actions.retain(|action| *action != ControlAction::None);
}
aast::Stmt_::Block(block_stmts) => {
let mut block_actions = get_control_actions(
if handle_block(
codebase,
interner,
resolved_names,
&block_stmts.0,
&block_stmts.1,
analysis_data,
break_context.clone(),
&break_context,
return_is_exit,
);

if !block_actions.contains(&ControlAction::None) {
control_actions.extend(block_actions);
control_actions.retain(|action| *action != ControlAction::None);

&mut control_actions,
) {
return control_actions;
}
}
aast::Stmt_::Concurrent(block_stmts) => {
if handle_block(
codebase,
interner,
resolved_names,
&block_stmts,
analysis_data,
&break_context,
return_is_exit,
&mut control_actions,
) {
return control_actions;
}

block_actions.retain(|action| *action != ControlAction::None);
control_actions.extend(block_actions);
}
aast::Stmt_::Awaitall(boxed) => {
let mut block_actions = get_control_actions(
Expand Down Expand Up @@ -475,6 +482,39 @@ pub(crate) fn get_control_actions(
control_actions
}

fn handle_block(
codebase: &CodebaseInfo,
interner: &Interner,
resolved_names: &FxHashMap<usize, StrId>,
block_stmts: &aast::Block<(), ()>,
analysis_data: Option<&FunctionAnalysisData>,
break_context: &Vec<BreakContext>,
return_is_exit: bool,
control_actions: &mut FxHashSet<ControlAction>,
) -> bool {
let mut block_actions = get_control_actions(
codebase,
interner,
resolved_names,
&block_stmts.0,
analysis_data,
break_context.clone(),
return_is_exit,
);

if !block_actions.contains(&ControlAction::None) {
control_actions.extend(block_actions);
control_actions.retain(|action| *action != ControlAction::None);

return true;
}

block_actions.retain(|action| *action != ControlAction::None);
control_actions.extend(block_actions);

false
}

fn handle_call(
call_expr: &CallExpr,
resolved_names: &FxHashMap<usize, StrId>,
Expand Down
83 changes: 46 additions & 37 deletions src/analyzer/stmt_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub(crate) fn analyze(
}
}
aast::Stmt_::Block(boxed) => {
for boxed_stmt in boxed {
for boxed_stmt in &boxed.1 {
analyze(
statements_analyzer,
boxed_stmt,
Expand All @@ -232,7 +232,18 @@ pub(crate) fn analyze(
);
return Err(AnalysisError::UserError);
}
aast::Stmt_::DeclareLocal(_) => {}
aast::Stmt_::DeclareLocal(_) => {},
aast::Stmt_::Concurrent(boxed) => {
for boxed_stmt in &boxed.0 {
analyze(
statements_analyzer,
boxed_stmt,
analysis_data,
context,
loop_scope,
)?;
}
},
}

context.cond_referenced_var_ids = FxHashSet::default();
Expand Down Expand Up @@ -399,7 +410,7 @@ fn detect_unused_statement_expressions(

fn analyze_awaitall(
boxed: (
&Vec<(Option<oxidized::tast::Lid>, aast::Expr<(), ()>)>,
&Vec<(oxidized::tast::Lid, aast::Expr<(), ()>)>,
&Vec<aast::Stmt<(), ()>>,
),
statements_analyzer: &StatementsAnalyzer,
Expand All @@ -413,45 +424,43 @@ fn analyze_awaitall(
for (assignment_id, expr) in boxed.0 {
expression_analyzer::analyze(statements_analyzer, expr, analysis_data, context, &mut None)?;

if let Some(assignment_id) = assignment_id {
let mut assignment_type = None;

if let Some(t) = analysis_data.get_expr_type(expr.pos()) {
let parent_nodes = t.parent_nodes.clone();
if t.is_single() {
let inner = t.get_single();
if let TAtomic::TNamedObject {
name: STR_AWAITABLE,
type_params: Some(type_params),
..
} = inner
{
let mut new = type_params.get(0).unwrap().clone();
let mut assignment_type = None;

if let Some(t) = analysis_data.get_expr_type(expr.pos()) {
let parent_nodes = t.parent_nodes.clone();
if t.is_single() {
let inner = t.get_single();
if let TAtomic::TNamedObject {
name: STR_AWAITABLE,
type_params: Some(type_params),
..
} = inner
{
let mut new = type_params.get(0).unwrap().clone();

new.parent_nodes = parent_nodes;
assignment_type = Some(new)
}
new.parent_nodes = parent_nodes;
assignment_type = Some(new)
}
}
}

assignment_analyzer::analyze(
statements_analyzer,
(
&ast_defs::Bop::Eq(None),
&aast::Expr(
(),
assignment_id.0.clone(),
aast::Expr_::Lvar(Box::new(assignment_id.clone())),
),
None,
assignment_analyzer::analyze(
statements_analyzer,
(
&ast_defs::Bop::Eq(None),
&aast::Expr(
(),
assignment_id.0.clone(),
aast::Expr_::Lvar(Box::new(assignment_id.clone())),
),
&stmt.0,
assignment_type.as_ref(),
analysis_data,
context,
false,
)?;
}
None,
),
&stmt.0,
assignment_type.as_ref(),
analysis_data,
context,
false,
)?;
}

for stmt in boxed.1 {
Expand Down
Loading

0 comments on commit b9eb8c0

Please sign in to comment.