| 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 22 matching lines...) Expand all Loading... |
| 33 #include "prettyprinter.h" | 33 #include "prettyprinter.h" |
| 34 #include "scopeinfo.h" | 34 #include "scopeinfo.h" |
| 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), |
| 44 exit_(generator), |
| 43 statement_position_(masm_->last_statement_position()), | 45 statement_position_(masm_->last_statement_position()), |
| 44 position_(masm_->last_position()) { | 46 position_(masm_->last_position()) { |
| 45 generator->AddDeferred(this); | 47 generator->AddDeferred(this); |
| 46 #ifdef DEBUG | 48 #ifdef DEBUG |
| 47 comment_ = ""; | 49 comment_ = ""; |
| 48 #endif | 50 #endif |
| 49 } | 51 } |
| 50 | 52 |
| 51 | 53 |
| 52 void CodeGenerator::ProcessDeferred() { | 54 void CodeGenerator::ProcessDeferred() { |
| 53 while (!deferred_.is_empty()) { | 55 while (!deferred_.is_empty()) { |
| 54 DeferredCode* code = deferred_.RemoveLast(); | 56 DeferredCode* code = deferred_.RemoveLast(); |
| 55 MacroAssembler* masm = code->masm(); | 57 MacroAssembler* masm = code->masm(); |
| 56 // Record position of deferred code stub. | 58 // Record position of deferred code stub. |
| 57 if (code->statement_position() != RelocInfo::kNoPosition) { | 59 if (code->statement_position() != RelocInfo::kNoPosition) { |
| 58 masm->RecordStatementPosition(code->statement_position()); | 60 masm->RecordStatementPosition(code->statement_position()); |
| 59 } | 61 } |
| 60 if (code->position() != RelocInfo::kNoPosition) { | 62 if (code->position() != RelocInfo::kNoPosition) { |
| 61 masm->RecordPosition(code->position()); | 63 masm->RecordPosition(code->position()); |
| 62 } | 64 } |
| 63 // Bind labels and generate the code. | 65 // Bind labels and generate the code. |
| 64 masm->bind(code->enter()); | 66 code->enter()->Bind(); |
| 65 Comment cmnt(masm, code->comment()); | 67 Comment cmnt(masm, code->comment()); |
| 66 code->Generate(); | 68 code->Generate(); |
| 67 if (code->exit()->is_bound()) { | 69 if (code->exit()->is_bound()) { |
| 68 masm->jmp(code->exit()); // platform independent? | 70 code->exit()->Jump(); |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 } | 73 } |
| 72 | 74 |
| 73 | 75 |
| 74 // Generate the code. Takes a function literal, generates code for it, assemble | 76 // Generate the code. Takes a function literal, generates code for it, assemble |
| 75 // all the pieces into a Code object. This function is only to be called by | 77 // all the pieces into a Code object. This function is only to be called by |
| 76 // the compiler.cc code. | 78 // the compiler.cc code. |
| 77 Handle<Code> CodeGenerator::MakeCode(FunctionLiteral* flit, | 79 Handle<Code> CodeGenerator::MakeCode(FunctionLiteral* flit, |
| 78 Handle<Script> script, | 80 Handle<Script> script, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 117 |
| 116 // Generate code. | 118 // Generate code. |
| 117 const int initial_buffer_size = 4 * KB; | 119 const int initial_buffer_size = 4 * KB; |
| 118 CodeGenerator cgen(initial_buffer_size, script, is_eval); | 120 CodeGenerator cgen(initial_buffer_size, script, is_eval); |
| 119 cgen.GenCode(flit); | 121 cgen.GenCode(flit); |
| 120 if (cgen.HasStackOverflow()) { | 122 if (cgen.HasStackOverflow()) { |
| 121 ASSERT(!Top::has_pending_exception()); | 123 ASSERT(!Top::has_pending_exception()); |
| 122 return Handle<Code>::null(); | 124 return Handle<Code>::null(); |
| 123 } | 125 } |
| 124 | 126 |
| 125 // Process any deferred code. | |
| 126 cgen.ProcessDeferred(); | |
| 127 | |
| 128 // Allocate and install the code. | 127 // Allocate and install the code. |
| 129 CodeDesc desc; | 128 CodeDesc desc; |
| 130 cgen.masm()->GetCode(&desc); | 129 cgen.masm()->GetCode(&desc); |
| 131 ScopeInfo<> sinfo(flit->scope()); | 130 ScopeInfo<> sinfo(flit->scope()); |
| 132 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); | 131 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); |
| 133 Handle<Code> code = Factory::NewCode(desc, &sinfo, flags); | 132 Handle<Code> code = Factory::NewCode(desc, &sinfo, flags); |
| 134 | 133 |
| 135 // Add unresolved entries in the code to the fixup list. | 134 // Add unresolved entries in the code to the fixup list. |
| 136 Bootstrapper::AddFixup(*code, cgen.masm()); | 135 Bootstrapper::AddFixup(*code, cgen.masm()); |
| 137 | 136 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { | 490 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { |
| 492 switch (type_) { | 491 switch (type_) { |
| 493 case READ_LENGTH: GenerateReadLength(masm); break; | 492 case READ_LENGTH: GenerateReadLength(masm); break; |
| 494 case READ_ELEMENT: GenerateReadElement(masm); break; | 493 case READ_ELEMENT: GenerateReadElement(masm); break; |
| 495 case NEW_OBJECT: GenerateNewObject(masm); break; | 494 case NEW_OBJECT: GenerateNewObject(masm); break; |
| 496 } | 495 } |
| 497 } | 496 } |
| 498 | 497 |
| 499 | 498 |
| 500 } } // namespace v8::internal | 499 } } // namespace v8::internal |
| OLD | NEW |