Fix to_boolean type feedback for unary and binary ops
authorolivf@chromium.org <olivf@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 25 Jun 2013 11:49:46 +0000 (11:49 +0000)
committerolivf@chromium.org <olivf@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 25 Jun 2013 11:49:46 +0000 (11:49 +0000)
BUG=
R=jkummerow@chromium.org, rossberg@chromium.org

Review URL: https://codereview.chromium.org/17444011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15319 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ast.cc
src/ast.h

index 21c38d5..589bd5a 100644 (file)
@@ -288,6 +288,16 @@ void TargetCollector::AddTarget(Label* target, Zone* zone) {
 }
 
 
+void UnaryOperation::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
+  // TODO(olivf) If this Operation is used in a test context, then the
+  // expression has a ToBoolean stub and we want to collect the type
+  // information. However the GraphBuilder expects it to be on the instruction
+  // corresponding to the TestContext, therefore we have to store it here and
+  // not on the operand.
+  set_to_boolean_types(oracle->ToBooleanTypes(expression()->test_id()));
+}
+
+
 bool UnaryOperation::ResultOverwriteAllowed() {
   switch (op_) {
     case Token::BIT_NOT:
@@ -299,6 +309,16 @@ bool UnaryOperation::ResultOverwriteAllowed() {
 }
 
 
+void BinaryOperation::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
+  // TODO(olivf) If this Operation is used in a test context, then the right
+  // hand side has a ToBoolean stub and we want to collect the type information.
+  // However the GraphBuilder expects it to be on the instruction corresponding
+  // to the TestContext, therefore we have to store it here and not on the
+  // right hand operand.
+  set_to_boolean_types(oracle->ToBooleanTypes(right()->test_id()));
+}
+
+
 bool BinaryOperation::ResultOverwriteAllowed() {
   switch (op_) {
     case Token::COMMA:
index 670c515..6336b3a 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -383,7 +383,7 @@ class Expression: public AstNode {
   }
 
   // TODO(rossberg): this should move to its own AST node eventually.
-  void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
+  virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
   byte to_boolean_types() const { return to_boolean_types_; }
 
   BailoutId id() const { return id_; }
@@ -395,6 +395,7 @@ class Expression: public AstNode {
         lower_type_(Type::None(), isolate),
         id_(GetNextId(isolate)),
         test_id_(GetNextId(isolate)) {}
+  void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
 
  private:
   Handle<Type> upper_type_;
@@ -1841,6 +1842,8 @@ class UnaryOperation: public Expression {
 
   TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); }
 
+  virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
+
  protected:
   UnaryOperation(Isolate* isolate,
                  Token::Value op,
@@ -1884,6 +1887,8 @@ class BinaryOperation: public Expression {
   Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
   void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
 
+  virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
+
  protected:
   BinaryOperation(Isolate* isolate,
                   Token::Value op,