Skip to content

Commit 8fa221a

Browse files
losvaldfacebook-github-bot
authored andcommitted
Kill source mapping option across stack
Summary: This option is explicitly set to true at every entry point to HackC, as well as in tests, but it's true by default in HHVM. It's also an outlier because it has 2 aliases when used as CLI argument: - hack.compiler.sourcemapping - eval.disassemblersourcemapping neither of which matches its JSON key: eval.disassembler_source_mapping. All of the abovee adds significant complexity, so kill it altogether. Reviewed By: shiqicao, alexeyt Differential Revision: D20295585 fbshipit-source-id: bed0040227143b6df122e2f11545bde909ace70e
1 parent aaf593f commit 8fa221a

File tree

15 files changed

+159
-151
lines changed

15 files changed

+159
-151
lines changed

hphp/hack/src/hhbc/emit_pos.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ open Instruction_sequence
1111
open Hhbc_ast
1212

1313
let emit_pos pos =
14-
if
15-
Hhbc_options.source_mapping !Hhbc_options.compiler_options
16-
&& pos <> Pos.none
17-
then
14+
if pos <> Pos.none then
1815
let (line_begin, line_end, col_begin, col_end) =
1916
Pos.info_pos_extended pos
2017
in

hphp/hack/src/hhbc/emit_pos.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@
55

66
use env::emitter::Emitter;
77
use instruction_sequence_rust::InstrSeq;
8-
use options::EvalFlags;
98
use oxidized::pos::Pos;
109
use std::convert::TryInto;
1110

1211
pub fn emit_pos(emitter: &Emitter, pos: &Pos) -> InstrSeq {
13-
if emitter
14-
.options()
15-
.eval_flags
16-
.contains(EvalFlags::DISASSEMBLER_SOURCE_MAPPING)
17-
&& !pos.is_none()
18-
{
12+
if !pos.is_none() {
1913
let (line_begin, line_end, col_begin, col_end) = pos.info_pos_extended();
2014
InstrSeq::make_srcloc(
2115
line_begin.try_into().unwrap(),

hphp/hack/src/hhbc/hhbc_hhas.ml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,7 @@ let add_fun_def buf fun_def =
15941594
if Hhbc_options.emit_generics_ub !Hhbc_options.compiler_options then
15951595
Acc.add buf (string_of_upper_bounds function_upper_bounds);
15961596
Acc.add buf (function_attributes fun_def);
1597-
if Hhbc_options.source_mapping !Hhbc_options.compiler_options then
1598-
Acc.add buf (string_of_span function_span ^ " ");
1597+
Acc.add buf (string_of_span function_span ^ " ");
15991598
Acc.add buf (string_of_type_info_option function_return_type);
16001599
Acc.add buf (Hhbc_id.Function.to_raw_string function_name);
16011600
Acc.add buf (string_of_params env function_params);
@@ -1734,8 +1733,7 @@ let add_method_def buf method_def =
17341733
Acc.add buf (string_of_upper_bounds method_upper_bounds)
17351734
);
17361735
Acc.add buf (method_attributes method_def);
1737-
if Hhbc_options.source_mapping !Hhbc_options.compiler_options then
1738-
Acc.add buf (string_of_span method_span ^ " ");
1736+
Acc.add buf (string_of_span method_span ^ " ");
17391737
Acc.add buf (string_of_type_info_option method_return_type);
17401738
Acc.add buf (Hhbc_id.Method.to_raw_string method_name);
17411739
Acc.add buf (string_of_params env method_params);
@@ -2102,8 +2100,7 @@ let add_class_def buf class_def =
21022100
Acc.add buf (string_of_upper_bounds (Hhas_class.upper_bounds class_def));
21032101
Acc.add buf (class_special_attributes class_def);
21042102
Acc.add buf (Hhbc_id.Class.to_raw_string class_name);
2105-
if Hhbc_options.source_mapping !Hhbc_options.compiler_options then
2106-
Acc.add buf (" " ^ string_of_span (Hhas_class.span class_def));
2103+
Acc.add buf (" " ^ string_of_span (Hhas_class.span class_def));
21072104
add_extends
21082105
buf
21092106
(Option.map ~f:Hhbc_id.Class.to_raw_string (Hhas_class.base class_def));
@@ -2168,8 +2165,7 @@ let add_data_region buf adata =
21682165

21692166
let add_main buf body =
21702167
Acc.add buf ".main ";
2171-
if Hhbc_options.source_mapping !Hhbc_options.compiler_options then
2172-
Acc.add buf "(1,1) ";
2168+
Acc.add buf "(1,1) ";
21732169
Acc.add buf "{";
21742170
add_body buf 2 body;
21752171
Acc.add buf "}\n"

hphp/hack/src/hhbc/hhbc_options.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ type t = {
1616
option_optimize_null_checks: bool;
1717
option_max_array_elem_size_on_the_stack: int;
1818
option_aliased_namespaces: (string * string) list;
19-
option_source_mapping: bool;
2019
option_relabel: bool;
2120
option_php7_uvs: bool;
2221
option_php7_ltr_assign: bool;
@@ -70,7 +69,6 @@ let default =
7069
option_optimize_null_checks = false;
7170
option_max_array_elem_size_on_the_stack = 64;
7271
option_aliased_namespaces = [];
73-
option_source_mapping = false;
7472
option_php7_uvs = false;
7573
option_php7_ltr_assign = false;
7674
(* If true, then renumber labels after generating code for a method
@@ -130,8 +128,6 @@ let max_array_elem_size_on_the_stack o =
130128

131129
let aliased_namespaces o = o.option_aliased_namespaces
132130

133-
let source_mapping o = o.option_source_mapping
134-
135131
let relabel o = o.option_relabel
136132

137133
let enable_uniform_variable_syntax o = o.option_php7_uvs
@@ -254,7 +250,6 @@ let to_string o =
254250
Printf.sprintf "max_array_elem_size_on_the_stack: %d"
255251
@@ max_array_elem_size_on_the_stack o;
256252
Printf.sprintf "aliased_namespaces: %s" aliased_namespaces_str;
257-
Printf.sprintf "source_mapping: %B" @@ source_mapping o;
258253
Printf.sprintf "relabel: %B" @@ relabel o;
259254
Printf.sprintf "enable_uniform_variable_syntax: %B"
260255
@@ enable_uniform_variable_syntax o;
@@ -335,10 +330,6 @@ let set_option options name value =
335330
{ options with option_constant_folding = as_bool value }
336331
| "hack.compiler.optimizenullcheck" ->
337332
{ options with option_optimize_null_checks = as_bool value }
338-
(* Keep both for backwards compatibility until next release *)
339-
| "hack.compiler.sourcemapping"
340-
| "eval.disassemblersourcemapping" ->
341-
{ options with option_source_mapping = as_bool value }
342333
| "hhvm.php7.ltr_assign" ->
343334
{ options with option_php7_ltr_assign = as_bool value }
344335
| "hhvm.php7.uvs" -> { options with option_php7_uvs = as_bool value }
@@ -502,8 +493,6 @@ let value_setters =
502493
@@ fun opts v -> { opts with option_constant_folding = v = 1 } );
503494
( set_value "hack.compiler.optimize_null_checks" get_value_from_config_int
504495
@@ fun opts v -> { opts with option_optimize_null_checks = v = 1 } );
505-
( set_value "eval.disassembler_source_mapping" get_value_from_config_int
506-
@@ fun opts v -> { opts with option_source_mapping = v = 1 } );
507496
( set_value "hhvm.php7.uvs" get_value_from_config_int @@ fun opts v ->
508497
{ opts with option_php7_uvs = v = 1 } );
509498
( set_value "hhvm.php7.ltr_assign" get_value_from_config_int @@ fun opts v ->

hphp/hack/src/hhbc/options.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ impl<T> Arg<T> {
137137

138138
// group options by JSON config prefix to avoid error-prone repetition & boilerplate in SerDe
139139

140-
// TODO move this "lonely wolf" to group "hack.compiler." (as hinted in D7057454);
141-
// however, this is a breaking change for stuff that passes this option as JSON key
142-
prefixed_flags!(EvalFlags, "eval.", DISASSEMBLER_SOURCE_MAPPING,);
143-
impl Default for EvalFlags {
144-
fn default() -> EvalFlags {
145-
EvalFlags::empty()
146-
}
147-
}
148-
149140
prefixed_flags!(
150141
CompilerFlags,
151142
"hack.compiler.",
@@ -289,13 +280,6 @@ pub struct Options {
289280
#[serde(default)]
290281
pub doc_root: Arg<String>,
291282

292-
#[serde(
293-
flatten,
294-
serialize_with = "serialize_flags",
295-
deserialize_with = "deserialize_flags"
296-
)]
297-
pub eval_flags: EvalFlags,
298-
299283
#[serde(
300284
flatten,
301285
serialize_with = "serialize_flags",
@@ -347,7 +331,6 @@ impl Default for Options {
347331
Options {
348332
max_array_elem_size_on_the_stack: defaults::max_array_elem_size_on_the_stack(),
349333
hack_compiler_flags: CompilerFlags::default(),
350-
eval_flags: EvalFlags::default(),
351334
hhvm: Hhvm::default(),
352335
phpism_flags: PhpismFlags::default(),
353336
php7_flags: Php7Flags::default(),
@@ -441,11 +424,6 @@ impl Options {
441424
opts.map_err(|e| e.to_string())
442425
}
443426

444-
pub fn source_map(&self) -> bool {
445-
self.eval_flags
446-
.contains(EvalFlags::DISASSEMBLER_SOURCE_MAPPING)
447-
}
448-
449427
pub fn array_provenance(&self) -> bool {
450428
self.hhvm.flags.contains(HhvmFlags::ARRAY_PROVENANCE)
451429
}
@@ -962,46 +940,6 @@ mod tests {
962940
}))
963941
.expect("boolish-parsing logic wrongly triggered");
964942
}
965-
966-
#[test]
967-
fn test_major_outlier_source_mapping_serde() {
968-
use serde::ser::Serialize;
969-
fn mk_source_mapping<T: Serialize>(v: T) -> Json {
970-
json!({
971-
"eval.disassembler_source_mapping": {
972-
"global_value": v
973-
}
974-
})
975-
}
976-
fn serialize_source_mapping(opts: Options) -> Json {
977-
let mut j = serde_json::to_value(opts).unwrap();
978-
// remove everything from Options JSON except this key
979-
const KEY: &str = "eval.disassembler_source_mapping";
980-
let m = j.as_object_mut().unwrap();
981-
let sm = m.remove(KEY);
982-
m.clear();
983-
sm.map(|val| m.insert(KEY.to_owned(), val));
984-
j
985-
}
986-
fn test<T: Serialize + std::fmt::Debug>(exp_val: bool, val: T) {
987-
let j = mk_source_mapping(dbg!(val));
988-
let opts: Options = serde_json::value::from_value(j).unwrap();
989-
assert_eq!(
990-
exp_val,
991-
opts.eval_flags
992-
.contains(EvalFlags::DISASSEMBLER_SOURCE_MAPPING)
993-
);
994-
let j_act = serialize_source_mapping(opts);
995-
let j_exp = mk_source_mapping(exp_val);
996-
assert_eq!(j_exp, j_act);
997-
}
998-
test(true, true);
999-
test(true, 1);
1000-
test(true, "true");
1001-
test(false, 0);
1002-
test(false, false);
1003-
test(false, "false");
1004-
}
1005943
}
1006944

1007945
// boilerplate code that could eventually be avoided via procedural macros
@@ -1010,7 +948,6 @@ bitflags! {
1010948
struct Flags: u64 {
1011949
const CONSTANT_FOLDING = 1 << 0;
1012950
const OPTIMIZE_NULL_CHECKS = 1 << 1;
1013-
const DISASSEMBLER_SOURCE_MAPPING = 1 << 2;
1014951
const UVS = 1 << 3;
1015952
const LTR_ASSIGN = 1 << 4;
1016953
/// If true, then renumber labels after generating code for a method

hphp/hack/src/hhbc/options_cli.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,33 @@ lazy_static! {
2626
/// the exceptions are overridden here for config list (-v KEY=VAL).
2727
pub static ref CANON_BY_ALIAS: HashMap<&'static str, &'static str> =
2828
impl_CANON_BY_ALIAS!(
29-
// group 1: multiple names, neither consistent with JSON field name
30-
"hack.compiler.sourcemapping" => "eval.disassembler_source_mapping",
31-
"eval.disassemblersourcemapping" => "eval.disassembler_source_mapping",
32-
// group 2: obtained by removing underscores from JSON field names
29+
// group 1: obtained by removing underscores from JSON field names
3330
"hack.compiler.constantfolding" => "hack.compiler.constant_folding",
3431
"hack.compiler.optimizenullcheck" => "hack.compiler.optimize_null_checks",
35-
// group 3: also different prefix without any obvious rule
32+
// group 2: also different prefix without any obvious rule
3633
"eval.hackarrcompatnotices" => "hhvm.hack_arr_compat_notices",
3734
"eval.hackarrdvarrs" => "hhvm.hack_arr_dv_arrs",
3835
"eval.emitfuncpointers" => "hhvm.emit_func_pointers",
3936
"eval.jitenablerenamefunction" => "hhvm.jit_enable_rename_function",
4037
"eval.logexterncompilerperf" => "hhvm.log_extern_compiler_perf",
4138
"eval.enableintrinsicsextension" => "hhvm.enable_intrinsics_extension",
4239
"eval.emitgenericsub" => "hhvm.emit_generics_ub",
43-
// group 4: we could ignore hhvm. part of prefix in deser.
40+
// group 3: we could ignore hhvm. part of prefix in deser.
4441
"hack.lang.disable_lval_as_an_expression" => "hhvm.hack.lang.disable_lval_as_an_expression",
45-
// group 5: combination of group 4 & 2
42+
// group 4: combination of group 3 & 1
4643
"hack.lang.phpism.disallowexecutionoperator" => "hhvm.hack.lang.phpism.disallow_execution_operator",
4744
"hack.lang.phpism.disablenontopleveldeclarations" => "hhvm.hack.lang.phpism.disable_nontoplevel_declarations",
4845
"hack.lang.phpism.disablestaticclosures" => "hhvm.hack.lang.phpism.disable_static_closures",
4946
"hack.lang.phpism.disablehaltcompiler" => "hhvm.hack.lang.phpism.disable_halt_compiler",
5047
"hack.lang.enablecoroutines" => "hhvm.hack.lang.enable_coroutines",
5148
"hack.lang.enablepocketuniverses" => "hhvm.hack.lang.enable_pocket_universes",
52-
// group 6: we could assume "hack." between "hhvm." and "lang."
49+
// group 5: we could assume "hack." between "hhvm." and "lang."
5350
"hhvm.lang.enable_class_level_where_clauses" => "hhvm.hack.lang.enable_class_level_where_clauses",
5451
"hhvm.lang.disable_legacy_soft_typehints" => "hhvm.hack.lang.disable_legacy_soft_typehints",
5552
"hhvm.lang.allow_new_attribute_syntax" => "hhvm.hack.lang.allow_new_attribute_syntax",
5653
"hhvm.lang.disable_legacy_attribute_syntax" => "hhvm.hack.lang.disable_legacy_attribute_syntax",
5754
"hhvm.lang.disallow_func_ptrs_in_constants" => "hhvm.hack.lang.disallow_func_ptrs_in_constants",
58-
// group 7: combination of group 6 & 2
55+
// group 6: combination of group 5 & 1
5956
"hhvm.lang.constdefaultfuncargs" => "hhvm.hack.lang.const_default_func_args",
6057
"hhvm.lang.abstractstaticprops" => "hhvm.hack.lang.abstract_static_props",
6158
"hhvm.lang.disableunsetclassconst" => "hhvm.hack.lang.disable_unset_class_const",

hphp/hack/src/hhbc/print.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,8 @@ fn print_fun_def<W: Write>(
292292
print_upper_bounds(w, &body.upper_bounds)?;
293293
}
294294
print_fun_attrs(ctx, w, fun_def)?;
295-
if ctx.opts.source_map() {
296-
w.write(string_of_span(&fun_def.span))?;
297-
w.write(" ")?;
298-
}
295+
w.write(string_of_span(&fun_def.span))?;
296+
w.write(" ")?;
299297
option(w, &body.return_type_info, print_type_info)?;
300298
w.write(" ")?;
301299
w.write(fun_def.name.to_raw_string())?;
@@ -678,9 +676,7 @@ fn print_class_def<W: Write>(
678676
}
679677
print_class_special_attributes(ctx, w, class_def)?;
680678
w.write(class_def.name.to_raw_string())?;
681-
if ctx.opts.source_map() {
682-
w.write(format!(" {}", string_of_span(&class_def.span)))?;
683-
}
679+
w.write(format!(" {}", string_of_span(&class_def.span)))?;
684680
print_extends(w, class_def.base.as_ref().map(|x| x.to_raw_string()))?;
685681
print_implements(w, &class_def.implements)?;
686682
w.write(" {")?;
@@ -865,9 +861,7 @@ fn print_file_attributes<W: Write>(
865861

866862
fn print_main<W: Write>(ctx: &mut Context, w: &mut W, body: &HhasBody) -> Result<(), W::Error> {
867863
w.write(".main ")?;
868-
if ctx.opts.source_map() {
869-
w.write("(1,1) ")?;
870-
}
864+
w.write("(1,1) ")?;
871865
wrap_by_braces(w, |w| {
872866
ctx.block(w, |c, w| print_body(c, w, body))?;
873867
newline(w)

hphp/hack/test/pocket_universes/compile/closure.good.php.exp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@
66
.adata A_0 = """Y:1:{s:8:\"nullable\";b:1;}""";
77
.adata A_1 = """v:0:{}""";
88

9-
.main {
9+
.main (1,1) {
10+
.srcloc 4:7,4:7;
1011
DefCls 0
1112
Int 1
1213
RetC
1314
}
1415

15-
.class C {
16-
.method [public static] <"HH\\void" N > derive(<"TE" "TE" extended_hint type_var> $field, <"HH\\mixed" N > $data) {
16+
.class C (4,14) {
17+
.method [public static] (10,13) <"HH\\void" N > derive(<"TE" "TE" extended_hint type_var> $field, <"HH\\mixed" N > $data) {
1718
.declvars $_;
19+
.srcloc 10:17,13:135;
1820
VerifyParamType $field
21+
.srcloc 12:12,12:16;
1922
CGetL $data
2023
SetL _3
2124
Array @A_0
@@ -28,17 +31,25 @@
2831
L0:
2932
PushL _3
3033
UnsetL _4
34+
.srcloc 12:7,12:39;
3135
SetL $_
36+
.srcloc 12:7,12:40;
3237
PopC
38+
.srcloc 13:6,13:6;
3339
Null
3440
RetC
3541
}
36-
.method [public static] <"HH\\mixed" N > E##Members() {
42+
.method [public static] (5,5) <"HH\\mixed" N > E##Members() {
3743
.declvars $mems;
44+
.srcloc 5:8,5:8;
3845
Vec @A_1
46+
.srcloc 5:8,5:8;
3947
SetL $mems
48+
.srcloc 5:8,5:8;
4049
PopC
50+
.srcloc 5:8,5:8;
4151
CGetL $mems
52+
.srcloc 5:8,5:8;
4253
RetC
4354
}
4455
}

0 commit comments

Comments
 (0)