Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,15 @@ def set_configuration_variable(configs, name, release=None, debug=None):
configs['Release']['variables'][name] = release
configs['Debug']['variables'][name] = debug

def set_configuration_variable_and_defines(configs, name, define, release=None, debug=None):
set_configuration_variable(configs, name, release, debug)
if configs['Debug'].get('defines') is None:
configs['Debug']['defines'] = []
if configs['Release'].get('defines') is None:
configs['Release']['defines'] = []
configs['Debug']['defines'].append(define)
configs['Release']['defines'].append(define)

Copy link
Member Author

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.

def configure_arm(o):
if options.arm_float_abi:
arm_float_abi = options.arm_float_abi
Expand Down Expand Up @@ -1817,7 +1826,13 @@ def configure_rust(o, configs):


def configure_v8(o, configs):
set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0)
set_configuration_variable_and_defines(
configs,
'v8_enable_v8_checks',
'V8_ENABLE_CHECKS',
release='0',
debug='1'
)

o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1
o['variables']['v8_enable_javascript_promise_hooks'] = 1
Expand Down
3 changes: 3 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const {
Error,
ErrorCaptureStackTrace,
FunctionPrototypeBind,
MathFloor,
NumberIsSafeInteger,
ObjectDefineProperties,
ObjectDefineProperty,
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
frameCount = MathFloor(frameCount);
return binding.getCallSites(frameCount);
return binding.getCallSites(MathFloor(frameCount));

Copy link
Member

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?

Copy link
Member Author

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.

};

Expand Down
2 changes: 1 addition & 1 deletion src/heap_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class JSGraph : public EmbedderGraph {
}

Node* V8Node(const Local<v8::Value>& value) override {
return V8Node(value.As<v8::Data>());
return V8Node(v8::Local<v8::Data>(value));
}

Node* AddNode(std::unique_ptr<Node> node) override {
Expand Down
3 changes: 2 additions & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "quic/guard.h"
#include "simdutf.h"
#include "util-inl.h"
#include "v8-value.h"

namespace node {
namespace builtins {
Expand Down Expand Up @@ -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>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
https://github.com/nodejs/node/blob/main/deps/v8/include/v8-local-handle.h#L424.

new_cached_data.reset(ScriptCompiler::CreateCodeCacheForFunction(fun));
}
CHECK_NOT_NULL(new_cached_data);
Expand Down
2 changes: 1 addition & 1 deletion src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(context);

CHECK_EQ(args.Length(), 1);
CHECK(args[0]->IsNumber());
CHECK(args[0]->IsUint32());
const uint32_t frames = args[0].As<Uint32>()->Value();
CHECK(frames >= 1 && frames <= 200);

Expand Down
8 changes: 7 additions & 1 deletion src/util-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line 684 why don't you just check for IsUint32?

Copy link
Member Author

Choose a reason for hiding this comment

The 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() &&
Expand Down
Loading