| 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 MarkFunctionAsInvisible(const Library& lib, |
| 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 MarkFunctionAsInvisible(Library::Handle(Library::lib()), \ |
| 154 #class_name, #function_name); \ |
| 155 |
| 156 INVISIBLE_LIST(MARK_FUNCTION) |
| 157 #undef MARK_FUNCTION |
| 158 } |
| 159 |
| 120 // Takes a vm internal name and makes it suitable for external user. | 160 // Takes a vm internal name and makes it suitable for external user. |
| 121 // | 161 // |
| 122 // Examples: | 162 // Examples: |
| 123 // | 163 // |
| 124 // Internal getter and setter prefixes are changed: | 164 // Internal getter and setter prefixes are changed: |
| 125 // | 165 // |
| 126 // get:foo -> foo | 166 // get:foo -> foo |
| 127 // set:foo -> foo= | 167 // set:foo -> foo= |
| 128 // | 168 // |
| 129 // Private name mangling is removed, possibly twice: | 169 // Private name mangling is removed, possibly twice: |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 return error.raw(); | 1072 return error.raw(); |
| 1033 } | 1073 } |
| 1034 Bootstrap::SetupNativeResolver(); | 1074 Bootstrap::SetupNativeResolver(); |
| 1035 | 1075 |
| 1036 // Remove the Object superclass cycle by setting the super type to null (not | 1076 // Remove the Object superclass cycle by setting the super type to null (not |
| 1037 // to the type of null). | 1077 // to the type of null). |
| 1038 cls = object_store->object_class(); | 1078 cls = object_store->object_class(); |
| 1039 cls.set_super_type(Type::Handle()); | 1079 cls.set_super_type(Type::Handle()); |
| 1040 | 1080 |
| 1041 ClassFinalizer::VerifyBootstrapClasses(); | 1081 ClassFinalizer::VerifyBootstrapClasses(); |
| 1082 MarkInvisibleFunctions(); |
| 1042 return Error::null(); | 1083 return Error::null(); |
| 1043 } | 1084 } |
| 1044 | 1085 |
| 1045 | 1086 |
| 1046 void Object::InitFromSnapshot(Isolate* isolate) { | 1087 void Object::InitFromSnapshot(Isolate* isolate) { |
| 1047 TIMERSCOPE(time_bootstrap); | 1088 TIMERSCOPE(time_bootstrap); |
| 1048 ObjectStore* object_store = isolate->object_store(); | 1089 ObjectStore* object_store = isolate->object_store(); |
| 1049 | 1090 |
| 1050 Class& cls = Class::Handle(); | 1091 Class& cls = Class::Handle(); |
| 1051 | 1092 |
| (...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3631 | 3672 |
| 3632 | 3673 |
| 3633 bool Function::IsInlineable() const { | 3674 bool Function::IsInlineable() const { |
| 3634 // '==' call is handled specially. | 3675 // '==' call is handled specially. |
| 3635 return InlinableBit::decode(raw_ptr()->kind_tag_) && | 3676 return InlinableBit::decode(raw_ptr()->kind_tag_) && |
| 3636 HasCode() && | 3677 HasCode() && |
| 3637 name() != Symbols::EqualOperator().raw(); | 3678 name() != Symbols::EqualOperator().raw(); |
| 3638 } | 3679 } |
| 3639 | 3680 |
| 3640 | 3681 |
| 3682 void Function::set_is_visible(bool value) const { |
| 3683 set_kind_tag(VisibleBit::update(value, raw_ptr()->kind_tag_)); |
| 3684 } |
| 3685 |
| 3686 |
| 3641 intptr_t Function::NumParameters() const { | 3687 intptr_t Function::NumParameters() const { |
| 3642 return num_fixed_parameters() + NumOptionalParameters(); | 3688 return num_fixed_parameters() + NumOptionalParameters(); |
| 3643 } | 3689 } |
| 3644 | 3690 |
| 3645 | 3691 |
| 3646 intptr_t Function::NumImplicitParameters() const { | 3692 intptr_t Function::NumImplicitParameters() const { |
| 3647 if (kind() == RawFunction::kConstructor) { | 3693 if (kind() == RawFunction::kConstructor) { |
| 3648 if (is_static()) { | 3694 if (is_static()) { |
| 3649 ASSERT(IsFactory()); | 3695 ASSERT(IsFactory()); |
| 3650 return 1; // Type arguments. | 3696 return 1; // Type arguments. |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4040 ASSERT(!owner.IsNull()); | 4086 ASSERT(!owner.IsNull()); |
| 4041 const Function& result = Function::Handle(Function::New()); | 4087 const Function& result = Function::Handle(Function::New()); |
| 4042 result.set_parameter_types(Object::empty_array()); | 4088 result.set_parameter_types(Object::empty_array()); |
| 4043 result.set_parameter_names(Object::empty_array()); | 4089 result.set_parameter_names(Object::empty_array()); |
| 4044 result.set_name(name); | 4090 result.set_name(name); |
| 4045 result.set_kind(kind); | 4091 result.set_kind(kind); |
| 4046 result.set_is_static(is_static); | 4092 result.set_is_static(is_static); |
| 4047 result.set_is_const(is_const); | 4093 result.set_is_const(is_const); |
| 4048 result.set_is_abstract(is_abstract); | 4094 result.set_is_abstract(is_abstract); |
| 4049 result.set_is_external(is_external); | 4095 result.set_is_external(is_external); |
| 4096 result.set_is_visible(true); // Will be computed later. |
| 4050 result.set_intrinsic_kind(kUnknownIntrinsic); | 4097 result.set_intrinsic_kind(kUnknownIntrinsic); |
| 4051 result.set_owner(owner); | 4098 result.set_owner(owner); |
| 4052 result.set_token_pos(token_pos); | 4099 result.set_token_pos(token_pos); |
| 4053 result.set_end_token_pos(token_pos); | 4100 result.set_end_token_pos(token_pos); |
| 4054 result.set_num_fixed_parameters(0); | 4101 result.set_num_fixed_parameters(0); |
| 4055 result.set_num_optional_parameters(0); | 4102 result.set_num_optional_parameters(0); |
| 4056 result.set_usage_counter(0); | 4103 result.set_usage_counter(0); |
| 4057 result.set_deoptimization_counter(0); | 4104 result.set_deoptimization_counter(0); |
| 4058 result.set_optimized_instruction_count(0); | 4105 result.set_optimized_instruction_count(0); |
| 4059 result.set_optimized_call_site_count(0); | 4106 result.set_optimized_call_site_count(0); |
| (...skipping 8683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12743 } | 12790 } |
| 12744 return result.raw(); | 12791 return result.raw(); |
| 12745 } | 12792 } |
| 12746 | 12793 |
| 12747 | 12794 |
| 12748 const char* WeakProperty::ToCString() const { | 12795 const char* WeakProperty::ToCString() const { |
| 12749 return "_WeakProperty"; | 12796 return "_WeakProperty"; |
| 12750 } | 12797 } |
| 12751 | 12798 |
| 12752 } // namespace dart | 12799 } // namespace dart |
| OLD | NEW |