Skip to content

Allow MixedArray::MakeReserveLike to work on arrays with virtual size#3065

Closed
tstarling wants to merge 1 commit intofacebook:masterfrom
tstarling:fix-array_map-proxy
Closed

Allow MixedArray::MakeReserveLike to work on arrays with virtual size#3065
tstarling wants to merge 1 commit intofacebook:masterfrom
tstarling:fix-array_map-proxy

Conversation

@tstarling
Copy link
Contributor

Previously this would try to create an array with 2^32 elements, causing
an assertion or crash. array_map.hhas calls NewLikeArrayL on arbitrary
input, which in turn calls MixedArray::MakeReserveLike. So any array
originating from EZC would crash when fed into array_map().

Added test case which previously crashed.

@tstarling
Copy link
Contributor Author

@jdelong
Copy link
Contributor

jdelong commented Jun 30, 2014

(Also: thanks for finding and fixing this. ;)

Previously this would try to create an array with 2^32 elements, causing
an assertion or crash. array_map.hhas calls NewLikeArrayL on arbitrary
input, which in turn calls MixedArray::MakeReserveLike. So any array
originating from EZC would crash when fed into array_map().

Added two test cases which previously crashed.
@tstarling
Copy link
Contributor Author

Thanks for the review.

Added $GLOBALS test.

@tstarling tstarling deleted the fix-array_map-proxy branch September 22, 2014 01:30
tstarling added a commit to tstarling/hhvm that referenced this pull request Sep 23, 2014
Fix JIT versions of count() and conversion of array to boolean, so
that they work with ProxyArray. In both cases, duplicate the logic in
ArrayData::size() -- if the sign bit of the size field is unset, use
that field, otherwise call vsize().

The resulting generated machine code for conversion to boolean is along
the lines of:

  mov    0x4(%rdi),%eax
  test   %eax,%eax
  js     0xf80049b
  setne  %al

where 0xf80049b is the slow path. This is similar to the machine code I
previously reported for ArrayData::size() in code review of 1717e028f18
(see facebook#3065).

Also fixed the non-JIT version of conversion to boolean.

Added test case which previously failed. Amended empty-globals.php test
which now actually works instead of being a "deliberate mistake".
hhvm-bot pushed a commit that referenced this pull request Sep 23, 2014
Summary: Fix JIT versions of count() and conversion of array to boolean, so that they work with ProxyArray. In both cases, duplicate the logic in ArrayData::size() -- if the sign bit of the size field is unset, use that field, otherwise call vsize().

The resulting generated machine code for conversion to boolean is along the lines of:

  mov    0x4(%rdi),%eax
  test   %eax,%eax
  js     0xf80049b
  setne  %al

where 0xf80049b is the slow path. This is similar to the machine code I previously reported for ArrayData::size() in code review of 1717e028f18 (see #3065).

Added test case which previously failed.
Closes #3811

Reviewed By: @ptarjan

Differential Revision: D1568919
rrh pushed a commit to newrelic-forks/hhvm that referenced this pull request Sep 24, 2014
Summary: Fix JIT versions of count() and conversion of array to boolean, so that they work with ProxyArray. In both cases, duplicate the logic in ArrayData::size() -- if the sign bit of the size field is unset, use that field, otherwise call vsize().

The resulting generated machine code for conversion to boolean is along the lines of:

  mov    0x4(%rdi),%eax
  test   %eax,%eax
  js     0xf80049b
  setne  %al

where 0xf80049b is the slow path. This is similar to the machine code I previously reported for ArrayData::size() in code review of 1717e028f18 (see facebook#3065).

Added test case which previously failed.
Closes facebook#3811

Reviewed By: @ptarjan

Differential Revision: D1568919
ptarjan pushed a commit that referenced this pull request Oct 28, 2014
Fix JIT versions of count() and conversion of array to boolean, so
that they work with ProxyArray. In both cases, duplicate the logic in
ArrayData::size() -- if the sign bit of the size field is unset, use
that field, otherwise call vsize().

The resulting generated machine code for conversion to boolean is along
the lines of:

  mov    0x4(%rdi),%eax
  test   %eax,%eax
  js     0xf80049b
  setne  %al

where 0xf80049b is the slow path. This is similar to the machine code I
previously reported for ArrayData::size() in code review of 1717e028f18
(see #3065).

Added test case which previously failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants