OLD | NEW |
---|---|
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 110 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
111 RawClass* Object::unhandled_exception_class_ = | 111 RawClass* Object::unhandled_exception_class_ = |
112 reinterpret_cast<RawClass*>(RAW_NULL); | 112 reinterpret_cast<RawClass*>(RAW_NULL); |
113 RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 113 RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
114 #undef RAW_NULL | 114 #undef RAW_NULL |
115 | 115 |
116 | 116 |
117 const double MegamorphicCache::kLoadFactor = 0.75; | 117 const double MegamorphicCache::kLoadFactor = 0.75; |
118 | 118 |
119 | 119 |
120 // The following functions are marked as invisible, meaning they will be hidden | |
121 // in the stack trace. | |
122 // (Library, class name, method name) | |
123 #define INVISIBLE_LIST(V) \ | |
124 V(CoreLibrary, Object, _noSuchMethod) \ | |
125 V(CoreLibrary, List, _throwArgumentError) \ | |
126 V(CoreLibrary, AssertionErrorImplementation, _throwNew) \ | |
127 V(CoreLibrary, TypeErrorImplementation, _throwNew) \ | |
128 V(CoreLibrary, FallThroughErrorImplementation, _throwNew) \ | |
129 V(CoreLibrary, AbstractClassInstantiationErrorImplementation, _throwNew) \ | |
130 V(CoreLibrary, NoSuchMethodError, _throwNew) \ | |
131 V(CoreLibrary, int, _throwFormatException) \ | |
132 V(CoreLibrary, int, _parse) \ | |
133 | |
134 | |
135 static void CallIt(const Library& lib, | |
Ivan Posva
2013/01/23 01:17:26
Please CallIt something more descriptive.
srdjan
2013/01/23 19:22:29
MarkFunctionAsInvisible
| |
136 const char* class_name, | |
137 const char* function_name) { | |
138 ASSERT(!lib.IsNull()); | |
139 const Class& cls = Class::Handle( | |
140 lib.LookupClass(String::Handle(String::New(class_name)))); | |
141 ASSERT(!cls.IsNull()); | |
142 const Function& function = | |
143 Function::Handle( | |
144 cls.LookupFunctionAllowPrivate( | |
145 String::Handle(String::New(function_name)))); | |
146 ASSERT(!function.IsNull()); | |
147 function.set_is_visible(false); | |
148 } | |
149 | |
150 | |
151 static void MarkInvisibleFunctions() { | |
152 #define MARK_FUNCTION(lib, class_name, function_name) \ | |
153 CallIt(Library::Handle(Library::lib()), #class_name, #function_name); | |
154 | |
155 INVISIBLE_LIST(MARK_FUNCTION) | |
156 #undef MARK_FUNCTION | |
157 } | |
158 | |
120 // Takes a vm internal name and makes it suitable for external user. | 159 // Takes a vm internal name and makes it suitable for external user. |
121 // | 160 // |
122 // Examples: | 161 // Examples: |
123 // | 162 // |
124 // Internal getter and setter prefixes are changed: | 163 // Internal getter and setter prefixes are changed: |
125 // | 164 // |
126 // get:foo -> foo | 165 // get:foo -> foo |
127 // set:foo -> foo= | 166 // set:foo -> foo= |
128 // | 167 // |
129 // Private name mangling is removed, possibly twice: | 168 // Private name mangling is removed, possibly twice: |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 return error.raw(); | 1056 return error.raw(); |
1018 } | 1057 } |
1019 Bootstrap::SetupNativeResolver(); | 1058 Bootstrap::SetupNativeResolver(); |
1020 | 1059 |
1021 // Remove the Object superclass cycle by setting the super type to null (not | 1060 // Remove the Object superclass cycle by setting the super type to null (not |
1022 // to the type of null). | 1061 // to the type of null). |
1023 cls = object_store->object_class(); | 1062 cls = object_store->object_class(); |
1024 cls.set_super_type(Type::Handle()); | 1063 cls.set_super_type(Type::Handle()); |
1025 | 1064 |
1026 ClassFinalizer::VerifyBootstrapClasses(); | 1065 ClassFinalizer::VerifyBootstrapClasses(); |
1066 MarkInvisibleFunctions(); | |
1027 return Error::null(); | 1067 return Error::null(); |
1028 } | 1068 } |
1029 | 1069 |
1030 | 1070 |
1031 void Object::InitFromSnapshot(Isolate* isolate) { | 1071 void Object::InitFromSnapshot(Isolate* isolate) { |
1032 TIMERSCOPE(time_bootstrap); | 1072 TIMERSCOPE(time_bootstrap); |
1033 ObjectStore* object_store = isolate->object_store(); | 1073 ObjectStore* object_store = isolate->object_store(); |
1034 | 1074 |
1035 Class& cls = Class::Handle(); | 1075 Class& cls = Class::Handle(); |
1036 | 1076 |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3621 | 3661 |
3622 | 3662 |
3623 bool Function::IsInlineable() const { | 3663 bool Function::IsInlineable() const { |
3624 // '==' call is handled specially. | 3664 // '==' call is handled specially. |
3625 return InlinableBit::decode(raw_ptr()->kind_tag_) && | 3665 return InlinableBit::decode(raw_ptr()->kind_tag_) && |
3626 HasCode() && | 3666 HasCode() && |
3627 name() != Symbols::EqualOperator().raw(); | 3667 name() != Symbols::EqualOperator().raw(); |
3628 } | 3668 } |
3629 | 3669 |
3630 | 3670 |
3671 void Function::set_is_visible(bool value) const { | |
3672 set_kind_tag(VisibleBit::update(value, raw_ptr()->kind_tag_)); | |
3673 } | |
3674 | |
3675 | |
3631 intptr_t Function::NumParameters() const { | 3676 intptr_t Function::NumParameters() const { |
3632 return num_fixed_parameters() + NumOptionalParameters(); | 3677 return num_fixed_parameters() + NumOptionalParameters(); |
3633 } | 3678 } |
3634 | 3679 |
3635 | 3680 |
3636 intptr_t Function::NumImplicitParameters() const { | 3681 intptr_t Function::NumImplicitParameters() const { |
3637 if (kind() == RawFunction::kConstructor) { | 3682 if (kind() == RawFunction::kConstructor) { |
3638 if (is_static()) { | 3683 if (is_static()) { |
3639 ASSERT(IsFactory()); | 3684 ASSERT(IsFactory()); |
3640 return 1; // Type arguments. | 3685 return 1; // Type arguments. |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4031 ASSERT(!owner.IsNull()); | 4076 ASSERT(!owner.IsNull()); |
4032 const Function& result = Function::Handle(Function::New()); | 4077 const Function& result = Function::Handle(Function::New()); |
4033 result.set_parameter_types(Object::empty_array()); | 4078 result.set_parameter_types(Object::empty_array()); |
4034 result.set_parameter_names(Object::empty_array()); | 4079 result.set_parameter_names(Object::empty_array()); |
4035 result.set_name(name); | 4080 result.set_name(name); |
4036 result.set_kind(kind); | 4081 result.set_kind(kind); |
4037 result.set_is_static(is_static); | 4082 result.set_is_static(is_static); |
4038 result.set_is_const(is_const); | 4083 result.set_is_const(is_const); |
4039 result.set_is_abstract(is_abstract); | 4084 result.set_is_abstract(is_abstract); |
4040 result.set_is_external(is_external); | 4085 result.set_is_external(is_external); |
4086 result.set_is_visible(true); // Will be computed later. | |
4041 result.set_intrinsic_kind(kUnknownIntrinsic); | 4087 result.set_intrinsic_kind(kUnknownIntrinsic); |
4042 result.set_owner(owner); | 4088 result.set_owner(owner); |
4043 result.set_token_pos(token_pos); | 4089 result.set_token_pos(token_pos); |
4044 result.set_end_token_pos(token_pos); | 4090 result.set_end_token_pos(token_pos); |
4045 result.set_num_fixed_parameters(0); | 4091 result.set_num_fixed_parameters(0); |
4046 result.set_num_optional_parameters(0); | 4092 result.set_num_optional_parameters(0); |
4047 result.set_usage_counter(0); | 4093 result.set_usage_counter(0); |
4048 result.set_deoptimization_counter(0); | 4094 result.set_deoptimization_counter(0); |
4049 result.set_optimized_instruction_count(0); | 4095 result.set_optimized_instruction_count(0); |
4050 result.set_optimized_call_site_count(0); | 4096 result.set_optimized_call_site_count(0); |
(...skipping 8644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12695 } | 12741 } |
12696 return result.raw(); | 12742 return result.raw(); |
12697 } | 12743 } |
12698 | 12744 |
12699 | 12745 |
12700 const char* WeakProperty::ToCString() const { | 12746 const char* WeakProperty::ToCString() const { |
12701 return "_WeakProperty"; | 12747 return "_WeakProperty"; |
12702 } | 12748 } |
12703 | 12749 |
12704 } // namespace dart | 12750 } // namespace dart |
OLD | NEW |