diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 8802998e9a021e..48ebd73817a50e 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -139,7 +139,7 @@ void CallAndPauseOnStart(const FunctionCallbackInfo& args) { env->inspector_agent()->PauseOnNextJavascriptStatement("Break on start"); v8::MaybeLocal retval = args[0].As()->Call(env->context(), args[1], - call_args.size(), call_args.data()); + call_args.length(), call_args.out()); if (!retval.IsEmpty()) { args.GetReturnValue().Set(retval.ToLocalChecked()); } @@ -164,8 +164,8 @@ void InspectorConsoleCall(const FunctionCallbackInfo& info) { v8::True(isolate)).FromJust()); CHECK(!inspector_method.As()->Call(context, info.Holder(), - call_args.size(), - call_args.data()).IsEmpty()); + call_args.length(), + call_args.out()).IsEmpty()); } CHECK(config_object->Delete(context, in_call_key).FromJust()); } @@ -174,8 +174,8 @@ void InspectorConsoleCall(const FunctionCallbackInfo& info) { CHECK(node_method->IsFunction()); node_method.As()->Call(context, info.Holder(), - call_args.size(), - call_args.data()).FromMaybe(Local()); + call_args.length(), + call_args.out()).FromMaybe(Local()); } static void* GetAsyncTask(int64_t asyncId) { diff --git a/src/node_perf.cc b/src/node_perf.cc index 9c0091d2bc9070..cefd0ff26dbf95 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -344,10 +344,10 @@ void TimerFunctionCall(const FunctionCallbackInfo& args) { v8::MaybeLocal ret; if (is_construct_call) { - ret = fn->NewInstance(context, call_args.size(), call_args.data()) + ret = fn->NewInstance(context, call_args.length(), call_args.out()) .FromMaybe(Local()); } else { - ret = fn->Call(context, args.This(), call_args.size(), call_args.data()); + ret = fn->Call(context, args.This(), call_args.length(), call_args.out()); } uint64_t end = PERFORMANCE_NOW(); diff --git a/src/util-inl.h b/src/util-inl.h index 6d612f1eb7c8b7..182c50268d3e0a 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -455,6 +455,17 @@ v8::MaybeLocal ToV8Value(v8::Local context, return v8::Number::New(isolate, static_cast(number)); } +SlicedArguments::SlicedArguments( + const v8::FunctionCallbackInfo& args, size_t start) { + const size_t length = static_cast(args.Length()); + if (start >= length) return; + const size_t size = length - start; + + AllocateSufficientStorage(size); + for (size_t i = 0; i < size; ++i) + (*this)[i] = args[i + start]; +} + } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/util.h b/src/util.h index f3a174821ab882..fcb543fcacfaab 100644 --- a/src/util.h +++ b/src/util.h @@ -629,37 +629,12 @@ constexpr T RoundUp(T a, T b) { #define MUST_USE_RESULT #endif -class SlicedArguments { +class SlicedArguments : public MaybeStackBuffer> { public: inline explicit SlicedArguments( const v8::FunctionCallbackInfo& args, size_t start = 0); - inline size_t size() const { return size_; } - inline v8::Local* data() { return data_; } - - private: - size_t size_; - v8::Local* data_; - v8::Local fixed_[64]; - std::vector> dynamic_; }; -SlicedArguments::SlicedArguments( - const v8::FunctionCallbackInfo& args, size_t start) - : size_(0), data_(fixed_) { - const size_t length = static_cast(args.Length()); - if (start >= length) return; - const size_t size = length - start; - - if (size > arraysize(fixed_)) { - dynamic_.resize(size); - data_ = dynamic_.data(); - } - - for (size_t i = 0; i < size; ++i) data_[i] = args[i + start]; - - size_ = size; -} - } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS