Skip to content

Commit

Permalink
Rip out old way to replace trivial builtin wrappers in sandbox mode (…
Browse files Browse the repository at this point in the history
…revert D61638064)

Summary:
Mostly a revert of a prior diff.

We can actually just grab the builtin off the attribute to avoid reading the .hhvmconfig in HHVM but still tie the map to www rev.

Reviewed By: mdko

Differential Revision: D63444793

fbshipit-source-id: 8fdfd4186e1a4216050f4aa5f54fdcf55b477abd
  • Loading branch information
voorka authored and facebook-github-bot committed Oct 25, 2024
1 parent f9ff628 commit 768df6a
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 34 deletions.
1 change: 0 additions & 1 deletion hphp/doc/configs.specification
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ The format can be found in hphp/tools/configs/generate-configs.rs
reified generic bytecode, powered by decl directed bytecode

- std::map<std::string,std::string> Hack.Lang.AliasedNamespaces = {}, UNKNOWN, repooptionsflag(Parser)|lookuppath(AliasedNamespaces)
- std::map<std::string,std::string> Hack.Lang.TrivialBuiltins = {}, UNKNOWN, repooptionsflag(Parser)|lookuppath(TrivialBuiltins)

- bool Hack.Lang.OptimizeParamLifetimes = false, paulbiss, repooptionsflag(Parser)|hackc(hhbc)
- bool Hack.Lang.OptimizeLocalLifetimes = false, paulbiss, repooptionsflag(Parser)|hackc(hhbc)
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/hackc/cli/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ pub(crate) fn native_env(filepath: RelativePath, opts: &SingleFileOpts) -> Resul
hhbc_flags,
hhvm: Hhvm {
include_roots: Default::default(),
trivial_builtins: Default::default(),
parser_options,
},
flags: opts.env_flags.clone(),
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/hackc/cli/hackc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ impl Opts {
filepath: relative_path::RelativePath::make(relative_path::Prefix::Dummy, path),
hhvm: Hhvm {
include_roots: Default::default(),
trivial_builtins: Default::default(),
parser_options,
},
flags: self.env_flags.clone(),
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/hackc/compile/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl Default for CompilerFlags {
pub struct Hhvm {
pub include_roots: BTreeMap<BString, BString>,
pub parser_options: ParserOptions,
pub trivial_builtins: BTreeMap<String, String>,
}

impl Hhvm {
Expand Down
14 changes: 7 additions & 7 deletions hphp/hack/src/hackc/emitter/emit_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ fn emit_call<'a, 'd>(
readonly_return: bool,
) -> Result<InstrSeq> {
if let Some(ast_defs::Id(_, s)) = expr.as_id() {
let fid = e.emit_function_name(s);
let fid = hhbc::FunctionName::from_ast_name(s);
e.add_function_ref(fid);
}
let readonly_this = match &expr.2 {
Expand All @@ -1837,7 +1837,7 @@ fn emit_call<'a, 'd>(
match expr.2.as_id() {
None => emit_call_default(e, env, pos, expr, targs, args, uarg, fcall_args),
Some(ast_defs::Id(_, id)) => {
let fq = e.emit_function_name(id);
let fq = hhbc::FunctionName::from_ast_name(id);
let lower_fq_name = fq.as_str();
emit_special_function(e, env, pos, targs, args, uarg, lower_fq_name)
.transpose()
Expand Down Expand Up @@ -2112,7 +2112,7 @@ fn emit_call_lhs_and_fcall<'a, 'd>(
]),
InstrSeq::gather(vec![instr::f_call_func_d(
fcall_args,
e.emit_function_name(fid),
hhbc::FunctionName::from_ast_name(fid),
)]),
))
}
Expand Down Expand Up @@ -2309,12 +2309,12 @@ fn emit_call_lhs_and_fcall<'a, 'd>(
} = fcall_args;
let fq_id = match string_utils::strip_global_ns(&id.1) {
"min" if num_args == 2 && !flags.contains(FCallArgsFlags::HasUnpack) => {
e.emit_function_name("__SystemLib\\min2")
hhbc::FunctionName::from_ast_name("__SystemLib\\min2")
}
"max" if num_args == 2 && !flags.contains(FCallArgsFlags::HasUnpack) => {
e.emit_function_name("__SystemLib\\max2")
hhbc::FunctionName::from_ast_name("__SystemLib\\max2")
}
_ => e.emit_function_name(&id.1),
_ => hhbc::FunctionName::from_ast_name(&id.1),
};
let generics = emit_generics(e, env, &mut fcall_args)?;
Ok((
Expand All @@ -2325,7 +2325,7 @@ fn emit_call_lhs_and_fcall<'a, 'd>(
Expr_::String(s) => {
match std::str::from_utf8(s) {
Ok(s) => {
let fq_id = e.emit_function_name(s);
let fq_id = hhbc::FunctionName::intern(s);
let generics = emit_generics(e, env, &mut fcall_args)?;
Ok((
InstrSeq::gather(vec![instr::null_uninit(), instr::null_uninit()]),
Expand Down
2 changes: 1 addition & 1 deletion hphp/hack/src/hackc/emitter/emit_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fn emit_call<'a, 'd>(
..
} = c
{
let ft = e.emit_function_name(&sid.1);
let ft = hhbc::FunctionName::from_ast_name(&sid.1);
let fname = ft.as_str();
if fname == "unset" {
Ok(InstrSeq::gather(
Expand Down
9 changes: 0 additions & 9 deletions hphp/hack/src/hackc/emitter/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,6 @@ impl<'d> Emitter<'d> {
let state = std::mem::take(&mut self.symbol_refs_state);
state.to_hhas()
}

pub fn emit_function_name(&self, s: &str) -> hhbc::FunctionName {
let stripped = hhbc_string_utils::strip_global_ns(s);
let ret = match self.options().hhvm.trivial_builtins.get(stripped) {
Some(v) => v,
None => s,
};
hhbc::FunctionName::from_ast_name(ret)
}
}

impl<'d> print_expr::SpecialClassResolver for Emitter<'d> {
Expand Down
4 changes: 0 additions & 4 deletions hphp/hack/src/hackc/ffi_bridge/compiler_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mod ffi {

filepath: String,
aliased_namespaces: Vec<StringMapEntry>,
trivial_builtins: Vec<StringMapEntry>,
include_roots: Vec<StringMapEntry>,

hhbc_flags: HhbcFlags,
Expand Down Expand Up @@ -542,9 +541,6 @@ impl ffi::NativeEnv {
include_roots: (self.include_roots.iter())
.map(|e| (e.key.clone().into(), e.value.clone().into()))
.collect(),
trivial_builtins: (self.trivial_builtins.iter())
.map(|e| (e.key.clone(), e.value.clone()))
.collect(),
parser_options: ParserOptions {
auto_namespace_map: (self.aliased_namespaces.iter())
.map(|e| (e.key.clone(), e.value.clone()))
Expand Down
7 changes: 0 additions & 7 deletions hphp/runtime/base/runtime-option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,6 @@ void RepoOptionsFlags::initAliasedNamespaces(hackc::NativeEnv& env) const {
}
}

void RepoOptionsFlags::initTrivialBuiltins(hackc::NativeEnv& env) const {
if (!RO::EvalReplaceTrivialBuiltins) return;
for (auto& [k, v] : TrivialBuiltins) {
env.trivial_builtins.emplace_back(hackc::StringMapEntry{k, v});
}
}

void RepoOptionsFlags::initDeclConfig(hackc::DeclParserConfig& config) const {
for (auto& [k, v] : AliasedNamespaces) {
config.aliased_namespaces.emplace_back(hackc::StringMapEntry{k, v});
Expand Down
1 change: 0 additions & 1 deletion hphp/runtime/base/runtime-option.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ SECTIONS_FOR_REPOOPTIONSFLAGS()
void initHhbcFlags(hackc::HhbcFlags&) const;
void initParserFlags(hackc::ParserFlags&) const;
void initAliasedNamespaces(hackc::NativeEnv&) const;
void initTrivialBuiltins(hackc::NativeEnv&) const;

std::string autoloadQuery() const { return Query; }
folly::dynamic autoloadQueryObj() const { return m_cachedQuery; }
Expand Down
1 change: 0 additions & 1 deletion hphp/runtime/vm/unit-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ CompilerResult hackc_compile(
}
};
options.initAliasedNamespaces(native_env);
options.initTrivialBuiltins(native_env);
options.initHhbcFlags(native_env.hhbc_flags);
options.initParserFlags(native_env.parser_flags);
if (RO::EvalHackCompilerInheritConfig) {
Expand Down

0 comments on commit 768df6a

Please sign in to comment.