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

Side by Side Diff: runtime/vm/symbols.h

Issue 1944213002: Support for taking full snapshots from 'dart', not just 'dart_bootstrap'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « runtime/vm/snapshot_test.cc ('k') | runtime/vm/symbols.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 #ifndef VM_SYMBOLS_H_ 5 #ifndef VM_SYMBOLS_H_
6 #define VM_SYMBOLS_H_ 6 #define VM_SYMBOLS_H_
7 7
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/snapshot_ids.h" 10 #include "vm/snapshot_ids.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 DART_KEYWORD_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) 548 DART_KEYWORD_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR)
549 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR 549 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR
550 550
551 // Get symbol for scanner token. 551 // Get symbol for scanner token.
552 static const String& Token(Token::Kind token); 552 static const String& Token(Token::Kind token);
553 553
554 // Initialize frequently used symbols in the vm isolate. 554 // Initialize frequently used symbols in the vm isolate.
555 static void InitOnce(Isolate* isolate); 555 static void InitOnce(Isolate* isolate);
556 static void InitOnceFromSnapshot(Isolate* isolate); 556 static void InitOnceFromSnapshot(Isolate* isolate);
557 557
558 // Add all the symbols that were cached in the VM isolate to this isolate,
559 // we do this when an Isolate is not created from the snapshot so that
560 // we get a unified symbol table that can be be dumped into the VM isolate
561 // snapshot.
562 static void AddPredefinedSymbolsToIsolate();
563
564 // Initialize and setup a symbol table for the isolate. 558 // Initialize and setup a symbol table for the isolate.
565 static void SetupSymbolTable(Isolate* isolate); 559 static void SetupSymbolTable(Isolate* isolate);
566 560
567 // Treat the symbol table as weak and collect garbage. Answer the number of 561 static RawArray* UnifiedSymbolTable();
568 // symbols deleted from the symbol table because they where not referenced 562
569 // from anywhere else. 563 #if defined(DART_PRECOMPILER)
570 static intptr_t Compact(Isolate* isolate); 564 // Treat the symbol table as weak and collect garbage.
565 static void Compact(Isolate* isolate);
566 #endif
571 567
572 // Creates a Symbol given a C string that is assumed to contain 568 // Creates a Symbol given a C string that is assumed to contain
573 // UTF-8 encoded characters and '\0' is considered a termination character. 569 // UTF-8 encoded characters and '\0' is considered a termination character.
574 // TODO(7123) - Rename this to FromCString(....). 570 // TODO(7123) - Rename this to FromCString(....).
575 static RawString* New(Thread* thread, const char* cstr) { 571 static RawString* New(Thread* thread, const char* cstr) {
576 return New(thread, cstr, strlen(cstr)); 572 return New(thread, cstr, strlen(cstr));
577 } 573 }
578 static RawString* New(Thread* thread, const char* cstr, intptr_t length); 574 static RawString* New(Thread* thread, const char* cstr, intptr_t length);
579 575
580 // Creates a new Symbol from an array of UTF-8 encoded characters. 576 // Creates a new Symbol from an array of UTF-8 encoded characters.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 633
638 // Returns Symbol::Null if no symbol is found. 634 // Returns Symbol::Null if no symbol is found.
639 static RawString* LookupFromConcat(Thread* thread, 635 static RawString* LookupFromConcat(Thread* thread,
640 const String& str1, 636 const String& str1,
641 const String& str2); 637 const String& str2);
642 638
643 static RawString* LookupFromGet(Thread* thread, const String& str); 639 static RawString* LookupFromGet(Thread* thread, const String& str);
644 static RawString* LookupFromSet(Thread* thread, const String& str); 640 static RawString* LookupFromSet(Thread* thread, const String& str);
645 static RawString* LookupFromDot(Thread* thread, const String& str); 641 static RawString* LookupFromDot(Thread* thread, const String& str);
646 642
643 static void GetStats(Isolate* isolate,
644 intptr_t* size,
645 intptr_t* capacity);
646
647 private: 647 private:
648 enum { 648 enum {
649 kInitialVMIsolateSymtabSize = 1024, 649 kInitialVMIsolateSymtabSize = 1024,
650 kInitialSymtabSize = 2048 650 kInitialSymtabSize = 2048
651 }; 651 };
652 652
653 static void GetStats(Isolate* isolate,
654 intptr_t* size,
655 intptr_t* capacity);
656
657 template<typename StringType> 653 template<typename StringType>
658 static RawString* NewSymbol(Thread* thread, const StringType& str); 654 static RawString* NewSymbol(Thread* thread, const StringType& str);
659 655
660 static intptr_t LookupVMSymbol(RawObject* obj); 656 static intptr_t LookupPredefinedSymbol(RawObject* obj);
661 static RawObject* GetVMSymbol(intptr_t object_id); 657 static RawObject* GetPredefinedSymbol(intptr_t object_id);
662 static bool IsVMSymbolId(intptr_t object_id) { 658 static bool IsPredefinedSymbolId(intptr_t object_id) {
663 return (object_id >= kMaxPredefinedObjectIds && 659 return (object_id >= kMaxPredefinedObjectIds &&
664 object_id < (kMaxPredefinedObjectIds + kMaxPredefinedId)); 660 object_id < (kMaxPredefinedObjectIds + kMaxPredefinedId));
665 } 661 }
666 662
667 // List of Latin1 characters stored in the vm isolate as symbols 663 // List of Latin1 characters stored in the vm isolate as symbols
668 // in order to make Symbols::FromCharCode fast. This structure is 664 // in order to make Symbols::FromCharCode fast. This structure is
669 // used in generated dart code for direct access to these objects. 665 // used in generated dart code for direct access to these objects.
670 static RawString* predefined_[kNumberOfOneCharCodeSymbols]; 666 static RawString* predefined_[kNumberOfOneCharCodeSymbols];
671 667
672 // List of handles for predefined symbols. 668 // List of handles for predefined symbols.
673 static String* symbol_handles_[kMaxPredefinedId]; 669 static String* symbol_handles_[kMaxPredefinedId];
674 670
675 friend class Dart; 671 friend class Dart;
676 friend class String; 672 friend class String;
677 friend class SnapshotReader; 673 friend class SnapshotReader;
678 friend class SnapshotWriter; 674 friend class SnapshotWriter;
679 friend class ApiMessageReader; 675 friend class ApiMessageReader;
680 676
681 DISALLOW_COPY_AND_ASSIGN(Symbols); 677 DISALLOW_COPY_AND_ASSIGN(Symbols);
682 }; 678 };
683 679
684 } // namespace dart 680 } // namespace dart
685 681
686 #endif // VM_SYMBOLS_H_ 682 #endif // VM_SYMBOLS_H_
OLDNEW
« no previous file with comments | « runtime/vm/snapshot_test.cc ('k') | runtime/vm/symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698