How to check the "undefined" or "null" object result

34 views
Skip to first unread message

Elmi Ahmadov

unread,
Jun 5, 2020, 6:05:08 PM6/5/20
to v8-users
Previously, I was using the V8 version 7.4.x and I have check method to test if the result object from the script execution is undefined/null or real object. Which works fine with the older version of the V8.

But now, I'm using V8 version 8.1.307 and my check does not work anymore.

This is the code snippet to reproduce the issue:
// create Isolate*, v8::Local<v8::Context>> and ...
v8
::Handle<v8::Value> undefinedResult = v8::Undefined(isolate);
v8
::Handle<v8::Value> nullResult = v8::Null(isolate);

std
::cout << "isUndefined: " << undefinedResult->IsUndefined() << std::endl;
std
::cout << "isNull: " << nullResult->IsNull() << std::endl;

with the V8 version 7.4.x, the snippet produces the following output:
isUndefined: 1
isNull
: 1

But things turn out different for the V8 version 8.1.307, the same snippet produces a different output:
isUndefined: 0
isNull
: 0

This is my gn args to generate the monolithic V8 7.4.x library:
target_os = "linux"
target_cpu
= "x64"
is_component_build
= false
is_debug
= false
use_custom_libcxx
= false
v8_monolithic
= true
v8_use_external_startup_data
= false
symbol_level
= 0
v8_enable_i18n_support
= false

I used the same gn args to generate the V8 version 8.1.307, but then V8 immediatelly crashes when `->IsUndefined()`called. I found that V8 8.1 contains a pointer compression feature so I disabled to see how this would effect the result, now there is no crash but wrong result.
target_os = "linux"
target_cpu
= "x64"
is_component_build
= false
is_debug
= false
use_custom_libcxx
= false
v8_monolithic
= true
v8_use_external_startup_data
= false
symbol_level
= 0
v8_enable_i18n_support
= false
v8_enable_pointer_compression
= false

What is the actual cause of this issue? How can I fix it? Maybe I'm missing something but I don't know what it is.



Ben Noordhuis

unread,
Jun 8, 2020, 2:43:31 AM6/8/20
to v8-users
v8_enable_31bit_smis_on_64bit_arch (corresponds to
-DV8_31BIT_SMIS_ON_64BIT_ARCH) also needs to be the same when building
V8 and your project.

Elmi Ahmadov

unread,
Jun 8, 2020, 5:56:09 AM6/8/20
to v8-users
What do you mean it needs to be same? I don't set it explicitly to any value in my gn args file and it's "true" by default

v8_enable_31bit_smis_on_64bit_arch
   
Current value (from the default) = true
   
From //BUILD.gn:110

Ben Noordhuis

unread,
Jun 9, 2020, 4:49:15 AM6/9/20
to v8-users
On Mon, Jun 8, 2020 at 11:56 AM Elmi Ahmadov <elmi...@gmail.com> wrote:
>
> What do you mean it needs to be same? I don't set it explicitly to any value in my gn args file and it's "true" by default
>
> v8_enable_31bit_smis_on_64bit_arch
> Current value (from the default) = true
> From //BUILD.gn:110

That's what I mean. If you turn on v8_enable_31bit_smis_on_64bit_arch,
you also need to build your downstream project with
-DV8_31BIT_SMIS_ON_64BIT_ARCH.
Reply all
Reply to author
Forward
0 new messages