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

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

Issue 11970043: Improve function lookup speed by working with raw objects only. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | « no previous file | runtime/vm/raw_object.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 2264
2265 2265
2266 RawFunction* Class::LookupFunction(const String& name) const { 2266 RawFunction* Class::LookupFunction(const String& name) const {
2267 Isolate* isolate = Isolate::Current(); 2267 Isolate* isolate = Isolate::Current();
2268 ASSERT(name.IsOneByteString()); 2268 ASSERT(name.IsOneByteString());
2269 Array& funcs = Array::Handle(isolate, functions()); 2269 Array& funcs = Array::Handle(isolate, functions());
2270 if (funcs.IsNull()) { 2270 if (funcs.IsNull()) {
2271 // This can occur, e.g., for Null classes. 2271 // This can occur, e.g., for Null classes.
2272 return Function::null(); 2272 return Function::null();
2273 } 2273 }
2274 Function& function = Function::Handle(isolate, Function::null()); 2274 const intptr_t len = funcs.Length();
2275 if (name.IsSymbol()) { 2275 if (name.IsSymbol()) {
2276 // Quick Symbol compare. 2276 // Quick Symbol compare.
2277 intptr_t len = funcs.Length(); 2277 NoGCScope no_gc;
2278 for (intptr_t i = 0; i < len; i++) { 2278 for (intptr_t i = 0; i < len; i++) {
2279 function ^= funcs.At(i); 2279 RawFunction* raw_func = reinterpret_cast<RawFunction*>(funcs.At(i));
2280 if (function.name() == name.raw()) { 2280 if (raw_func->ptr()->name_ == name.raw()) {
2281 return function.raw(); 2281 return raw_func;
2282 } 2282 }
2283 } 2283 }
2284 } else { 2284 } else {
2285 Function& function = Function::Handle(isolate, Function::null());
2285 String& function_name = String::Handle(isolate, String::null()); 2286 String& function_name = String::Handle(isolate, String::null());
2286 intptr_t len = funcs.Length();
2287 for (intptr_t i = 0; i < len; i++) { 2287 for (intptr_t i = 0; i < len; i++) {
2288 function ^= funcs.At(i); 2288 function ^= funcs.At(i);
2289 function_name ^= function.name(); 2289 function_name ^= function.name();
2290 if (function_name.Equals(name)) { 2290 if (function_name.Equals(name)) {
2291 return function.raw(); 2291 return function.raw();
2292 } 2292 }
2293 } 2293 }
2294 } 2294 }
2295 // No function found. 2295 // No function found.
2296 return Function::null(); 2296 return Function::null();
(...skipping 10298 matching lines...) Expand 10 before | Expand all | Expand 10 after
12595 } 12595 }
12596 return result.raw(); 12596 return result.raw();
12597 } 12597 }
12598 12598
12599 12599
12600 const char* WeakProperty::ToCString() const { 12600 const char* WeakProperty::ToCString() const {
12601 return "_WeakProperty"; 12601 return "_WeakProperty";
12602 } 12602 }
12603 12603
12604 } // namespace dart 12604 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698