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

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

Issue 10280007: Check upper bounds of type arguments when allocating objects of a generic type (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
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_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 M(StaticSetter, StaticSetterComp) \ 45 M(StaticSetter, StaticSetterComp) \
46 M(LoadInstanceField, LoadInstanceFieldComp) \ 46 M(LoadInstanceField, LoadInstanceFieldComp) \
47 M(StoreInstanceField, StoreInstanceFieldComp) \ 47 M(StoreInstanceField, StoreInstanceFieldComp) \
48 M(LoadStaticField, LoadStaticFieldComp) \ 48 M(LoadStaticField, LoadStaticFieldComp) \
49 M(StoreStaticField, StoreStaticFieldComp) \ 49 M(StoreStaticField, StoreStaticFieldComp) \
50 M(BooleanNegate, BooleanNegateComp) \ 50 M(BooleanNegate, BooleanNegateComp) \
51 M(InstanceOf, InstanceOfComp) \ 51 M(InstanceOf, InstanceOfComp) \
52 M(CreateArray, CreateArrayComp) \ 52 M(CreateArray, CreateArrayComp) \
53 M(CreateClosure, CreateClosureComp) \ 53 M(CreateClosure, CreateClosureComp) \
54 M(AllocateObject, AllocateObjectComp) \ 54 M(AllocateObject, AllocateObjectComp) \
55 M(AllocateObjectWithBoundsCheck, AllocateObjectWithBoundsCheckComp) \
55 M(NativeLoadField, NativeLoadFieldComp) \ 56 M(NativeLoadField, NativeLoadFieldComp) \
56 M(ExtractFactoryTypeArguments, ExtractFactoryTypeArgumentsComp) \ 57 M(ExtractFactoryTypeArguments, ExtractFactoryTypeArgumentsComp) \
57 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ 58 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \
58 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ 59 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \
59 M(AllocateContext, AllocateContextComp) \ 60 M(AllocateContext, AllocateContextComp) \
60 M(ChainContext, ChainContextComp) \ 61 M(ChainContext, ChainContextComp) \
61 M(CloneContext, CloneContextComp) \ 62 M(CloneContext, CloneContextComp) \
62 M(CatchEntry, CatchEntryComp) \ 63 M(CatchEntry, CatchEntryComp) \
63 64
64 65
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } 763 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; }
763 764
764 private: 765 private:
765 const ConstructorCallNode& ast_node_; 766 const ConstructorCallNode& ast_node_;
766 const intptr_t try_index_; 767 const intptr_t try_index_;
767 ZoneGrowableArray<Value*>* const arguments_; 768 ZoneGrowableArray<Value*>* const arguments_;
768 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); 769 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp);
769 }; 770 };
770 771
771 772
773 class AllocateObjectWithBoundsCheckComp : public Computation {
774 public:
775 AllocateObjectWithBoundsCheckComp(ConstructorCallNode* node,
776 intptr_t try_index,
777 ZoneGrowableArray<Value*>* arguments)
778 : ast_node_(*node), try_index_(try_index), arguments_(arguments) {
779 // One type-argument and one instantiator.
780 ASSERT(arguments->length() == 2);
781 }
782
783 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck)
784
785 const Function& constructor() const { return ast_node_.constructor(); }
786 intptr_t token_index() const { return ast_node_.token_index(); }
787 intptr_t try_index() const { return try_index_; }
788 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; }
789
790 private:
791 const ConstructorCallNode& ast_node_;
792 const intptr_t try_index_;
793 ZoneGrowableArray<Value*>* const arguments_;
794 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp);
795 };
796
797
772 class CreateArrayComp : public Computation { 798 class CreateArrayComp : public Computation {
773 public: 799 public:
774 CreateArrayComp(ArrayNode* node, 800 CreateArrayComp(ArrayNode* node,
775 intptr_t try_index, 801 intptr_t try_index,
776 ZoneGrowableArray<Value*>* elements) 802 ZoneGrowableArray<Value*>* elements)
777 : ast_node_(*node), try_index_(try_index), elements_(elements) { 803 : ast_node_(*node), try_index_(try_index), elements_(elements) {
778 #if defined(DEBUG) 804 #if defined(DEBUG)
779 for (int i = 0; i < ElementCount(); ++i) { 805 for (int i = 0; i < ElementCount(); ++i) {
780 ASSERT(ElementAt(i) != NULL); 806 ASSERT(ElementAt(i) != NULL);
781 } 807 }
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 const GrowableArray<BlockEntryInstr*>& block_order_; 1579 const GrowableArray<BlockEntryInstr*>& block_order_;
1554 1580
1555 private: 1581 private:
1556 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 1582 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
1557 }; 1583 };
1558 1584
1559 1585
1560 } // namespace dart 1586 } // namespace dart
1561 1587
1562 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 1588 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698