Add support for PHP7 "spaceship" operator
commitb5f289ba1a989621fb632712a03c027277b2ede1
authorRick Lavoie <rlavoie@fb.com>
Wed, 16 Sep 2015 14:15:28 +0000 (16 07:15 -0700)
committerhhvm-bot <hhvm-bot@fb.com>
Wed, 16 Sep 2015 14:30:35 +0000 (16 07:30 -0700)
tree5a153350206bb4ed0e708fc223882a4ba5abad69
parent04efbb79698deb4ebdac96a5bf5b31aa81df17f7
Add support for PHP7 "spaceship" operator

Summary: Add support for the new PHP7 "spaceship" operator. The invokation "A
 <=> B" compares A and B and returns -1 if A is less than B, 0 if they are
 equal, and 1 if A is greater than B.

Supporting this involves adding a new bytecode instruction called "Cmp", as well
as a handful of new IR opcodes for each type. This utilizes most of the
machinery of the IR type-specific opcode conversion. Note that this operator
cannot be simply be de-sugared into a set of less-than and greater-than
operations, because that would be observable for types that invoke user code
during comparisons.

Closes https://github.com/facebook/hhvm/issues/5499

Reviewed By: @swtaarrs

Differential Revision: D2438952
40 files changed:
hphp/compiler/analysis/capture_extractor.cpp
hphp/compiler/analysis/emitter.cpp
hphp/compiler/code_model_enums.h
hphp/compiler/expression/binary_op_expression.cpp
hphp/compiler/expression/unary_op_expression.cpp
hphp/doc/bytecode.specification
hphp/doc/ir.specification
hphp/hhbbc/interp.cpp
hphp/hhbbc/optimize.cpp
hphp/parser/hphp.5.tab.cpp
hphp/parser/hphp.7.tab.cpp
hphp/parser/hphp.ll
hphp/parser/hphp.tab.hpp
hphp/parser/hphp.y
hphp/parser/lex.yy.cpp
hphp/runtime/base/array-data.cpp
hphp/runtime/base/comparisons.cpp
hphp/runtime/base/comparisons.h
hphp/runtime/base/object-data.cpp
hphp/runtime/base/object-data.h
hphp/runtime/base/tv-comparisons.cpp
hphp/runtime/base/tv-comparisons.h
hphp/runtime/base/type-array.cpp
hphp/runtime/base/type-array.h
hphp/runtime/debugger/debugger_base.cpp
hphp/runtime/ext/std/ext_std_misc.cpp
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/hhbc.h
hphp/runtime/vm/jit/code-gen-x64.cpp
hphp/runtime/vm/jit/dce.cpp
hphp/runtime/vm/jit/gvn.cpp
hphp/runtime/vm/jit/irgen-arith.cpp
hphp/runtime/vm/jit/memory-effects.cpp
hphp/runtime/vm/jit/native-calls.cpp
hphp/runtime/vm/jit/simplify.cpp
hphp/runtime/vm/jit/translator.cpp
hphp/test/quick/all_type_comparison_test.php
hphp/test/quick/all_type_comparison_test.php.expect
hphp/test/slow/php7_backported/spaceship.php [new file with mode: 0644]
hphp/test/slow/php7_backported/spaceship.php.expect [new file with mode: 0644]