Skip to content

Conversation

@yosuke-furukawa
Copy link
Member

I am checking benchmark tests.
When I execute the following tests, I got the errors.

$ ./iojs benchmark/common.js misc/
misc//v8-bench.js
util.js:84
    if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
        ^
TypeError: object is not a function
    at Object.exports.debuglog (util.js:84:32)
    at timers.js:12:29
    at NativeModule.compile (node.js:800:5)
    at NativeModule.require (node.js:769:18)
    at net.js:5:14
    at NativeModule.compile (node.js:800:5)
    at NativeModule.require (node.js:769:18)
    at tty.js:4:11
    at NativeModule.compile (node.js:800:5)
    at Function.NativeModule.require (node.js:769:18)

I don't understand why this error is occurred, but I guess RegExp is not function in vm context.
So I just checked RegExp is function, the benchmark test works fine.

misc//v8-bench.js
misc/v8_bench.js Richards: 24581
misc/v8_bench.js DeltaBlue: 37548
misc/v8_bench.js Crypto: 20758
misc/v8_bench.js RayTrace: 52835
misc/v8_bench.js EarleyBoyer: 31814
misc/v8_bench.js RegExp: 4523
misc/v8_bench.js Splay: 12264
misc/v8_bench.js NavierStokes: 23945
misc/v8_bench.js Score (version 7): 21326

@vkurchatkin
Copy link
Contributor

Throwing random check doesn't seem like a good idea. For some reason v8 does this: https://github.com/iojs/io.js/blob/v1.x/deps/v8/benchmarks/regexp.js#L40

Wrapping code in IIFE doesn't work because benchmark relies on globals, so the solution is to run code in a new context.

@yosuke-furukawa
Copy link
Member Author

OK. Thank you for your suggestion. I will try to separate the RegExp benchmark test.

bnoordhuis added a commit to bnoordhuis/io.js that referenced this pull request Jan 18, 2015
deps/v8/benchmarks/regexp.js clobbers the RegExp global, breaking
util.format() and console.log().  Unclobber it to keep the other
benchmarks working.

Fixes the following error when running benchmark/misc/v8-bench.js:

    $ out/Release/iojs benchmark/misc/v8-bench.js
    util.js:84
        if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
            ^
    TypeError: object is not a function
        at Object.exports.debuglog (util.js:84:9)
        at timers.js:12:29
        at NativeModule.compile (node.js:800:5)
        at NativeModule.require (node.js:769:18)
        at net.js:5:14
        at NativeModule.compile (node.js:800:5)
        at NativeModule.require (node.js:769:18)
        at tty.js:4:11
        at NativeModule.compile (node.js:800:5)
        at Function.NativeModule.require (node.js:769:18)

This could alternatively be addressed by caching the RegExp global
in lib/util.js.  That's not a bad approach and I considered it but
doing it for just RegExp and not other globals would be half-baked.

Maybe the more thorough approach where we cache all globals at
start-up is something for a follow-up pull request.

Fixes: nodejs#475
bnoordhuis added a commit that referenced this pull request Jan 18, 2015
deps/v8/benchmarks/regexp.js clobbers the RegExp global, breaking
util.format() and console.log().  Unclobber it to keep the other
benchmarks working.

Fixes the following error when running benchmark/misc/v8-bench.js:

    $ out/Release/iojs benchmark/misc/v8-bench.js
    util.js:84
        if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
            ^
    TypeError: object is not a function
        at Object.exports.debuglog (util.js:84:9)
        at timers.js:12:29
        at NativeModule.compile (node.js:800:5)
        at NativeModule.require (node.js:769:18)
        at net.js:5:14
        at NativeModule.compile (node.js:800:5)
        at NativeModule.require (node.js:769:18)
        at tty.js:4:11
        at NativeModule.compile (node.js:800:5)
        at Function.NativeModule.require (node.js:769:18)

This could alternatively be addressed by caching the RegExp global
in lib/util.js.  That's not a bad approach and I considered it but
doing it for just RegExp and not other globals would be half-baked.

Maybe the more thorough approach where we cache all globals at
start-up is something for a follow-up pull request.

Fixes: #475
PR-URL: #489
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Yosuke Furukawa <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants