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

Side by Side Diff: src/lithium.cc

Issue 10701157: Rename LChunkBase to LChunk, LChunk to LPlatformChunk and remove some unneeded explicit constructor… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/lithium.h ('k') | src/lithium-allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 case FAST_HOLEY_ELEMENTS: 250 case FAST_HOLEY_ELEMENTS:
251 case DICTIONARY_ELEMENTS: 251 case DICTIONARY_ELEMENTS:
252 case NON_STRICT_ARGUMENTS_ELEMENTS: 252 case NON_STRICT_ARGUMENTS_ELEMENTS:
253 return kPointerSizeLog2; 253 return kPointerSizeLog2;
254 } 254 }
255 UNREACHABLE(); 255 UNREACHABLE();
256 return 0; 256 return 0;
257 } 257 }
258 258
259 259
260 LLabel* LChunkBase::GetLabel(int block_id) const { 260 LLabel* LChunk::GetLabel(int block_id) const {
261 HBasicBlock* block = graph_->blocks()->at(block_id); 261 HBasicBlock* block = graph_->blocks()->at(block_id);
262 int first_instruction = block->first_instruction_index(); 262 int first_instruction = block->first_instruction_index();
263 return LLabel::cast(instructions_[first_instruction]); 263 return LLabel::cast(instructions_[first_instruction]);
264 } 264 }
265 265
266 266
267 int LChunkBase::LookupDestination(int block_id) const { 267 int LChunk::LookupDestination(int block_id) const {
268 LLabel* cur = GetLabel(block_id); 268 LLabel* cur = GetLabel(block_id);
269 while (cur->replacement() != NULL) { 269 while (cur->replacement() != NULL) {
270 cur = cur->replacement(); 270 cur = cur->replacement();
271 } 271 }
272 return cur->block_id(); 272 return cur->block_id();
273 } 273 }
274 274
275 Label* LChunkBase::GetAssemblyLabel(int block_id) const { 275 Label* LChunk::GetAssemblyLabel(int block_id) const {
276 LLabel* label = GetLabel(block_id); 276 LLabel* label = GetLabel(block_id);
277 ASSERT(!label->HasReplacement()); 277 ASSERT(!label->HasReplacement());
278 return label->label(); 278 return label->label();
279 } 279 }
280 280
281 void LChunkBase::MarkEmptyBlocks() { 281 void LChunk::MarkEmptyBlocks() {
282 HPhase phase("L_Mark empty blocks", this); 282 HPhase phase("L_Mark empty blocks", this);
283 for (int i = 0; i < graph()->blocks()->length(); ++i) { 283 for (int i = 0; i < graph()->blocks()->length(); ++i) {
284 HBasicBlock* block = graph()->blocks()->at(i); 284 HBasicBlock* block = graph()->blocks()->at(i);
285 int first = block->first_instruction_index(); 285 int first = block->first_instruction_index();
286 int last = block->last_instruction_index(); 286 int last = block->last_instruction_index();
287 LInstruction* first_instr = instructions()->at(first); 287 LInstruction* first_instr = instructions()->at(first);
288 LInstruction* last_instr = instructions()->at(last); 288 LInstruction* last_instr = instructions()->at(last);
289 289
290 LLabel* label = LLabel::cast(first_instr); 290 LLabel* label = LLabel::cast(first_instr);
291 if (last_instr->IsGoto()) { 291 if (last_instr->IsGoto()) {
(...skipping 15 matching lines...) Expand all
307 307
308 if (can_eliminate) { 308 if (can_eliminate) {
309 label->set_replacement(GetLabel(goto_instr->block_id())); 309 label->set_replacement(GetLabel(goto_instr->block_id()));
310 } 310 }
311 } 311 }
312 } 312 }
313 } 313 }
314 } 314 }
315 315
316 316
317 void LChunkBase::AddInstruction(LInstruction* instr, HBasicBlock* block) { 317 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
318 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); 318 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block);
319 int index = -1; 319 int index = -1;
320 if (instr->IsControl()) { 320 if (instr->IsControl()) {
321 instructions_.Add(gap, zone()); 321 instructions_.Add(gap, zone());
322 index = instructions_.length(); 322 index = instructions_.length();
323 instructions_.Add(instr, zone()); 323 instructions_.Add(instr, zone());
324 } else { 324 } else {
325 index = instructions_.length(); 325 index = instructions_.length();
326 instructions_.Add(instr, zone()); 326 instructions_.Add(instr, zone());
327 instructions_.Add(gap, zone()); 327 instructions_.Add(gap, zone());
328 } 328 }
329 if (instr->HasPointerMap()) { 329 if (instr->HasPointerMap()) {
330 pointer_maps_.Add(instr->pointer_map(), zone()); 330 pointer_maps_.Add(instr->pointer_map(), zone());
331 instr->pointer_map()->set_lithium_position(index); 331 instr->pointer_map()->set_lithium_position(index);
332 } 332 }
333 } 333 }
334 334
335 335
336 LConstantOperand* LChunkBase::DefineConstantOperand(HConstant* constant) { 336 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
337 return LConstantOperand::Create(constant->id(), zone()); 337 return LConstantOperand::Create(constant->id(), zone());
338 } 338 }
339 339
340 340
341 int LChunkBase::GetParameterStackSlot(int index) const { 341 int LChunk::GetParameterStackSlot(int index) const {
342 // The receiver is at index 0, the first parameter at index 1, so we 342 // The receiver is at index 0, the first parameter at index 1, so we
343 // shift all parameter indexes down by the number of parameters, and 343 // shift all parameter indexes down by the number of parameters, and
344 // make sure they end up negative so they are distinguishable from 344 // make sure they end up negative so they are distinguishable from
345 // spill slots. 345 // spill slots.
346 int result = index - info()->scope()->num_parameters() - 1; 346 int result = index - info()->scope()->num_parameters() - 1;
347 ASSERT(result < 0); 347 ASSERT(result < 0);
348 return result; 348 return result;
349 } 349 }
350 350
351 351
352 // A parameter relative to ebp in the arguments stub. 352 // A parameter relative to ebp in the arguments stub.
353 int LChunkBase::ParameterAt(int index) { 353 int LChunk::ParameterAt(int index) {
354 ASSERT(-1 <= index); // -1 is the receiver. 354 ASSERT(-1 <= index); // -1 is the receiver.
355 return (1 + info()->scope()->num_parameters() - index) * 355 return (1 + info()->scope()->num_parameters() - index) *
356 kPointerSize; 356 kPointerSize;
357 } 357 }
358 358
359 359
360 LGap* LChunkBase::GetGapAt(int index) const { 360 LGap* LChunk::GetGapAt(int index) const {
361 return LGap::cast(instructions_[index]); 361 return LGap::cast(instructions_[index]);
362 } 362 }
363 363
364 364
365 bool LChunkBase::IsGapAt(int index) const { 365 bool LChunk::IsGapAt(int index) const {
366 return instructions_[index]->IsGap(); 366 return instructions_[index]->IsGap();
367 } 367 }
368 368
369 369
370 int LChunkBase::NearestGapPos(int index) const { 370 int LChunk::NearestGapPos(int index) const {
371 while (!IsGapAt(index)) index--; 371 while (!IsGapAt(index)) index--;
372 return index; 372 return index;
373 } 373 }
374 374
375 375
376 void LChunkBase::AddGapMove(int index, LOperand* from, LOperand* to) { 376 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
377 GetGapAt(index)->GetOrCreateParallelMove( 377 GetGapAt(index)->GetOrCreateParallelMove(
378 LGap::START, zone())->AddMove(from, to, zone()); 378 LGap::START, zone())->AddMove(from, to, zone());
379 } 379 }
380 380
381 381
382 HConstant* LChunkBase::LookupConstant(LConstantOperand* operand) const { 382 HConstant* LChunk::LookupConstant(LConstantOperand* operand) const {
383 return HConstant::cast(graph_->LookupValue(operand->index())); 383 return HConstant::cast(graph_->LookupValue(operand->index()));
384 } 384 }
385 385
386 386
387 Representation LChunkBase::LookupLiteralRepresentation( 387 Representation LChunk::LookupLiteralRepresentation(
388 LConstantOperand* operand) const { 388 LConstantOperand* operand) const {
389 return graph_->LookupValue(operand->index())->representation(); 389 return graph_->LookupValue(operand->index())->representation();
390 } 390 }
391 391
392 392
393 LChunkBase* LChunkBase::NewChunk(HGraph* graph) { 393 LChunk* LChunk::NewChunk(HGraph* graph) {
394 int values = graph->GetMaximumValueID(); 394 int values = graph->GetMaximumValueID();
395 if (values > LUnallocated::kMaxVirtualRegisters) { 395 if (values > LUnallocated::kMaxVirtualRegisters) {
396 if (FLAG_trace_bailout) { 396 if (FLAG_trace_bailout) {
397 PrintF("Not enough virtual registers for (values).\n"); 397 PrintF("Not enough virtual registers for (values).\n");
398 } 398 }
399 return NULL; 399 return NULL;
400 } 400 }
401 LAllocator allocator(values, graph); 401 LAllocator allocator(values, graph);
402 LChunkBuilder builder(graph->info(), graph, &allocator); 402 LChunkBuilder builder(graph->info(), graph, &allocator);
403 LChunkBase* chunk = builder.Build(); 403 LChunk* chunk = builder.Build();
404 if (chunk == NULL) return NULL; 404 if (chunk == NULL) return NULL;
405 405
406 if (!allocator.Allocate(chunk)) { 406 if (!allocator.Allocate(chunk)) {
407 if (FLAG_trace_bailout) { 407 if (FLAG_trace_bailout) {
408 PrintF("Not enough virtual registers (regalloc).\n"); 408 PrintF("Not enough virtual registers (regalloc).\n");
409 } 409 }
410 return NULL; 410 return NULL;
411 } 411 }
412 412
413 return chunk; 413 return chunk;
414 } 414 }
415 415
416 416
417 Handle<Code> LChunkBase::Codegen() { 417 Handle<Code> LChunk::Codegen() {
418 MacroAssembler assembler(info()->isolate(), NULL, 0); 418 MacroAssembler assembler(info()->isolate(), NULL, 0);
419 LCodeGen generator(this, &assembler, info()); 419 LCodeGen generator(this, &assembler, info());
420 420
421 MarkEmptyBlocks(); 421 MarkEmptyBlocks();
422 422
423 if (generator.GenerateCode()) { 423 if (generator.GenerateCode()) {
424 if (FLAG_trace_codegen) { 424 if (FLAG_trace_codegen) {
425 PrintF("Crankshaft Compiler - "); 425 PrintF("Crankshaft Compiler - ");
426 } 426 }
427 CodeGenerator::MakeCodePrologue(info()); 427 CodeGenerator::MakeCodePrologue(info());
428 Code::Flags flags = Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); 428 Code::Flags flags = Code::ComputeFlags(Code::OPTIMIZED_FUNCTION);
429 Handle<Code> code = 429 Handle<Code> code =
430 CodeGenerator::MakeCodeEpilogue(&assembler, flags, info()); 430 CodeGenerator::MakeCodeEpilogue(&assembler, flags, info());
431 generator.FinishCode(code); 431 generator.FinishCode(code);
432 CodeGenerator::PrintCode(code, info()); 432 CodeGenerator::PrintCode(code, info());
433 return code; 433 return code;
434 } 434 }
435 return Handle<Code>::null(); 435 return Handle<Code>::null();
436 } 436 }
437 437
438 438
439 } } // namespace v8::internal 439 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium.h ('k') | src/lithium-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698