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

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

Issue 2853423002: Move the Kernel canonical name table into the VM's heap (Closed)
Patch Set: Merge a bugfix Created 3 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
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 Thread* thread() { return thread_; } 275 Thread* thread() { return thread_; }
276 276
277 Zone* zone() { return zone_; } 277 Zone* zone() { return zone_; }
278 278
279 Isolate* isolate() { return isolate_; } 279 Isolate* isolate() { return isolate_; }
280 280
281 Heap::Space allocation_space() { return allocation_space_; } 281 Heap::Space allocation_space() { return allocation_space_; }
282 282
283 // Access to strings. 283 // Access to strings.
284 const TypedData& string_offsets() { return string_offsets_; } 284 const TypedData& string_offsets() { return string_offsets_; }
285 void SetStringOffsets(const TypedData& string_data); 285 void SetStringOffsets(const TypedData& string_offsets);
286 286
287 const TypedData& string_data() { return string_data_; } 287 const TypedData& string_data() { return string_data_; }
288 void SetStringData(const TypedData& string_data); 288 void SetStringData(const TypedData& string_data);
289 289
290 const TypedData& canonical_names() { return canonical_names_; }
291 void SetCanonicalNames(const TypedData& canonical_names);
292
290 intptr_t StringOffset(intptr_t string_index) const; 293 intptr_t StringOffset(intptr_t string_index) const;
291 intptr_t StringSize(intptr_t string_index) const; 294 intptr_t StringSize(intptr_t string_index) const;
292 uint8_t CharacterAt(intptr_t string_index, intptr_t index); 295 uint8_t CharacterAt(intptr_t string_index, intptr_t index);
293 bool StringEquals(intptr_t string_index, const char* other); 296 bool StringEquals(intptr_t string_index, const char* other);
294 297
295 // Predicates on CanonicalNames. 298 // Accessors and predicates for canonical names.
296 bool IsAdministrative(CanonicalName* name); 299 intptr_t CanonicalNameParent(intptr_t name);
297 bool IsPrivate(CanonicalName* name); 300 intptr_t CanonicalNameString(intptr_t name);
298 bool IsRoot(CanonicalName* name); 301 bool IsAdministrative(intptr_t name);
299 bool IsLibrary(CanonicalName* name); 302 bool IsPrivate(intptr_t name);
300 bool IsClass(CanonicalName* name); 303 bool IsRoot(intptr_t name);
301 bool IsMember(CanonicalName* name); 304 bool IsLibrary(intptr_t name);
302 bool IsField(CanonicalName* name); 305 bool IsClass(intptr_t name);
303 bool IsConstructor(CanonicalName* name); 306 bool IsMember(intptr_t name);
304 bool IsProcedure(CanonicalName* name); 307 bool IsField(intptr_t name);
305 bool IsMethod(CanonicalName* name); 308 bool IsConstructor(intptr_t name);
306 bool IsGetter(CanonicalName* name); 309 bool IsProcedure(intptr_t name);
307 bool IsSetter(CanonicalName* name); 310 bool IsMethod(intptr_t name);
308 bool IsFactory(CanonicalName* name); 311 bool IsGetter(intptr_t name);
312 bool IsSetter(intptr_t name);
313 bool IsFactory(intptr_t name);
309 314
310 // For a member (field, constructor, or procedure) return the canonical name 315 // For a member (field, constructor, or procedure) return the canonical name
311 // of the enclosing class or library. 316 // of the enclosing class or library.
312 CanonicalName* EnclosingName(CanonicalName* name); 317 intptr_t EnclosingName(intptr_t name);
313 318
314 RawInstance* Canonicalize(const Instance& instance); 319 RawInstance* Canonicalize(const Instance& instance);
315 320
316 const dart::String& DartString(const char* content) { 321 const dart::String& DartString(const char* content) {
317 return DartString(content, allocation_space_); 322 return DartString(content, allocation_space_);
318 } 323 }
319 const dart::String& DartString(const char* content, Heap::Space space); 324 const dart::String& DartString(const char* content, Heap::Space space);
320 325
321 dart::String& DartString(intptr_t string_index) { 326 dart::String& DartString(intptr_t string_index) {
322 return DartString(string_index, allocation_space_); 327 return DartString(string_index, allocation_space_);
323 } 328 }
324 dart::String& DartString(intptr_t string_index, Heap::Space space); 329 dart::String& DartString(intptr_t string_index, Heap::Space space);
325 330
326 dart::String& DartString(const uint8_t* utf8_array, intptr_t len) { 331 dart::String& DartString(const uint8_t* utf8_array, intptr_t len) {
327 return DartString(utf8_array, len, allocation_space_); 332 return DartString(utf8_array, len, allocation_space_);
328 } 333 }
329 dart::String& DartString(const uint8_t* utf8_array, 334 dart::String& DartString(const uint8_t* utf8_array,
330 intptr_t len, 335 intptr_t len,
331 Heap::Space space); 336 Heap::Space space);
332 337
333 const dart::String& DartSymbol(const char* content) const; 338 const dart::String& DartSymbol(const char* content) const;
334 dart::String& DartSymbol(intptr_t string_index) const; 339 dart::String& DartSymbol(intptr_t string_index) const;
335 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const; 340 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const;
336 341
337 const dart::String& DartClassName(CanonicalName* kernel_class); 342 const dart::String& DartClassName(intptr_t kernel_class);
338 343
339 const dart::String& DartConstructorName(CanonicalName* constructor); 344 const dart::String& DartConstructorName(intptr_t constructor);
340 345
341 const dart::String& DartProcedureName(CanonicalName* procedure); 346 const dart::String& DartProcedureName(intptr_t procedure);
342 347
343 const dart::String& DartSetterName(CanonicalName* setter); 348 const dart::String& DartSetterName(intptr_t setter);
344 const dart::String& DartSetterName(Name* setter_name); 349 const dart::String& DartSetterName(Name* setter_name);
345 350
346 const dart::String& DartGetterName(CanonicalName* getter); 351 const dart::String& DartGetterName(intptr_t getter);
347 const dart::String& DartGetterName(Name* getter_name); 352 const dart::String& DartGetterName(Name* getter_name);
348 353
349 const dart::String& DartFieldName(Name* kernel_name); 354 const dart::String& DartFieldName(Name* kernel_name);
350 355
351 const dart::String& DartInitializerName(Name* kernel_name); 356 const dart::String& DartInitializerName(Name* kernel_name);
352 357
353 const dart::String& DartMethodName(CanonicalName* method); 358 const dart::String& DartMethodName(intptr_t method);
354 const dart::String& DartMethodName(Name* method_name); 359 const dart::String& DartMethodName(Name* method_name);
355 360
356 const dart::String& DartFactoryName(CanonicalName* factory); 361 const dart::String& DartFactoryName(intptr_t factory);
357 362
358 const Array& ArgumentNames(List<NamedExpression>* named); 363 const Array& ArgumentNames(List<NamedExpression>* named);
359 364
360 // A subclass overrides these when reading in the Kernel program in order to 365 // A subclass overrides these when reading in the Kernel program in order to
361 // support recursive type expressions (e.g. for "implements X" ... 366 // support recursive type expressions (e.g. for "implements X" ...
362 // annotations). 367 // annotations).
363 virtual RawLibrary* LookupLibraryByKernelLibrary(CanonicalName* library); 368 virtual RawLibrary* LookupLibraryByKernelLibrary(intptr_t library);
364 virtual RawClass* LookupClassByKernelClass(CanonicalName* klass); 369 virtual RawClass* LookupClassByKernelClass(intptr_t klass);
365 370
366 RawField* LookupFieldByKernelField(CanonicalName* field); 371 RawField* LookupFieldByKernelField(intptr_t field);
367 RawFunction* LookupStaticMethodByKernelProcedure(CanonicalName* procedure); 372 RawFunction* LookupStaticMethodByKernelProcedure(intptr_t procedure);
368 RawFunction* LookupConstructorByKernelConstructor(CanonicalName* constructor); 373 RawFunction* LookupConstructorByKernelConstructor(intptr_t constructor);
369 dart::RawFunction* LookupConstructorByKernelConstructor( 374 dart::RawFunction* LookupConstructorByKernelConstructor(
370 const dart::Class& owner, 375 const dart::Class& owner,
371 CanonicalName* constructor); 376 intptr_t constructor);
372 377
373 dart::Type& GetCanonicalType(const dart::Class& klass); 378 dart::Type& GetCanonicalType(const dart::Class& klass);
374 379
375 void ReportError(const char* format, ...); 380 void ReportError(const char* format, ...);
376 void ReportError(const Error& prev_error, const char* format, ...); 381 void ReportError(const Error& prev_error, const char* format, ...);
377 382
378 private: 383 private:
379 // This will mangle [name_to_modify] if necessary and make the result a symbol 384 // This will mangle [name_to_modify] if necessary and make the result a symbol
380 // if asked. The result will be available in [name_to_modify] and it is also 385 // if asked. The result will be available in [name_to_modify] and it is also
381 // returned. If the name is private, the canonical name [parent] will be used 386 // returned. If the name is private, the canonical name [parent] will be used
382 // to get the import URI of the library where the name is visible. 387 // to get the import URI of the library where the name is visible.
383 dart::String& ManglePrivateName(CanonicalName* parent, 388 dart::String& ManglePrivateName(intptr_t parent,
384 dart::String* name_to_modify, 389 dart::String* name_to_modify,
385 bool symbolize = true); 390 bool symbolize = true);
386 391
387 const dart::String& DartSetterName(CanonicalName* parent, intptr_t setter); 392 const dart::String& DartSetterName(intptr_t parent, intptr_t setter);
388 const dart::String& DartGetterName(CanonicalName* parent, intptr_t getter); 393 const dart::String& DartGetterName(intptr_t parent, intptr_t getter);
389 const dart::String& DartMethodName(CanonicalName* parent, intptr_t method); 394 const dart::String& DartMethodName(intptr_t parent, intptr_t method);
390 395
391 Thread* thread_; 396 Thread* thread_;
392 Zone* zone_; 397 Zone* zone_;
393 Isolate* isolate_; 398 Isolate* isolate_;
394 Heap::Space allocation_space_; 399 Heap::Space allocation_space_;
395 400
396 TypedData& string_offsets_; 401 TypedData& string_offsets_;
397 TypedData& string_data_; 402 TypedData& string_data_;
403 TypedData& canonical_names_;
398 }; 404 };
399 405
400 // Regarding malformed types: 406 // Regarding malformed types:
401 // The spec says in section "19.1 Static Types" roughly: 407 // The spec says in section "19.1 Static Types" roughly:
402 // 408 //
403 // A type T is malformed iff: 409 // A type T is malformed iff:
404 // * T does not denote a type in scope 410 // * T does not denote a type in scope
405 // * T refers to a type parameter in a static member 411 // * T refers to a type parameter in a static member
406 // * T is a parametrized Type G<T1, ...> and G is malformed 412 // * T is a parametrized Type G<T1, ...> and G is malformed
407 // * T denotes declarations from multiple imports 413 // * T denotes declarations from multiple imports
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 858
853 TargetEntryInstr* BuildTargetEntry(); 859 TargetEntryInstr* BuildTargetEntry();
854 JoinEntryInstr* BuildJoinEntry(); 860 JoinEntryInstr* BuildJoinEntry();
855 JoinEntryInstr* BuildJoinEntry(intptr_t try_index); 861 JoinEntryInstr* BuildJoinEntry(intptr_t try_index);
856 862
857 Fragment TranslateArguments(Arguments* node, Array* argument_names); 863 Fragment TranslateArguments(Arguments* node, Array* argument_names);
858 ArgumentArray GetArguments(int count); 864 ArgumentArray GetArguments(int count);
859 865
860 Fragment TranslateInitializers(Class* kernel_class, 866 Fragment TranslateInitializers(Class* kernel_class,
861 List<Initializer>* initialiers); 867 List<Initializer>* initialiers);
862 Fragment TranslateFieldInitializer(CanonicalName* canonical_name, 868 Fragment TranslateFieldInitializer(intptr_t canonical_name, Expression* init);
863 Expression* init);
864 869
865 Fragment TranslateStatement(Statement* statement); 870 Fragment TranslateStatement(Statement* statement);
866 Fragment TranslateCondition(Expression* expression, bool* negate); 871 Fragment TranslateCondition(Expression* expression, bool* negate);
867 Fragment TranslateExpression(Expression* expression); 872 Fragment TranslateExpression(Expression* expression);
868 873
869 Fragment TranslateFinallyFinalizers(TryFinallyBlock* outer_finally, 874 Fragment TranslateFinallyFinalizers(TryFinallyBlock* outer_finally,
870 intptr_t target_context_depth); 875 intptr_t target_context_depth);
871 876
872 Fragment TranslateFunctionNode(FunctionNode* node, TreeNode* parent); 877 Fragment TranslateFunctionNode(FunctionNode* node, TreeNode* parent);
873 878
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 Fragment AssertAssignable(const dart::AbstractType& dst_type, 988 Fragment AssertAssignable(const dart::AbstractType& dst_type,
984 const dart::String& dst_name); 989 const dart::String& dst_name);
985 990
986 template <class Invocation> 991 template <class Invocation>
987 bool RecognizeComparisonWithNull(Token::Kind token_kind, Invocation* node); 992 bool RecognizeComparisonWithNull(Token::Kind token_kind, Invocation* node);
988 993
989 bool NeedsDebugStepCheck(const Function& function, TokenPosition position); 994 bool NeedsDebugStepCheck(const Function& function, TokenPosition position);
990 bool NeedsDebugStepCheck(Value* value, TokenPosition position); 995 bool NeedsDebugStepCheck(Value* value, TokenPosition position);
991 Fragment DebugStepCheck(TokenPosition position); 996 Fragment DebugStepCheck(TokenPosition position);
992 997
993 dart::RawFunction* LookupMethodByMember(CanonicalName* target, 998 dart::RawFunction* LookupMethodByMember(intptr_t target,
994 const dart::String& method_name); 999 const dart::String& method_name);
995 1000
996 LocalVariable* MakeTemporary(); 1001 LocalVariable* MakeTemporary();
997 LocalVariable* MakeNonTemporary(const dart::String& symbol); 1002 LocalVariable* MakeNonTemporary(const dart::String& symbol);
998 1003
999 intptr_t CurrentTryIndex(); 1004 intptr_t CurrentTryIndex();
1000 intptr_t AllocateTryIndex() { return next_used_try_index_++; } 1005 intptr_t AllocateTryIndex() { return next_used_try_index_++; }
1001 1006
1002 void AddVariable(VariableDeclaration* declaration, LocalVariable* variable); 1007 void AddVariable(VariableDeclaration* declaration, LocalVariable* variable);
1003 void AddParameter(VariableDeclaration* declaration, 1008 void AddParameter(VariableDeclaration* declaration,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 namespace kernel { 1160 namespace kernel {
1156 1161
1157 RawObject* EvaluateMetadata(const dart::Field& metadata_field); 1162 RawObject* EvaluateMetadata(const dart::Field& metadata_field);
1158 RawObject* BuildParameterDescriptor(const Function& function); 1163 RawObject* BuildParameterDescriptor(const Function& function);
1159 1164
1160 } // namespace kernel 1165 } // namespace kernel
1161 } // namespace dart 1166 } // namespace dart
1162 1167
1163 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1168 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1164 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ 1169 #endif // RUNTIME_VM_KERNEL_TO_IL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698