Chromium Code Reviews| Index: runtime/vm/precompiler.cc |
| diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc |
| index d6a654060cd7262eaa7b23923a0ea80014caf57b..eb27da46ea8a883f09aa6f3439dce256b2cf04bc 100644 |
| --- a/runtime/vm/precompiler.cc |
| +++ b/runtime/vm/precompiler.cc |
| @@ -4,6 +4,7 @@ |
| #include "vm/precompiler.h" |
| +#include "vm/code_patcher.h" |
| #include "vm/compiler.h" |
| #include "vm/isolate.h" |
| #include "vm/log.h" |
| @@ -328,6 +329,8 @@ void Precompiler::CleanUp() { |
| DropUncompiledFunctions(); |
| // TODO(rmacnak): DropEmptyClasses(); |
| + |
| + BindStaticCalls(); |
| } |
| @@ -691,4 +694,69 @@ void Precompiler::DropUncompiledFunctions() { |
| } |
| } |
| + |
| +void Precompiler::BindStaticCalls() { |
| + Library& lib = Library::Handle(Z); |
| + Class& cls = Class::Handle(Z); |
| + Array& functions = Array::Handle(Z); |
| + Function& function = Function::Handle(Z); |
| + GrowableObjectArray& retained_functions = GrowableObjectArray::Handle(Z); |
| + GrowableObjectArray& closures = GrowableObjectArray::Handle(Z); |
| + |
| + for (intptr_t i = 0; i < libraries_.Length(); i++) { |
| + lib ^= libraries_.At(i); |
| + ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
| + while (it.HasNext()) { |
| + cls = it.GetNextClass(); |
| + if (cls.IsDynamicClass()) { |
| + continue; // class 'dynamic' is in the read-only VM isolate. |
| + } |
| + |
| + functions = cls.functions(); |
| + retained_functions = GrowableObjectArray::New(); |
|
Ivan Posva
2015/10/03 00:07:31
What purpose does this allocation serve?
rmacnak
2015/10/05 17:54:03
From copied iteration code. Removed.
|
| + for (intptr_t j = 0; j < functions.Length(); j++) { |
| + function ^= functions.At(j); |
| + BindStaticCalls(function); |
| + } |
| + |
| + closures = cls.closures(); |
| + if (!closures.IsNull()) { |
| + for (intptr_t j = 0; j < closures.Length(); j++) { |
| + function ^= closures.At(j); |
| + BindStaticCalls(function); |
| + } |
| + } |
| + } |
| + } |
| +} |
| + |
| + |
| +void Precompiler::BindStaticCalls(const Function& function) { |
| + ASSERT(function.HasCode()); |
| + |
| + const Code& code = Code::Handle(Z, function.CurrentCode()); |
| + |
| + const Array& table = Array::Handle(Z, code.static_calls_target_table()); |
| + Smi& pc_offset = Smi::Handle(Z); |
| + Function& target = Function::Handle(Z); |
| + Code& target_code = Code::Handle(Z); |
| + |
| + for (intptr_t i = 0; i < table.Length(); i += Code::kSCallTableEntryLength) { |
| + pc_offset ^= table.At(i + Code::kSCallTableOffsetEntry); |
| + target ^= table.At(i + Code::kSCallTableFunctionEntry); |
| + if (target.IsNull()) { |
| + target_code ^= table.At(i + Code::kSCallTableCodeEntry); |
| + ASSERT(!target_code.IsNull()); |
| + ASSERT(!target_code.IsFunctionCode()); |
| + // Allocation stub or AllocateContext or AllocateArray or ... |
| + } else { |
| + ASSERT(target.HasCode()); |
| + target_code ^= target.CurrentCode(); |
| + CodePatcher::PatchStaticCallAt(pc_offset.Value() + code.EntryPoint(), |
|
Ivan Posva
2015/10/03 00:07:31
Can you please explain why only patching of the fu
rmacnak
2015/10/05 17:54:03
Allocation stubs are generated eagerly, so their u
Ivan Posva
2015/10/05 18:30:06
Put differently: You are using the stub as a handl
|
| + code, target_code); |
| + } |
| + } |
| + code.set_static_calls_target_table(Object::empty_array()); |
| +} |
| + |
| } // namespace dart |