| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 24 matching lines...) Expand all Loading... |
| 35 #include "runtime.h" | 35 #include "runtime.h" |
| 36 #include "stub-cache.h" | 36 #include "stub-cache.h" |
| 37 | 37 |
| 38 namespace v8 { namespace internal { | 38 namespace v8 { namespace internal { |
| 39 | 39 |
| 40 DeferredCode::DeferredCode(CodeGenerator* generator) | 40 DeferredCode::DeferredCode(CodeGenerator* generator) |
| 41 : masm_(generator->masm()), | 41 : masm_(generator->masm()), |
| 42 generator_(generator), | 42 generator_(generator), |
| 43 enter_(generator), | 43 enter_(generator), |
| 44 exit_(generator), | 44 exit_(generator), |
| 45 statement_position_(masm_->last_statement_position()), | 45 statement_position_(masm_->current_statement_position()), |
| 46 position_(masm_->last_position()) { | 46 position_(masm_->current_position()) { |
| 47 generator->AddDeferred(this); | 47 generator->AddDeferred(this); |
| 48 ASSERT(statement_position_ != RelocInfo::kNoPosition); |
| 49 ASSERT(position_ != RelocInfo::kNoPosition); |
| 48 #ifdef DEBUG | 50 #ifdef DEBUG |
| 49 comment_ = ""; | 51 comment_ = ""; |
| 50 #endif | 52 #endif |
| 51 } | 53 } |
| 52 | 54 |
| 53 | 55 |
| 54 void CodeGenerator::ProcessDeferred() { | 56 void CodeGenerator::ProcessDeferred() { |
| 55 while (!deferred_.is_empty()) { | 57 while (!deferred_.is_empty()) { |
| 56 DeferredCode* code = deferred_.RemoveLast(); | 58 DeferredCode* code = deferred_.RemoveLast(); |
| 57 MacroAssembler* masm = code->masm(); | 59 MacroAssembler* masm = code->masm(); |
| 58 // Record position of deferred code stub. | 60 // Record position of deferred code stub. |
| 59 if (code->statement_position() != RelocInfo::kNoPosition) { | 61 masm->RecordStatementPosition(code->statement_position()); |
| 60 masm->RecordStatementPosition(code->statement_position()); | |
| 61 } | |
| 62 if (code->position() != RelocInfo::kNoPosition) { | 62 if (code->position() != RelocInfo::kNoPosition) { |
| 63 masm->RecordPosition(code->position()); | 63 masm->RecordPosition(code->position()); |
| 64 } | 64 } |
| 65 // Bind labels and generate the code. | 65 // Bind labels and generate the code. |
| 66 code->enter()->Bind(); | 66 code->enter()->Bind(); |
| 67 frame_->SpillAll(); | 67 frame_->SpillAll(); |
| 68 Comment cmnt(masm, code->comment()); | 68 Comment cmnt(masm, code->comment()); |
| 69 code->Generate(); | 69 code->Generate(); |
| 70 if (code->exit()->is_bound()) { | 70 if (code->exit()->is_bound()) { |
| 71 code->exit()->Jump(); | 71 code->exit()->Jump(); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (range / FastCaseSwitchMaxOverheadFactor() > length) { | 471 if (range / FastCaseSwitchMaxOverheadFactor() > length) { |
| 472 return false; // range of labels is too sparse | 472 return false; // range of labels is too sparse |
| 473 } | 473 } |
| 474 | 474 |
| 475 // Optimization accepted, generate code. | 475 // Optimization accepted, generate code. |
| 476 GenerateFastCaseSwitchStatement(node, min_index, range, default_index); | 476 GenerateFastCaseSwitchStatement(node, min_index, range, default_index); |
| 477 return true; | 477 return true; |
| 478 } | 478 } |
| 479 | 479 |
| 480 | 480 |
| 481 void CodeGenerator::CodeForStatement(Node* node) { |
| 482 if (FLAG_debug_info) { |
| 483 int pos = node->statement_pos(); |
| 484 if (pos != RelocInfo::kNoPosition) { |
| 485 masm()->RecordStatementPosition(pos); |
| 486 CodeForSourcePosition(pos); |
| 487 } |
| 488 } |
| 489 } |
| 490 |
| 491 |
| 492 void CodeGenerator::CodeForSourcePosition(int pos) { |
| 493 if (FLAG_debug_info) { |
| 494 if (pos != RelocInfo::kNoPosition) { |
| 495 masm()->RecordPosition(pos); |
| 496 } |
| 497 } |
| 498 } |
| 499 |
| 500 |
| 481 const char* RuntimeStub::GetName() { | 501 const char* RuntimeStub::GetName() { |
| 482 return Runtime::FunctionForId(id_)->stub_name; | 502 return Runtime::FunctionForId(id_)->stub_name; |
| 483 } | 503 } |
| 484 | 504 |
| 485 | 505 |
| 486 void RuntimeStub::Generate(MacroAssembler* masm) { | 506 void RuntimeStub::Generate(MacroAssembler* masm) { |
| 487 masm->TailCallRuntime(ExternalReference(id_), num_arguments_); | 507 masm->TailCallRuntime(ExternalReference(id_), num_arguments_); |
| 488 } | 508 } |
| 489 | 509 |
| 490 | 510 |
| 491 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { | 511 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { |
| 492 switch (type_) { | 512 switch (type_) { |
| 493 case READ_LENGTH: GenerateReadLength(masm); break; | 513 case READ_LENGTH: GenerateReadLength(masm); break; |
| 494 case READ_ELEMENT: GenerateReadElement(masm); break; | 514 case READ_ELEMENT: GenerateReadElement(masm); break; |
| 495 case NEW_OBJECT: GenerateNewObject(masm); break; | 515 case NEW_OBJECT: GenerateNewObject(masm); break; |
| 496 } | 516 } |
| 497 } | 517 } |
| 498 | 518 |
| 499 | 519 |
| 500 } } // namespace v8::internal | 520 } } // namespace v8::internal |
| OLD | NEW |