| Index: runtime/vm/isolate.cc
|
| diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
|
| index 1a098fa78fa8b2587fea530accbbe10c0d887853..378ed6a2626a90e19b1050fcc43ee0992e4b1942 100644
|
| --- a/runtime/vm/isolate.cc
|
| +++ b/runtime/vm/isolate.cc
|
| @@ -1517,6 +1517,66 @@ static int MostUsedFunctionFirst(const Function* const* a,
|
| }
|
|
|
|
|
| +void Isolate::AddClosureFunction(const Function& function) const {
|
| + GrowableObjectArray& closures =
|
| + GrowableObjectArray::Handle(object_store()->closure_functions());
|
| + ASSERT(!closures.IsNull());
|
| + ASSERT(function.IsNonImplicitClosureFunction());
|
| + closures.Add(function, Heap::kOld);
|
| +}
|
| +
|
| +
|
| +RawFunction* Isolate::LookupClosureFunction(const Script& script,
|
| + intptr_t token_pos) const {
|
| + const GrowableObjectArray& closures =
|
| + GrowableObjectArray::Handle(object_store()->closure_functions());
|
| + ASSERT(!closures.IsNull());
|
| + Function& closure = Function::Handle();
|
| + intptr_t num_closures = closures.Length();
|
| + intptr_t best_fit_token_pos = -1;
|
| + intptr_t best_fit_index = -1;
|
| + for (intptr_t i = 0; i < num_closures; i++) {
|
| + closure ^= closures.At(i);
|
| + ASSERT(!closure.IsNull());
|
| + if ((closure.token_pos() <= token_pos) &&
|
| + (token_pos <= closure.end_token_pos()) &&
|
| + (best_fit_token_pos < closure.token_pos()) &&
|
| + (closure.script() == script.raw())) {
|
| + best_fit_index = i;
|
| + best_fit_token_pos = closure.token_pos();
|
| + }
|
| + }
|
| + closure = Function::null();
|
| + if (best_fit_index >= 0) {
|
| + closure ^= closures.At(best_fit_index);
|
| + }
|
| + return closure.raw();
|
| +}
|
| +
|
| +
|
| +intptr_t Isolate::FindClosureIndex(const Function& needle) const {
|
| + const GrowableObjectArray& closures_array =
|
| + GrowableObjectArray::Handle(object_store()->closure_functions());
|
| + intptr_t num_closures = closures_array.Length();
|
| + for (intptr_t i = 0; i < num_closures; i++) {
|
| + if (closures_array.At(i) == needle.raw()) {
|
| + return i;
|
| + }
|
| + }
|
| + return -1;
|
| +}
|
| +
|
| +
|
| +RawFunction* Isolate::ClosureFunctionFromIndex(intptr_t idx) const {
|
| + const GrowableObjectArray& closures_array =
|
| + GrowableObjectArray::Handle(object_store()->closure_functions());
|
| + if ((idx < 0) || (idx >= closures_array.Length())) {
|
| + return Function::null();
|
| + }
|
| + return Function::RawCast(closures_array.At(idx));
|
| +}
|
| +
|
| +
|
| static void AddFunctionsFromClass(const Class& cls,
|
| GrowableArray<const Function*>* functions) {
|
| const Array& class_functions = Array::Handle(cls.functions());
|
|
|