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

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

Issue 187503002: 1. Restructure reusable handles to make individual Scopes for each handle type (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « runtime/vm/object.h ('k') | runtime/vm/reusable_handles.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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 new_arr.SetAt(arr.Length(), function); 1801 new_arr.SetAt(arr.Length(), function);
1802 SetFunctions(new_arr); 1802 SetFunctions(new_arr);
1803 } 1803 }
1804 1804
1805 1805
1806 intptr_t Class::FindFunctionIndex(const Function& needle) const { 1806 intptr_t Class::FindFunctionIndex(const Function& needle) const {
1807 Isolate* isolate = Isolate::Current(); 1807 Isolate* isolate = Isolate::Current();
1808 if (EnsureIsFinalized(isolate) != Error::null()) { 1808 if (EnsureIsFinalized(isolate) != Error::null()) {
1809 return -1; 1809 return -1;
1810 } 1810 }
1811 ReusableHandleScope reused_handles(isolate); 1811 REUSABLE_ARRAY_HANDLESCOPE(isolate);
1812 Array& funcs = reused_handles.ArrayHandle(); 1812 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
1813 Array& funcs = isolate->ArrayHandle();
1814 Function& function = isolate->FunctionHandle();
1813 funcs ^= functions(); 1815 funcs ^= functions();
1814 ASSERT(!funcs.IsNull()); 1816 ASSERT(!funcs.IsNull());
1815 Function& function = reused_handles.FunctionHandle();
1816 const intptr_t len = funcs.Length(); 1817 const intptr_t len = funcs.Length();
1817 for (intptr_t i = 0; i < len; i++) { 1818 for (intptr_t i = 0; i < len; i++) {
1818 function ^= funcs.At(i); 1819 function ^= funcs.At(i);
1819 if (function.raw() == needle.raw()) { 1820 if (function.raw() == needle.raw()) {
1820 return i; 1821 return i;
1821 } 1822 }
1822 } 1823 }
1823 // No function found. 1824 // No function found.
1824 return -1; 1825 return -1;
1825 } 1826 }
(...skipping 27 matching lines...) Expand all
1853 ASSERT(!closure_func.IsNull()); 1854 ASSERT(!closure_func.IsNull());
1854 return closure_func.raw(); 1855 return closure_func.raw();
1855 } 1856 }
1856 1857
1857 1858
1858 intptr_t Class::FindImplicitClosureFunctionIndex(const Function& needle) const { 1859 intptr_t Class::FindImplicitClosureFunctionIndex(const Function& needle) const {
1859 Isolate* isolate = Isolate::Current(); 1860 Isolate* isolate = Isolate::Current();
1860 if (EnsureIsFinalized(isolate) != Error::null()) { 1861 if (EnsureIsFinalized(isolate) != Error::null()) {
1861 return -1; 1862 return -1;
1862 } 1863 }
1863 ReusableHandleScope reused_handles(isolate); 1864 REUSABLE_ARRAY_HANDLESCOPE(isolate);
1864 Array& funcs = reused_handles.ArrayHandle(); 1865 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
1866 Array& funcs = isolate->ArrayHandle();
1867 Function& function = isolate->FunctionHandle();
1865 funcs ^= functions(); 1868 funcs ^= functions();
1866 ASSERT(!funcs.IsNull()); 1869 ASSERT(!funcs.IsNull());
1867 Function& function = reused_handles.FunctionHandle(); 1870 Function& implicit_closure = Function::Handle(isolate);
1868 Function& implicit_closure = Function::Handle();
1869 const intptr_t len = funcs.Length(); 1871 const intptr_t len = funcs.Length();
1870 for (intptr_t i = 0; i < len; i++) { 1872 for (intptr_t i = 0; i < len; i++) {
1871 function ^= funcs.At(i); 1873 function ^= funcs.At(i);
1872 implicit_closure ^= function.implicit_closure_function(); 1874 implicit_closure ^= function.implicit_closure_function();
1873 if (implicit_closure.IsNull()) { 1875 if (implicit_closure.IsNull()) {
1874 // Skip non-implicit closure functions. 1876 // Skip non-implicit closure functions.
1875 continue; 1877 continue;
1876 } 1878 }
1877 if (needle.raw() == implicit_closure.raw()) { 1879 if (needle.raw() == implicit_closure.raw()) {
1878 return i; 1880 return i;
1879 } 1881 }
1880 } 1882 }
1881 // No function found. 1883 // No function found.
1882 return -1; 1884 return -1;
1883 } 1885 }
1884 1886
1885 1887
1886 1888
1887 intptr_t Class::FindInvocationDispatcherFunctionIndex( 1889 intptr_t Class::FindInvocationDispatcherFunctionIndex(
1888 const Function& needle) const { 1890 const Function& needle) const {
1889 Isolate* isolate = Isolate::Current(); 1891 Isolate* isolate = Isolate::Current();
1890 if (EnsureIsFinalized(isolate) != Error::null()) { 1892 if (EnsureIsFinalized(isolate) != Error::null()) {
1891 return -1; 1893 return -1;
1892 } 1894 }
1893 ReusableHandleScope reused_handles(isolate); 1895 REUSABLE_ARRAY_HANDLESCOPE(isolate);
1894 Array& funcs = reused_handles.ArrayHandle(); 1896 REUSABLE_OBJECT_HANDLESCOPE(isolate);
1897 Array& funcs = isolate->ArrayHandle();
1898 Object& object = isolate->ObjectHandle();
1895 funcs ^= invocation_dispatcher_cache(); 1899 funcs ^= invocation_dispatcher_cache();
1896 ASSERT(!funcs.IsNull()); 1900 ASSERT(!funcs.IsNull());
1897 Object& object = reused_handles.ObjectHandle();
1898 const intptr_t len = funcs.Length(); 1901 const intptr_t len = funcs.Length();
1899 for (intptr_t i = 0; i < len; i++) { 1902 for (intptr_t i = 0; i < len; i++) {
1900 object = funcs.At(i); 1903 object = funcs.At(i);
1901 // The invocation_dispatcher_cache is a table with some entries that 1904 // The invocation_dispatcher_cache is a table with some entries that
1902 // are functions. 1905 // are functions.
1903 if (object.IsFunction()) { 1906 if (object.IsFunction()) {
1904 if (Function::Cast(object).raw() == needle.raw()) { 1907 if (Function::Cast(object).raw() == needle.raw()) {
1905 return i; 1908 return i;
1906 } 1909 }
1907 } 1910 }
1908 } 1911 }
1909 // No function found. 1912 // No function found.
1910 return -1; 1913 return -1;
1911 } 1914 }
1912 1915
1913 1916
1914 1917
1915 RawFunction* Class::InvocationDispatcherFunctionFromIndex(intptr_t idx) const { 1918 RawFunction* Class::InvocationDispatcherFunctionFromIndex(intptr_t idx) const {
1916 ReusableHandleScope reused_handles(Isolate::Current()); 1919 Isolate* isolate = Isolate::Current();
1917 Array& dispatcher_cache = reused_handles.ArrayHandle(); 1920 REUSABLE_ARRAY_HANDLESCOPE(isolate);
1921 REUSABLE_OBJECT_HANDLESCOPE(isolate);
1922 Array& dispatcher_cache = isolate->ArrayHandle();
1923 Object& object = isolate->ObjectHandle();
1918 dispatcher_cache ^= invocation_dispatcher_cache(); 1924 dispatcher_cache ^= invocation_dispatcher_cache();
1919 Object& object = reused_handles.ObjectHandle();
1920 object = dispatcher_cache.At(idx); 1925 object = dispatcher_cache.At(idx);
1921 if (!object.IsFunction()) { 1926 if (!object.IsFunction()) {
1922 return Function::null(); 1927 return Function::null();
1923 } 1928 }
1924 return Function::Cast(object).raw(); 1929 return Function::Cast(object).raw();
1925 } 1930 }
1926 1931
1927 1932
1928 void Class::AddClosureFunction(const Function& function) const { 1933 void Class::AddClosureFunction(const Function& function) const {
1929 GrowableObjectArray& closures = 1934 GrowableObjectArray& closures =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 closure ^= closures.At(best_fit_index); 1968 closure ^= closures.At(best_fit_index);
1964 } 1969 }
1965 return closure.raw(); 1970 return closure.raw();
1966 } 1971 }
1967 1972
1968 intptr_t Class::FindClosureIndex(const Function& needle) const { 1973 intptr_t Class::FindClosureIndex(const Function& needle) const {
1969 if (closures() == GrowableObjectArray::null()) { 1974 if (closures() == GrowableObjectArray::null()) {
1970 return -1; 1975 return -1;
1971 } 1976 }
1972 Isolate* isolate = Isolate::Current(); 1977 Isolate* isolate = Isolate::Current();
1973 ReusableHandleScope reused_handles(isolate);
1974 const GrowableObjectArray& closures_array = 1978 const GrowableObjectArray& closures_array =
1975 GrowableObjectArray::Handle(isolate, closures()); 1979 GrowableObjectArray::Handle(isolate, closures());
1976 Function& closure = reused_handles.FunctionHandle(); 1980 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
1981 Function& closure = isolate->FunctionHandle();
1977 intptr_t num_closures = closures_array.Length(); 1982 intptr_t num_closures = closures_array.Length();
1978 for (intptr_t i = 0; i < num_closures; i++) { 1983 for (intptr_t i = 0; i < num_closures; i++) {
1979 closure ^= closures_array.At(i); 1984 closure ^= closures_array.At(i);
1980 ASSERT(!closure.IsNull()); 1985 ASSERT(!closure.IsNull());
1981 if (closure.raw() == needle.raw()) { 1986 if (closure.raw() == needle.raw()) {
1982 return i; 1987 return i;
1983 } 1988 }
1984 } 1989 }
1985 return -1; 1990 return -1;
1986 } 1991 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 } 2025 }
2021 2026
2022 2027
2023 intptr_t Class::NumTypeParameters(Isolate* isolate) const { 2028 intptr_t Class::NumTypeParameters(Isolate* isolate) const {
2024 if (IsMixinApplication() && !is_mixin_type_applied()) { 2029 if (IsMixinApplication() && !is_mixin_type_applied()) {
2025 ClassFinalizer::ApplyMixinType(*this); 2030 ClassFinalizer::ApplyMixinType(*this);
2026 } 2031 }
2027 if (type_parameters() == TypeArguments::null()) { 2032 if (type_parameters() == TypeArguments::null()) {
2028 return 0; 2033 return 0;
2029 } 2034 }
2030 ReusableHandleScope reused_handles(isolate); 2035 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate);
2031 TypeArguments& type_params = reused_handles.TypeArgumentsHandle(); 2036 TypeArguments& type_params = isolate->TypeArgumentsHandle();
2032 type_params = type_parameters(); 2037 type_params = type_parameters();
2033 return type_params.Length(); 2038 return type_params.Length();
2034 } 2039 }
2035 2040
2036 2041
2037 intptr_t Class::NumOwnTypeArguments() const { 2042 intptr_t Class::NumOwnTypeArguments() const {
2038 // Return cached value if already calculated. 2043 // Return cached value if already calculated.
2039 if (num_own_type_arguments() != kUnknownNumTypeArguments) { 2044 if (num_own_type_arguments() != kUnknownNumTypeArguments) {
2040 return num_own_type_arguments(); 2045 return num_own_type_arguments();
2041 } 2046 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 value.IsMixinAppType()); 2166 value.IsMixinAppType());
2162 StorePointer(&raw_ptr()->super_type_, value.raw()); 2167 StorePointer(&raw_ptr()->super_type_, value.raw());
2163 } 2168 }
2164 2169
2165 2170
2166 // Return a TypeParameter if the type_name is a type parameter of this class. 2171 // Return a TypeParameter if the type_name is a type parameter of this class.
2167 // Return null otherwise. 2172 // Return null otherwise.
2168 RawTypeParameter* Class::LookupTypeParameter(const String& type_name) const { 2173 RawTypeParameter* Class::LookupTypeParameter(const String& type_name) const {
2169 ASSERT(!type_name.IsNull()); 2174 ASSERT(!type_name.IsNull());
2170 Isolate* isolate = Isolate::Current(); 2175 Isolate* isolate = Isolate::Current();
2171 ReusableHandleScope reused_handles(isolate); 2176 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate);
2172 TypeArguments& type_params = reused_handles.TypeArgumentsHandle(); 2177 REUSABLE_TYPE_PARAMETER_HANDLESCOPE(isolate);
2178 REUSABLE_STRING_HANDLESCOPE(isolate);
2179 TypeArguments& type_params = isolate->TypeArgumentsHandle();
2180 TypeParameter& type_param = isolate->TypeParameterHandle();
2181 String& type_param_name = isolate->StringHandle();
2182
2173 type_params ^= type_parameters(); 2183 type_params ^= type_parameters();
2174 TypeParameter& type_param = reused_handles.TypeParameterHandle();
2175 String& type_param_name = reused_handles.StringHandle();
2176 if (!type_params.IsNull()) { 2184 if (!type_params.IsNull()) {
2177 const intptr_t num_type_params = type_params.Length(); 2185 const intptr_t num_type_params = type_params.Length();
2178 for (intptr_t i = 0; i < num_type_params; i++) { 2186 for (intptr_t i = 0; i < num_type_params; i++) {
2179 type_param ^= type_params.TypeAt(i); 2187 type_param ^= type_params.TypeAt(i);
2180 type_param_name = type_param.name(); 2188 type_param_name = type_param.name();
2181 if (type_param_name.Equals(type_name)) { 2189 if (type_param_name.Equals(type_name)) {
2182 return type_param.raw(); 2190 return type_param.raw();
2183 } 2191 }
2184 } 2192 }
2185 } 2193 }
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 // The value of static fields is already initialized to null. 2708 // The value of static fields is already initialized to null.
2701 StorePointer(&raw_ptr()->fields_, value.raw()); 2709 StorePointer(&raw_ptr()->fields_, value.raw());
2702 } 2710 }
2703 2711
2704 2712
2705 intptr_t Class::FindFieldIndex(const Field& needle) const { 2713 intptr_t Class::FindFieldIndex(const Field& needle) const {
2706 Isolate* isolate = Isolate::Current(); 2714 Isolate* isolate = Isolate::Current();
2707 if (EnsureIsFinalized(isolate) != Error::null()) { 2715 if (EnsureIsFinalized(isolate) != Error::null()) {
2708 return -1; 2716 return -1;
2709 } 2717 }
2710 ReusableHandleScope reused_handles(isolate); 2718 REUSABLE_ARRAY_HANDLESCOPE(isolate);
2711 Array& fields_array = reused_handles.ArrayHandle(); 2719 REUSABLE_FIELD_HANDLESCOPE(isolate);
2720 REUSABLE_STRING_HANDLESCOPE(isolate);
2721 Array& fields_array = isolate->ArrayHandle();
2722 Field& field = isolate->FieldHandle();
2723 String& field_name = isolate->StringHandle();
2712 fields_array ^= fields(); 2724 fields_array ^= fields();
2713 ASSERT(!fields_array.IsNull()); 2725 ASSERT(!fields_array.IsNull());
2714 Field& field = reused_handles.FieldHandle();
2715 String& field_name = reused_handles.StringHandle();
2716 String& needle_name = String::Handle(isolate); 2726 String& needle_name = String::Handle(isolate);
2717 needle_name ^= needle.name(); 2727 needle_name ^= needle.name();
2718 const intptr_t len = fields_array.Length(); 2728 const intptr_t len = fields_array.Length();
2719 for (intptr_t i = 0; i < len; i++) { 2729 for (intptr_t i = 0; i < len; i++) {
2720 field ^= fields_array.At(i); 2730 field ^= fields_array.At(i);
2721 field_name ^= field.name(); 2731 field_name ^= field.name();
2722 if (field_name.Equals(needle_name)) { 2732 if (field_name.Equals(needle_name)) {
2723 return i; 2733 return i;
2724 } 2734 }
2725 } 2735 }
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 } 3551 }
3542 return Function::null(); 3552 return Function::null();
3543 } 3553 }
3544 3554
3545 3555
3546 RawFunction* Class::LookupFunction(const String& name, intptr_t type) const { 3556 RawFunction* Class::LookupFunction(const String& name, intptr_t type) const {
3547 Isolate* isolate = Isolate::Current(); 3557 Isolate* isolate = Isolate::Current();
3548 if (EnsureIsFinalized(isolate) != Error::null()) { 3558 if (EnsureIsFinalized(isolate) != Error::null()) {
3549 return Function::null(); 3559 return Function::null();
3550 } 3560 }
3551 ReusableHandleScope reused_handles(isolate); 3561 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3552 Array& funcs = reused_handles.ArrayHandle(); 3562 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
3563 Array& funcs = isolate->ArrayHandle();
3553 funcs ^= functions(); 3564 funcs ^= functions();
3554 ASSERT(!funcs.IsNull()); 3565 ASSERT(!funcs.IsNull());
3555 Function& function = reused_handles.FunctionHandle();
3556 const intptr_t len = funcs.Length(); 3566 const intptr_t len = funcs.Length();
3567 Function& function = isolate->FunctionHandle();
3557 if (name.IsSymbol()) { 3568 if (name.IsSymbol()) {
3558 // Quick Symbol compare. 3569 // Quick Symbol compare.
3559 NoGCScope no_gc; 3570 NoGCScope no_gc;
3560 for (intptr_t i = 0; i < len; i++) { 3571 for (intptr_t i = 0; i < len; i++) {
3561 function ^= funcs.At(i); 3572 function ^= funcs.At(i);
3562 if (function.name() == name.raw()) { 3573 if (function.name() == name.raw()) {
3563 return CheckFunctionType(function, type); 3574 return CheckFunctionType(function, type);
3564 } 3575 }
3565 } 3576 }
3566 } else { 3577 } else {
3567 String& function_name = reused_handles.StringHandle(); 3578 REUSABLE_STRING_HANDLESCOPE(isolate);
3579 String& function_name = isolate->StringHandle();
3568 for (intptr_t i = 0; i < len; i++) { 3580 for (intptr_t i = 0; i < len; i++) {
3569 function ^= funcs.At(i); 3581 function ^= funcs.At(i);
3570 function_name ^= function.name(); 3582 function_name ^= function.name();
3571 if (function_name.Equals(name)) { 3583 if (function_name.Equals(name)) {
3572 return CheckFunctionType(function, type); 3584 return CheckFunctionType(function, type);
3573 } 3585 }
3574 } 3586 }
3575 } 3587 }
3576 // No function found. 3588 // No function found.
3577 return Function::null(); 3589 return Function::null();
3578 } 3590 }
3579 3591
3580 3592
3581 RawFunction* Class::LookupFunctionAllowPrivate(const String& name, 3593 RawFunction* Class::LookupFunctionAllowPrivate(const String& name,
3582 intptr_t type) const { 3594 intptr_t type) const {
3583 Isolate* isolate = Isolate::Current(); 3595 Isolate* isolate = Isolate::Current();
3584 if (EnsureIsFinalized(isolate) != Error::null()) { 3596 if (EnsureIsFinalized(isolate) != Error::null()) {
3585 return Function::null(); 3597 return Function::null();
3586 } 3598 }
3587 ReusableHandleScope reused_handles(isolate); 3599 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3588 Array& funcs = reused_handles.ArrayHandle(); 3600 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
3601 REUSABLE_STRING_HANDLESCOPE(isolate);
3602 Array& funcs = isolate->ArrayHandle();
3589 funcs ^= functions(); 3603 funcs ^= functions();
3590 ASSERT(!funcs.IsNull()); 3604 ASSERT(!funcs.IsNull());
3591 Function& function = reused_handles.FunctionHandle();
3592 String& function_name = reused_handles.StringHandle();
3593 intptr_t len = funcs.Length(); 3605 intptr_t len = funcs.Length();
3606 Function& function = isolate->FunctionHandle();
3607 String& function_name = isolate->StringHandle();
3594 for (intptr_t i = 0; i < len; i++) { 3608 for (intptr_t i = 0; i < len; i++) {
3595 function ^= funcs.At(i); 3609 function ^= funcs.At(i);
3596 function_name ^= function.name(); 3610 function_name ^= function.name();
3597 if (String::EqualsIgnoringPrivateKey(function_name, name)) { 3611 if (String::EqualsIgnoringPrivateKey(function_name, name)) {
3598 return CheckFunctionType(function, type); 3612 return CheckFunctionType(function, type);
3599 } 3613 }
3600 } 3614 }
3601 // No function found. 3615 // No function found.
3602 return Function::null(); 3616 return Function::null();
3603 } 3617 }
3604 3618
3605 3619
3606 RawFunction* Class::LookupGetterFunction(const String& name) const { 3620 RawFunction* Class::LookupGetterFunction(const String& name) const {
3607 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); 3621 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name);
3608 } 3622 }
3609 3623
3610 3624
3611 RawFunction* Class::LookupSetterFunction(const String& name) const { 3625 RawFunction* Class::LookupSetterFunction(const String& name) const {
3612 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name); 3626 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name);
3613 } 3627 }
3614 3628
3615 3629
3616 RawFunction* Class::LookupAccessorFunction(const char* prefix, 3630 RawFunction* Class::LookupAccessorFunction(const char* prefix,
3617 intptr_t prefix_length, 3631 intptr_t prefix_length,
3618 const String& name) const { 3632 const String& name) const {
3619 Isolate* isolate = Isolate::Current(); 3633 Isolate* isolate = Isolate::Current();
3620 if (EnsureIsFinalized(isolate) != Error::null()) { 3634 if (EnsureIsFinalized(isolate) != Error::null()) {
3621 return Function::null(); 3635 return Function::null();
3622 } 3636 }
3623 ReusableHandleScope reused_handles(isolate); 3637 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3624 Array& funcs = reused_handles.ArrayHandle(); 3638 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
3639 REUSABLE_STRING_HANDLESCOPE(isolate);
3640 Array& funcs = isolate->ArrayHandle();
3625 funcs ^= functions(); 3641 funcs ^= functions();
3626 Function& function = reused_handles.FunctionHandle();
3627 String& function_name = reused_handles.StringHandle();
3628 intptr_t len = funcs.Length(); 3642 intptr_t len = funcs.Length();
3643 Function& function = isolate->FunctionHandle();
3644 String& function_name = isolate->StringHandle();
3629 for (intptr_t i = 0; i < len; i++) { 3645 for (intptr_t i = 0; i < len; i++) {
3630 function ^= funcs.At(i); 3646 function ^= funcs.At(i);
3631 function_name ^= function.name(); 3647 function_name ^= function.name();
3632 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) { 3648 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) {
3633 return function.raw(); 3649 return function.raw();
3634 } 3650 }
3635 } 3651 }
3636 3652
3637 // No function found. 3653 // No function found.
3638 return Function::null(); 3654 return Function::null();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 RawField* Class::LookupField(const String& name) const { 3694 RawField* Class::LookupField(const String& name) const {
3679 return LookupField(name, kAny); 3695 return LookupField(name, kAny);
3680 } 3696 }
3681 3697
3682 3698
3683 RawField* Class::LookupField(const String& name, intptr_t type) const { 3699 RawField* Class::LookupField(const String& name, intptr_t type) const {
3684 Isolate* isolate = Isolate::Current(); 3700 Isolate* isolate = Isolate::Current();
3685 if (EnsureIsFinalized(isolate) != Error::null()) { 3701 if (EnsureIsFinalized(isolate) != Error::null()) {
3686 return Field::null(); 3702 return Field::null();
3687 } 3703 }
3688 ReusableHandleScope reused_handles(isolate); 3704 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3689 Array& flds = reused_handles.ArrayHandle(); 3705 REUSABLE_FIELD_HANDLESCOPE(isolate);
3706 REUSABLE_STRING_HANDLESCOPE(isolate);
3707 Array& flds = isolate->ArrayHandle();
3690 flds ^= fields(); 3708 flds ^= fields();
3691 ASSERT(!flds.IsNull()); 3709 ASSERT(!flds.IsNull());
3692 Field& field = reused_handles.FieldHandle();
3693 String& field_name = reused_handles.StringHandle();
3694 intptr_t len = flds.Length(); 3710 intptr_t len = flds.Length();
3711 Field& field = isolate->FieldHandle();
3712 String& field_name = isolate->StringHandle();
3695 for (intptr_t i = 0; i < len; i++) { 3713 for (intptr_t i = 0; i < len; i++) {
3696 field ^= flds.At(i); 3714 field ^= flds.At(i);
3697 field_name ^= field.name(); 3715 field_name ^= field.name();
3698 if (String::EqualsIgnoringPrivateKey(field_name, name)) { 3716 if (String::EqualsIgnoringPrivateKey(field_name, name)) {
3699 if (type == kInstance) { 3717 if (type == kInstance) {
3700 if (!field.is_static()) { 3718 if (!field.is_static()) {
3701 return field.raw(); 3719 return field.raw();
3702 } 3720 }
3703 } else if (type == kStatic) { 3721 } else if (type == kStatic) {
3704 if (field.is_static()) { 3722 if (field.is_static()) {
(...skipping 4296 matching lines...) Expand 10 before | Expand all | Expand 10 after
8001 } 8019 }
8002 StorePointer(&raw_ptr()->exports_, exports.raw()); 8020 StorePointer(&raw_ptr()->exports_, exports.raw());
8003 return obj.raw(); 8021 return obj.raw();
8004 } 8022 }
8005 return Object::null(); 8023 return Object::null();
8006 } 8024 }
8007 8025
8008 8026
8009 RawObject* Library::LookupEntry(const String& name, intptr_t *index) const { 8027 RawObject* Library::LookupEntry(const String& name, intptr_t *index) const {
8010 Isolate* isolate = Isolate::Current(); 8028 Isolate* isolate = Isolate::Current();
8011 ReusableHandleScope reused_handles(isolate); 8029 REUSABLE_ARRAY_HANDLESCOPE(isolate);
8012 Array& dict = reused_handles.ArrayHandle(); 8030 REUSABLE_OBJECT_HANDLESCOPE(isolate);
8031 REUSABLE_STRING_HANDLESCOPE(isolate);
8032 Array& dict = isolate->ArrayHandle();
8013 dict ^= dictionary(); 8033 dict ^= dictionary();
8014 intptr_t dict_size = dict.Length() - 1; 8034 intptr_t dict_size = dict.Length() - 1;
8015 *index = name.Hash() % dict_size; 8035 *index = name.Hash() % dict_size;
8016 8036 Object& entry = isolate->ObjectHandle();
8017 Object& entry = reused_handles.ObjectHandle(); 8037 String& entry_name = isolate->StringHandle();
8018 String& entry_name = reused_handles.StringHandle();
8019 entry = dict.At(*index); 8038 entry = dict.At(*index);
8020 // Search the entry in the hash set. 8039 // Search the entry in the hash set.
8021 while (!entry.IsNull()) { 8040 while (!entry.IsNull()) {
8022 entry_name = entry.DictionaryName(); 8041 entry_name = entry.DictionaryName();
8023 ASSERT(!entry_name.IsNull()); 8042 ASSERT(!entry_name.IsNull());
8024 if (entry_name.Equals(name)) { 8043 if (entry_name.Equals(name)) {
8025 return entry.raw(); 8044 return entry.raw();
8026 } 8045 }
8027 *index = (*index + 1) % dict_size; 8046 *index = (*index + 1) % dict_size;
8028 entry = dict.At(*index); 8047 entry = dict.At(*index);
(...skipping 9469 matching lines...) Expand 10 before | Expand all | Expand 10 after
17498 return "_MirrorReference"; 17517 return "_MirrorReference";
17499 } 17518 }
17500 17519
17501 17520
17502 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17521 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17503 Instance::PrintToJSONStream(stream, ref); 17522 Instance::PrintToJSONStream(stream, ref);
17504 } 17523 }
17505 17524
17506 17525
17507 } // namespace dart 17526 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/reusable_handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698