-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
build: enable -DV8_ENABLE_CHECKS flag #61327
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ const { | |||||||
| Error, | ||||||||
| ErrorCaptureStackTrace, | ||||||||
| FunctionPrototypeBind, | ||||||||
| MathFloor, | ||||||||
| NumberIsSafeInteger, | ||||||||
| ObjectDefineProperties, | ||||||||
| ObjectDefineProperty, | ||||||||
|
|
@@ -456,6 +457,8 @@ function getCallSites(frameCount = 10, options) { | |||||||
| if (options.sourceMap === true || (getOptionValue('--enable-source-maps') && options.sourceMap !== false)) { | ||||||||
| return mapCallSite(binding.getCallSites(frameCount)); | ||||||||
| } | ||||||||
|
|
||||||||
| frameCount = MathFloor(frameCount); | ||||||||
| return binding.getCallSites(frameCount); | ||||||||
|
||||||||
| frameCount = MathFloor(frameCount); | |
| return binding.getCallSites(frameCount); | |
| return binding.getCallSites(MathFloor(frameCount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is experimental, would it make more sense to switch to validateInteger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I switched to validateInteger to limit it to integers.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| #include "quic/guard.h" | ||
| #include "simdutf.h" | ||
| #include "util-inl.h" | ||
| #include "v8-value.h" | ||
|
|
||
| namespace node { | ||
| namespace builtins { | ||
|
|
@@ -441,7 +442,7 @@ void BuiltinLoader::SaveCodeCache(const std::string& id, Local<Data> data) { | |
| new_cached_data.reset( | ||
| ScriptCompiler::CreateCodeCache(mod->GetUnboundModuleScript())); | ||
| } else { | ||
| Local<Function> fun = data.As<Function>(); | ||
| Local<Function> fun = data.As<Value>().As<Function>(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When V8_ENABLE_CHECKS is enabled, Local::As() fails because v8::Function only supports Cast(Value*), causing a compile error. |
||
| new_cached_data.reset(ScriptCompiler::CreateCodeCacheForFunction(fun)); | ||
| } | ||
| CHECK_NOT_NULL(new_cached_data); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| #ifndef SRC_UTIL_INL_H_ | ||
| #define SRC_UTIL_INL_H_ | ||
|
|
||
| #include "v8-isolate.h" | ||
| #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
|
|
||
| #include <cmath> | ||
|
|
@@ -678,10 +679,15 @@ T FromV8Value(v8::Local<v8::Value> value) { | |
| "Type is out of unsigned integer range"); | ||
| if constexpr (!loose) { | ||
| CHECK(value->IsUint32()); | ||
| return static_cast<T>(value.As<v8::Uint32>()->Value()); | ||
| } else { | ||
| CHECK(value->IsNumber()); | ||
| v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| v8::Local<v8::Context> context = isolate->GetCurrentContext(); | ||
| v8::Maybe<uint32_t> maybe = value->Uint32Value(context); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in line 684 why don't you just check for IsUint32?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need to accept signed values for some call sites (e.g. fs.chown), not only strict Uint32. |
||
| CHECK(!maybe.IsNothing()); | ||
| return static_cast<T>(maybe.FromJust()); | ||
| } | ||
| return static_cast<T>(value.As<v8::Uint32>()->Value()); | ||
| } else if constexpr (std::is_integral_v<T> && std::is_signed_v<T>) { | ||
| static_assert( | ||
| std::numeric_limits<T>::max() <= std::numeric_limits<int32_t>::max() && | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a GYP issue, but it seems that variables defined inside a conditions block are not reflected when evaluating other conditions.
In this case, the value of v8_enable_v8_checks set in configure.py (https://github.com/nodejs/node/blob/main/configure.py#L1530-L1532
) does not appear to be used when evaluating the condition 'v8_enable_v8_checks==1' in tools/v8_gypfiles/features.gypi (https://github.com/nodejs/node/blob/main/tools/v8_gypfiles/features.gypi#L405-L407
).
Therefore, I’m setting the defines directly.