Bug 918828, part 3 - Implement JSOP_SYMBOL in the baseline compiler. r=nbp.
authorJason Orendorff <jorendorff@mozilla.com>
Tue, 01 Jul 2014 21:28:11 -0500
changeset 213225 ee7bea7db458165c733965a54e767937c2334635
parent 213224 606dc149145e4d36f96103e1a029fa615537efe1
child 213226 aa46e794d919716822068c37d673f48420da7c47
push id27745
push usercbook@mozilla.com
push dateFri, 31 Oct 2014 13:09:12 +0000
treeherdermozilla-central@6bd2071b373f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs918828
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 918828, part 3 - Implement JSOP_SYMBOL in the baseline compiler. r=nbp.
js/src/jit-test/tests/for-of/array-jit.js
js/src/jit-test/tests/symbol/toNumber-2.js
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineCompiler.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/for-of/array-jit.js
@@ -0,0 +1,6 @@
+var arr = [1, 2, 3];
+var y = 0;
+for (var i = 0; i < 10; i++)
+    for (var x of arr)
+        y += x;
+assertEq(y, 60);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/toNumber-2.js
@@ -0,0 +1,14 @@
+// |jit-test| error: ReferenceError
+function eq(e, a) {
+    passed = (a == e);
+}
+function f(e, a) {
+    fail();
+    eq(e, a);
+}
+try {
+    f();
+} catch (exc1) {}
+eq(.1, .1);
+var sym = Symbol("method");
+evaluate("f(test, sym, 0)", {compileAndGo: true});
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -1254,16 +1254,25 @@ BaselineCompiler::emit_JSOP_DOUBLE()
 
 bool
 BaselineCompiler::emit_JSOP_STRING()
 {
     frame.push(StringValue(script->getAtom(pc)));
     return true;
 }
 
+bool
+BaselineCompiler::emit_JSOP_SYMBOL()
+{
+    unsigned which = GET_UINT8(pc);
+    JS::Symbol *sym = cx->runtime()->wellKnownSymbols->get(which);
+    frame.push(SymbolValue(sym));
+    return true;
+}
+
 typedef NativeObject *(*DeepCloneObjectLiteralFn)(JSContext *, HandleNativeObject, NewObjectKind);
 static const VMFunction DeepCloneObjectLiteralInfo =
     FunctionInfo<DeepCloneObjectLiteralFn>(DeepCloneObjectLiteral);
 
 bool
 BaselineCompiler::emit_JSOP_OBJECT()
 {
     if (JS::CompartmentOptionsRef(cx).cloneSingletons()) {
--- a/js/src/jit/BaselineCompiler.h
+++ b/js/src/jit/BaselineCompiler.h
@@ -56,16 +56,17 @@ namespace jit {
     _(JSOP_ZERO)               \
     _(JSOP_ONE)                \
     _(JSOP_INT8)               \
     _(JSOP_INT32)              \
     _(JSOP_UINT16)             \
     _(JSOP_UINT24)             \
     _(JSOP_DOUBLE)             \
     _(JSOP_STRING)             \
+    _(JSOP_SYMBOL)             \
     _(JSOP_OBJECT)             \
     _(JSOP_CALLSITEOBJ)        \
     _(JSOP_REGEXP)             \
     _(JSOP_LAMBDA)             \
     _(JSOP_LAMBDA_ARROW)       \
     _(JSOP_BITOR)              \
     _(JSOP_BITXOR)             \
     _(JSOP_BITAND)             \