Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce compatibility with V8 7.3 #138

Merged
merged 9 commits into from Apr 24, 2019
Merged

Introduce compatibility with V8 7.3 #138

merged 9 commits into from Apr 24, 2019

Conversation

ignisf
Copy link
Collaborator

@ignisf ignisf commented Apr 24, 2019

Fixes #115
Closes #125

Due to the non-maybe version of String::ToObject() being deprecated and
altogether removed from V8 [1] it is necessary to migrate to using the maybe
version.

This commit is a mechanical change that uses the context at hand when calling
String::ToObject() to pass it to it.

The resulting MaybeLocal is then unwrapped with MaybeLocal::ToLocalChecked() as
I consider the verifications performed on the String instances to be sufficient
to ensure no crashes.

[1] https://chromium-review.googlesource.com/c/v8/v8/+/1172350/
    https://chromium.googlesource.com/v8/v8/+/c8376b0069ebe16c67acf90c3cda3457ddccba4f
Due to the non-maybe version of Local<T>::ToString() being deprecated and
altogether removed from V8 [1] it is necessary to migrate to using the maybe
version.

This commit is a mechanical change that uses the context at hand when calling
Local<T>::ToString() to pass it to it.

The resulting MaybeLocal is then unwrapped with MaybeLocal::ToLocalChecked() as
I consider the context of the uses to be sufficiently safe.

[1] https://chromium-review.googlesource.com/c/v8/v8/+/1172350/
    https://chromium.googlesource.com/v8/v8/+/c8376b0069ebe16c67acf90c3cda3457ddccba4f
…mberValue()

Due to the non-maybe version of Value::Int32Value() and Value::NumberValue()
being deprecated and altogether removed from V8 [1] it is necessary to migrate
to using the maybe versions.

This commit is a mechanical change that uses the context at hand when calling
Value::Int32Value() or Value::NumberValue() to pass it to the respective
function.

The resulting Maybe is then unwrapped with Maybe::ToChecked() as I consider the
verifications performed on the Value instances to be sufficient to ensure no
crashes.

[1] https://chromium-review.googlesource.com/c/v8/v8/+/1172350/
    https://chromium.googlesource.com/v8/v8/+/c8376b0069ebe16c67acf90c3cda3457ddccba4f
@ignisf ignisf requested a review from SamSaffron April 24, 2019 11:09
@ignisf
Copy link
Collaborator Author

ignisf commented Apr 24, 2019

@SamSaffron, I took the liberty to put something more useful in the LICENSE.txt copyright statement. Check if you're OK with it.

The build failures on head and 2.5 seem to be due to Bundler version mismatch. I prefer to not take any action to fix this, as I hope it will be fixed in the next version of Bundler (rubygems/bundler#6996 (comment))

Due to V8::CreateSnapshotDataBlob() and V8::WarmUpSnapshotDataBlob() being
deprecated and altogether removed from V8 [1] it is necessary to migrate to
using local implementations of them.

This commit introduces create_snapshot_data_blob(), warm_up_snapshot_data_blob()
and the helper function run_extra_code(). Their implementations have been copied
over from [2].

[1] v8/v8@b3738e6
    https://chromium-review.googlesource.com/c/v8/v8/+/1019442/

[2] https://github.com/v8/v8/blob/7.3.492.27/test/cctest/test-serialize.cc
    https://chromium.googlesource.com/v8/v8.git/+/30602560a8fdb0bbfb50d70be867f32b72758a2f/test/cctest/test-serialize.cc
Due to the non-maybe version of Date::New() being deprecated and altogether
removed from V8 [1] it is necessary to migrate to using the maybe version.

This commit introduces a context argument to the convert_ruby_to_v8() function
so it can be passed to the maybe version of Date::New().

This imposed changes throughout the code base so that the context can be passed
together with the isolate to convert_ruby_to_v8().

[1] https://chromium-review.googlesource.com/c/v8/v8/+/1357056
    v8/v8@e84b92d
This commit builds upon fe62f7935582bd889742ec77ee2289a8f6cb16e6. The use of
Local<T>::ToString() in convert_result_to_ruby() did not have an immediately
available context to use. This commit unwraps the context from p_ctx and passes
it to the function and then unwraps the MaybeLocal result with
MaybeLocal::ToLocalChecked() assuming the verification beforehand is sufficient
to ensure there won't be any crashes.
Due to the version of String::Utf8Length() with no paramters being deprecated
and altogether removed from V8 [1] it is necessary to migrate to using the
version that accepts isolate as a parameter.

This commit is a mechanical change that uses the isolate available in the
context where String::Utf8Length() is called.

This is a breaking change imposing use of V8 6.9.411 or up.

[1] https://chromium-review.googlesource.com/c/v8/v8/+/1124724/
    https://chromium.googlesource.com/v8/v8/+/3dd5c6fe38355b8323597341409b37f931de5a85
@SamSaffron
Copy link
Collaborator

This is so awesome! Thanks so much.

Should we pin to 7.3 instead of 6.9 ?

@SamSaffron SamSaffron merged commit a22348f into master Apr 24, 2019
@SamSaffron
Copy link
Collaborator

@gschlager FYI ... :) 🎊

@ignisf
Copy link
Collaborator Author

ignisf commented Apr 25, 2019

Eh... It won't have any consequences I think. I won't be releasing an older version of V8 anyway so it's effectively pinning it to 7.3 even now

@gschlager
Copy link
Contributor

Thanks! Unfortunately my regular expression still doesn't work. I did a little bit of digging in the code from V8 and libv8 and I think I figured out the reason. I created an issue for it. rubyjs/libv8#278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove instances of use of functions deprecated in V8 7.3
3 participants