Skip to content

Commit f9580d8

Browse files
kvakilNo9
authored andcommitted
Arguments adaptor no longer exists
1 parent 2916168 commit f9580d8

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/llv8-inl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,12 @@ inline JSFunction JSFrame::GetFunction(Error& err) {
228228

229229

230230
inline int64_t JSFrame::LeaParamSlot(int slot, int count) const {
231+
// On older versions of V8 with argument adaptor frames (particularly for
232+
// Node.js v14), parameters are pushed onto the stack in the "reverse" order.
233+
int64_t offset =
234+
v8()->frame()->kAdaptorFrame == -1 ? slot + 1 : count - slot - 1;
231235
return raw() + v8()->frame()->kArgsOffset +
232-
(count - slot - 1) * v8()->common()->kPointerSize;
236+
offset * v8()->common()->kPointerSize;
233237
}
234238

235239

test/plugin/frame-test.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function testFrameList(t, sess, frameNumber, sourceCode, cb) {
6262
}
6363

6464
tape('v8 stack', async (t) => {
65-
t.timeoutAfter(15000);
65+
t.timeoutAfter(30000);
6666

6767
const sess = common.Session.create('frame-scenario.js');
6868
sess.waitBreak = promisify(sess.waitBreak);
@@ -78,15 +78,19 @@ tape('v8 stack', async (t) => {
7878
t.ok(lines.length > 4, 'frame count');
7979

8080
lines = lines.filter((s) => !/<builtin>|<stub>/.test(s));
81-
const exit = lines[5];
82-
const crasher = lines[4];
83-
const adapter = lines[3];
81+
const hasArgumentAdaptorFrame = nodejsVersion()[0] < 16;
82+
const argumentAdaptorOffset = hasArgumentAdaptorFrame ? 1 : 0;
83+
const exit = lines[4 + argumentAdaptorOffset];
84+
const crasher = lines[3 + argumentAdaptorOffset];
85+
if (hasArgumentAdaptorFrame) {
86+
const adaptor = lines[3];
87+
t.ok(/<adaptor>/.test(adaptor), 'arguments adapter frame');
88+
}
8489
const fnInferredName = lines[2];
8590
const fnInferredNamePrototype = lines[1];
8691
const fnFunctionName = lines[0];
8792
t.ok(/<exit>/.test(exit), 'exit frame');
8893
t.ok(/crasher/.test(crasher), 'crasher frame');
89-
t.ok(/<adaptor>/.test(adapter), 'arguments adapter frame');
9094
if (nodejsVersion()[0] < 12)
9195
t.ok(/\sfnInferredName\(/.test(fnInferredName), 'fnInferredName frame');
9296
t.ok(/\sModule.fnInferredNamePrototype\(/.test(fnInferredNamePrototype),

0 commit comments

Comments
 (0)