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/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 153 RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
154 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 154 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
155 RawClass* Object::unhandled_exception_class_ = | 155 RawClass* Object::unhandled_exception_class_ = |
156 reinterpret_cast<RawClass*>(RAW_NULL); | 156 reinterpret_cast<RawClass*>(RAW_NULL); |
157 RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 157 RawClass* Object::unwind_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
158 | 158 |
159 | 159 |
160 const double MegamorphicCache::kLoadFactor = 0.75; | 160 const double MegamorphicCache::kLoadFactor = 0.75; |
161 | 161 |
162 | 162 |
| 163 // The following functions are marked as invisible, meaning they will be hidden |
| 164 // in the stack trace and will be hidden from reflective access. |
| 165 // All mutators of canonical constants should be hidden from reflective access. |
| 166 // Additionally, private functions in dart:* that are native or constructors are |
| 167 // marked as invisible by the parser. |
| 168 #define INVISIBLE_CLASS_FUNCTIONS(V) \ |
| 169 V(AsyncLibrary, _AsyncRun, _scheduleImmediate) \ |
| 170 V(CoreLibrary, StringBuffer, _addPart) \ |
| 171 V(CoreLibrary, _Bigint, _ensureLength) \ |
| 172 V(CoreLibrary, _Bigint, _clamp) \ |
| 173 V(CoreLibrary, _Bigint, _absAdd) \ |
| 174 V(CoreLibrary, _Bigint, _absSub) \ |
| 175 V(CoreLibrary, _Bigint, _estQuotientDigit) \ |
| 176 V(CoreLibrary, _Bigint, _mulAdd) \ |
| 177 V(CoreLibrary, _Bigint, _sqrAdd) \ |
| 178 V(CoreLibrary, _Double, _addFromInteger) \ |
| 179 V(CoreLibrary, _Double, _moduloFromInteger) \ |
| 180 V(CoreLibrary, _Double, _mulFromInteger) \ |
| 181 V(CoreLibrary, _Double, _remainderFromInteger) \ |
| 182 V(CoreLibrary, _Double, _subFromInteger) \ |
| 183 V(CoreLibrary, _Double, _truncDivFromInteger) \ |
| 184 V(CoreLibrary, _Montgomery, _mulMod) \ |
| 185 V(CoreLibrary, int, _parse) \ |
| 186 V(CoreLibrary, int, _throwFormatException) \ |
| 187 |
| 188 |
| 189 #define INVISIBLE_LIBRARY_FUNCTIONS(V) \ |
| 190 V(AsyncLibrary, _asyncRunCallback) \ |
| 191 V(AsyncLibrary, _rootHandleUncaughtError) \ |
| 192 V(AsyncLibrary, _scheduleAsyncCallback) \ |
| 193 V(AsyncLibrary, _schedulePriorityAsyncCallback) \ |
| 194 V(AsyncLibrary, _setScheduleImmediateClosure) \ |
| 195 V(AsyncLibrary, _setTimerFactoryClosure) \ |
| 196 V(IsolateLibrary, _isolateScheduleImmediate) \ |
| 197 V(IsolateLibrary, _startIsolate) \ |
| 198 V(IsolateLibrary, _startMainIsolate) \ |
| 199 V(MirrorsLibrary, _n) \ |
| 200 V(MirrorsLibrary, _s) \ |
| 201 V(TypedDataLibrary, _toInt16) \ |
| 202 V(TypedDataLibrary, _toInt32) \ |
| 203 V(TypedDataLibrary, _toInt64) \ |
| 204 V(TypedDataLibrary, _toInt8) \ |
| 205 V(TypedDataLibrary, _toUint16) \ |
| 206 V(TypedDataLibrary, _toUint32) \ |
| 207 V(TypedDataLibrary, _toUint64) \ |
| 208 V(TypedDataLibrary, _toUint8) \ |
| 209 |
| 210 |
| 211 static void MarkClassFunctionAsInvisible(const Library& lib, |
| 212 const char* class_name, |
| 213 const char* function_name) { |
| 214 ASSERT(!lib.IsNull()); |
| 215 const Class& cls = Class::Handle( |
| 216 lib.LookupClassAllowPrivate(String::Handle(String::New(class_name)))); |
| 217 ASSERT(!cls.IsNull()); |
| 218 const Function& function = |
| 219 Function::Handle( |
| 220 cls.LookupFunctionAllowPrivate( |
| 221 String::Handle(String::New(function_name)))); |
| 222 ASSERT(!function.IsNull()); |
| 223 function.set_is_visible(false); |
| 224 } |
| 225 |
| 226 static void MarkLibraryFunctionAsInvisible(const Library& lib, |
| 227 const char* function_name) { |
| 228 ASSERT(!lib.IsNull()); |
| 229 const Function& function = |
| 230 Function::Handle( |
| 231 lib.LookupFunctionAllowPrivate( |
| 232 String::Handle(String::New(function_name)))); |
| 233 ASSERT(!function.IsNull()); |
| 234 function.set_is_visible(false); |
| 235 } |
| 236 |
| 237 |
| 238 static void MarkInvisibleFunctions() { |
| 239 #define MARK_FUNCTION(lib, class_name, function_name) \ |
| 240 MarkClassFunctionAsInvisible(Library::Handle(Library::lib()), \ |
| 241 #class_name, #function_name); \ |
| 242 |
| 243 INVISIBLE_CLASS_FUNCTIONS(MARK_FUNCTION) |
| 244 #undef MARK_FUNCTION |
| 245 |
| 246 #define MARK_FUNCTION(lib, function_name) \ |
| 247 MarkLibraryFunctionAsInvisible(Library::Handle(Library::lib()), \ |
| 248 #function_name); \ |
| 249 |
| 250 INVISIBLE_LIBRARY_FUNCTIONS(MARK_FUNCTION) |
| 251 #undef MARK_FUNCTION |
| 252 } |
| 253 |
| 254 |
163 // Takes a vm internal name and makes it suitable for external user. | 255 // Takes a vm internal name and makes it suitable for external user. |
164 // | 256 // |
165 // Examples: | 257 // Examples: |
166 // | 258 // |
167 // Internal getter and setter prefixes are changed: | 259 // Internal getter and setter prefixes are changed: |
168 // | 260 // |
169 // get:foo -> foo | 261 // get:foo -> foo |
170 // set:foo -> foo= | 262 // set:foo -> foo= |
171 // | 263 // |
172 // Private name mangling is removed, possibly multiple times: | 264 // Private name mangling is removed, possibly multiple times: |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 | 1484 |
1393 // Finish the initialization by compiling the bootstrap scripts containing the | 1485 // Finish the initialization by compiling the bootstrap scripts containing the |
1394 // base interfaces and the implementation of the internal classes. | 1486 // base interfaces and the implementation of the internal classes. |
1395 StubCode::InitBootstrapStubs(isolate); | 1487 StubCode::InitBootstrapStubs(isolate); |
1396 const Error& error = Error::Handle(Bootstrap::LoadandCompileScripts()); | 1488 const Error& error = Error::Handle(Bootstrap::LoadandCompileScripts()); |
1397 if (!error.IsNull()) { | 1489 if (!error.IsNull()) { |
1398 return error.raw(); | 1490 return error.raw(); |
1399 } | 1491 } |
1400 | 1492 |
1401 ClassFinalizer::VerifyBootstrapClasses(); | 1493 ClassFinalizer::VerifyBootstrapClasses(); |
| 1494 MarkInvisibleFunctions(); |
1402 | 1495 |
1403 // Set up the intrinsic state of all functions (core, math and typed data). | 1496 // Set up the intrinsic state of all functions (core, math and typed data). |
1404 Intrinsifier::InitializeState(); | 1497 Intrinsifier::InitializeState(); |
1405 | 1498 |
1406 // Set up recognized state of all functions (core, math and typed data). | 1499 // Set up recognized state of all functions (core, math and typed data). |
1407 MethodRecognizer::InitializeState(); | 1500 MethodRecognizer::InitializeState(); |
1408 | 1501 |
1409 // Adds static const fields (class ids) to the class 'ClassID'); | 1502 // Adds static const fields (class ids) to the class 'ClassID'); |
1410 lib = Library::LookupLibrary(Symbols::DartInternal()); | 1503 lib = Library::LookupLibrary(Symbols::DartInternal()); |
1411 ASSERT(!lib.IsNull()); | 1504 ASSERT(!lib.IsNull()); |
(...skipping 19139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20551 return tag_label.ToCString(); | 20644 return tag_label.ToCString(); |
20552 } | 20645 } |
20553 | 20646 |
20554 | 20647 |
20555 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20648 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20556 Instance::PrintJSONImpl(stream, ref); | 20649 Instance::PrintJSONImpl(stream, ref); |
20557 } | 20650 } |
20558 | 20651 |
20559 | 20652 |
20560 } // namespace dart | 20653 } // namespace dart |
OLD | NEW |