Questions tagged [spidermonkey]

SpiderMonkey is Mozilla's JavaScript and WebAssembly Engine. A highly tailored version of which executes JavaScript & WebAssembly in the Firefox web browser.

SpiderMonkey is Mozilla's JavaScript & WebAssembly Engine. A highly tailored and polished-to-fit version of SpiderMonkey executes JavaScript & WebAssembly in the Firefox web browser. SpiderMonkey is also the first JavaScript engine ever made.

This virtual machine (VM) is implemented in C++, Rust and JavaScript and has support for Just-In-Time (JIT) compilation on several major platforms.

Resources


Related tags

318 questions
8
votes
1 answer

Is it an optimization to explicitly initialize undefined object members in JavaScript, given knowledge of the innerworkings of V8/spidermonkey/chakra?

In JavaScript, a commonly touted principle for good performance is to avoid changing the shape of an object. This makes me wonder, is this class Foo { constructor() { this.bar = undefined; } baz(x) { this.bar = x; } } a worthwhile…
M-Pixel
  • 3,501
  • 2
  • 16
  • 27
8
votes
2 answers

Error while compiling an embedded SpiderMonkey program

Alright, so I downloaded the SpiderMonkey source code using the command wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz and extracted it. Then I successfully built the include files and static library by executing the following…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
8
votes
1 answer

Constant declaration with block

Recently I was looking into Firefox Add-on Builder SDK sources, and stumbled on such constants declaration: const { getCodeForKey, toJSON } = require("../../keyboard/utils"); I could find information about CommonJS Modules, but left part of this…
7
votes
3 answers

SpiderMonkey vs JavaScriptCore vs?

I have a C++ desktop application (written in wxWidgets) and I want to add support for some scripting language. Scripting would mostly be used for run-time conversions of strings, numbers and dates by user supplied JavaScript code. I'd like to use…
Milan Babuškov
  • 59,775
  • 49
  • 126
  • 179
7
votes
5 answers

Parse JavaScript to instrument code

I need to split a JavaScript file into single instructions. For example a = 2; foo() function bar() { b = 5; print("spam"); } has to be separated into three instructions. (assignment, function call and function definition). Basically I need…
BruceBerry
  • 1,166
  • 1
  • 9
  • 21
7
votes
1 answer

Javascript internals: how events are implemented?

My question is related to how the JS engines implement the pattern of asynchronous events when we do something like bind event handlers on a dom for lets say a click event? Do they have something like a separate thread that is listening to all the…
sbr
  • 4,735
  • 5
  • 43
  • 49
7
votes
1 answer

switch-case performance in ECMAscript

I'm using switch-case statements on regular bases in ECMAscript. Beside my personal endorsement about it, there is tons of specialist literature out, about performance in this language in general and about conditional statements specifically. One…
jAndy
  • 231,737
  • 57
  • 305
  • 359
6
votes
2 answers

Rhino VS Spidermonkey performance tests

I have a project I'm working on for my company and right now I need to decide which JS Engine I should use. Currently the choices I have are Spidermonkey or Rhino. My main concern is performance and scalability, I wanted to know if performance…
Ben Benedek
  • 61
  • 1
  • 5
6
votes
2 answers

Why do neither V8 nor spidermonkey seem to unroll static loops?

Doing a small check, it looks like neither V8 nor spidermonkey unroll loops, even if it is completely obvious, how long they are (literal as condition, declared locally): const f = () => { let counter = 0; for (let i = 0; i < 100_000_000; i++)…
Doofus
  • 952
  • 4
  • 19
6
votes
1 answer

Firefox ES6, get class constructor name

I have problems getting the name of the constructor when using ES6 classes in Firefox. In Chromium it works fine, but Firefox seem to have some kind of bug? In Firefox I only get an empty string back. Anyone that knows of a workaround? class MyClass…
tirithen
  • 3,219
  • 11
  • 41
  • 65
6
votes
1 answer

How to detect from nodejs which JavaScript engine it is running on?

There are now several forks of nodejs and some of them support JavaScript engines other than Google's V8 engine. For my node code to see which JS engine it is running under, what is currently the best way? The engines I am aware of are: Google's V8…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
6
votes
1 answer

Asynchronously calling a callback function in Spidermonkey JS engine

Using Spidermonkey v27: What is the proper way to "retain" and then asynchronously call a temporary JS function from C++? JS code: myFunction(function(){ console.log("The function works"); }); C++ code: bool js_myFunction(JSContext* cx,…
Nathanael Weiss
  • 737
  • 1
  • 10
  • 23
6
votes
3 answers

Confusing operation of JavaScript `var` keyword

I’ve run into a very strange (to me) problem with the var keyword. I’ve reduced it to a fairly minimal test case, and found it’s exhibited in Node.js (thus, V8 and Chrome), Safari 4’s inspector (thus, Nitro), and FireBug (obviously, SpiderMonkey). I…
ELLIOTTCABLE
  • 17,185
  • 12
  • 62
  • 78
6
votes
2 answers

Take user input with JavaScript in the console

I need to get user input when running a .js in a console with spidermonkey like this: $ js myprogram.js What's the JavaScript equivalent of Ruby's gets?
alt
  • 13,357
  • 19
  • 80
  • 120
6
votes
1 answer

Program crashes if using JS_NewGlobalObject : SpiderMonkey

I am using the latest release of SpiderMonkey (js185-1.0.0.tar.gz) and when I am running the sample program which embeds Javascript, crashes the program The sample program is directly from the docs The program runs fine if I am using…
Ashwin
  • 1,942
  • 4
  • 30
  • 59
1 2
3
21 22