Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:51:15+00:00 2026-05-24T23:51:15+00:00

I’ve written a portable framework in JavaScript, and I’d like to run some performance

  • 0

I’ve written a portable framework in JavaScript, and I’d like to run some performance tests under various JavaScript interpreter shell environments. In order to accomplish this, I need to be able to pass command-line arguments (argv) to the script context. Rhino and Spidermonkey interpreters do this by default already, exposing all arguments after the script file as an array bound to the the “arguments” identifier on the global object. It was originally my intention to bring the same functionality to the v8 sample shell, as well as the JavaScriptCore jsc shell, but I soon realized that this would require much more effort, and I really only need the last command-line argument in order to run my tests. So, I have been able to get this working in v8, converting the last char* element in argv to a v8::String and binding it to the identifier “lastArg” on the global object.

Unfortunately, I’m having much more trouble accomplishing the same thing with JavaScriptCore. I haven’t been able to find much documentation on the JavaScriptCore C++ API, and the code in the JavaScriptCore jsc interpreter (in Source/JavaScriptCore/jsc.cpp) is more difficult for me to understand than the code in the v8 sample shell.

Specifically, I’d appreciate any resources (documentation, tutorials, sample code, etc.) that could help illustrate the following tasks:

  • creating a new JavaScriptCore JSString instance from a char*
  • binding the JSString instance to an identifier on the GlobalObject global object instance.

I intend to simply patch function jscmain of jsc.cpp:

int jscmain(int argc, char** argv, JSGlobalData* globalData)
{
    JSLock lock(SilenceAssertionsOnly);

    Options options;
    parseArguments(argc, argv, options, globalData);

    GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);

    //TODO: my patch would go here: create a new javascript string, and assign it to an identifier on globalObject instance

    bool success = runWithScripts(globalObject, options.scripts, options.dump);
    if (options.interactive && success)
        runInteractive(globalObject);

    return success ? 0 : 3;
}

I’d greatly appreciate any guidance anyone can offer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:51:15+00:00Added an answer on May 24, 2026 at 11:51 pm

    To create a JSString from a char*:

    JSC::JSGlobalData * globalData;
    
    JSString * CreateJSString(const char * chars, size_t length)
    {   
        const char * string = chars;
        if (0 == length)
        {
            length = strlen(chars);
        }
    
        if (isASCII(string, length))
        {
            JSString * jsstr = JSC::jsString(globalData, JSC::UString(string, length));
            return jsstr;
        }
    
        // Fall through
        return NULL;
    }
    

    Adding to global object:

    JSC::JSGlobalObject * globalObject;
    JSC::JSGlobalData * globalData;
    JSC::Identifier name;
    JSC::JSString * str;
    
    globalObject->putDirect(*globalData, name, JSC::JSValue(str));
    

    Note:: Assumes you create the stubbed objects properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.