Re: [webkit-dev] Function Property Names
CodeBlock::m_numParameters counts a function's expected parameter count. Geoff On May 3, 2010, at 9:21 PM, Nyx wrote: Is there any way to get the number of parameters a function has declared from a JSFunction object? I'm asking because I want to get the argument values a function is receiving in an op_call (in the interpreter). I copied this snipper of code for the case where a host function is called: Register* thisRegister = callFrame-registers() - RegisterFile::CallFrameHeaderSize - argCount; ArgList args(thisRegister + 1, argCount - 1); The problem is that argCount is the number of arguments passed, and so, if the function takes 5 arguments and 3 are passed, I'm not getting the first 2, only the last 3, two of which show up as undefined. Hence I believe I would need the number of arguments the function declares takes to properly compute the register offset. -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28442878.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
Hi, https://bugs.webkit.org/show_bug.cgi?id=32561 Zoltan Is there any way to map specific bytecode instruction instances to the position in the source code of the JavaScript code they correspond to? -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28429934.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
I'm looking for a way to map the bytecodes that the interpreter is running back to source positions, not the machine code generated by the JIT. At the very least, I'd like to know if I can uniquely identify specific bytecode instructions by their offset and the source id of the code block they belong to. Can multiple code blocks have the same source id, and can there be multiple code blocks for the same source code? - Maxime Zoltan Herczeg wrote: Hi, https://bugs.webkit.org/show_bug.cgi?id=32561 Zoltan Is there any way to map specific bytecode instruction instances to the position in the source code of the JavaScript code they correspond to? -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28429934.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28435520.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
ext Nyx wrote: I'm looking for a way to map the bytecodes that the interpreter is running back to source positions, not the machine code generated by the JIT. Have a look at bytecodeOffsetForPC(), CodeBlock::lineNumberForBytecodeOffset(), and Interpreter::throwException(). Kent ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
Is there any way to get the number of parameters a function has declared from a JSFunction object? I'm asking because I want to get the argument values a function is receiving in an op_call (in the interpreter). I copied this snipper of code for the case where a host function is called: Register* thisRegister = callFrame-registers() - RegisterFile::CallFrameHeaderSize - argCount; ArgList args(thisRegister + 1, argCount - 1); The problem is that argCount is the number of arguments passed, and so, if the function takes 5 arguments and 3 are passed, I'm not getting the first 2, only the last 3, two of which show up as undefined. Hence I believe I would need the number of arguments the function declares takes to properly compute the register offset. -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28442878.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
Is there any way to map specific bytecode instruction instances to the position in the source code of the JavaScript code they correspond to? -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28429934.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
Hi, ext Nyx wrote: I'm in the process of writing a program to analyze traces of JavaScript code. This involves logging events that occur in the interpreter. Currently, I'm trying to just log function calls and property accesses. However, I'm unsure exactly how to go about getting the names (identifiers) associated with functions (and properties). I wrote the following piece of code just to test things out, which I inserted in Interpreter.cpp, in the definition of the op_call opcode, after the vPC = newCodeBlock-instructions().begin(); line: JSGlobalObject* globalObject = callFrame-scopeChain()-globalObject; printf(Function call: %s\n, asFunction(v)-name(globalObject-globalExec()).ascii()); printf(%s\n, newCodeBlock-ownerExecutable()-sourceURL().ascii()); printf(%i\n, newCodeBlock-ownerExecutable()-lineNo()); Works for me. You can pass callFrame to name() if you want, the result is the same. What does your JavaScript look like? E.g., if you're using a function expression Foo.prototype.bar = function() { ... } Then that function isn't going to have a name, e.g. your op_call code will print an empty string if you do f = new Foo(); f.bar();. You could partially name it by doing Foo.prototype.bar = function bar() { ... } For function definitions (e.g. function foo() { ... } in global code), the function is named accordingly. Kent ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
Kent Hansen-2 wrote: Works for me. You can pass callFrame to name() if you want, the result is the same. What does your JavaScript look like? E.g., if you're using a function expression Foo.prototype.bar = function() { ... } Then that function isn't going to have a name, e.g. your op_call code will print an empty string if you do f = new Foo(); f.bar();. You could partially name it by doing Foo.prototype.bar = function bar() { ... } For function definitions (e.g. function foo() { ... } in global code), the function is named accordingly. Ah! I assumed it didn't work because there were alot of empty strings and strange two letter names. I didn't realize the JavaScript code for google.com is actually obfuscated. Now I just need a way to get variable and property names... By the way, is there some interpreter function somewhere that gets called when a new page is loaded? I'm assuming a page load causes all the current code to be unloaded? -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28401921.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
[webkit-dev] Function Property Names
I'm in the process of writing a program to analyze traces of JavaScript code. This involves logging events that occur in the interpreter. Currently, I'm trying to just log function calls and property accesses. However, I'm unsure exactly how to go about getting the names (identifiers) associated with functions (and properties). I wrote the following piece of code just to test things out, which I inserted in Interpreter.cpp, in the definition of the op_call opcode, after the vPC = newCodeBlock-instructions().begin(); line: JSGlobalObject* globalObject = callFrame-scopeChain()-globalObject; printf(Function call: %s\n, asFunction(v)-name(globalObject-globalExec()).ascii()); printf(%s\n, newCodeBlock-ownerExecutable()-sourceURL().ascii()); printf(%i\n, newCodeBlock-ownerExecutable()-lineNo()); My goal was to report the name of the function being called each time an op_call is executed. However, this does not report the function names correctly. My guess is that I'm passing the wrong value to InternalFunction::name(). Can anyone tell me what I'm doing wrong here? I'm rather unfamiliar with the WebKit code. -- View this message in context: http://old.nabble.com/Function---Property-Names-tp28394250p28394250.html Sent from the Webkit mailing list archive at Nabble.com. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Function Property Names
However, this does not report the function names correctly. What happens instead? Geoff ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev