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

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

Issue 816353012: Mark all private functions in dart: libraries as invisible (*sniff*). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
255 // Takes a vm internal name and makes it suitable for external user. 163 // Takes a vm internal name and makes it suitable for external user.
256 // 164 //
257 // Examples: 165 // Examples:
258 // 166 //
259 // Internal getter and setter prefixes are changed: 167 // Internal getter and setter prefixes are changed:
260 // 168 //
261 // get:foo -> foo 169 // get:foo -> foo
262 // set:foo -> foo= 170 // set:foo -> foo=
263 // 171 //
264 // Private name mangling is removed, possibly multiple times: 172 // Private name mangling is removed, possibly multiple times:
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 1392
1485 // Finish the initialization by compiling the bootstrap scripts containing the 1393 // Finish the initialization by compiling the bootstrap scripts containing the
1486 // base interfaces and the implementation of the internal classes. 1394 // base interfaces and the implementation of the internal classes.
1487 StubCode::InitBootstrapStubs(isolate); 1395 StubCode::InitBootstrapStubs(isolate);
1488 const Error& error = Error::Handle(Bootstrap::LoadandCompileScripts()); 1396 const Error& error = Error::Handle(Bootstrap::LoadandCompileScripts());
1489 if (!error.IsNull()) { 1397 if (!error.IsNull()) {
1490 return error.raw(); 1398 return error.raw();
1491 } 1399 }
1492 1400
1493 ClassFinalizer::VerifyBootstrapClasses(); 1401 ClassFinalizer::VerifyBootstrapClasses();
1494 MarkInvisibleFunctions();
1495 1402
1496 // Set up the intrinsic state of all functions (core, math and typed data). 1403 // Set up the intrinsic state of all functions (core, math and typed data).
1497 Intrinsifier::InitializeState(); 1404 Intrinsifier::InitializeState();
1498 1405
1499 // Set up recognized state of all functions (core, math and typed data). 1406 // Set up recognized state of all functions (core, math and typed data).
1500 MethodRecognizer::InitializeState(); 1407 MethodRecognizer::InitializeState();
1501 1408
1502 // Adds static const fields (class ids) to the class 'ClassID'); 1409 // Adds static const fields (class ids) to the class 'ClassID');
1503 lib = Library::LookupLibrary(Symbols::DartInternal()); 1410 lib = Library::LookupLibrary(Symbols::DartInternal());
1504 ASSERT(!lib.IsNull()); 1411 ASSERT(!lib.IsNull());
(...skipping 19139 matching lines...) Expand 10 before | Expand all | Expand 10 after
20644 return tag_label.ToCString(); 20551 return tag_label.ToCString();
20645 } 20552 }
20646 20553
20647 20554
20648 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20555 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20649 Instance::PrintJSONImpl(stream, ref); 20556 Instance::PrintJSONImpl(stream, ref);
20650 } 20557 }
20651 20558
20652 20559
20653 } // namespace dart 20560 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698