Revision: 8736
Author: [email protected]
Date: Mon Jul 25 07:08:36 2011
Log: Record ToBoolean's type information in Hydrogen's HBranch
instruction, so we can use it in LCodeGen::DoBranch later.
Review URL: http://codereview.chromium.org/7491043
http://code.google.com/p/v8/source/detail?r=8736
Modified:
/branches/bleeding_edge/src/code-stubs.h
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
/branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
/branches/bleeding_edge/src/type-info.cc
/branches/bleeding_edge/src/type-info.h
=======================================
--- /branches/bleeding_edge/src/code-stubs.h Fri Jul 22 05:42:40 2011
+++ /branches/bleeding_edge/src/code-stubs.h Mon Jul 25 07:08:36 2011
@@ -932,6 +932,8 @@
private:
EnumSet<Type, byte> set_;
};
+
+ static Types no_types() { return Types(); }
explicit ToBooleanStub(Register tos, Types types = Types())
: tos_(tos), types_(types) { }
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon Jul 25 06:28:35
2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Mon Jul 25 07:08:36
2011
@@ -933,8 +933,12 @@
class HBranch: public HUnaryControlInstruction {
public:
- HBranch(HValue* value, HBasicBlock* true_target, HBasicBlock*
false_target)
- : HUnaryControlInstruction(value, true_target, false_target) {
+ HBranch(HValue* value,
+ HBasicBlock* true_target,
+ HBasicBlock* false_target,
+ ToBooleanStub::Types expected_input_types =
ToBooleanStub::no_types())
+ : HUnaryControlInstruction(value, true_target, false_target),
+ expected_input_types_(expected_input_types) {
ASSERT(true_target != NULL && false_target != NULL);
}
explicit HBranch(HValue* value)
@@ -944,8 +948,15 @@
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::None();
}
+
+ ToBooleanStub::Types expected_input_types() const {
+ return expected_input_types_;
+ }
DECLARE_CONCRETE_INSTRUCTION(Branch)
+
+ private:
+ ToBooleanStub::Types expected_input_types_;
};
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Jul 21 05:01:51 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Mon Jul 25 07:08:36 2011
@@ -2158,7 +2158,9 @@
}
HBasicBlock* empty_true = builder->graph()->CreateBasicBlock();
HBasicBlock* empty_false = builder->graph()->CreateBasicBlock();
- HBranch* test = new(zone()) HBranch(value, empty_true, empty_false);
+ unsigned test_id = condition()->test_id();
+ ToBooleanStub::Types
expected(builder->oracle()->ToBooleanTypes(test_id));
+ HBranch* test = new(zone()) HBranch(value, empty_true, empty_false,
expected);
builder->current_block()->Finish(test);
empty_true->Goto(if_true());
@@ -5504,9 +5506,11 @@
// We need an extra block to maintain edge-split form.
HBasicBlock* empty_block = graph()->CreateBasicBlock();
HBasicBlock* eval_right = graph()->CreateBasicBlock();
+ unsigned test_id = expr->left()->test_id();
+ ToBooleanStub::Types expected(oracle()->ToBooleanTypes(test_id));
HBranch* test = is_logical_and
- ? new(zone()) HBranch(Top(), eval_right, empty_block)
- : new(zone()) HBranch(Top(), empty_block, eval_right);
+ ? new(zone()) HBranch(Top(), eval_right, empty_block, expected)
+ : new(zone()) HBranch(Top(), empty_block, eval_right, expected);
current_block()->Finish(test);
set_current_block(eval_right);
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Tue Jul 5 06:21:29 2011
+++ /branches/bleeding_edge/src/hydrogen.h Mon Jul 25 07:08:36 2011
@@ -718,6 +718,8 @@
HBasicBlock* CreateJoin(HBasicBlock* first,
HBasicBlock* second,
int join_id);
+
+ TypeFeedbackOracle* oracle() const { return function_state()->oracle(); }
private:
// Type of a member function that generates inline code for a native
function.
@@ -747,7 +749,6 @@
CompilationInfo* info() const {
return function_state()->compilation_info();
}
- TypeFeedbackOracle* oracle() const { return function_state()->oracle(); }
AstContext* call_context() const {
return function_state()->call_context();
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Wed Jul 13
02:09:04 2011
+++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Mon Jul 25
07:08:36 2011
@@ -572,7 +572,7 @@
Label* fall_through) {
ToBooleanStub stub(result_register());
__ push(result_register());
- __ CallStub(&stub);
+ __ CallStub(&stub, condition->test_id());
__ test(result_register(), Operand(result_register()));
// The stub returns nonzero for true.
Split(not_zero, if_true, if_false, fall_through);
=======================================
--- /branches/bleeding_edge/src/type-info.cc Wed Jun 29 06:32:27 2011
+++ /branches/bleeding_edge/src/type-info.cc Mon Jul 25 07:08:36 2011
@@ -437,6 +437,12 @@
}
}
}
+
+
+byte TypeFeedbackOracle::ToBooleanTypes(unsigned ast_id) {
+ Handle<Object> object = GetInfo(ast_id);
+ return object->IsCode() ?
Handle<Code>::cast(object)->to_boolean_state() : 0;
+}
// Things are a bit tricky here: The iterator for the RelocInfos and the
infos
@@ -523,6 +529,7 @@
case Code::UNARY_OP_IC:
case Code::BINARY_OP_IC:
case Code::COMPARE_IC:
+ case Code::TO_BOOLEAN_IC:
SetInfo(ast_id, target);
break;
=======================================
--- /branches/bleeding_edge/src/type-info.h Tue Jul 12 01:03:19 2011
+++ /branches/bleeding_edge/src/type-info.h Mon Jul 25 07:08:36 2011
@@ -238,6 +238,11 @@
bool LoadIsBuiltin(Property* expr, Builtins::Name id);
+ // TODO(1571) We can't use ToBooleanStub::Types as the return value
because
+ // of various cylces in our headers. Death to tons of implementations in
+ // headers!! :-P
+ byte ToBooleanTypes(unsigned ast_id);
+
// Get type information for arithmetic operations and compares.
TypeInfo UnaryType(UnaryOperation* expr);
TypeInfo BinaryType(BinaryOperation* expr);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev