Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Bad value context for arguments value': additional precaution #13

Open
vsemozhetbyt opened this issue Jan 29, 2017 · 0 comments
Open

Comments

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jan 29, 2017

I've tried to reduce the case reported in this comment.

It seems in addition to the precautions mentioned here there is another one:

  • Never use a direct function call with arguments[i] (i.e. arguments[i]()); use an intermediate variable instead (i.e. const arg = arguments[i]; arg();).

This case is valid even for a function call in a dead code, without an actual function call in the runtime.

Code to confirm the precaution:

'use strict';

function mainFuncGood() {
  const arg0 = arguments[0];
  if (0 === 1) arg0();
}

function mainFuncBad() {
  if (0 === 1) arguments[0](); // must be op, simple `if (false)` will not do for bailout
}

function paramFunc() {}

for (let i = 0; i < 1e3; i++) mainFuncGood(paramFunc);

for (let i = 0; i < 1e3; i++) mainFuncBad(paramFunc);
node --trace_opt --trace_deopt test.js

[marking 000002685E5E0B51 <JS Function mainFuncGood (SharedFunctionInfo 000003ED2AE67B21)> for optimized recompilation, reason: small function, ICs with typeinfo: 2/3 (66%), generic ICs: 0/3 (0%)]
[compiling method 000002685E5E0B51 <JS Function mainFuncGood (SharedFunctionInfo 000003ED2AE67B21)> using Crankshaft]
[optimizing 000002685E5E0B51 <JS Function mainFuncGood (SharedFunctionInfo 000003ED2AE67B21)> - took 0.147, 0.121, 0.053 ms]
[completed optimizing 000002685E5E0B51 <JS Function mainFuncGood (SharedFunctionInfo 000003ED2AE67B21)>]

[marking 000002685E5E0B99 <JS Function mainFuncBad (SharedFunctionInfo 000003ED2AE67BE1)> for optimized recompilation, reason: small function, ICs with typeinfo: 1/3 (33%), generic ICs: 0/3 (0%)]
[compiling method 000002685E5E0B99 <JS Function mainFuncBad (SharedFunctionInfo 000003ED2AE67BE1)> using Crankshaft]
[disabled optimization for 000003ED2AE67BE1 <SharedFunctionInfo mainFuncBad>, reason: Bad value context for arguments value]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant