Skip to content

Commit bbb871a

Browse files
committed
build: enable -DV8_ENABLE_CHECKS flag
Fixes: #61301
1 parent 37d9cfc commit bbb871a

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

configure.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,15 @@ def set_configuration_variable(configs, name, release=None, debug=None):
14811481
configs['Release']['variables'][name] = release
14821482
configs['Debug']['variables'][name] = debug
14831483

1484+
def set_configuration_variable_and_defines(configs, name, define, release=None, debug=None):
1485+
set_configuration_variable(configs, name, release, debug)
1486+
if configs['Debug'].get('defines') is None:
1487+
configs['Debug']['defines'] = []
1488+
if configs['Release'].get('defines') is None:
1489+
configs['Release']['defines'] = []
1490+
configs['Debug']['defines'].append(define)
1491+
configs['Release']['defines'].append(define)
1492+
14841493
def configure_arm(o):
14851494
if options.arm_float_abi:
14861495
arm_float_abi = options.arm_float_abi
@@ -1817,8 +1826,14 @@ def configure_rust(o, configs):
18171826

18181827

18191828
def configure_v8(o, configs):
1820-
set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0)
1821-
1829+
set_configuration_variable_and_defines(
1830+
configs,
1831+
'v8_enable_v8_checks',
1832+
'V8_ENABLE_CHECKS',
1833+
release='0',
1834+
debug='1'
1835+
)
1836+
18221837
o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1
18231838
o['variables']['v8_enable_javascript_promise_hooks'] = 1
18241839
o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0

lib/util.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ function getCallSites(frameCount = 10, options) {
456456
if (options.sourceMap === true || (getOptionValue('--enable-source-maps') && options.sourceMap !== false)) {
457457
return mapCallSite(binding.getCallSites(frameCount));
458458
}
459+
460+
frameCount = Math.floor(frameCount);
459461
return binding.getCallSites(frameCount);
460462
};
461463

src/heap_utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class JSGraph : public EmbedderGraph {
8989
}
9090

9191
Node* V8Node(const Local<v8::Value>& value) override {
92-
return V8Node(value.As<v8::Data>());
92+
return V8Node(v8::Local<v8::Data>(value));
9393
}
9494

9595
Node* AddNode(std::unique_ptr<Node> node) override {

src/node_builtins.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "quic/guard.h"
1010
#include "simdutf.h"
1111
#include "util-inl.h"
12+
#include "v8-value.h"
1213

1314
namespace node {
1415
namespace builtins {
@@ -441,7 +442,7 @@ void BuiltinLoader::SaveCodeCache(const std::string& id, Local<Data> data) {
441442
new_cached_data.reset(
442443
ScriptCompiler::CreateCodeCache(mod->GetUnboundModuleScript()));
443444
} else {
444-
Local<Function> fun = data.As<Function>();
445+
Local<Function> fun = data.As<Value>().As<Function>();
445446
new_cached_data.reset(ScriptCompiler::CreateCodeCacheForFunction(fun));
446447
}
447448
CHECK_NOT_NULL(new_cached_data);

src/node_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
258258
Environment* env = Environment::GetCurrent(context);
259259

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

src/util-inl.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifndef SRC_UTIL_INL_H_
2323
#define SRC_UTIL_INL_H_
2424

25+
#include "v8-isolate.h"
2526
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
2627

2728
#include <cmath>
@@ -678,10 +679,15 @@ T FromV8Value(v8::Local<v8::Value> value) {
678679
"Type is out of unsigned integer range");
679680
if constexpr (!loose) {
680681
CHECK(value->IsUint32());
682+
return static_cast<T>(value.As<v8::Uint32>()->Value());
681683
} else {
682684
CHECK(value->IsNumber());
685+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
686+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
687+
v8::Maybe<uint32_t> maybe = value->Uint32Value(context);
688+
CHECK(!maybe.IsNothing());
689+
return static_cast<T>(maybe.FromJust());
683690
}
684-
return static_cast<T>(value.As<v8::Uint32>()->Value());
685691
} else if constexpr (std::is_integral_v<T> && std::is_signed_v<T>) {
686692
static_assert(
687693
std::numeric_limits<T>::max() <= std::numeric_limits<int32_t>::max() &&

0 commit comments

Comments
 (0)