Reviewers: Yang,

Description:
Merged r17425, r17428 into trunk branch.

Temporarily allow HistogramTimerScopes to be nested

ia32: Fix comparisons of two constant double operands when exactly one of them
is in new space.

[email protected]

Please review this at https://codereview.chromium.org/50463003/

SVN Base: https://v8.googlecode.com/svn/trunk

Affected files (+65, -15 lines):
  M src/counters.h
  M src/ia32/lithium-ia32.cc
  M src/parser.cc
  M src/version.cc
  A + test/mjsunit/regress/regress-compare-constant-doubles.js


Index: src/counters.h
diff --git a/src/counters.h b/src/counters.h
index 93911d721615dfd81e3198cd70074927a4cfa01f..821c25f8cec1c2a3391ddcc297a22e731b6552fb 100644
--- a/src/counters.h
+++ b/src/counters.h
@@ -259,22 +259,51 @@ class HistogramTimer : public Histogram {
     return Enabled() && timer_.IsStarted();
   }

+  // TODO(bmeurer): Remove this when HistogramTimerScope is fixed.
+#ifdef DEBUG
+  ElapsedTimer* timer() { return &timer_; }
+#endif
+
  private:
   ElapsedTimer timer_;
 };

 // Helper class for scoping a HistogramTimer.
+// TODO(bmeurer): The ifdeffery is an ugly hack around the fact that the
+// Parser is currently reentrant (when it throws an error, we call back
+// into JavaScript and all bets are off), but ElapsedTimer is not
+// reentry-safe. Fix this properly and remove |allow_nesting|.
 class HistogramTimerScope BASE_EMBEDDED {
  public:
-  explicit HistogramTimerScope(HistogramTimer* timer) :
-  timer_(timer) {
+  explicit HistogramTimerScope(HistogramTimer* timer,
+                               bool allow_nesting = false)
+#ifdef DEBUG
+      : timer_(timer),
+        skipped_timer_start_(false) {
+    if (timer_->timer()->IsStarted() && allow_nesting) {
+      skipped_timer_start_ = true;
+    } else {
+      timer_->Start();
+    }
+#else
+      : timer_(timer) {
     timer_->Start();
+#endif
   }
   ~HistogramTimerScope() {
+#ifdef DEBUG
+    if (!skipped_timer_start_) {
+      timer_->Stop();
+    }
+#else
     timer_->Stop();
+#endif
   }
  private:
   HistogramTimer* timer_;
+#ifdef DEBUG
+  bool skipped_timer_start_;
+#endif
 };


Index: src/ia32/lithium-ia32.cc
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index 0800823fdb3e2401d9cda7c6d34eb26fa7f1500a..b4ebe6dea4ad1ba74d059f50d8487e4bcc5a565f 100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1728,9 +1728,12 @@ LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
     ASSERT(instr->right()->representation().IsDouble());
     LOperand* left;
     LOperand* right;
-    if (instr->left()->IsConstant() && instr->right()->IsConstant()) {
-      left = UseRegisterOrConstantAtStart(instr->left());
-      right = UseRegisterOrConstantAtStart(instr->right());
+    if (CanBeImmediateConstant(instr->left()) &&
+        CanBeImmediateConstant(instr->right())) {
+      // The code generator requires either both inputs to be constant
+      // operands, or neither.
+      left = UseConstant(instr->left());
+      right = UseConstant(instr->right());
     } else {
       left = UseRegisterAtStart(instr->left());
       right = UseRegisterAtStart(instr->right());
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index a17883fd456182865a90a1b76225ff02ae826ddb..d84649d86b268cb224d28c0a0115f2638f99582b 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -565,7 +565,9 @@ Parser::Parser(CompilationInfo* info)


 FunctionLiteral* Parser::ParseProgram() {
-  HistogramTimerScope timer_scope(isolate()->counters()->parse());
+  // TODO(bmeurer): We temporarily need to pass allow_nesting = true here,
+  // see comment for HistogramTimerScope class.
+  HistogramTimerScope timer_scope(isolate()->counters()->parse(), true);
   Handle<String> source(String::cast(script_->source()));
   isolate()->counters()->total_parse_size()->Increment(source->length());
   ElapsedTimer timer;
Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index ccd60b188da81754f41edec1d8ab83dd73134bee..aad4e5fa9317c5638d8219b8a00e908fe675f466 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     22
 #define BUILD_NUMBER      23
-#define PATCH_LEVEL       1
+#define PATCH_LEVEL       2
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
Index: test/mjsunit/regress/regress-compare-constant-doubles.js
diff --git a/test/mjsunit/constant-compare-nil-value.js b/test/mjsunit/regress/regress-compare-constant-doubles.js
similarity index 78%
copy from test/mjsunit/constant-compare-nil-value.js
copy to test/mjsunit/regress/regress-compare-constant-doubles.js
index 9f5b2adb063abc0c7920d8dee30edb7ee6eb1ff9..0f8ffe307d154178993da4db370c7201552504a7 100644
--- a/test/mjsunit/constant-compare-nil-value.js
+++ b/test/mjsunit/regress/regress-compare-constant-doubles.js
@@ -27,16 +27,32 @@

 // Flags: --allow-natives-syntax

-function inlined() {
-    return 1;
-}
+var left = 1.5;
+var right;
+
+var keepalive;

 function foo() {
-    if ((inlined() + 0.5) == null) return "null";
-    return "non-null";
+  // Fill XMM registers with cruft.
+  var a1 = Math.sin(1) + 10;
+  var a2 = a1 + 1;
+  var a3 = a2 + 1;
+  var a4 = a3 + 1;
+  var a5 = a4 + 1;
+  var a6 = a5 + 1;
+  keepalive = [a1, a2, a3, a4, a5, a6];
+
+  // Actual test.
+  if (left < right) return "ok";
+  return "bad";
+}
+
+function prepare(base) {
+  right = 0.5 * base;
 }

-assertEquals("non-null", foo());
-assertEquals("non-null", foo());
+prepare(21);
+assertEquals("ok", foo());
+assertEquals("ok", foo());
 %OptimizeFunctionOnNextCall(foo);
-assertEquals("non-null", foo());
+assertEquals("ok", foo());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to