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

Unified Diff: src/compiler/code-generator.cc

Issue 707803002: [turbofan] move label generation to code generator (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
« no previous file with comments | « src/compiler/code-generator.h ('k') | src/compiler/code-generator-impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/code-generator.cc
diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc
index 7ca27ce7596e90326b26bf574a4798ac8ca8bc9e..6b04eef62451abef4c491f28c567a333f7dbc487 100644
--- a/src/compiler/code-generator.cc
+++ b/src/compiler/code-generator.cc
@@ -18,6 +18,7 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
linkage_(linkage),
code_(code),
info_(info),
+ labels_(zone()->NewArray<Label>(code->InstructionBlockCount())),
current_block_(BasicBlock::RpoNumber::Invalid()),
current_source_position_(SourcePosition::Invalid()),
masm_(code->zone()->isolate(), NULL, 0),
@@ -26,7 +27,11 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
deoptimization_states_(code->zone()),
deoptimization_literals_(code->zone()),
translations_(code->zone()),
- last_lazy_deopt_pc_(0) {}
+ last_lazy_deopt_pc_(0) {
+ for (int i = 0; i < code->InstructionBlockCount(); ++i) {
+ new (&labels_[i]) Label;
+ }
+}
Handle<Code> CodeGenerator::GenerateCode() {
@@ -45,19 +50,24 @@ Handle<Code> CodeGenerator::GenerateCode() {
info->set_prologue_offset(masm()->pc_offset());
AssemblePrologue();
- // Assemble all non-deferred instructions.
- for (auto const block : code()->instruction_blocks()) {
- if (block->IsDeferred()) continue;
- for (int i = block->code_start(); i < block->code_end(); ++i) {
- AssembleInstruction(code()->InstructionAt(i));
- }
- }
-
- // Assemble all deferred instructions.
- for (auto const block : code()->instruction_blocks()) {
- if (!block->IsDeferred()) continue;
- for (int i = block->code_start(); i < block->code_end(); ++i) {
- AssembleInstruction(code()->InstructionAt(i));
+ // Assemble all non-deferred blocks, followed by deferred ones.
+ for (int deferred = 0; deferred < 2; ++deferred) {
+ for (auto const block : code()->instruction_blocks()) {
+ if (block->IsDeferred() == (deferred == 0)) {
+ continue;
+ }
+ // Bind a label for a block.
+ current_block_ = block->rpo_number();
+ if (FLAG_code_comments) {
+ // TODO(titzer): these code comments are a giant memory leak.
+ Vector<char> buffer = Vector<char>::New(32);
+ SNPrintF(buffer, "-- B%d start --", block->id().ToInt());
+ masm()->RecordComment(buffer.start());
+ }
+ masm()->bind(GetLabel(current_block_));
+ for (int i = block->code_start(); i < block->code_end(); ++i) {
+ AssembleInstruction(code()->InstructionAt(i));
+ }
}
}
@@ -120,18 +130,6 @@ void CodeGenerator::RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind,
void CodeGenerator::AssembleInstruction(Instruction* instr) {
- if (instr->IsBlockStart()) {
- // Bind a label for a block start and handle parallel moves.
- BlockStartInstruction* block_start = BlockStartInstruction::cast(instr);
- current_block_ = block_start->rpo_number();
- if (FLAG_code_comments) {
- // TODO(titzer): these code comments are a giant memory leak.
- Vector<char> buffer = Vector<char>::New(32);
- SNPrintF(buffer, "-- B%d start --", block_start->id().ToInt());
- masm()->RecordComment(buffer.start());
- }
- masm()->bind(block_start->label());
- }
if (instr->IsGapMoves()) {
// Handle parallel moves associated with the gap instruction.
AssembleGap(GapInstruction::cast(instr));
« no previous file with comments | « src/compiler/code-generator.h ('k') | src/compiler/code-generator-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698