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

Side by Side Diff: runtime/vm/precompiler.cc

Issue 1382243002: Precompilation: Eagerly bind all the static calls after compiling and drop the static call table. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/precompiler.h" 5 #include "vm/precompiler.h"
6 6
7 #include "vm/code_patcher.h"
7 #include "vm/compiler.h" 8 #include "vm/compiler.h"
8 #include "vm/isolate.h" 9 #include "vm/isolate.h"
9 #include "vm/log.h" 10 #include "vm/log.h"
10 #include "vm/longjump.h" 11 #include "vm/longjump.h"
11 #include "vm/object.h" 12 #include "vm/object.h"
12 #include "vm/object_store.h" 13 #include "vm/object_store.h"
13 #include "vm/resolver.h" 14 #include "vm/resolver.h"
14 #include "vm/symbols.h" 15 #include "vm/symbols.h"
15 16
16 namespace dart { 17 namespace dart {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 322 }
322 } 323 }
323 324
324 325
325 void Precompiler::CleanUp() { 326 void Precompiler::CleanUp() {
326 I->set_collected_closures(GrowableObjectArray::Handle(Z)); 327 I->set_collected_closures(GrowableObjectArray::Handle(Z));
327 328
328 DropUncompiledFunctions(); 329 DropUncompiledFunctions();
329 330
330 // TODO(rmacnak): DropEmptyClasses(); 331 // TODO(rmacnak): DropEmptyClasses();
332
333 BindStaticCalls();
331 } 334 }
332 335
333 336
334 void Precompiler::ProcessFunction(const Function& function) { 337 void Precompiler::ProcessFunction(const Function& function) {
335 if (!function.HasCode()) { 338 if (!function.HasCode()) {
336 function_count_++; 339 function_count_++;
337 340
338 if (FLAG_trace_precompiler) { 341 if (FLAG_trace_precompiler) {
339 THR_Print("Precompiling %" Pd " %s (%" Pd ", %s)\n", 342 THR_Print("Precompiling %" Pd " %s (%" Pd ", %s)\n",
340 function_count_, 343 function_count_,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 if (!closures.IsNull()) { 687 if (!closures.IsNull()) {
685 for (intptr_t j = 0; j < closures.Length(); j++) { 688 for (intptr_t j = 0; j < closures.Length(); j++) {
686 function ^= closures.At(j); 689 function ^= closures.At(j);
687 ASSERT(function.HasCode()); 690 ASSERT(function.HasCode());
688 } 691 }
689 } 692 }
690 } 693 }
691 } 694 }
692 } 695 }
693 696
697
698 void Precompiler::BindStaticCalls() {
699 Library& lib = Library::Handle(Z);
700 Class& cls = Class::Handle(Z);
701 Array& functions = Array::Handle(Z);
702 Function& function = Function::Handle(Z);
703 GrowableObjectArray& closures = GrowableObjectArray::Handle(Z);
704
705 for (intptr_t i = 0; i < libraries_.Length(); i++) {
706 lib ^= libraries_.At(i);
707 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
708 while (it.HasNext()) {
709 cls = it.GetNextClass();
710 if (cls.IsDynamicClass()) {
711 continue; // class 'dynamic' is in the read-only VM isolate.
712 }
713
714 functions = cls.functions();
715 for (intptr_t j = 0; j < functions.Length(); j++) {
716 function ^= functions.At(j);
717 BindStaticCalls(function);
718 }
719
720 closures = cls.closures();
721 if (!closures.IsNull()) {
722 for (intptr_t j = 0; j < closures.Length(); j++) {
723 function ^= closures.At(j);
724 BindStaticCalls(function);
725 }
726 }
727 }
728 }
729 }
730
731
732 void Precompiler::BindStaticCalls(const Function& function) {
733 ASSERT(function.HasCode());
734
735 const Code& code = Code::Handle(Z, function.CurrentCode());
736
737 const Array& table = Array::Handle(Z, code.static_calls_target_table());
738 Smi& pc_offset = Smi::Handle(Z);
739 Function& target = Function::Handle(Z);
740 Code& target_code = Code::Handle(Z);
741
742 for (intptr_t i = 0; i < table.Length(); i += Code::kSCallTableEntryLength) {
743 pc_offset ^= table.At(i + Code::kSCallTableOffsetEntry);
744 target ^= table.At(i + Code::kSCallTableFunctionEntry);
745 if (target.IsNull()) {
746 target_code ^= table.At(i + Code::kSCallTableCodeEntry);
747 ASSERT(!target_code.IsNull());
748 ASSERT(!target_code.IsFunctionCode());
749 // Allocation stub or AllocateContext or AllocateArray or ...
750 } else {
751 // Cf. runtime entry PatchStaticCall called from CallStaticFunction stub.
752 ASSERT(target.HasCode());
753 target_code ^= target.CurrentCode();
754 CodePatcher::PatchStaticCallAt(pc_offset.Value() + code.EntryPoint(),
755 code, target_code);
756 }
757 }
758 code.set_static_calls_target_table(Object::empty_array());
759 }
760
694 } // namespace dart 761 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698