OLD | NEW |
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // is safe as long as the unoptimized code has deoptimization | 304 // is safe as long as the unoptimized code has deoptimization |
305 // support. | 305 // support. |
306 ASSERT(FLAG_always_opt || code->optimizable()); | 306 ASSERT(FLAG_always_opt || code->optimizable()); |
307 ASSERT(info()->shared_info()->has_deoptimization_support()); | 307 ASSERT(info()->shared_info()->has_deoptimization_support()); |
308 | 308 |
309 if (FLAG_trace_hydrogen) { | 309 if (FLAG_trace_hydrogen) { |
310 PrintF("-----------------------------------------------------------\n"); | 310 PrintF("-----------------------------------------------------------\n"); |
311 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); | 311 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); |
312 HTracer::Instance()->TraceCompilation(info()->function()); | 312 HTracer::Instance()->TraceCompilation(info()->function()); |
313 } | 313 } |
314 Handle<Context> global_context( | 314 Handle<Context> native_context( |
315 info()->closure()->context()->global_context()); | 315 info()->closure()->context()->native_context()); |
316 oracle_ = new(info()->zone()) TypeFeedbackOracle( | 316 oracle_ = new(info()->zone()) TypeFeedbackOracle( |
317 code, global_context, info()->isolate(), info()->zone()); | 317 code, native_context, info()->isolate(), info()->zone()); |
318 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); | 318 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); |
319 HPhase phase(HPhase::kTotal); | 319 HPhase phase(HPhase::kTotal); |
320 graph_ = graph_builder_->CreateGraph(); | 320 graph_ = graph_builder_->CreateGraph(); |
321 | 321 |
322 if (info()->isolate()->has_pending_exception()) { | 322 if (info()->isolate()->has_pending_exception()) { |
323 info()->SetCode(Handle<Code>::null()); | 323 info()->SetCode(Handle<Code>::null()); |
324 return SetLastStatus(FAILED); | 324 return SetLastStatus(FAILED); |
325 } | 325 } |
326 | 326 |
327 // The function being compiled may have bailed out due to an inline | 327 // The function being compiled may have bailed out due to an inline |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 return succeeded; | 412 return succeeded; |
413 } | 413 } |
414 #endif | 414 #endif |
415 | 415 |
416 | 416 |
417 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { | 417 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { |
418 Isolate* isolate = info->isolate(); | 418 Isolate* isolate = info->isolate(); |
419 ZoneScope zone_scope(info->zone(), DELETE_ON_EXIT); | 419 ZoneScope zone_scope(info->zone(), DELETE_ON_EXIT); |
420 PostponeInterruptsScope postpone(isolate); | 420 PostponeInterruptsScope postpone(isolate); |
421 | 421 |
422 ASSERT(!isolate->global_context().is_null()); | 422 ASSERT(!isolate->native_context().is_null()); |
423 Handle<Script> script = info->script(); | 423 Handle<Script> script = info->script(); |
424 script->set_context_data((*isolate->global_context())->data()); | 424 script->set_context_data((*isolate->native_context())->data()); |
425 | 425 |
426 #ifdef ENABLE_DEBUGGER_SUPPORT | 426 #ifdef ENABLE_DEBUGGER_SUPPORT |
427 if (info->is_eval()) { | 427 if (info->is_eval()) { |
428 Script::CompilationType compilation_type = Script::COMPILATION_TYPE_EVAL; | 428 Script::CompilationType compilation_type = Script::COMPILATION_TYPE_EVAL; |
429 script->set_compilation_type(Smi::FromInt(compilation_type)); | 429 script->set_compilation_type(Smi::FromInt(compilation_type)); |
430 // For eval scripts add information on the function from which eval was | 430 // For eval scripts add information on the function from which eval was |
431 // called. | 431 // called. |
432 if (info->is_eval()) { | 432 if (info->is_eval()) { |
433 StackTraceFrameIterator it(isolate); | 433 StackTraceFrameIterator it(isolate); |
434 if (!it.done()) { | 434 if (!it.done()) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); | 729 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
730 } | 730 } |
731 | 731 |
732 | 732 |
733 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 733 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
734 Handle<Code> code = info->code(); | 734 Handle<Code> code = info->code(); |
735 Handle<JSFunction> function = info->closure(); | 735 Handle<JSFunction> function = info->closure(); |
736 if (FLAG_cache_optimized_code && code->kind() == Code::OPTIMIZED_FUNCTION) { | 736 if (FLAG_cache_optimized_code && code->kind() == Code::OPTIMIZED_FUNCTION) { |
737 Handle<SharedFunctionInfo> shared(function->shared()); | 737 Handle<SharedFunctionInfo> shared(function->shared()); |
738 Handle<FixedArray> literals(function->literals()); | 738 Handle<FixedArray> literals(function->literals()); |
739 Handle<Context> global_context(function->context()->global_context()); | 739 Handle<Context> native_context(function->context()->native_context()); |
740 SharedFunctionInfo::AddToOptimizedCodeMap( | 740 SharedFunctionInfo::AddToOptimizedCodeMap( |
741 shared, global_context, code, literals); | 741 shared, native_context, code, literals); |
742 } | 742 } |
743 } | 743 } |
744 | 744 |
745 | 745 |
746 static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) { | 746 static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) { |
747 if (FLAG_cache_optimized_code && info->IsOptimizing()) { | 747 if (FLAG_cache_optimized_code && info->IsOptimizing()) { |
748 Handle<SharedFunctionInfo> shared = info->shared_info(); | 748 Handle<SharedFunctionInfo> shared = info->shared_info(); |
749 Handle<JSFunction> function = info->closure(); | 749 Handle<JSFunction> function = info->closure(); |
750 ASSERT(!function.is_null()); | 750 ASSERT(!function.is_null()); |
751 Handle<Context> global_context(function->context()->global_context()); | 751 Handle<Context> native_context(function->context()->native_context()); |
752 int index = shared->SearchOptimizedCodeMap(*global_context); | 752 int index = shared->SearchOptimizedCodeMap(*native_context); |
753 if (index > 0) { | 753 if (index > 0) { |
754 if (FLAG_trace_opt) { | 754 if (FLAG_trace_opt) { |
755 PrintF("[found optimized code for: "); | 755 PrintF("[found optimized code for: "); |
756 function->PrintName(); | 756 function->PrintName(); |
757 PrintF(" / %" V8PRIxPTR "]\n", reinterpret_cast<intptr_t>(*function)); | 757 PrintF(" / %" V8PRIxPTR "]\n", reinterpret_cast<intptr_t>(*function)); |
758 } | 758 } |
759 // Caching of optimized code enabled and optimized code found. | 759 // Caching of optimized code enabled and optimized code found. |
760 shared->InstallFromOptimizedCodeMap(*function, index); | 760 shared->InstallFromOptimizedCodeMap(*function, index); |
761 return true; | 761 return true; |
762 } | 762 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 ASSERT(status == OptimizingCompiler::SUCCEEDED || | 886 ASSERT(status == OptimizingCompiler::SUCCEEDED || |
887 status == OptimizingCompiler::BAILED_OUT); | 887 status == OptimizingCompiler::BAILED_OUT); |
888 } | 888 } |
889 | 889 |
890 InstallCodeCommon(*info); | 890 InstallCodeCommon(*info); |
891 if (status == OptimizingCompiler::SUCCEEDED) { | 891 if (status == OptimizingCompiler::SUCCEEDED) { |
892 Handle<Code> code = info->code(); | 892 Handle<Code> code = info->code(); |
893 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty()); | 893 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty()); |
894 info->closure()->ReplaceCode(*code); | 894 info->closure()->ReplaceCode(*code); |
895 if (info->shared_info()->SearchOptimizedCodeMap( | 895 if (info->shared_info()->SearchOptimizedCodeMap( |
896 info->closure()->context()->global_context()) == -1) { | 896 info->closure()->context()->native_context()) == -1) { |
897 InsertCodeIntoOptimizedCodeMap(*info); | 897 InsertCodeIntoOptimizedCodeMap(*info); |
898 } | 898 } |
899 } else { | 899 } else { |
900 info->SetCode(Handle<Code>(info->shared_info()->code())); | 900 info->SetCode(Handle<Code>(info->shared_info()->code())); |
901 InstallFullCode(*info); | 901 InstallFullCode(*info); |
902 } | 902 } |
903 } | 903 } |
904 | 904 |
905 | 905 |
906 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 906 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 } | 1027 } |
1028 } | 1028 } |
1029 | 1029 |
1030 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1030 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1031 Handle<Script>(info->script()), | 1031 Handle<Script>(info->script()), |
1032 Handle<Code>(info->code()), | 1032 Handle<Code>(info->code()), |
1033 info)); | 1033 info)); |
1034 } | 1034 } |
1035 | 1035 |
1036 } } // namespace v8::internal | 1036 } } // namespace v8::internal |
OLD | NEW |