File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11#include " timers.h"
2+
23#include " env-inl.h"
4+ #include " node_debug.h"
35#include " node_external_reference.h"
46#include " util-inl.h"
57#include " v8.h"
@@ -35,6 +37,7 @@ void BindingData::SlowGetLibuvNow(const FunctionCallbackInfo<Value>& args) {
3537
3638double BindingData::FastGetLibuvNow (Local<Object> unused,
3739 Local<Object> receiver) {
40+ TRACK_V8_FAST_API_CALL (" timers.getLibuvNow" );
3841 return GetLibuvNowImpl (FromJSObject<BindingData>(receiver));
3942}
4043
Original file line number Diff line number Diff line change 1+ // Flags: --expose-internals --no-warnings --allow-natives-syntax
12'use strict' ;
2- // Flags: --expose-internals
33
4- require ( '../common' ) ;
5- const assert = require ( 'assert' ) ;
4+ const common = require ( '../common' ) ;
5+ const assert = require ( 'node: assert' ) ;
66const { internalBinding } = require ( 'internal/test/binding' ) ;
77const binding = internalBinding ( 'timers' ) ;
88
99// Return value of getLibuvNow() should easily fit in a SMI after start-up.
1010// We need to use the binding as the receiver for fast API calls.
1111assert ( binding . getLibuvNow ( ) < 0x3ffffff ) ;
12+
13+ {
14+ // Only javascript methods can be optimized through %OptimizeFunctionOnNextCall
15+ // This is why we surround the C++ method we want to optimize with a JS function.
16+ function getLibuvNow ( ) {
17+ return binding . getLibuvNow ( ) ;
18+ }
19+
20+ eval ( '%PrepareFunctionForOptimization(getLibuvNow)' ) ;
21+ getLibuvNow ( ) ;
22+ eval ( '%OptimizeFunctionOnNextCall(getLibuvNow)' ) ;
23+ assert ( getLibuvNow ( ) < 0x3ffffff ) ;
24+
25+ if ( common . isDebug ) {
26+ const { getV8FastApiCallCount } = internalBinding ( 'debug' ) ;
27+ assert . strictEqual ( getV8FastApiCallCount ( 'timers.getLibuvNow' ) , 1 ) ;
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments