| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
| 31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
| 32 #include "compiler.h" | 32 #include "compiler.h" |
| 33 #include "debug.h" | 33 #include "debug.h" |
| 34 #include "liveedit.h" |
| 34 #include "oprofile-agent.h" | 35 #include "oprofile-agent.h" |
| 35 #include "prettyprinter.h" | 36 #include "prettyprinter.h" |
| 36 #include "register-allocator-inl.h" | 37 #include "register-allocator-inl.h" |
| 37 #include "rewriter.h" | 38 #include "rewriter.h" |
| 38 #include "runtime.h" | 39 #include "runtime.h" |
| 39 #include "scopeinfo.h" | 40 #include "scopeinfo.h" |
| 40 #include "stub-cache.h" | 41 #include "stub-cache.h" |
| 41 | 42 |
| 42 namespace v8 { | 43 namespace v8 { |
| 43 namespace internal { | 44 namespace internal { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 Counters::total_compiled_code_size.Increment(code->instruction_size()); | 228 Counters::total_compiled_code_size.Increment(code->instruction_size()); |
| 228 } | 229 } |
| 229 return code; | 230 return code; |
| 230 } | 231 } |
| 231 | 232 |
| 232 | 233 |
| 233 // Generate the code. Takes a function literal, generates code for it, assemble | 234 // Generate the code. Takes a function literal, generates code for it, assemble |
| 234 // all the pieces into a Code object. This function is only to be called by | 235 // all the pieces into a Code object. This function is only to be called by |
| 235 // the compiler.cc code. | 236 // the compiler.cc code. |
| 236 Handle<Code> CodeGenerator::MakeCode(CompilationInfo* info) { | 237 Handle<Code> CodeGenerator::MakeCode(CompilationInfo* info) { |
| 238 LiveEditFunctionTracker live_edit_tracker(info->function()); |
| 237 Handle<Script> script = info->script(); | 239 Handle<Script> script = info->script(); |
| 238 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 240 if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
| 239 int len = String::cast(script->source())->length(); | 241 int len = String::cast(script->source())->length(); |
| 240 Counters::total_old_codegen_source_size.Increment(len); | 242 Counters::total_old_codegen_source_size.Increment(len); |
| 241 } | 243 } |
| 242 MakeCodePrologue(info); | 244 MakeCodePrologue(info); |
| 243 // Generate code. | 245 // Generate code. |
| 244 const int kInitialBufferSize = 4 * KB; | 246 const int kInitialBufferSize = 4 * KB; |
| 245 MacroAssembler masm(NULL, kInitialBufferSize); | 247 MacroAssembler masm(NULL, kInitialBufferSize); |
| 246 CodeGenerator cgen(&masm); | 248 CodeGenerator cgen(&masm); |
| 247 CodeGeneratorScope scope(&cgen); | 249 CodeGeneratorScope scope(&cgen); |
| 250 live_edit_tracker.RecordFunctionScope(info->function()->scope()); |
| 248 cgen.Generate(info, PRIMARY); | 251 cgen.Generate(info, PRIMARY); |
| 249 if (cgen.HasStackOverflow()) { | 252 if (cgen.HasStackOverflow()) { |
| 250 ASSERT(!Top::has_pending_exception()); | 253 ASSERT(!Top::has_pending_exception()); |
| 251 return Handle<Code>::null(); | 254 return Handle<Code>::null(); |
| 252 } | 255 } |
| 253 | 256 |
| 254 InLoopFlag in_loop = (cgen.loop_nesting() != 0) ? IN_LOOP : NOT_IN_LOOP; | 257 InLoopFlag in_loop = (cgen.loop_nesting() != 0) ? IN_LOOP : NOT_IN_LOOP; |
| 255 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, in_loop); | 258 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, in_loop); |
| 256 return MakeCodeEpilogue(cgen.masm(), flags, info); | 259 Handle<Code> result = MakeCodeEpilogue(cgen.masm(), flags, info); |
| 260 live_edit_tracker.RecordFunctionCode(result); |
| 261 return result; |
| 257 } | 262 } |
| 258 | 263 |
| 259 | 264 |
| 260 #ifdef ENABLE_LOGGING_AND_PROFILING | 265 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 261 | 266 |
| 262 bool CodeGenerator::ShouldGenerateLog(Expression* type) { | 267 bool CodeGenerator::ShouldGenerateLog(Expression* type) { |
| 263 ASSERT(type != NULL); | 268 ASSERT(type != NULL); |
| 264 if (!Logger::is_logging()) return false; | 269 if (!Logger::is_logging()) return false; |
| 265 Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle()); | 270 Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle()); |
| 266 if (FLAG_log_regexp) { | 271 if (FLAG_log_regexp) { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 523 } |
| 519 } | 524 } |
| 520 | 525 |
| 521 | 526 |
| 522 void ApiGetterEntryStub::SetCustomCache(Code* value) { | 527 void ApiGetterEntryStub::SetCustomCache(Code* value) { |
| 523 info()->set_load_stub_cache(value); | 528 info()->set_load_stub_cache(value); |
| 524 } | 529 } |
| 525 | 530 |
| 526 | 531 |
| 527 } } // namespace v8::internal | 532 } } // namespace v8::internal |
| OLD | NEW |