Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Unified Diff: src/hydrogen.cc

Issue 700963002: Replace C++ bitfields with our own BitFields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 31fcd4ca46549f5adc575766f2dce2ec90186da1..b72cd50e9ea432529df5003a2a68df158b8ad667 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -82,11 +82,11 @@ HBasicBlock::HBasicBlock(HGraph* graph)
deleted_phis_(4, graph->zone()),
parent_loop_header_(NULL),
inlined_entry_block_(NULL),
- is_inline_return_target_(false),
- is_reachable_(true),
- dominates_loop_successors_(false),
- is_osr_entry_(false),
- is_ordered_(false) { }
+ bit_field_(IsInlineReturnTargetField::encode(false) |
+ IsReachableField::encode(true) |
+ DominatesLoopSuccessorsField::encode(false) |
+ IsOsrEntryField::encode(false) |
+ IsOrderedField::encode(false)) {}
Isolate* HBasicBlock::isolate() const {
@@ -95,7 +95,7 @@ Isolate* HBasicBlock::isolate() const {
void HBasicBlock::MarkUnreachable() {
- is_reachable_ = false;
+ bit_field_ = IsReachableField::update(bit_field_, false);
}
@@ -748,18 +748,21 @@ bool HGraph::IsStandardConstant(HConstant* constant) {
}
-HGraphBuilder::IfBuilder::IfBuilder() : builder_(NULL), needs_compare_(true) {}
+HGraphBuilder::IfBuilder::IfBuilder()
+ : builder_(NULL), bit_field_(NeedsCompareField::encode(true)) {}
HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder)
- : needs_compare_(true) {
+ : bit_field_(NeedsCompareField::encode(true)) {
Initialize(builder);
}
HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder,
HIfContinuation* continuation)
- : needs_compare_(false), first_true_block_(NULL), first_false_block_(NULL) {
+ : bit_field_(NeedsCompareField::encode(false)),
+ first_true_block_(NULL),
+ first_false_block_(NULL) {
InitializeDontCreateBlocks(builder);
continuation->Continue(&first_true_block_, &first_false_block_);
}
@@ -768,14 +771,13 @@ HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder,
void HGraphBuilder::IfBuilder::InitializeDontCreateBlocks(
HGraphBuilder* builder) {
builder_ = builder;
- finished_ = false;
- did_then_ = false;
- did_else_ = false;
- did_else_if_ = false;
- did_and_ = false;
- did_or_ = false;
- captured_ = false;
- pending_merge_block_ = false;
+ bool needs_compare = NeedsCompareField::decode(bit_field_);
+ bit_field_ = FinishedField::encode(false) | DidThenField::encode(false) |
+ DidElseField::encode(false) | DidElseIfField::encode(false) |
+ DidAndField::encode(false) | DidOrField::encode(false) |
+ CapturedField::encode(false) |
+ NeedsCompareField::encode(needs_compare) |
+ PendingMergeBlockField::encode(false);
split_edge_merge_block_ = NULL;
merge_at_join_blocks_ = NULL;
normal_merge_at_join_block_count_ = 0;
@@ -793,15 +795,15 @@ void HGraphBuilder::IfBuilder::Initialize(HGraphBuilder* builder) {
HControlInstruction* HGraphBuilder::IfBuilder::AddCompare(
HControlInstruction* compare) {
- DCHECK(did_then_ == did_else_);
- if (did_else_) {
+ DCHECK(did_then() == did_else());
+ if (did_else()) {
// Handle if-then-elseif
- did_else_if_ = true;
- did_else_ = false;
- did_then_ = false;
- did_and_ = false;
- did_or_ = false;
- pending_merge_block_ = false;
+ set_did_else_if(true);
+ set_did_else(false);
+ set_did_then(false);
+ set_did_and(false);
+ set_did_or(false);
+ set_pending_merge_block(false);
split_edge_merge_block_ = NULL;
HEnvironment* env = builder()->environment();
first_true_block_ = builder()->CreateBasicBlock(env->Copy());
@@ -810,7 +812,7 @@ HControlInstruction* HGraphBuilder::IfBuilder::AddCompare(
if (split_edge_merge_block_ != NULL) {
HEnvironment* env = first_false_block_->last_environment();
HBasicBlock* split_edge = builder()->CreateBasicBlock(env->Copy());
- if (did_or_) {
+ if (did_or()) {
compare->SetSuccessorAt(0, split_edge);
compare->SetSuccessorAt(1, first_false_block_);
} else {
@@ -823,15 +825,15 @@ HControlInstruction* HGraphBuilder::IfBuilder::AddCompare(
compare->SetSuccessorAt(1, first_false_block_);
}
builder()->FinishCurrentBlock(compare);
- needs_compare_ = false;
+ set_needs_compare(false);
return compare;
}
void HGraphBuilder::IfBuilder::Or() {
- DCHECK(!needs_compare_);
- DCHECK(!did_and_);
- did_or_ = true;
+ DCHECK(!needs_compare());
+ DCHECK(!did_and());
+ set_did_or(true);
HEnvironment* env = first_false_block_->last_environment();
if (split_edge_merge_block_ == NULL) {
split_edge_merge_block_ = builder()->CreateBasicBlock(env->Copy());
@@ -844,9 +846,9 @@ void HGraphBuilder::IfBuilder::Or() {
void HGraphBuilder::IfBuilder::And() {
- DCHECK(!needs_compare_);
- DCHECK(!did_or_);
- did_and_ = true;
+ DCHECK(!needs_compare());
+ DCHECK(!did_or());
+ set_did_and(true);
HEnvironment* env = first_false_block_->last_environment();
if (split_edge_merge_block_ == NULL) {
split_edge_merge_block_ = builder()->CreateBasicBlock(env->Copy());
@@ -860,9 +862,9 @@ void HGraphBuilder::IfBuilder::And() {
void HGraphBuilder::IfBuilder::CaptureContinuation(
HIfContinuation* continuation) {
- DCHECK(!did_else_if_);
- DCHECK(!finished_);
- DCHECK(!captured_);
+ DCHECK(!did_else_if());
+ DCHECK(!finished());
+ DCHECK(!captured());
HBasicBlock* true_block = NULL;
HBasicBlock* false_block = NULL;
@@ -870,16 +872,16 @@ void HGraphBuilder::IfBuilder::CaptureContinuation(
DCHECK(true_block != NULL);
DCHECK(false_block != NULL);
continuation->Capture(true_block, false_block);
- captured_ = true;
+ set_captured();
builder()->set_current_block(NULL);
End();
}
void HGraphBuilder::IfBuilder::JoinContinuation(HIfContinuation* continuation) {
- DCHECK(!did_else_if_);
- DCHECK(!finished_);
- DCHECK(!captured_);
+ DCHECK(!did_else_if());
+ DCHECK(!finished());
+ DCHECK(!captured());
HBasicBlock* true_block = NULL;
HBasicBlock* false_block = NULL;
Finish(&true_block, &false_block);
@@ -892,16 +894,16 @@ void HGraphBuilder::IfBuilder::JoinContinuation(HIfContinuation* continuation) {
DCHECK(continuation->IsFalseReachable());
builder()->GotoNoSimulate(false_block, continuation->false_branch());
}
- captured_ = true;
+ set_captured();
End();
}
void HGraphBuilder::IfBuilder::Then() {
- DCHECK(!captured_);
- DCHECK(!finished_);
- did_then_ = true;
- if (needs_compare_) {
+ DCHECK(!captured());
+ DCHECK(!finished());
+ set_did_then(true);
+ if (needs_compare()) {
// Handle if's without any expressions, they jump directly to the "else"
// branch. However, we must pretend that the "then" branch is reachable,
// so that the graph builder visits it and sees any live range extending
@@ -914,23 +916,23 @@ void HGraphBuilder::IfBuilder::Then() {
builder()->FinishCurrentBlock(branch);
}
builder()->set_current_block(first_true_block_);
- pending_merge_block_ = true;
+ set_pending_merge_block(true);
}
void HGraphBuilder::IfBuilder::Else() {
- DCHECK(did_then_);
- DCHECK(!captured_);
- DCHECK(!finished_);
+ DCHECK(did_then());
+ DCHECK(!captured());
+ DCHECK(!finished());
AddMergeAtJoinBlock(false);
builder()->set_current_block(first_false_block_);
- pending_merge_block_ = true;
- did_else_ = true;
+ set_pending_merge_block(true);
+ set_did_else(true);
}
void HGraphBuilder::IfBuilder::Deopt(const char* reason) {
- DCHECK(did_then_);
+ DCHECK(did_then());
builder()->Add<HDeoptimize>(reason, Deoptimizer::EAGER);
AddMergeAtJoinBlock(true);
}
@@ -945,7 +947,7 @@ void HGraphBuilder::IfBuilder::Return(HValue* value) {
void HGraphBuilder::IfBuilder::AddMergeAtJoinBlock(bool deopt) {
- if (!pending_merge_block_) return;
+ if (!pending_merge_block()) return;
HBasicBlock* block = builder()->current_block();
DCHECK(block == NULL || !block->IsFinished());
MergeAtJoinBlock* record = new (builder()->zone())
@@ -960,21 +962,21 @@ void HGraphBuilder::IfBuilder::AddMergeAtJoinBlock(bool deopt) {
}
}
builder()->set_current_block(NULL);
- pending_merge_block_ = false;
+ set_pending_merge_block(false);
}
void HGraphBuilder::IfBuilder::Finish() {
- DCHECK(!finished_);
- if (!did_then_) {
+ DCHECK(!finished());
+ if (!did_then()) {
Then();
}
AddMergeAtJoinBlock(false);
- if (!did_else_) {
+ if (!did_else()) {
Else();
AddMergeAtJoinBlock(false);
}
- finished_ = true;
+ set_finished();
}
@@ -995,7 +997,7 @@ void HGraphBuilder::IfBuilder::Finish(HBasicBlock** then_continuation,
void HGraphBuilder::IfBuilder::End() {
- if (captured_) return;
+ if (captured()) return;
Finish();
int total_merged_blocks = normal_merge_at_join_block_count_ +

Powered by Google App Engine
This is Rietveld 408576698