Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d728545

Browse filesBrowse files
Renegade334targos
authored andcommitted
timers: fix binding fast call signatures
PR-URL: #59600 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 8c21c4b commit d728545
Copy full SHA for d728545

File tree

Expand file treeCollapse file tree

3 files changed

+37
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+37
-17
lines changed
Open diff view settings
Collapse file

‎src/timers.cc‎

Copy file name to clipboardExpand all lines: src/timers.cc
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ void BindingData::SlowScheduleTimer(const FunctionCallbackInfo<Value>& args) {
5353
}
5454
}
5555

56-
void BindingData::FastScheduleTimer(Local<Object> unused,
57-
Local<Object> receiver,
58-
int64_t duration) {
56+
void BindingData::FastScheduleTimer(Local<Object> receiver, int64_t duration) {
57+
TRACK_V8_FAST_API_CALL("timers.scheduleTimer");
5958
ScheduleTimerImpl(FromJSObject<BindingData>(receiver), duration);
6059
}
6160

@@ -69,9 +68,8 @@ void BindingData::SlowToggleTimerRef(
6968
args[0]->IsTrue());
7069
}
7170

72-
void BindingData::FastToggleTimerRef(Local<Object> unused,
73-
Local<Object> receiver,
74-
bool ref) {
71+
void BindingData::FastToggleTimerRef(Local<Object> receiver, bool ref) {
72+
TRACK_V8_FAST_API_CALL("timers.toggleTimerRef");
7573
ToggleTimerRefImpl(FromJSObject<BindingData>(receiver), ref);
7674
}
7775

@@ -85,9 +83,8 @@ void BindingData::SlowToggleImmediateRef(
8583
args[0]->IsTrue());
8684
}
8785

88-
void BindingData::FastToggleImmediateRef(Local<Object> unused,
89-
Local<Object> receiver,
90-
bool ref) {
86+
void BindingData::FastToggleImmediateRef(Local<Object> receiver, bool ref) {
87+
TRACK_V8_FAST_API_CALL("timers.toggleImmediateRef");
9188
ToggleImmediateRefImpl(FromJSObject<BindingData>(receiver), ref);
9289
}
9390

Collapse file

‎src/timers.h‎

Copy file name to clipboardExpand all lines: src/timers.h
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,18 @@ class BindingData : public SnapshotableObject {
3131

3232
static void SlowScheduleTimer(
3333
const v8::FunctionCallbackInfo<v8::Value>& args);
34-
static void FastScheduleTimer(v8::Local<v8::Object> unused,
35-
v8::Local<v8::Object> receiver,
34+
static void FastScheduleTimer(v8::Local<v8::Object> receiver,
3635
int64_t duration);
3736
static void ScheduleTimerImpl(BindingData* data, int64_t duration);
3837

3938
static void SlowToggleTimerRef(
4039
const v8::FunctionCallbackInfo<v8::Value>& args);
41-
static void FastToggleTimerRef(v8::Local<v8::Object> unused,
42-
v8::Local<v8::Object> receiver,
43-
bool ref);
40+
static void FastToggleTimerRef(v8::Local<v8::Object> receiver, bool ref);
4441
static void ToggleTimerRefImpl(BindingData* data, bool ref);
4542

4643
static void SlowToggleImmediateRef(
4744
const v8::FunctionCallbackInfo<v8::Value>& args);
48-
static void FastToggleImmediateRef(v8::Local<v8::Object> unused,
49-
v8::Local<v8::Object> receiver,
50-
bool ref);
45+
static void FastToggleImmediateRef(v8::Local<v8::Object> receiver, bool ref);
5146
static void ToggleImmediateRefImpl(BindingData* data, bool ref);
5247

5348
static void CreatePerIsolateProperties(IsolateData* isolate_data,
Collapse file
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Flags: --allow-natives-syntax --expose-internals --no-warnings
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('assert');
6+
7+
const { internalBinding } = require('internal/test/binding');
8+
const binding = internalBinding('timers');
9+
10+
function testFastCalls() {
11+
binding.scheduleTimer(1);
12+
binding.toggleTimerRef(true);
13+
binding.toggleTimerRef(false);
14+
binding.toggleImmediateRef(true);
15+
binding.toggleImmediateRef(false);
16+
}
17+
18+
eval('%PrepareFunctionForOptimization(testFastCalls)');
19+
testFastCalls();
20+
eval('%OptimizeFunctionOnNextCall(testFastCalls)');
21+
testFastCalls();
22+
23+
if (common.isDebug) {
24+
const { getV8FastApiCallCount } = internalBinding('debug');
25+
assert.strictEqual(getV8FastApiCallCount('timers.scheduleTimer'), 1);
26+
assert.strictEqual(getV8FastApiCallCount('timers.toggleTimerRef'), 2);
27+
assert.strictEqual(getV8FastApiCallCount('timers.toggleImmediateRef'), 2);
28+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.