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

Side by Side Diff: src/compiler.cc

Issue 133443009: A64: Synchronize with r17441. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/compiler.h ('k') | src/contexts.cc » ('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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 Zone* zone) { 105 Zone* zone) {
106 isolate_ = isolate; 106 isolate_ = isolate;
107 function_ = NULL; 107 function_ = NULL;
108 scope_ = NULL; 108 scope_ = NULL;
109 global_scope_ = NULL; 109 global_scope_ = NULL;
110 extension_ = NULL; 110 extension_ = NULL;
111 pre_parse_data_ = NULL; 111 pre_parse_data_ = NULL;
112 zone_ = zone; 112 zone_ = zone;
113 deferred_handles_ = NULL; 113 deferred_handles_ = NULL;
114 code_stub_ = NULL; 114 code_stub_ = NULL;
115 prologue_offset_ = kPrologueOffsetNotSet; 115 prologue_offset_ = Code::kPrologueOffsetNotSet;
116 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); 116 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count();
117 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() 117 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling()
118 ? new List<OffsetRange>(2) : NULL; 118 ? new List<OffsetRange>(2) : NULL;
119 for (int i = 0; i < DependentCode::kGroupCount; i++) { 119 for (int i = 0; i < DependentCode::kGroupCount; i++) {
120 dependencies_[i] = NULL; 120 dependencies_[i] = NULL;
121 } 121 }
122 if (mode == STUB) { 122 if (mode == STUB) {
123 mode_ = STUB; 123 mode_ = STUB;
124 return; 124 return;
125 } 125 }
126 mode_ = isolate->use_crankshaft() ? mode : NONOPT; 126 mode_ = mode;
127 abort_due_to_dependency_ = false; 127 abort_due_to_dependency_ = false;
128 if (script_->type()->value() == Script::TYPE_NATIVE) { 128 if (script_->type()->value() == Script::TYPE_NATIVE) {
129 MarkAsNative(); 129 MarkAsNative();
130 } 130 }
131 if (!shared_info_.is_null()) { 131 if (!shared_info_.is_null()) {
132 ASSERT(language_mode() == CLASSIC_MODE); 132 ASSERT(language_mode() == CLASSIC_MODE);
133 SetLanguageMode(shared_info_->language_mode()); 133 SetLanguageMode(shared_info_->language_mode());
134 } 134 }
135 set_bailout_reason(kUnknown); 135 set_bailout_reason(kUnknown);
136 } 136 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 status = job.OptimizeGraph(); 306 status = job.OptimizeGraph();
307 if (status != RecompileJob::SUCCEEDED) { 307 if (status != RecompileJob::SUCCEEDED) {
308 status = job.AbortOptimization(); 308 status = job.AbortOptimization();
309 return status != RecompileJob::FAILED; 309 return status != RecompileJob::FAILED;
310 } 310 }
311 status = job.GenerateAndInstallCode(); 311 status = job.GenerateAndInstallCode();
312 return status != RecompileJob::FAILED; 312 return status != RecompileJob::FAILED;
313 } 313 }
314 314
315 315
316 class HOptimizedGraphBuilderWithPotisions: public HOptimizedGraphBuilder {
317 public:
318 explicit HOptimizedGraphBuilderWithPotisions(CompilationInfo* info)
319 : HOptimizedGraphBuilder(info) {
320 }
321
322 #define DEF_VISIT(type) \
323 virtual void Visit##type(type* node) V8_OVERRIDE { \
324 if (node->position() != RelocInfo::kNoPosition) { \
325 SetSourcePosition(node->position()); \
326 } \
327 HOptimizedGraphBuilder::Visit##type(node); \
328 }
329 EXPRESSION_NODE_LIST(DEF_VISIT)
330 #undef DEF_VISIT
331
332 #define DEF_VISIT(type) \
333 virtual void Visit##type(type* node) V8_OVERRIDE { \
334 if (node->position() != RelocInfo::kNoPosition) { \
335 SetSourcePosition(node->position()); \
336 } \
337 HOptimizedGraphBuilder::Visit##type(node); \
338 }
339 STATEMENT_NODE_LIST(DEF_VISIT)
340 #undef DEF_VISIT
341
342 #define DEF_VISIT(type) \
343 virtual void Visit##type(type* node) V8_OVERRIDE { \
344 HOptimizedGraphBuilder::Visit##type(node); \
345 }
346 MODULE_NODE_LIST(DEF_VISIT)
347 DECLARATION_NODE_LIST(DEF_VISIT)
348 AUXILIARY_NODE_LIST(DEF_VISIT)
349 #undef DEF_VISIT
350 };
351
352
316 RecompileJob::Status RecompileJob::CreateGraph() { 353 RecompileJob::Status RecompileJob::CreateGraph() {
317 ASSERT(isolate()->use_crankshaft()); 354 ASSERT(isolate()->use_crankshaft());
318 ASSERT(info()->IsOptimizing()); 355 ASSERT(info()->IsOptimizing());
319 ASSERT(!info()->IsCompilingForDebugging()); 356 ASSERT(!info()->IsCompilingForDebugging());
320 357
321 // We should never arrive here if there is no code object on the 358 // We should never arrive here if there is no code object on the
322 // shared function object. 359 // shared function object.
323 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION); 360 ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION);
324 361
325 if (FLAG_trace_opt) { 362 if (FLAG_trace_opt) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 if (FLAG_trace_hydrogen) { 458 if (FLAG_trace_hydrogen) {
422 Handle<String> name = info()->function()->debug_name(); 459 Handle<String> name = info()->function()->debug_name();
423 PrintF("-----------------------------------------------------------\n"); 460 PrintF("-----------------------------------------------------------\n");
424 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); 461 PrintF("Compiling method %s using hydrogen\n", *name->ToCString());
425 isolate()->GetHTracer()->TraceCompilation(info()); 462 isolate()->GetHTracer()->TraceCompilation(info());
426 } 463 }
427 464
428 // Type-check the function. 465 // Type-check the function.
429 AstTyper::Run(info()); 466 AstTyper::Run(info());
430 467
431 graph_builder_ = new(info()->zone()) HOptimizedGraphBuilder(info()); 468 graph_builder_ = FLAG_emit_opt_code_positions
469 ? new(info()->zone()) HOptimizedGraphBuilderWithPotisions(info())
470 : new(info()->zone()) HOptimizedGraphBuilder(info());
432 471
433 Timer t(this, &time_taken_to_create_graph_); 472 Timer t(this, &time_taken_to_create_graph_);
434 graph_ = graph_builder_->CreateGraph(); 473 graph_ = graph_builder_->CreateGraph();
435 474
436 if (isolate()->has_pending_exception()) { 475 if (isolate()->has_pending_exception()) {
437 info()->SetCode(Handle<Code>::null()); 476 info()->SetCode(Handle<Code>::null());
438 return SetLastStatus(FAILED); 477 return SetLastStatus(FAILED);
439 } 478 }
440 479
441 // The function being compiled may have bailed out due to an inline 480 // The function being compiled may have bailed out due to an inline
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 #endif 596 #endif
558 597
559 598
560 static bool DebuggerWantsEagerCompilation(CompilationInfo* info, 599 static bool DebuggerWantsEagerCompilation(CompilationInfo* info,
561 bool allow_lazy_without_ctx = false) { 600 bool allow_lazy_without_ctx = false) {
562 return LiveEditFunctionTracker::IsActive(info->isolate()) || 601 return LiveEditFunctionTracker::IsActive(info->isolate()) ||
563 (info->isolate()->DebuggerHasBreakPoints() && !allow_lazy_without_ctx); 602 (info->isolate()->DebuggerHasBreakPoints() && !allow_lazy_without_ctx);
564 } 603 }
565 604
566 605
606 // Sets the expected number of properties based on estimate from compiler.
607 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
608 int estimate) {
609 // See the comment in SetExpectedNofProperties.
610 if (shared->live_objects_may_exist()) return;
611
612 // If no properties are added in the constructor, they are more likely
613 // to be added later.
614 if (estimate == 0) estimate = 2;
615
616 // TODO(yangguo): check whether those heuristics are still up-to-date.
617 // We do not shrink objects that go into a snapshot (yet), so we adjust
618 // the estimate conservatively.
619 if (Serializer::enabled()) {
620 estimate += 2;
621 } else if (FLAG_clever_optimizations) {
622 // Inobject slack tracking will reclaim redundant inobject space later,
623 // so we can afford to adjust the estimate generously.
624 estimate += 8;
625 } else {
626 estimate += 3;
627 }
628
629 shared->set_expected_nof_properties(estimate);
630 }
631
632
567 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { 633 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
568 Isolate* isolate = info->isolate(); 634 Isolate* isolate = info->isolate();
569 PostponeInterruptsScope postpone(isolate); 635 PostponeInterruptsScope postpone(isolate);
570 636
571 ASSERT(!isolate->native_context().is_null()); 637 ASSERT(!isolate->native_context().is_null());
572 Handle<Script> script = info->script(); 638 Handle<Script> script = info->script();
573 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 639 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
574 FixedArray* array = isolate->native_context()->embedder_data(); 640 FixedArray* array = isolate->native_context()->embedder_data();
575 script->set_context_data(array->get(0)); 641 script->set_context_data(array->get(0));
576 642
(...skipping 24 matching lines...) Expand all
601 Parser parser(info); 667 Parser parser(info);
602 if ((info->pre_parse_data() != NULL || 668 if ((info->pre_parse_data() != NULL ||
603 String::cast(script->source())->length() > FLAG_min_preparse_length) && 669 String::cast(script->source())->length() > FLAG_min_preparse_length) &&
604 !DebuggerWantsEagerCompilation(info)) 670 !DebuggerWantsEagerCompilation(info))
605 parser.set_allow_lazy(true); 671 parser.set_allow_lazy(true);
606 if (!parser.Parse()) { 672 if (!parser.Parse()) {
607 return Handle<SharedFunctionInfo>::null(); 673 return Handle<SharedFunctionInfo>::null();
608 } 674 }
609 } 675 }
610 676
611 // Measure how long it takes to do the compilation; only take the
612 // rest of the function into account to avoid overlap with the
613 // parsing statistics.
614 HistogramTimer* rate = info->is_eval()
615 ? info->isolate()->counters()->compile_eval()
616 : info->isolate()->counters()->compile();
617 HistogramTimerScope timer(rate);
618
619 // Compile the code.
620 FunctionLiteral* lit = info->function(); 677 FunctionLiteral* lit = info->function();
621 LiveEditFunctionTracker live_edit_tracker(isolate, lit); 678 LiveEditFunctionTracker live_edit_tracker(isolate, lit);
622 if (!MakeCode(info)) { 679 Handle<SharedFunctionInfo> result;
623 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 680 {
624 return Handle<SharedFunctionInfo>::null(); 681 // Measure how long it takes to do the compilation; only take the
682 // rest of the function into account to avoid overlap with the
683 // parsing statistics.
684 HistogramTimer* rate = info->is_eval()
685 ? info->isolate()->counters()->compile_eval()
686 : info->isolate()->counters()->compile();
687 HistogramTimerScope timer(rate);
688
689 // Compile the code.
690 if (!MakeCode(info)) {
691 if (!isolate->has_pending_exception()) isolate->StackOverflow();
692 return Handle<SharedFunctionInfo>::null();
693 }
694
695 // Allocate function.
696 ASSERT(!info->code().is_null());
697 result =
698 isolate->factory()->NewSharedFunctionInfo(
699 lit->name(),
700 lit->materialized_literal_count(),
701 lit->is_generator(),
702 info->code(),
703 ScopeInfo::Create(info->scope(), info->zone()));
704
705 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
706 Compiler::SetFunctionInfo(result, lit, true, script);
707
708 if (script->name()->IsString()) {
709 PROFILE(isolate, CodeCreateEvent(
710 info->is_eval()
711 ? Logger::EVAL_TAG
712 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
713 *info->code(),
714 *result,
715 info,
716 String::cast(script->name())));
717 GDBJIT(AddCode(Handle<String>(String::cast(script->name())),
718 script,
719 info->code(),
720 info));
721 } else {
722 PROFILE(isolate, CodeCreateEvent(
723 info->is_eval()
724 ? Logger::EVAL_TAG
725 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
726 *info->code(),
727 *result,
728 info,
729 isolate->heap()->empty_string()));
730 GDBJIT(AddCode(Handle<String>(), script, info->code(), info));
731 }
732
733 // Hint to the runtime system used when allocating space for initial
734 // property space by setting the expected number of properties for
735 // the instances of the function.
736 SetExpectedNofPropertiesFromEstimate(result,
737 lit->expected_property_count());
738
739 script->set_compilation_state(Script::COMPILATION_STATE_COMPILED);
625 } 740 }
626 741
627 // Allocate function.
628 ASSERT(!info->code().is_null());
629 Handle<SharedFunctionInfo> result =
630 isolate->factory()->NewSharedFunctionInfo(
631 lit->name(),
632 lit->materialized_literal_count(),
633 lit->is_generator(),
634 info->code(),
635 ScopeInfo::Create(info->scope(), info->zone()));
636
637 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
638 Compiler::SetFunctionInfo(result, lit, true, script);
639
640 if (script->name()->IsString()) {
641 PROFILE(isolate, CodeCreateEvent(
642 info->is_eval()
643 ? Logger::EVAL_TAG
644 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
645 *info->code(),
646 *result,
647 info,
648 String::cast(script->name())));
649 GDBJIT(AddCode(Handle<String>(String::cast(script->name())),
650 script,
651 info->code(),
652 info));
653 } else {
654 PROFILE(isolate, CodeCreateEvent(
655 info->is_eval()
656 ? Logger::EVAL_TAG
657 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
658 *info->code(),
659 *result,
660 info,
661 isolate->heap()->empty_string()));
662 GDBJIT(AddCode(Handle<String>(), script, info->code(), info));
663 }
664
665 // Hint to the runtime system used when allocating space for initial
666 // property space by setting the expected number of properties for
667 // the instances of the function.
668 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count());
669
670 script->set_compilation_state(Script::COMPILATION_STATE_COMPILED);
671
672 #ifdef ENABLE_DEBUGGER_SUPPORT 742 #ifdef ENABLE_DEBUGGER_SUPPORT
673 // Notify debugger 743 // Notify debugger
674 isolate->debugger()->OnAfterCompile( 744 isolate->debugger()->OnAfterCompile(
675 script, Debugger::NO_AFTER_COMPILE_FLAGS); 745 script, Debugger::NO_AFTER_COMPILE_FLAGS);
676 #endif 746 #endif
677 747
678 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); 748 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone());
679 749
680 return result; 750 return result;
681 } 751 }
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 AllowHandleDereference allow_deref; 1359 AllowHandleDereference allow_deref;
1290 bool tracing_on = info()->IsStub() 1360 bool tracing_on = info()->IsStub()
1291 ? FLAG_trace_hydrogen_stubs 1361 ? FLAG_trace_hydrogen_stubs
1292 : (FLAG_trace_hydrogen && 1362 : (FLAG_trace_hydrogen &&
1293 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1363 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1294 return (tracing_on && 1364 return (tracing_on &&
1295 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1365 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1296 } 1366 }
1297 1367
1298 } } // namespace v8::internal 1368 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/contexts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698