Infer constant closure variables
https://bugs.webkit.org/show_bug.cgi?id=124630
Source/JavaScriptCore:
Reviewed by Geoffrey Garen.
Captured variables that are assigned once (not counting op_enter's Undefined
initialization) and that are contained within a function that has thus far only been
entered once are now constant folded. It's pretty awesome.
This involves a watchpoint on the assignment to variables and a watchpoint on entry
into the function. The former is reused from global variable constant inference and the
latter is reused from one-time closure inference.
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::CodeBlock):
* bytecode/Instruction.h:
(JSC::Instruction::Instruction):
* bytecode/Opcode.h:
(JSC::padOpcodeName):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedInstruction::UnlinkedInstruction):
* bytecode/VariableWatchpointSet.h:
(JSC::VariableWatchpointSet::invalidate):
* bytecode/Watchpoint.h:
(JSC::WatchpointSet::invalidate):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::addVar):
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitInitLazyRegister):
(JSC::BytecodeGenerator::emitMove):
(JSC::BytecodeGenerator::emitNewFunctionInternal):
(JSC::BytecodeGenerator::createArgumentsIfNecessary):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::addVar):
(JSC::BytecodeGenerator::watchableVariable):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::getLocal):
(JSC::DFG::ByteCodeParser::inferredConstant):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::parse):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::tryGetActivation):
(JSC::DFG::Graph::tryGetRegisters):
* dfg/DFGGraph.h:
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):
* jit/JIT.h:
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_mov):
(JSC::JIT::emit_op_captured_mov):
(JSC::JIT::emit_op_new_captured_func):
(JSC::JIT::emitSlow_op_captured_mov):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_mov):
(JSC::JIT::emit_op_captured_mov):
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):
* runtime/CommonSlowPaths.h:
* runtime/ConstantMode.h: Added.
* runtime/JSGlobalObject.h:
* runtime/JSScope.cpp:
(JSC::abstractAccess):
* runtime/SymbolTable.cpp:
(JSC::SymbolTableEntry::prepareToWatch):
LayoutTests:
Reviewed by Geoffrey Garen.
This adds both correctness and performance tests for constant closure variable
inference.
* js/regress/infer-closure-const-then-mov-expected.txt: Added.
* js/regress/infer-closure-const-then-mov-no-inline-expected.txt: Added.
* js/regress/infer-closure-const-then-mov-no-inline.html: Added.
* js/regress/infer-closure-const-then-mov.html: Added.
* js/regress/infer-closure-const-then-put-to-scope-expected.txt: Added.
* js/regress/infer-closure-const-then-put-to-scope-no-inline-expected.txt: Added.
* js/regress/infer-closure-const-then-put-to-scope-no-inline.html: Added.
* js/regress/infer-closure-const-then-put-to-scope.html: Added.
* js/regress/infer-closure-const-then-reenter-expected.txt: Added.
* js/regress/infer-closure-const-then-reenter-no-inline-expected.txt: Added.
* js/regress/infer-closure-const-then-reenter-no-inline.html: Added.
* js/regress/infer-closure-const-then-reenter.html: Added.
* js/regress/script-tests/infer-closure-const-then-mov-no-inline.js: Added.
* js/regress/script-tests/infer-closure-const-then-mov.js: Added.
* js/regress/script-tests/infer-closure-const-then-put-to-scope-no-inline.js: Added.
(thingy.):
(thingy):
* js/regress/script-tests/infer-closure-const-then-put-to-scope.js: Added.
(thingy.):
(thingy):
* js/regress/script-tests/infer-closure-const-then-reenter-no-inline.js: Added.
(.return.foo):
(foo):
* js/regress/script-tests/infer-closure-const-then-reenter.js: Added.
(.return.foo):
(foo):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7bc2036..db012b8 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,40 @@
+2013-12-03 Filip Pizlo <fpizlo@apple.com>
+
+ Infer constant closure variables
+ https://bugs.webkit.org/show_bug.cgi?id=124630
+
+ Reviewed by Geoffrey Garen.
+
+ This adds both correctness and performance tests for constant closure variable
+ inference.
+
+ * js/regress/infer-closure-const-then-mov-expected.txt: Added.
+ * js/regress/infer-closure-const-then-mov-no-inline-expected.txt: Added.
+ * js/regress/infer-closure-const-then-mov-no-inline.html: Added.
+ * js/regress/infer-closure-const-then-mov.html: Added.
+ * js/regress/infer-closure-const-then-put-to-scope-expected.txt: Added.
+ * js/regress/infer-closure-const-then-put-to-scope-no-inline-expected.txt: Added.
+ * js/regress/infer-closure-const-then-put-to-scope-no-inline.html: Added.
+ * js/regress/infer-closure-const-then-put-to-scope.html: Added.
+ * js/regress/infer-closure-const-then-reenter-expected.txt: Added.
+ * js/regress/infer-closure-const-then-reenter-no-inline-expected.txt: Added.
+ * js/regress/infer-closure-const-then-reenter-no-inline.html: Added.
+ * js/regress/infer-closure-const-then-reenter.html: Added.
+ * js/regress/script-tests/infer-closure-const-then-mov-no-inline.js: Added.
+ * js/regress/script-tests/infer-closure-const-then-mov.js: Added.
+ * js/regress/script-tests/infer-closure-const-then-put-to-scope-no-inline.js: Added.
+ (thingy.):
+ (thingy):
+ * js/regress/script-tests/infer-closure-const-then-put-to-scope.js: Added.
+ (thingy.):
+ (thingy):
+ * js/regress/script-tests/infer-closure-const-then-reenter-no-inline.js: Added.
+ (.return.foo):
+ (foo):
+ * js/regress/script-tests/infer-closure-const-then-reenter.js: Added.
+ (.return.foo):
+ (foo):
+
2013-12-04 Mario Sanchez Prada <mario.prada@samsung.com>
Unreviewed GTK gardening. Updated expectations for GTK and share them with EFL.
diff --git a/LayoutTests/js/regress/infer-closure-const-then-mov-expected.txt b/LayoutTests/js/regress/infer-closure-const-then-mov-expected.txt
new file mode 100644
index 0000000..a28a749
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-mov-expected.txt
@@ -0,0 +1,10 @@
+JSRegress/infer-closure-const-then-mov
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/infer-closure-const-then-mov-no-inline-expected.txt b/LayoutTests/js/regress/infer-closure-const-then-mov-no-inline-expected.txt
new file mode 100644
index 0000000..1abcefe
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-mov-no-inline-expected.txt
@@ -0,0 +1,10 @@
+JSRegress/infer-closure-const-then-mov-no-inline
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/infer-closure-const-then-mov-no-inline.html b/LayoutTests/js/regress/infer-closure-const-then-mov-no-inline.html
new file mode 100644
index 0000000..71a553a
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-mov-no-inline.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/infer-closure-const-then-mov-no-inline.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/infer-closure-const-then-mov.html b/LayoutTests/js/regress/infer-closure-const-then-mov.html
new file mode 100644
index 0000000..8d2e3b9
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-mov.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/infer-closure-const-then-mov.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-expected.txt b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-expected.txt
new file mode 100644
index 0000000..e1bb730
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-expected.txt
@@ -0,0 +1,10 @@
+JSRegress/infer-closure-const-then-put-to-scope
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-no-inline-expected.txt b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-no-inline-expected.txt
new file mode 100644
index 0000000..7d7dbbe
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-no-inline-expected.txt
@@ -0,0 +1,10 @@
+JSRegress/infer-closure-const-then-put-to-scope-no-inline
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-no-inline.html b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-no-inline.html
new file mode 100644
index 0000000..a42e439
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope-no-inline.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/infer-closure-const-then-put-to-scope-no-inline.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/infer-closure-const-then-put-to-scope.html b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope.html
new file mode 100644
index 0000000..ad4910a
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-put-to-scope.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/infer-closure-const-then-put-to-scope.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/infer-closure-const-then-reenter-expected.txt b/LayoutTests/js/regress/infer-closure-const-then-reenter-expected.txt
new file mode 100644
index 0000000..7c33bfd
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-reenter-expected.txt
@@ -0,0 +1,10 @@
+JSRegress/infer-closure-const-then-reenter
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/infer-closure-const-then-reenter-no-inline-expected.txt b/LayoutTests/js/regress/infer-closure-const-then-reenter-no-inline-expected.txt
new file mode 100644
index 0000000..6e40238
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-reenter-no-inline-expected.txt
@@ -0,0 +1,10 @@
+JSRegress/infer-closure-const-then-reenter-no-inline
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/infer-closure-const-then-reenter-no-inline.html b/LayoutTests/js/regress/infer-closure-const-then-reenter-no-inline.html
new file mode 100644
index 0000000..19d25f2
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-reenter-no-inline.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/infer-closure-const-then-reenter-no-inline.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/infer-closure-const-then-reenter.html b/LayoutTests/js/regress/infer-closure-const-then-reenter.html
new file mode 100644
index 0000000..5f94deb
--- /dev/null
+++ b/LayoutTests/js/regress/infer-closure-const-then-reenter.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/infer-closure-const-then-reenter.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/script-tests/infer-closure-const-then-mov-no-inline.js b/LayoutTests/js/regress/script-tests/infer-closure-const-then-mov-no-inline.js
new file mode 100644
index 0000000..7f822ae
--- /dev/null
+++ b/LayoutTests/js/regress/script-tests/infer-closure-const-then-mov-no-inline.js
@@ -0,0 +1,34 @@
+(function(){
+ var a = 42;
+ var b = 23;
+ var c = 84;
+ var d = 13;
+ var e = 90;
+ var f = 34;
+ var g = 52;
+
+ function foo() {
+ return a + b + c + d + e + f + g;
+ }
+
+ noInline(foo);
+
+ for (var i = 0; i < 500000; ++i) {
+ var result = foo();
+ if (result != 42 + 23 + 84 + 13 + 90 + 34 + 52)
+ throw "Error: bad result: " + result;
+ }
+
+ a = 1;
+ b = 2;
+ c = 3;
+ d = 4;
+ e = 5;
+ f = 6;
+ g = 7;
+
+ var result = foo();
+ if (result != 1 + 2 + 3 + 4 + 5 + 6 + 7)
+ throw "Error: bad result: " + result;
+})();
+
diff --git a/LayoutTests/js/regress/script-tests/infer-closure-const-then-mov.js b/LayoutTests/js/regress/script-tests/infer-closure-const-then-mov.js
new file mode 100644
index 0000000..08a192c
--- /dev/null
+++ b/LayoutTests/js/regress/script-tests/infer-closure-const-then-mov.js
@@ -0,0 +1,32 @@
+(function(){
+ var a = 42;
+ var b = 23;
+ var c = 84;
+ var d = 13;
+ var e = 90;
+ var f = 34;
+ var g = 52;
+
+ function foo() {
+ return a + b + c + d + e + f + g;
+ }
+
+ for (var i = 0; i < 10000000; ++i) {
+ var result = foo();
+ if (result != 42 + 23 + 84 + 13 + 90 + 34 + 52)
+ throw "Error: bad result: " + result;
+ }
+
+ a = 1;
+ b = 2;
+ c = 3;
+ d = 4;
+ e = 5;
+ f = 6;
+ g = 7;
+
+ var result = foo();
+ if (result != 1 + 2 + 3 + 4 + 5 + 6 + 7)
+ throw "Error: bad result: " + result;
+})();
+
diff --git a/LayoutTests/js/regress/script-tests/infer-closure-const-then-put-to-scope-no-inline.js b/LayoutTests/js/regress/script-tests/infer-closure-const-then-put-to-scope-no-inline.js
new file mode 100644
index 0000000..f71310a
--- /dev/null
+++ b/LayoutTests/js/regress/script-tests/infer-closure-const-then-put-to-scope-no-inline.js
@@ -0,0 +1,36 @@
+var thingy = (function(){
+ var a = 42;
+ var b = 23;
+ var c = 84;
+ var d = 13;
+ var e = 90;
+ var f = 34;
+ var g = 52;
+ return {
+ foo: function() {
+ return a + b + c + d + e + f + g;
+ },
+ bar: function() {
+ a = 1;
+ b = 2;
+ c = 3;
+ d = 4;
+ e = 5;
+ f = 6;
+ g = 7;
+ }
+ };
+})();
+
+noInline(thingy.foo);
+
+for (var i = 0; i < 2000000; ++i) {
+ var result = thingy.foo();
+ if (result != 42 + 23 + 84 + 13 + 90 + 34 + 52)
+ throw "Error: bad result: " + result;
+}
+
+thingy.bar();
+var result = thingy.foo();
+if (result != 1 + 2 + 3 + 4 + 5 + 6 + 7)
+ throw "Error: bad result: " + result;
diff --git a/LayoutTests/js/regress/script-tests/infer-closure-const-then-put-to-scope.js b/LayoutTests/js/regress/script-tests/infer-closure-const-then-put-to-scope.js
new file mode 100644
index 0000000..b3dcd37
--- /dev/null
+++ b/LayoutTests/js/regress/script-tests/infer-closure-const-then-put-to-scope.js
@@ -0,0 +1,34 @@
+var thingy = (function(){
+ var a = 42;
+ var b = 23;
+ var c = 84;
+ var d = 13;
+ var e = 90;
+ var f = 34;
+ var g = 52;
+ return {
+ foo: function() {
+ return a + b + c + d + e + f + g;
+ },
+ bar: function() {
+ a = 1;
+ b = 2;
+ c = 3;
+ d = 4;
+ e = 5;
+ f = 6;
+ g = 7;
+ }
+ };
+})();
+
+for (var i = 0; i < 10000000; ++i) {
+ var result = thingy.foo();
+ if (result != 42 + 23 + 84 + 13 + 90 + 34 + 52)
+ throw "Error: bad result: " + result;
+}
+
+thingy.bar();
+var result = thingy.foo();
+if (result != 1 + 2 + 3 + 4 + 5 + 6 + 7)
+ throw "Error: bad result: " + result;
diff --git a/LayoutTests/js/regress/script-tests/infer-closure-const-then-reenter-no-inline.js b/LayoutTests/js/regress/script-tests/infer-closure-const-then-reenter-no-inline.js
new file mode 100644
index 0000000..c298111
--- /dev/null
+++ b/LayoutTests/js/regress/script-tests/infer-closure-const-then-reenter-no-inline.js
@@ -0,0 +1,28 @@
+function foo(a_, b_, c_, d_, e_, f_, g_) {
+ var a = a_;
+ var b = b_;
+ var c = c_;
+ var d = d_;
+ var e = e_;
+ var f = f_;
+ var g = g_;
+ return {
+ foo: function() {
+ return a + b + c + d + e + f + g;
+ }
+ };
+}
+
+noInline(foo);
+
+var thingy = foo(42, 23, 84, 13, 90, 34, 52);
+noInline(thingy.foo);
+for (var i = 0; i < 10000000; ++i) {
+ var result = thingy.foo();
+ if (result != 42 + 23 + 84 + 13 + 90 + 34 + 52)
+ throw "Error: bad result: " + result;
+}
+
+var result = foo(1, 2, 3, 4, 5, 6, 7).foo();
+if (result != 1 + 2 + 3 + 4 + 5 + 6 + 7)
+ throw "Error: bad result: " + result;
diff --git a/LayoutTests/js/regress/script-tests/infer-closure-const-then-reenter.js b/LayoutTests/js/regress/script-tests/infer-closure-const-then-reenter.js
new file mode 100644
index 0000000..a0d4da5
--- /dev/null
+++ b/LayoutTests/js/regress/script-tests/infer-closure-const-then-reenter.js
@@ -0,0 +1,25 @@
+function foo(a_, b_, c_, d_, e_, f_, g_) {
+ var a = a_;
+ var b = b_;
+ var c = c_;
+ var d = d_;
+ var e = e_;
+ var f = f_;
+ var g = g_;
+ return {
+ foo: function() {
+ return a + b + c + d + e + f + g;
+ }
+ };
+}
+
+var thingy = foo(42, 23, 84, 13, 90, 34, 52);
+for (var i = 0; i < 10000000; ++i) {
+ var result = thingy.foo();
+ if (result != 42 + 23 + 84 + 13 + 90 + 34 + 52)
+ throw "Error: bad result: " + result;
+}
+
+var result = foo(1, 2, 3, 4, 5, 6, 7).foo();
+if (result != 1 + 2 + 3 + 4 + 5 + 6 + 7)
+ throw "Error: bad result: " + result;
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 129bbef..93afe3a 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,77 @@
+2013-12-03 Filip Pizlo <fpizlo@apple.com>
+
+ Infer constant closure variables
+ https://bugs.webkit.org/show_bug.cgi?id=124630
+
+ Reviewed by Geoffrey Garen.
+
+ Captured variables that are assigned once (not counting op_enter's Undefined
+ initialization) and that are contained within a function that has thus far only been
+ entered once are now constant folded. It's pretty awesome.
+
+ This involves a watchpoint on the assignment to variables and a watchpoint on entry
+ into the function. The former is reused from global variable constant inference and the
+ latter is reused from one-time closure inference.
+
+ * GNUmakefile.list.am:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dumpBytecode):
+ (JSC::CodeBlock::CodeBlock):
+ * bytecode/Instruction.h:
+ (JSC::Instruction::Instruction):
+ * bytecode/Opcode.h:
+ (JSC::padOpcodeName):
+ * bytecode/UnlinkedCodeBlock.h:
+ (JSC::UnlinkedInstruction::UnlinkedInstruction):
+ * bytecode/VariableWatchpointSet.h:
+ (JSC::VariableWatchpointSet::invalidate):
+ * bytecode/Watchpoint.h:
+ (JSC::WatchpointSet::invalidate):
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::addVar):
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ (JSC::BytecodeGenerator::emitInitLazyRegister):
+ (JSC::BytecodeGenerator::emitMove):
+ (JSC::BytecodeGenerator::emitNewFunctionInternal):
+ (JSC::BytecodeGenerator::createArgumentsIfNecessary):
+ * bytecompiler/BytecodeGenerator.h:
+ (JSC::BytecodeGenerator::addVar):
+ (JSC::BytecodeGenerator::watchableVariable):
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::getLocal):
+ (JSC::DFG::ByteCodeParser::inferredConstant):
+ (JSC::DFG::ByteCodeParser::parseBlock):
+ (JSC::DFG::ByteCodeParser::parse):
+ * dfg/DFGGraph.cpp:
+ (JSC::DFG::Graph::tryGetActivation):
+ (JSC::DFG::Graph::tryGetRegisters):
+ * dfg/DFGGraph.h:
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileMainPass):
+ (JSC::JIT::privateCompileSlowCases):
+ * jit/JIT.h:
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_mov):
+ (JSC::JIT::emit_op_captured_mov):
+ (JSC::JIT::emit_op_new_captured_func):
+ (JSC::JIT::emitSlow_op_captured_mov):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::emit_op_mov):
+ (JSC::JIT::emit_op_captured_mov):
+ * llint/LowLevelInterpreter32_64.asm:
+ * llint/LowLevelInterpreter64.asm:
+ * runtime/CommonSlowPaths.cpp:
+ (JSC::SLOW_PATH_DECL):
+ * runtime/CommonSlowPaths.h:
+ * runtime/ConstantMode.h: Added.
+ * runtime/JSGlobalObject.h:
+ * runtime/JSScope.cpp:
+ (JSC::abstractAccess):
+ * runtime/SymbolTable.cpp:
+ (JSC::SymbolTableEntry::prepareToWatch):
+
2013-12-04 Brent Fulgham <bfulgham@apple.com>
[Win] Unreviewed project file gardening.
diff --git a/Source/JavaScriptCore/GNUmakefile.list.am b/Source/JavaScriptCore/GNUmakefile.list.am
index 0d8b54c..e1929b8 100644
--- a/Source/JavaScriptCore/GNUmakefile.list.am
+++ b/Source/JavaScriptCore/GNUmakefile.list.am
@@ -822,6 +822,7 @@
Source/JavaScriptCore/runtime/Completion.cpp \
Source/JavaScriptCore/runtime/Completion.h \
Source/JavaScriptCore/runtime/ConcurrentJITLock.h \
+ Source/JavaScriptCore/runtime/ConstantMode.h \
Source/JavaScriptCore/runtime/ConstructData.cpp \
Source/JavaScriptCore/runtime/ConstructData.h \
Source/JavaScriptCore/runtime/DataView.cpp \
diff --git a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
index b7bb63bc..0f60fce 100644
--- a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
@@ -1113,6 +1113,7 @@
<ClInclude Include="..\runtime\CommonSlowPathsExceptions.h" />
<ClInclude Include="..\runtime\CompilationResult.h" />
<ClInclude Include="..\runtime\Completion.h" />
+ <ClInclude Include="..\runtime\ConstantMode.h" />
<ClInclude Include="..\runtime\ConstructData.h" />
<ClInclude Include="..\runtime\DataView.h" />
<ClInclude Include="..\runtime\DateConstructor.h" />
diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 36a9dfe..0ac1898 100644
--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -541,6 +541,7 @@
0FFB921E16D02F470055A5DB /* DFGVariadicFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F85A31E16AB76AE0077571E /* DFGVariadicFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FFB921F16D033050055A5DB /* (null) in Headers */ = {isa = PBXBuildFile; settings = {ATTRIBUTES = (Private, ); }; };
0FFB922016D033B70055A5DB /* NodeConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 930DAD030FB1EB1A0082D205 /* NodeConstructors.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0FFC99D1184EC8AD009C10AB /* ConstantMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFC99D0184EC8AD009C10AB /* ConstantMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FFFC95714EF90A000C72532 /* DFGCFAPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFFC94B14EF909500C72532 /* DFGCFAPhase.cpp */; };
0FFFC95814EF90A200C72532 /* DFGCFAPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFFC94C14EF909500C72532 /* DFGCFAPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FFFC95914EF90A600C72532 /* DFGCSEPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFFC94D14EF909500C72532 /* DFGCSEPhase.cpp */; };
@@ -1845,6 +1846,7 @@
0FF729A1166AD347000F5BA3 /* ProfilerOriginStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProfilerOriginStack.cpp; path = profiler/ProfilerOriginStack.cpp; sourceTree = "<group>"; };
0FF729A2166AD347000F5BA3 /* ProfilerOriginStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProfilerOriginStack.h; path = profiler/ProfilerOriginStack.h; sourceTree = "<group>"; };
0FF922CF14F46B130041A24E /* JSCLLIntOffsetsExtractor */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = JSCLLIntOffsetsExtractor; sourceTree = BUILT_PRODUCTS_DIR; };
+ 0FFC99D0184EC8AD009C10AB /* ConstantMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstantMode.h; sourceTree = "<group>"; };
0FFFC94B14EF909500C72532 /* DFGCFAPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGCFAPhase.cpp; path = dfg/DFGCFAPhase.cpp; sourceTree = "<group>"; };
0FFFC94C14EF909500C72532 /* DFGCFAPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGCFAPhase.h; path = dfg/DFGCFAPhase.h; sourceTree = "<group>"; };
0FFFC94D14EF909500C72532 /* DFGCSEPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGCSEPhase.cpp; path = dfg/DFGCSEPhase.cpp; sourceTree = "<group>"; };
@@ -3404,6 +3406,7 @@
969A09220ED1E09C00F1F681 /* Completion.cpp */,
F5BB2BC5030F772101FCFE1D /* Completion.h */,
0FDB2CE9174896C7007B3C1B /* ConcurrentJITLock.h */,
+ 0FFC99D0184EC8AD009C10AB /* ConstantMode.h */,
BCA62DFF0E2826310004F30D /* ConstructData.cpp */,
BC8F3CCF0DAF17BA00577A80 /* ConstructData.h */,
0F2B66B017B6B5AB00A7AE3F /* DataView.cpp */,
@@ -4418,6 +4421,7 @@
0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */,
0FD8A32617D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h in Headers */,
0FC0976A1468A6F700CF2442 /* DFGOSRExit.h in Headers */,
+ 0FFC99D1184EC8AD009C10AB /* ConstantMode.h in Headers */,
0F235BEC17178E7300690C7F /* DFGOSRExitBase.h in Headers */,
A5BA15ED182340B400A82E69 /* RemoteInspectorXPCConnection.h in Headers */,
0FFB921C16D02F110055A5DB /* DFGOSRExitCompilationInfo.h in Headers */,
diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
index cb80548..30de6c7 100644
--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -768,6 +768,7 @@
int r1 = (++it)->u.operand;
printLocationAndOp(out, exec, location, it, "captured_mov");
out.printf("%s, %s", registerName(r0).data(), registerName(r1).data());
+ ++it;
break;
}
case op_not: {
@@ -1224,9 +1225,9 @@
case op_new_captured_func: {
int r0 = (++it)->u.operand;
int f0 = (++it)->u.operand;
- int shouldCheck = (++it)->u.operand;
printLocationAndOp(out, exec, location, it, "new_captured_func");
- out.printf("%s, f%d, %s", registerName(r0).data(), f0, shouldCheck ? "<Checked>" : "<Unchecked>");
+ out.printf("%s, f%d", registerName(r0).data(), f0);
+ ++it;
break;
}
case op_new_func_exp: {
@@ -1551,10 +1552,13 @@
{
ASSERT(m_heap->isDeferred());
+ bool didCloneSymbolTable = false;
+
if (SymbolTable* symbolTable = unlinkedCodeBlock->symbolTable()) {
- if (codeType() == FunctionCode && symbolTable->captureCount())
+ if (codeType() == FunctionCode && symbolTable->captureCount()) {
m_symbolTable.set(*m_vm, m_ownerExecutable.get(), symbolTable->clone(*m_vm));
- else
+ didCloneSymbolTable = true;
+ } else
m_symbolTable.set(*m_vm, m_ownerExecutable.get(), symbolTable);
}
@@ -1820,11 +1824,28 @@
instructions[i + 4].u.operand = ResolveModeAndType(modeAndType.mode(), op.type).operand();
if (op.type == GlobalVar || op.type == GlobalVarWithVarInjectionChecks)
instructions[i + 5].u.watchpointSet = op.watchpointSet;
- else if (op.structure)
+ else if (op.type == ClosureVar || op.type == ClosureVarWithVarInjectionChecks) {
+ if (op.watchpointSet)
+ op.watchpointSet->invalidate();
+ } else if (op.structure)
instructions[i + 5].u.structure.set(*vm(), ownerExecutable, op.structure);
instructions[i + 6].u.pointer = reinterpret_cast<void*>(op.operand);
break;
}
+
+ case op_captured_mov:
+ case op_new_captured_func: {
+ StringImpl* uid = pc[i + 3].u.uid;
+ if (!uid)
+ break;
+ RELEASE_ASSERT(didCloneSymbolTable);
+ ConcurrentJITLocker locker(m_symbolTable->m_lock);
+ SymbolTable::Map::iterator iter = m_symbolTable->find(locker, uid);
+ ASSERT(iter != m_symbolTable->end(locker));
+ iter->value.prepareToWatch();
+ instructions[i + 3].u.watchpointSet = iter->value.watchpointSet();
+ break;
+ }
default:
break;
diff --git a/Source/JavaScriptCore/bytecode/Instruction.h b/Source/JavaScriptCore/bytecode/Instruction.h
index 81451e5..00bd815 100644
--- a/Source/JavaScriptCore/bytecode/Instruction.h
+++ b/Source/JavaScriptCore/bytecode/Instruction.h
@@ -90,16 +90,13 @@
Instruction(PropertySlot::GetValueFunc getterFunc) { u.getterFunc = getterFunc; }
Instruction(LLIntCallLinkInfo* callLinkInfo) { u.callLinkInfo = callLinkInfo; }
-
Instruction(ValueProfile* profile) { u.profile = profile; }
Instruction(ArrayProfile* profile) { u.arrayProfile = profile; }
Instruction(ArrayAllocationProfile* profile) { u.arrayAllocationProfile = profile; }
Instruction(ObjectAllocationProfile* profile) { u.objectAllocationProfile = profile; }
-
Instruction(WriteBarrier<Unknown>* registerPointer) { u.registerPointer = registerPointer; }
-
Instruction(Special::Pointer pointer) { u.specialPointer = pointer; }
-
+ Instruction(StringImpl* uid) { u.uid = uid; }
Instruction(bool* predicatePointer) { u.predicatePointer = predicatePointer; }
union {
@@ -112,6 +109,7 @@
Special::Pointer specialPointer;
PropertySlot::GetValueFunc getterFunc;
LLIntCallLinkInfo* callLinkInfo;
+ StringImpl* uid;
ValueProfile* profile;
ArrayProfile* arrayProfile;
ArrayAllocationProfile* arrayAllocationProfile;
diff --git a/Source/JavaScriptCore/bytecode/Opcode.h b/Source/JavaScriptCore/bytecode/Opcode.h
index 347f2bd..ec259e6 100644
--- a/Source/JavaScriptCore/bytecode/Opcode.h
+++ b/Source/JavaScriptCore/bytecode/Opcode.h
@@ -55,7 +55,7 @@
macro(op_new_array_buffer, 5) \
macro(op_new_regexp, 3) \
macro(op_mov, 3) \
- macro(op_captured_mov, 3) \
+ macro(op_captured_mov, 4) \
\
macro(op_not, 3) \
macro(op_eq, 4) \
diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
index b2ff326..22ccf6e 100644
--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
@@ -229,9 +229,11 @@
UnlinkedInstruction() { u.operand = 0; }
UnlinkedInstruction(OpcodeID opcode) { u.opcode = opcode; }
UnlinkedInstruction(int operand) { u.operand = operand; }
+ UnlinkedInstruction(StringImpl* uid) { u.uid = uid; }
union {
OpcodeID opcode;
int32_t operand;
+ StringImpl* uid;
} u;
};
diff --git a/Source/JavaScriptCore/bytecode/VariableWatchpointSet.h b/Source/JavaScriptCore/bytecode/VariableWatchpointSet.h
index a400ff2..4dec404 100644
--- a/Source/JavaScriptCore/bytecode/VariableWatchpointSet.h
+++ b/Source/JavaScriptCore/bytecode/VariableWatchpointSet.h
@@ -80,10 +80,8 @@
void invalidate()
{
- ASSERT(!!m_inferredValue);
- ASSERT(state() == IsWatched);
m_inferredValue = JSValue();
- fireAll();
+ WatchpointSet::invalidate();
}
void finalizeUnconditionally()
diff --git a/Source/JavaScriptCore/bytecode/Watchpoint.h b/Source/JavaScriptCore/bytecode/Watchpoint.h
index 37b72a7..79e2d2f 100644
--- a/Source/JavaScriptCore/bytecode/Watchpoint.h
+++ b/Source/JavaScriptCore/bytecode/Watchpoint.h
@@ -115,6 +115,13 @@
else
fireAll();
}
+
+ void invalidate()
+ {
+ if (state() == IsWatched)
+ fireAll();
+ m_state = IsInvalidated;
+ }
int8_t* addressOfState() { return &m_state; }
int8_t* addressOfSetIsNotEmpty() { return &m_setIsNotEmpty; }
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index a22b17a..4548101 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -115,19 +115,31 @@
return ParserError(ParserError::ErrorNone);
}
-bool BytecodeGenerator::addVar(const Identifier& ident, bool isConstant, RegisterID*& r0)
+bool BytecodeGenerator::addVar(
+ const Identifier& ident, ConstantMode constantMode, WatchMode watchMode, RegisterID*& r0)
{
+ ASSERT(static_cast<size_t>(m_codeBlock->m_numVars) == m_calleeRegisters.size());
+
ConcurrentJITLocker locker(symbolTable().m_lock);
int index = virtualRegisterForLocal(m_calleeRegisters.size()).offset();
- SymbolTableEntry newEntry(index, isConstant ? ReadOnly : 0);
+ SymbolTableEntry newEntry(index, constantMode == IsConstant ? ReadOnly : 0);
SymbolTable::Map::AddResult result = symbolTable().add(locker, ident.impl(), newEntry);
if (!result.isNewEntry) {
r0 = ®isterFor(result.iterator->value.getIndex());
return false;
}
-
+
+ if (watchMode == IsWatchable) {
+ while (m_watchableVariables.size() < static_cast<size_t>(m_codeBlock->m_numVars))
+ m_watchableVariables.append(nullptr);
+ m_watchableVariables.append(ident.impl());
+ }
+
r0 = addVar();
+
+ ASSERT(watchMode == NotWatchable || static_cast<size_t>(m_codeBlock->m_numVars) == m_watchableVariables.size());
+
return true;
}
@@ -236,7 +248,7 @@
if (functionBody->usesArguments() || codeBlock->usesEval()) { // May reify arguments object.
RegisterID* unmodifiedArgumentsRegister = addVar(); // Anonymous, so it can't be modified by user code.
- RegisterID* argumentsRegister = addVar(propertyNames().arguments, false); // Can be changed by assigning to 'arguments'.
+ RegisterID* argumentsRegister = addVar(propertyNames().arguments, IsVariable, NotWatchable); // Can be changed by assigning to 'arguments'.
// We can save a little space by hard-coding the knowledge that the two
// 'arguments' values are stored in consecutive registers, and storing
@@ -307,13 +319,13 @@
instructions().append(m_activationRegister->index());
}
m_functions.add(ident.impl());
- emitNewFunction(addVar(ident, false), IsCaptured, function);
+ emitNewFunction(addVar(ident, IsVariable, IsWatchable), IsCaptured, function);
}
}
for (size_t i = 0; i < varStack.size(); ++i) {
const Identifier& ident = varStack[i].first;
if (functionBody->captures(ident))
- addVar(ident, varStack[i].second & DeclarationStacks::IsConstant);
+ addVar(ident, (varStack[i].second & DeclarationStacks::IsConstant) ? IsConstant : IsVariable, IsWatchable);
}
}
bool canLazilyCreateFunctions = !functionBody->needsActivationForMoreThanVariables() && !m_shouldEmitDebugHooks;
@@ -331,7 +343,7 @@
const Identifier& ident = function->ident();
if (!functionBody->captures(ident)) {
m_functions.add(ident.impl());
- RefPtr<RegisterID> reg = addVar(ident, false);
+ RefPtr<RegisterID> reg = addVar(ident, IsVariable, NotWatchable);
// Don't lazily create functions that override the name 'arguments'
// as this would complicate lazy instantiation of actual arguments.
if (!canLazilyCreateFunctions || ident == propertyNames().arguments)
@@ -346,7 +358,7 @@
for (size_t i = 0; i < varStack.size(); ++i) {
const Identifier& ident = varStack[i].first;
if (!functionBody->captures(ident))
- addVar(ident, varStack[i].second & DeclarationStacks::IsConstant);
+ addVar(ident, (varStack[i].second & DeclarationStacks::IsConstant) ? IsConstant : IsVariable, NotWatchable);
}
if (shouldCaptureAllTheThings)
@@ -457,6 +469,7 @@
{
emitOpcode(op_init_lazy_reg);
instructions().append(reg->index());
+ ASSERT(!watchableVariable(reg->index()));
return reg;
}
@@ -1007,6 +1020,8 @@
emitOpcode(captureMode == IsCaptured ? op_captured_mov : op_mov);
instructions().append(dst->index());
instructions().append(src->index());
+ if (captureMode == IsCaptured)
+ instructions().append(watchableVariable(dst->index()));
return dst;
}
@@ -1579,7 +1594,11 @@
emitOpcode(captureMode == IsCaptured ? op_new_captured_func : op_new_func);
instructions().append(dst->index());
instructions().append(index);
- instructions().append(doNullCheck);
+ if (captureMode == IsCaptured) {
+ ASSERT(!doNullCheck);
+ instructions().append(watchableVariable(dst->index()));
+ } else
+ instructions().append(doNullCheck);
return dst;
}
@@ -1621,6 +1640,7 @@
emitOpcode(op_create_arguments);
instructions().append(m_codeBlock->argumentsRegister().offset());
+ ASSERT(!watchableVariable(m_codeBlock->argumentsRegister().offset()));
}
void BytecodeGenerator::createActivationIfNecessary()
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
index 71404c9..2667f7e 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
@@ -497,15 +497,16 @@
RegisterID* newRegister();
// Adds a var slot and maps it to the name ident in symbolTable().
- RegisterID* addVar(const Identifier& ident, bool isConstant)
+ enum WatchMode { IsWatchable, NotWatchable };
+ RegisterID* addVar(const Identifier& ident, ConstantMode constantMode, WatchMode watchMode)
{
RegisterID* local;
- addVar(ident, isConstant, local);
+ addVar(ident, constantMode, watchMode, local);
return local;
}
// Ditto. Returns true if a new RegisterID was added, false if a pre-existing RegisterID was re-used.
- bool addVar(const Identifier&, bool isConstant, RegisterID*&);
+ bool addVar(const Identifier&, ConstantMode, WatchMode, RegisterID*&);
// Adds an anonymous var slot. To give this slot a name, add it to symbolTable().
RegisterID* addVar()
@@ -590,6 +591,16 @@
void createActivationIfNecessary();
RegisterID* createLazyRegisterIfNecessary(RegisterID*);
+ StringImpl* watchableVariable(int operand)
+ {
+ VirtualRegister reg(operand);
+ if (!reg.isLocal())
+ return 0;
+ if (static_cast<size_t>(reg.toLocal()) >= m_watchableVariables.size())
+ return 0;
+ return m_watchableVariables[reg.toLocal()];
+ }
+
Vector<UnlinkedInstruction, 0, UnsafeVectorOverflow> m_instructions;
bool m_shouldEmitDebugHooks;
@@ -609,6 +620,7 @@
RegisterID* m_activationRegister;
RegisterID* m_emptyValueRegister;
RegisterID* m_globalObjectRegister;
+ Vector<StringImpl*, 16> m_watchableVariables;
SegmentedVector<RegisterID, 32> m_constantPoolRegisters;
SegmentedVector<RegisterID, 32> m_calleeRegisters;
SegmentedVector<RegisterID, 32> m_parameters;
diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
index ebf53d9..02490d4 100644
--- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
+++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
@@ -263,6 +263,24 @@
Node* getLocal(VirtualRegister operand)
{
unsigned local = operand.toLocal();
+
+ if (local < m_localWatchpoints.size()) {
+ if (VariableWatchpointSet* set = m_localWatchpoints[local]) {
+ if (JSValue value = set->inferredValue()) {
+ addToGraph(FunctionReentryWatchpoint, OpInfo(m_codeBlock->symbolTable()));
+ addToGraph(VariableWatchpoint, OpInfo(set));
+ // Note: this is very special from an OSR exit standpoint. We wouldn't be
+ // able to do this for most locals, but it works here because we're dealing
+ // with a flushed local. For most locals we would need to issue a GetLocal
+ // here and ensure that we have uses in DFG IR wherever there would have
+ // been uses in bytecode. Clearly this optimization does not do this. But
+ // that's fine, because we don't need to track liveness for captured
+ // locals, and this optimization only kicks in for captured locals.
+ return inferredConstant(value);
+ }
+ }
+ }
+
Node* node = m_currentBlock->variablesAtTail.local(local);
bool isCaptured = m_codeBlock->isCaptured(operand, inlineCallFrame());
@@ -684,6 +702,13 @@
return result.iterator->value;
}
+ Node* inferredConstant(JSValue value)
+ {
+ if (value.isCell())
+ return cellConstant(value.asCell());
+ return getJSConstantForValue(value, 0);
+ }
+
InlineCallFrame* inlineCallFrame()
{
return m_inlineStackTop->m_inlineCallFrame;
@@ -1000,6 +1025,8 @@
HashMap<ConstantBufferKey, unsigned> m_constantBufferCache;
+ Vector<VariableWatchpointSet*, 16> m_localWatchpoints;
+
struct InlineStackEntry {
ByteCodeParser* m_byteCodeParser;
@@ -2145,12 +2172,21 @@
addToGraph(Breakpoint);
NEXT_OPCODE(op_debug);
#endif
- case op_mov:
- case op_captured_mov: {
+ case op_mov: {
Node* op = get(VirtualRegister(currentInstruction[2].u.operand));
set(VirtualRegister(currentInstruction[1].u.operand), op);
NEXT_OPCODE(op_mov);
}
+
+ case op_captured_mov: {
+ Node* op = get(VirtualRegister(currentInstruction[2].u.operand));
+ if (VariableWatchpointSet* set = currentInstruction[3].u.watchpointSet) {
+ if (set->state() != IsInvalidated)
+ addToGraph(NotifyWrite, OpInfo(set), op);
+ }
+ set(VirtualRegister(currentInstruction[1].u.operand), op);
+ NEXT_OPCODE(op_captured_mov);
+ }
case op_check_has_instance:
addToGraph(CheckHasInstance, get(VirtualRegister(currentInstruction[3].u.operand)));
@@ -3026,7 +3062,7 @@
case op_get_from_scope: {
int dst = currentInstruction[1].u.operand;
- unsigned scope = currentInstruction[2].u.operand;
+ int scope = currentInstruction[2].u.operand;
unsigned identifierNumber = m_inlineStackTop->m_identifierRemap[currentInstruction[3].u.operand];
StringImpl* uid = m_graph.identifiers()[identifierNumber];
ResolveType resolveType = ResolveModeAndType(currentInstruction[4].u.operand).type();
@@ -3077,15 +3113,27 @@
}
addToGraph(VariableWatchpoint, OpInfo(watchpointSet));
- if (specificValue.isCell())
- set(VirtualRegister(dst), cellConstant(specificValue.asCell()));
- else
- set(VirtualRegister(dst), getJSConstantForValue(specificValue, 0));
+ set(VirtualRegister(dst), inferredConstant(specificValue));
break;
}
case ClosureVar:
case ClosureVarWithVarInjectionChecks: {
Node* scopeNode = get(VirtualRegister(scope));
+ if (JSActivation* activation = m_graph.tryGetActivation(scopeNode)) {
+ SymbolTable* symbolTable = activation->symbolTable();
+ ConcurrentJITLocker locker(symbolTable->m_lock);
+ SymbolTable::Map::iterator iter = symbolTable->find(locker, uid);
+ ASSERT(iter != symbolTable->end(locker));
+ VariableWatchpointSet* watchpointSet = iter->value.watchpointSet();
+ if (watchpointSet) {
+ if (JSValue value = watchpointSet->inferredValue()) {
+ addToGraph(Phantom, scopeNode);
+ addToGraph(VariableWatchpoint, OpInfo(watchpointSet));
+ set(VirtualRegister(dst), inferredConstant(value));
+ break;
+ }
+ }
+ }
set(VirtualRegister(dst),
addToGraph(GetClosureVar, OpInfo(operand), OpInfo(prediction),
addToGraph(GetClosureRegisters, scopeNode)));
@@ -3226,8 +3274,7 @@
NEXT_OPCODE(op_get_argument_by_val);
}
- case op_new_func:
- case op_new_captured_func: {
+ case op_new_func: {
if (!currentInstruction[3].u.operand) {
set(VirtualRegister(currentInstruction[1].u.operand),
addToGraph(NewFunctionNoCheck, OpInfo(currentInstruction[2].u.operand)));
@@ -3241,6 +3288,15 @@
NEXT_OPCODE(op_new_func);
}
+ case op_new_captured_func: {
+ Node* function = addToGraph(
+ NewFunctionNoCheck, OpInfo(currentInstruction[2].u.operand));
+ if (VariableWatchpointSet* set = currentInstruction[3].u.watchpointSet)
+ addToGraph(NotifyWrite, OpInfo(set), function);
+ set(VirtualRegister(currentInstruction[1].u.operand), function);
+ NEXT_OPCODE(op_new_captured_func);
+ }
+
case op_new_func_exp: {
set(VirtualRegister(currentInstruction[1].u.operand),
addToGraph(NewFunctionExpression, OpInfo(currentInstruction[2].u.operand)));
@@ -3610,6 +3666,22 @@
// Set during construction.
ASSERT(!m_currentIndex);
+ if (m_codeBlock->captureCount()) {
+ SymbolTable* symbolTable = m_codeBlock->symbolTable();
+ ConcurrentJITLocker locker(symbolTable->m_lock);
+ SymbolTable::Map::iterator iter = symbolTable->begin(locker);
+ SymbolTable::Map::iterator end = symbolTable->end(locker);
+ for (; iter != end; ++iter) {
+ VariableWatchpointSet* set = iter->value.watchpointSet();
+ if (!set)
+ continue;
+ size_t index = static_cast<size_t>(VirtualRegister(iter->value.getIndex()).toLocal());
+ while (m_localWatchpoints.size() <= index)
+ m_localWatchpoints.append(nullptr);
+ m_localWatchpoints[index] = set;
+ }
+ }
+
InlineStackEntry inlineStackEntry(
this, m_codeBlock, m_profiledBlock, 0, 0, VirtualRegister(), VirtualRegister(),
m_codeBlock->numParameters(), CodeForCall);
diff --git a/Source/JavaScriptCore/dfg/DFGGraph.cpp b/Source/JavaScriptCore/dfg/DFGGraph.cpp
index 75f2b5f..a3581ed 100644
--- a/Source/JavaScriptCore/dfg/DFGGraph.cpp
+++ b/Source/JavaScriptCore/dfg/DFGGraph.cpp
@@ -723,11 +723,16 @@
return std::max(frameRegisterCount(), requiredRegisterCountForExit());
}
-WriteBarrierBase<Unknown>* Graph::tryGetRegisters(Node* node)
+JSActivation* Graph::tryGetActivation(Node* node)
{
if (!node->hasConstant())
return 0;
- JSActivation* activation = jsDynamicCast<JSActivation*>(valueOfJSConstant(node));
+ return jsDynamicCast<JSActivation*>(valueOfJSConstant(node));
+}
+
+WriteBarrierBase<Unknown>* Graph::tryGetRegisters(Node* node)
+{
+ JSActivation* activation = tryGetActivation(node);
if (!activation)
return 0;
if (!activation->isTornOff())
diff --git a/Source/JavaScriptCore/dfg/DFGGraph.h b/Source/JavaScriptCore/dfg/DFGGraph.h
index de01c33..31ee5b0 100644
--- a/Source/JavaScriptCore/dfg/DFGGraph.h
+++ b/Source/JavaScriptCore/dfg/DFGGraph.h
@@ -791,6 +791,7 @@
unsigned requiredRegisterCountForExit();
unsigned requiredRegisterCountForExecutionAndExit();
+ JSActivation* tryGetActivation(Node*);
WriteBarrierBase<Unknown>* tryGetRegisters(Node*);
VM& m_vm;
diff --git a/Source/JavaScriptCore/jit/JIT.cpp b/Source/JavaScriptCore/jit/JIT.cpp
index 791ea00..ab68080 100644
--- a/Source/JavaScriptCore/jit/JIT.cpp
+++ b/Source/JavaScriptCore/jit/JIT.cpp
@@ -226,7 +226,7 @@
DEFINE_OP(op_loop_hint)
DEFINE_OP(op_lshift)
DEFINE_OP(op_mod)
- case op_captured_mov:
+ DEFINE_OP(op_captured_mov)
DEFINE_OP(op_mov)
DEFINE_OP(op_mul)
DEFINE_OP(op_negate)
@@ -235,8 +235,8 @@
DEFINE_OP(op_new_array)
DEFINE_OP(op_new_array_with_size)
DEFINE_OP(op_new_array_buffer)
- case op_new_captured_func:
DEFINE_OP(op_new_func)
+ DEFINE_OP(op_new_captured_func)
DEFINE_OP(op_new_func_exp)
DEFINE_OP(op_new_object)
DEFINE_OP(op_new_regexp)
@@ -369,6 +369,7 @@
DEFINE_SLOWCASE_OP(op_construct)
DEFINE_SLOWCASE_OP(op_to_this)
DEFINE_SLOWCASE_OP(op_create_this)
+ DEFINE_SLOWCASE_OP(op_captured_mov)
DEFINE_SLOWCASE_OP(op_div)
DEFINE_SLOWCASE_OP(op_eq)
DEFINE_SLOWCASE_OP(op_get_callee)
diff --git a/Source/JavaScriptCore/jit/JIT.h b/Source/JavaScriptCore/jit/JIT.h
index 9d227c6..a7a137d 100644
--- a/Source/JavaScriptCore/jit/JIT.h
+++ b/Source/JavaScriptCore/jit/JIT.h
@@ -463,6 +463,7 @@
void emit_op_call(Instruction*);
void emit_op_call_eval(Instruction*);
void emit_op_call_varargs(Instruction*);
+ void emit_op_captured_mov(Instruction*);
void emit_op_catch(Instruction*);
void emit_op_construct(Instruction*);
void emit_op_get_callee(Instruction*);
@@ -515,6 +516,7 @@
void emit_op_new_array_with_size(Instruction*);
void emit_op_new_array_buffer(Instruction*);
void emit_op_new_func(Instruction*);
+ void emit_op_new_captured_func(Instruction*);
void emit_op_new_func_exp(Instruction*);
void emit_op_new_object(Instruction*);
void emit_op_new_regexp(Instruction*);
@@ -559,6 +561,7 @@
void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
+ void emitSlow_op_captured_mov(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_to_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_create_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
diff --git a/Source/JavaScriptCore/jit/JITOpcodes.cpp b/Source/JavaScriptCore/jit/JITOpcodes.cpp
index c6169b3..012f990 100644
--- a/Source/JavaScriptCore/jit/JITOpcodes.cpp
+++ b/Source/JavaScriptCore/jit/JITOpcodes.cpp
@@ -55,12 +55,20 @@
int dst = currentInstruction[1].u.operand;
int src = currentInstruction[2].u.operand;
- // Use simpler approach, since the DFG thinks that the last result register
- // is always set to the destination on every operation.
emitGetVirtualRegister(src, regT0);
emitPutVirtualRegister(dst);
}
+void JIT::emit_op_captured_mov(Instruction* currentInstruction)
+{
+ int dst = currentInstruction[1].u.operand;
+ int src = currentInstruction[2].u.operand;
+
+ emitGetVirtualRegister(src, regT0);
+ emitNotifyWrite(regT0, regT1, currentInstruction[3].u.watchpointSet);
+ emitPutVirtualRegister(dst);
+}
+
void JIT::emit_op_end(Instruction* currentInstruction)
{
RELEASE_ASSERT(returnValueGPR != callFrameRegister);
@@ -1171,6 +1179,12 @@
lazyJump.link(this);
}
+void JIT::emit_op_new_captured_func(Instruction* currentInstruction)
+{
+ JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_new_captured_func);
+ slowPathCall.call();
+}
+
void JIT::emit_op_new_func_exp(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
@@ -1212,6 +1226,16 @@
callOperation(operationNewArrayBufferWithProfile, dst, currentInstruction[4].u.arrayAllocationProfile, values, size);
}
+void JIT::emitSlow_op_captured_mov(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ VariableWatchpointSet* set = currentInstruction[3].u.watchpointSet;
+ if (!set || set->state() == IsInvalidated)
+ return;
+ linkSlowCase(iter);
+ JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_captured_mov);
+ slowPathCall.call();
+}
+
} // namespace JSC
#endif // ENABLE(JIT)
diff --git a/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp b/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
index 319f198..2b1423d 100644
--- a/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
+++ b/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
@@ -152,7 +152,7 @@
{
int dst = currentInstruction[1].u.operand;
int src = currentInstruction[2].u.operand;
-
+
if (m_codeBlock->isConstantRegisterIndex(src))
emitStore(dst, getConstantOperand(src));
else {
@@ -161,6 +161,16 @@
}
}
+void JIT::emit_op_captured_mov(Instruction* currentInstruction)
+{
+ int dst = currentInstruction[1].u.operand;
+ int src = currentInstruction[2].u.operand;
+
+ emitLoad(src, regT1, regT0);
+ emitNotifyWrite(regT1, regT0, regT2, currentInstruction[3].u.watchpointSet);
+ emitStore(dst, regT1, regT0);
+}
+
void JIT::emit_op_end(Instruction* currentInstruction)
{
ASSERT(returnValueGPR != callFrameRegister);
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
index 38348cb..e33ade1 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
@@ -670,14 +670,43 @@
dispatch(3)
+macro notifyWrite(set, valueTag, valuePayload, scratch, slow)
+ loadb VariableWatchpointSet::m_state[set], scratch
+ bieq scratch, IsInvalidated, .done
+ bineq scratch, ClearWatchpoint, .overwrite
+ storei valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set]
+ storei valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set]
+ storeb IsWatched, VariableWatchpointSet::m_state[set]
+ jmp .done
+
+.overwrite:
+ bineq valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set], .definitelyDifferent
+ bieq valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set], .done
+.definitelyDifferent:
+ btbnz VariableWatchpointSet::m_setIsNotEmpty[set], slow
+ storei EmptyValueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set]
+ storei 0, VariableWatchpointSet::m_inferredValue + PayloadOffset[set]
+ storeb IsInvalidated, VariableWatchpointSet::m_state[set]
+
+.done:
+end
+
_llint_op_captured_mov:
traceExecution()
loadi 8[PC], t1
- loadi 4[PC], t0
loadConstantOrVariable(t1, t2, t3)
+ loadpFromInstruction(3, t0)
+ btpz t0, .opCapturedMovReady
+ notifyWrite(t0, t2, t3, t1, .opCapturedMovSlow)
+.opCapturedMovReady:
+ loadi 4[PC], t0
storei t2, TagOffset[cfr, t0, 8]
storei t3, PayloadOffset[cfr, t0, 8]
- dispatch(3)
+ dispatch(4)
+
+.opCapturedMovSlow:
+ callSlowPath(_slow_path_captured_mov)
+ dispatch(4)
_llint_op_not:
@@ -1802,12 +1831,7 @@
_llint_op_new_captured_func:
traceExecution()
- btiz 12[PC], .opNewCapturedFuncUnchecked
- loadi 4[PC], t1
- bineq TagOffset[cfr, t1, 8], EmptyValueTag, .opNewCapturedFuncDone
-.opNewCapturedFuncUnchecked:
- callSlowPath(_llint_slow_path_new_func)
-.opNewCapturedFuncDone:
+ callSlowPath(_slow_path_new_captured_func)
dispatch(4)
@@ -2281,27 +2305,6 @@
storePropertyAtVariableOffset(t1, t0, t2, t3)
end
-macro notifyWrite(set, valueTag, valuePayload, scratch, slow)
- loadb VariableWatchpointSet::m_state[set], scratch
- bieq scratch, IsInvalidated, .done
- bineq scratch, ClearWatchpoint, .overwrite
- storei valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set]
- storei valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set]
- storeb IsWatched, VariableWatchpointSet::m_state[set]
- jmp .done
-
-.overwrite:
- bineq valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set], .definitelyDifferent
- bieq valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set], .done
-.definitelyDifferent:
- btbnz VariableWatchpointSet::m_setIsNotEmpty[set], slow
- storei EmptyValueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set]
- storei 0, VariableWatchpointSet::m_inferredValue + PayloadOffset[set]
- storeb IsInvalidated, VariableWatchpointSet::m_state[set]
-
-.done:
-end
-
macro putGlobalVar()
loadisFromInstruction(3, t0)
loadConstantOrVariable(t0, t1, t2)
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
index 9da9561..bde3cc0 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
@@ -502,13 +502,38 @@
dispatch(3)
+macro notifyWrite(set, value, scratch, slow)
+ loadb VariableWatchpointSet::m_state[set], scratch
+ bieq scratch, IsInvalidated, .done
+ bineq scratch, ClearWatchpoint, .overwrite
+ storeq value, VariableWatchpointSet::m_inferredValue[set]
+ storeb IsWatched, VariableWatchpointSet::m_state[set]
+ jmp .done
+
+.overwrite:
+ bqeq value, VariableWatchpointSet::m_inferredValue[set], .done
+ btbnz VariableWatchpointSet::m_setIsNotEmpty[set], slow
+ storeq 0, VariableWatchpointSet::m_inferredValue[set]
+ storeb IsInvalidated, VariableWatchpointSet::m_state[set]
+
+.done:
+end
+
_llint_op_captured_mov:
traceExecution()
loadisFromInstruction(2, t1)
- loadisFromInstruction(1, t0)
loadConstantOrVariable(t1, t2)
+ loadpFromInstruction(3, t0)
+ btpz t0, .opCapturedMovReady
+ notifyWrite(t0, t2, t1, .opCapturedMovSlow)
+.opCapturedMovReady:
+ loadisFromInstruction(1, t0)
storeq t2, [cfr, t0, 8]
- dispatch(3)
+ dispatch(4)
+
+.opCapturedMovSlow:
+ callSlowPath(_slow_path_captured_mov)
+ dispatch(4)
_llint_op_not:
@@ -1609,13 +1634,7 @@
_llint_op_new_captured_func:
traceExecution()
- loadisFromInstruction(3, t2)
- btiz t2, .opNewCapturedFuncUnchecked
- loadisFromInstruction(1, t1)
- btqnz [cfr, t1, 8], .opNewCapturedFuncDone
-.opNewCapturedFuncUnchecked:
- callSlowPath(_llint_slow_path_new_func)
-.opNewCapturedFuncDone:
+ callSlowPath(_slow_path_new_captured_func)
dispatch(4)
@@ -2057,23 +2076,6 @@
storePropertyAtVariableOffset(t1, t0, t2)
end
-macro notifyWrite(set, value, scratch, slow)
- loadb VariableWatchpointSet::m_state[set], scratch
- bieq scratch, IsInvalidated, .done
- bineq scratch, ClearWatchpoint, .overwrite
- storeq value, VariableWatchpointSet::m_inferredValue[set]
- storeb IsWatched, VariableWatchpointSet::m_state[set]
- jmp .done
-
-.overwrite:
- bqeq value, VariableWatchpointSet::m_inferredValue[set], .done
- btbnz VariableWatchpointSet::m_setIsNotEmpty[set], slow
- storeq 0, VariableWatchpointSet::m_inferredValue[set]
- storeb IsInvalidated, VariableWatchpointSet::m_state[set]
-
-.done:
-end
-
macro putGlobalVar()
loadisFromInstruction(3, t0)
loadConstantOrVariable(t0, t1)
diff --git a/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp b/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
index 8504532..06d5431 100644
--- a/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
+++ b/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
@@ -244,6 +244,29 @@
RETURN(v1.toThis(exec, exec->codeBlock()->isStrictMode() ? StrictMode : NotStrictMode));
}
+SLOW_PATH_DECL(slow_path_captured_mov)
+{
+ BEGIN();
+ JSValue value = OP_C(2).jsValue();
+ if (VariableWatchpointSet* set = pc[3].u.watchpointSet)
+ set->notifyWrite(value);
+ RETURN(value);
+}
+
+SLOW_PATH_DECL(slow_path_new_captured_func)
+{
+ BEGIN();
+ CodeBlock* codeBlock = exec->codeBlock();
+ ASSERT(
+ codeBlock->codeType() != FunctionCode
+ || !codeBlock->needsFullScopeChain()
+ || exec->uncheckedR(codeBlock->activationRegister().offset()).jsValue());
+ JSValue value = JSFunction::create(vm, codeBlock->functionDecl(pc[2].u.operand), exec->scope());
+ if (VariableWatchpointSet* set = pc[3].u.watchpointSet)
+ set->notifyWrite(value);
+ RETURN(value);
+}
+
SLOW_PATH_DECL(slow_path_not)
{
BEGIN();
diff --git a/Source/JavaScriptCore/runtime/CommonSlowPaths.h b/Source/JavaScriptCore/runtime/CommonSlowPaths.h
index 6747fb0..8acbf9f 100644
--- a/Source/JavaScriptCore/runtime/CommonSlowPaths.h
+++ b/Source/JavaScriptCore/runtime/CommonSlowPaths.h
@@ -165,6 +165,8 @@
SLOW_PATH_HIDDEN_DECL(slow_path_create_this);
SLOW_PATH_HIDDEN_DECL(slow_path_get_callee);
SLOW_PATH_HIDDEN_DECL(slow_path_to_this);
+SLOW_PATH_HIDDEN_DECL(slow_path_captured_mov);
+SLOW_PATH_HIDDEN_DECL(slow_path_new_captured_func);
SLOW_PATH_HIDDEN_DECL(slow_path_not);
SLOW_PATH_HIDDEN_DECL(slow_path_eq);
SLOW_PATH_HIDDEN_DECL(slow_path_neq);
diff --git a/Source/JavaScriptCore/runtime/ConstantMode.h b/Source/JavaScriptCore/runtime/ConstantMode.h
new file mode 100644
index 0000000..389a074
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/ConstantMode.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ConstantMode_h
+#define ConstantMode_h
+
+namespace JSC {
+
+enum ConstantMode { IsConstant, IsVariable };
+
+} // namespace JSC
+
+#endif // ConstantMode_h
+
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h
index 44c9049..3250d7c 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h
@@ -23,6 +23,7 @@
#define JSGlobalObject_h
#include "ArrayAllocationProfile.h"
+#include "ConstantMode.h"
#include "JSArray.h"
#include "JSArrayBufferPrototype.h"
#include "JSClassRef.h"
@@ -295,7 +296,6 @@
init(thisValue);
}
- enum ConstantMode { IsConstant, IsVariable };
struct NewGlobalVar {
int registerNumber;
VariableWatchpointSet* set;
diff --git a/Source/JavaScriptCore/runtime/JSScope.cpp b/Source/JavaScriptCore/runtime/JSScope.cpp
index 505da21..3440bc6 100644
--- a/Source/JavaScriptCore/runtime/JSScope.cpp
+++ b/Source/JavaScriptCore/runtime/JSScope.cpp
@@ -65,7 +65,7 @@
}
if (!entry.isNull()) {
- op = ResolveOp(makeType(ClosureVar, needsVarInjectionChecks), depth, 0, activation, 0, entry.getIndex());
+ op = ResolveOp(makeType(ClosureVar, needsVarInjectionChecks), depth, 0, activation, entry.watchpointSet(), entry.getIndex());
return true;
}
diff --git a/Source/JavaScriptCore/runtime/SymbolTable.cpp b/Source/JavaScriptCore/runtime/SymbolTable.cpp
index a2e15a2..556dbf7 100644
--- a/Source/JavaScriptCore/runtime/SymbolTable.cpp
+++ b/Source/JavaScriptCore/runtime/SymbolTable.cpp
@@ -68,7 +68,8 @@
void SymbolTableEntry::prepareToWatch()
{
FatEntry* entry = inflate();
- ASSERT(!entry->m_watchpoints);
+ if (entry->m_watchpoints)
+ return;
entry->m_watchpoints = adoptRef(new VariableWatchpointSet());
}