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

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

Issue 2820363002: Move Kernel strings into the VM's heap. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 RUNTIME_VM_KERNEL_TO_IL_H_ 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ 6 #define RUNTIME_VM_KERNEL_TO_IL_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 9
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ~ActiveFunctionScope() { *active_class_ = saved_; } 262 ~ActiveFunctionScope() { *active_class_ = saved_; }
263 263
264 private: 264 private:
265 ActiveClass* active_class_; 265 ActiveClass* active_class_;
266 ActiveClass saved_; 266 ActiveClass saved_;
267 }; 267 };
268 268
269 269
270 class TranslationHelper { 270 class TranslationHelper {
271 public: 271 public:
272 explicit TranslationHelper(dart::Thread* thread) 272 explicit TranslationHelper(dart::Thread* thread);
273 : thread_(thread),
274 zone_(thread->zone()),
275 isolate_(thread->isolate()),
276 allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld) {
277 }
278 virtual ~TranslationHelper() {} 273 virtual ~TranslationHelper() {}
279 274
280 Thread* thread() { return thread_; } 275 Thread* thread() { return thread_; }
281 276
282 Zone* zone() { return zone_; } 277 Zone* zone() { return zone_; }
283 278
284 Isolate* isolate() { return isolate_; } 279 Isolate* isolate() { return isolate_; }
285 280
286 Heap::Space allocation_space() { return allocation_space_; } 281 Heap::Space allocation_space() { return allocation_space_; }
287 282
283 // Access to strings.
284 const TypedData& string_data() { return string_data_; }
285 void SetStringData(const TypedData& string_data);
286 uint8_t CharacterAt(String* str, intptr_t index);
287 bool StringEquals(String* str, const char* other);
288
289 // Predicates on CanonicalNames.
290 bool IsAdministrative(CanonicalName* name);
291 bool IsPrivate(CanonicalName* name);
292 bool IsRoot(CanonicalName* name);
293 bool IsLibrary(CanonicalName* name);
294 bool IsClass(CanonicalName* name);
295 bool IsMember(CanonicalName* name);
296 bool IsField(CanonicalName* name);
297 bool IsConstructor(CanonicalName* name);
298 bool IsProcedure(CanonicalName* name);
299 bool IsMethod(CanonicalName* name);
300 bool IsGetter(CanonicalName* name);
301 bool IsSetter(CanonicalName* name);
302 bool IsFactory(CanonicalName* name);
303
304 // For a member (field, constructor, or procedure) return the canonical name
305 // of the enclosing class or library.
306 CanonicalName* EnclosingName(CanonicalName* name);
307
288 RawInstance* Canonicalize(const Instance& instance); 308 RawInstance* Canonicalize(const Instance& instance);
289 309
290 const dart::String& DartString(const char* content) { 310 const dart::String& DartString(const char* content) {
291 return DartString(content, allocation_space_); 311 return DartString(content, allocation_space_);
292 } 312 }
293 const dart::String& DartString(const char* content, Heap::Space space); 313 const dart::String& DartString(const char* content, Heap::Space space);
294 314
295 dart::String& DartString(String* content) { 315 dart::String& DartString(String* content) {
296 return DartString(content, allocation_space_); 316 return DartString(content, allocation_space_);
297 } 317 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // returned. If the name is private, the canonical name [parent] will be used 375 // returned. If the name is private, the canonical name [parent] will be used
356 // to get the import URI of the library where the name is visible. 376 // to get the import URI of the library where the name is visible.
357 dart::String& ManglePrivateName(CanonicalName* parent, 377 dart::String& ManglePrivateName(CanonicalName* parent,
358 dart::String* name_to_modify, 378 dart::String* name_to_modify,
359 bool symbolize = true); 379 bool symbolize = true);
360 380
361 const dart::String& DartSetterName(CanonicalName* parent, String* setter); 381 const dart::String& DartSetterName(CanonicalName* parent, String* setter);
362 const dart::String& DartGetterName(CanonicalName* parent, String* getter); 382 const dart::String& DartGetterName(CanonicalName* parent, String* getter);
363 const dart::String& DartMethodName(CanonicalName* parent, String* method); 383 const dart::String& DartMethodName(CanonicalName* parent, String* method);
364 384
365 dart::Thread* thread_; 385 Thread* thread_;
366 dart::Zone* zone_; 386 Zone* zone_;
367 dart::Isolate* isolate_; 387 Isolate* isolate_;
368 Heap::Space allocation_space_; 388 Heap::Space allocation_space_;
389
390 TypedData& string_data_;
369 }; 391 };
370 392
371 // Regarding malformed types: 393 // Regarding malformed types:
372 // The spec says in section "19.1 Static Types" roughly: 394 // The spec says in section "19.1 Static Types" roughly:
373 // 395 //
374 // A type T is malformed iff: 396 // A type T is malformed iff:
375 // * T does not denote a type in scope 397 // * T does not denote a type in scope
376 // * T refers to a type parameter in a static member 398 // * T refers to a type parameter in a static member
377 // * T is a parametrized Type G<T1, ...> and G is malformed 399 // * T is a parametrized Type G<T1, ...> and G is malformed
378 // * T denotes declarations from multiple imports 400 // * T denotes declarations from multiple imports
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 GrowableArray<LocalVariable*> stack_trace_variables; 643 GrowableArray<LocalVariable*> stack_trace_variables;
622 GrowableArray<LocalVariable*> catch_context_variables; 644 GrowableArray<LocalVariable*> catch_context_variables;
623 645
624 // For-in iterators, one per for-in nesting level. 646 // For-in iterators, one per for-in nesting level.
625 GrowableArray<LocalVariable*> iterator_variables; 647 GrowableArray<LocalVariable*> iterator_variables;
626 }; 648 };
627 649
628 650
629 class ScopeBuilder : public RecursiveVisitor { 651 class ScopeBuilder : public RecursiveVisitor {
630 public: 652 public:
631 ScopeBuilder(ParsedFunction* parsed_function, TreeNode* node) 653 ScopeBuilder(ParsedFunction* parsed_function, TreeNode* node);
632 : result_(NULL),
633 parsed_function_(parsed_function),
634 node_(node),
635 translation_helper_(Thread::Current()),
636 zone_(translation_helper_.zone()),
637 type_translator_(&translation_helper_,
638 &active_class_,
639 /*finalize=*/true),
640 current_function_scope_(NULL),
641 scope_(NULL),
642 depth_(0),
643 name_index_(0),
644 needs_expr_temp_(false) {}
645 654
646 virtual ~ScopeBuilder() {} 655 virtual ~ScopeBuilder() {}
647 656
648 ScopeBuildingResult* BuildScopes(); 657 ScopeBuildingResult* BuildScopes();
649 658
650 virtual void VisitName(Name* node) { /* NOP */ 659 virtual void VisitName(Name* node) { /* NOP */
651 } 660 }
652 661
653 virtual void VisitThisExpression(ThisExpression* node); 662 virtual void VisitThisExpression(ThisExpression* node);
654 virtual void VisitTypeParameterType(TypeParameterType* node); 663 virtual void VisitTypeParameterType(TypeParameterType* node);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1122
1114 private: 1123 private:
1115 FlowGraphBuilder* builder_; 1124 FlowGraphBuilder* builder_;
1116 CatchBlock* outer_; 1125 CatchBlock* outer_;
1117 LocalVariable* exception_var_; 1126 LocalVariable* exception_var_;
1118 LocalVariable* stack_trace_var_; 1127 LocalVariable* stack_trace_var_;
1119 intptr_t catch_try_index_; 1128 intptr_t catch_try_index_;
1120 }; 1129 };
1121 1130
1122 1131
1123 RawObject* EvaluateMetadata(TreeNode* const kernel_node); 1132 RawObject* EvaluateMetadata(const dart::Field& metadata_field);
1124 RawObject* BuildParameterDescriptor(TreeNode* const kernel_node); 1133 RawObject* BuildParameterDescriptor(TreeNode* const kernel_node);
1125 1134
1126 1135
1127 } // namespace kernel 1136 } // namespace kernel
1128 } // namespace dart 1137 } // namespace dart
1129 1138
1130 #else // !defined(DART_PRECOMPILED_RUNTIME) 1139 #else // !defined(DART_PRECOMPILED_RUNTIME)
1131 1140
1132 #include "vm/object.h" 1141 #include "vm/object.h"
1133 #include "vm/kernel.h" 1142 #include "vm/kernel.h"
1134 1143
1135 namespace dart { 1144 namespace dart {
1136 namespace kernel { 1145 namespace kernel {
1137 1146
1138 RawObject* EvaluateMetadata(TreeNode* const kernel_node); 1147 RawObject* EvaluateMetadata(const dart::Field& metadata_field);
1139 RawObject* BuildParameterDescriptor(TreeNode* const kernel_node); 1148 RawObject* BuildParameterDescriptor(TreeNode* const kernel_node);
1140 1149
1141 } // namespace kernel 1150 } // namespace kernel
1142 } // namespace dart 1151 } // namespace dart
1143 1152
1144 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1153 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1145 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ 1154 #endif // RUNTIME_VM_KERNEL_TO_IL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698