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

Unified Diff: runtime/vm/object.cc

Issue 1436243005: Collect closure functions in isolate (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 5851501f154ee182bad4c86f33f87ba0e3f0f9b9..6f4a64c4b3d0cecaa161dbb58a3a7bdf1797289f 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2320,7 +2320,6 @@ intptr_t Class::FindInvocationDispatcherFunctionIndex(
}
-
RawFunction* Class::InvocationDispatcherFunctionFromIndex(intptr_t idx) const {
Thread* thread = Thread::Current();
REUSABLE_ARRAY_HANDLESCOPE(thread);
@@ -2336,86 +2335,6 @@ RawFunction* Class::InvocationDispatcherFunctionFromIndex(intptr_t idx) const {
}
-void Class::set_closures(const GrowableObjectArray& value) const {
- StorePointer(&raw_ptr()->closure_functions_, value.raw());
-}
-
-
-void Class::AddClosureFunction(const Function& function) const {
- GrowableObjectArray& closures =
- GrowableObjectArray::Handle(raw_ptr()->closure_functions_);
- if (closures.IsNull()) {
- closures = GrowableObjectArray::New(4, Heap::kOld);
- StorePointer(&raw_ptr()->closure_functions_, closures.raw());
- }
- ASSERT(function.IsNonImplicitClosureFunction());
- ASSERT(function.Owner() == this->raw());
- closures.Add(function, Heap::kOld);
-}
-
-
-// Lookup the innermost closure function that contains token at token_pos.
-RawFunction* Class::LookupClosureFunction(intptr_t token_pos) const {
- if (raw_ptr()->closure_functions_ == GrowableObjectArray::null()) {
- return Function::null();
- }
- const GrowableObjectArray& closures =
- GrowableObjectArray::Handle(raw_ptr()->closure_functions_);
- 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())) {
- 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 Class::FindClosureIndex(const Function& needle) const {
- if (closures() == GrowableObjectArray::null()) {
- return -1;
- }
- Thread* thread = Thread::Current();
- const GrowableObjectArray& closures_array =
- GrowableObjectArray::Handle(thread->zone(), closures());
- REUSABLE_FUNCTION_HANDLESCOPE(thread);
- Function& closure = thread->FunctionHandle();
- intptr_t num_closures = closures_array.Length();
- for (intptr_t i = 0; i < num_closures; i++) {
- closure ^= closures_array.At(i);
- ASSERT(!closure.IsNull());
- if (closure.raw() == needle.raw()) {
- return i;
- }
- }
- return -1;
-}
-
-
-RawFunction* Class::ClosureFunctionFromIndex(intptr_t idx) const {
- const GrowableObjectArray& closures_array =
- GrowableObjectArray::Handle(closures());
- if ((idx < 0) || (idx >= closures_array.Length())) {
- return Function::null();
- }
- Function& func = Function::Handle();
- func ^= closures_array.At(idx);
- ASSERT(!func.IsNull());
- return func.raw();
-}
-
-
void Class::set_signature_function(const Function& value) const {
ASSERT(value.IsClosureFunction() || value.IsSignatureFunction());
StorePointer(&raw_ptr()->signature_function_, value.raw());
@@ -7216,7 +7135,7 @@ static void AddFunctionServiceId(const JSONObject& jsobj,
intptr_t id = -1;
const char* selector = NULL;
if (f.IsNonImplicitClosureFunction()) {
- id = cls.FindClosureIndex(f);
+ id = Isolate::Current()->FindClosureIndex(f);
selector = "closures";
} else if (f.IsImplicitClosureFunction()) {
id = cls.FindImplicitClosureFunctionIndex(f);

Powered by Google App Engine
This is Rietveld 408576698