Chromium Code Reviews| Index: src/lithium.cc |
| diff --git a/src/lithium.cc b/src/lithium.cc |
| index fd8b7965f1d7497cb1ae29fc05636a47be7a84a3..441d5b1ae610081d0922b316259b222d9e207106 100644 |
| --- a/src/lithium.cc |
| +++ b/src/lithium.cc |
| @@ -27,6 +27,20 @@ |
| #include "v8.h" |
| #include "lithium.h" |
| +#include "lithium-allocator.h" |
| +#include "lithium-allocator-inl.h" |
| + |
| +#if V8_TARGET_ARCH_IA32 |
| +#include "ia32/lithium-codegen-ia32.h" |
| +#elif V8_TARGET_ARCH_X64 |
| +#include "x64/lithium-codegen-x64.h" |
| +#elif V8_TARGET_ARCH_ARM |
| +#include "arm/lithium-codegen-arm.h" |
| +#elif V8_TARGET_ARCH_MIPS |
| +#include "mips/lithium-codegen-mips.h" |
| +#else |
| +#error Unsupported target architecture. |
| +#endif |
| namespace v8 { |
| namespace internal { |
| @@ -240,4 +254,46 @@ int ElementsKindToShiftSize(ElementsKind elements_kind) { |
| } |
| +LChunk* Lithium::CreateChunk(HGraph* graph, HGraphBuilder* graph_builder) { |
|
danno
2012/07/11 10:04:57
Again, adding a dependency on graph builder here i
|
| + int values = graph->GetMaximumValueID(); |
| + if (values > LUnallocated::kMaxVirtualRegisters) { |
| + graph_builder->Bailout("Not enough virtual registers for (values).\n"); |
| + return NULL; |
| + } |
| + LAllocator allocator(values, graph); |
| + LChunkBuilder builder(graph->info(), graph, &allocator); |
| + LChunk* chunk = builder.Build(); |
| + if (chunk == NULL) return NULL; |
| + |
| + if (!allocator.Allocate(chunk)) { |
| + graph_builder->Bailout("Not enough virtual registers (regalloc).\n"); |
| + return NULL; |
| + } |
| + |
| + return chunk; |
| +} |
| + |
| + |
| +Handle<Code> Lithium::Codegen(LChunk* chunk) { |
| + MacroAssembler assembler(chunk->info()->isolate(), NULL, 0); |
| + LCodeGen generator(chunk, &assembler, chunk->info()); |
| + |
| + chunk->MarkEmptyBlocks(); |
| + |
| + if (generator.GenerateCode()) { |
| + if (FLAG_trace_codegen) { |
| + PrintF("Crankshaft Compiler - "); |
| + } |
| + CodeGenerator::MakeCodePrologue(chunk->info()); |
| + Code::Flags flags = Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); |
| + Handle<Code> code = |
| + CodeGenerator::MakeCodeEpilogue(&assembler, flags, chunk->info()); |
| + generator.FinishCode(code); |
| + CodeGenerator::PrintCode(code, chunk->info()); |
| + return code; |
| + } |
| + return Handle<Code>::null(); |
| +} |
| + |
| + |
| } } // namespace v8::internal |