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

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

Issue 11360033: Inline native String.charCodeAt in optimized code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed a bug in indexed ops and added more tests Created 8 years, 1 month 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 19 matching lines...) Expand all
30 30
31 // TODO(srdjan): Add _ByteArrayBase, get:length. 31 // TODO(srdjan): Add _ByteArrayBase, get:length.
32 32
33 #define RECOGNIZED_LIST(V) \ 33 #define RECOGNIZED_LIST(V) \
34 V(_ObjectArray, get:length, ObjectArrayLength) \ 34 V(_ObjectArray, get:length, ObjectArrayLength) \
35 V(_ImmutableArray, get:length, ImmutableArrayLength) \ 35 V(_ImmutableArray, get:length, ImmutableArrayLength) \
36 V(_GrowableObjectArray, get:length, GrowableArrayLength) \ 36 V(_GrowableObjectArray, get:length, GrowableArrayLength) \
37 V(_GrowableObjectArray, get:capacity, GrowableArrayCapacity) \ 37 V(_GrowableObjectArray, get:capacity, GrowableArrayCapacity) \
38 V(_StringBase, get:length, StringBaseLength) \ 38 V(_StringBase, get:length, StringBaseLength) \
39 V(_StringBase, get:isEmpty, StringBaseIsEmpty) \ 39 V(_StringBase, get:isEmpty, StringBaseIsEmpty) \
40 V(_StringBase, charCodeAt, StringBaseCharCodeAt) \
40 V(_IntegerImplementation, toDouble, IntegerToDouble) \ 41 V(_IntegerImplementation, toDouble, IntegerToDouble) \
41 V(_Double, toInt, DoubleToInteger) \ 42 V(_Double, toInt, DoubleToInteger) \
42 V(::, sqrt, MathSqrt) \ 43 V(::, sqrt, MathSqrt) \
43 44
44 // Class that recognizes the name and owner of a function and returns the 45 // Class that recognizes the name and owner of a function and returns the
45 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable 46 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable
46 // functions. 47 // functions.
47 class MethodRecognizer : public AllStatic { 48 class MethodRecognizer : public AllStatic {
48 public: 49 public:
49 enum Kind { 50 enum Kind {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 M(MathSqrt) \ 257 M(MathSqrt) \
257 M(UnboxDouble) \ 258 M(UnboxDouble) \
258 M(BoxDouble) \ 259 M(BoxDouble) \
259 M(UnboxInteger) \ 260 M(UnboxInteger) \
260 M(BoxInteger) \ 261 M(BoxInteger) \
261 M(BinaryMintOp) \ 262 M(BinaryMintOp) \
262 M(ShiftMintOp) \ 263 M(ShiftMintOp) \
263 M(UnaryMintOp) \ 264 M(UnaryMintOp) \
264 M(CheckArrayBound) \ 265 M(CheckArrayBound) \
265 M(Constraint) \ 266 M(Constraint) \
267 M(StringCharCodeAt)
266 268
267 269
268 #define FORWARD_DECLARATION(type) class type##Instr; 270 #define FORWARD_DECLARATION(type) class type##Instr;
269 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 271 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
270 #undef FORWARD_DECLARATION 272 #undef FORWARD_DECLARATION
271 273
272 274
273 // Functions required in all concrete instruction classes. 275 // Functions required in all concrete instruction classes.
274 #define DECLARE_INSTRUCTION(type) \ 276 #define DECLARE_INSTRUCTION(type) \
275 virtual Tag tag() const { return k##type; } \ 277 virtual Tag tag() const { return k##type; } \
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 friend class BinaryMintOpInstr; 520 friend class BinaryMintOpInstr;
519 friend class BinarySmiOpInstr; 521 friend class BinarySmiOpInstr;
520 friend class UnarySmiOpInstr; 522 friend class UnarySmiOpInstr;
521 friend class ShiftMintOpInstr; 523 friend class ShiftMintOpInstr;
522 friend class UnaryMintOpInstr; 524 friend class UnaryMintOpInstr;
523 friend class MathSqrtInstr; 525 friend class MathSqrtInstr;
524 friend class CheckClassInstr; 526 friend class CheckClassInstr;
525 friend class CheckSmiInstr; 527 friend class CheckSmiInstr;
526 friend class CheckArrayBoundInstr; 528 friend class CheckArrayBoundInstr;
527 friend class CheckEitherNonSmiInstr; 529 friend class CheckEitherNonSmiInstr;
530 friend class StringCharCodeAtInstr;
528 friend class LICM; 531 friend class LICM;
529 532
530 intptr_t deopt_id_; 533 intptr_t deopt_id_;
531 intptr_t lifetime_position_; // Position used by register allocator. 534 intptr_t lifetime_position_; // Position used by register allocator.
532 Instruction* previous_; 535 Instruction* previous_;
533 Instruction* next_; 536 Instruction* next_;
534 Environment* env_; 537 Environment* env_;
535 intptr_t expr_id_; 538 intptr_t expr_id_;
536 539
537 DISALLOW_COPY_AND_ASSIGN(Instruction); 540 DISALLOW_COPY_AND_ASSIGN(Instruction);
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 2631
2629 virtual intptr_t ResultCid() const { return kDynamicCid; } 2632 virtual intptr_t ResultCid() const { return kDynamicCid; }
2630 2633
2631 private: 2634 private:
2632 const Field& field_; 2635 const Field& field_;
2633 2636
2634 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr); 2637 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr);
2635 }; 2638 };
2636 2639
2637 2640
2641 class StringCharCodeAtInstr : public TemplateDefinition<2> {
2642 public:
2643 StringCharCodeAtInstr(Value* receiver,
2644 Value* index,
2645 intptr_t class_id)
2646 : class_id_(class_id) {
2647 ASSERT(receiver != NULL);
2648 ASSERT(index != NULL);
2649 inputs_[0] = receiver;
2650 inputs_[1] = index;
2651 }
2652
2653 DECLARE_INSTRUCTION(StringCharCodeAt)
2654 virtual RawAbstractType* CompileType() const;
2655
2656 Value* receiver() const { return inputs_[0]; }
2657 Value* index() const { return inputs_[1]; }
2658 intptr_t class_id() const { return class_id_; }
2659
2660 virtual bool CanDeoptimize() const { return false; }
2661
2662 virtual bool HasSideEffect() const { return false; }
2663
2664 virtual intptr_t ResultCid() const;
2665
2666 virtual bool AttributesEqual(Instruction* other) const;
2667
2668 virtual bool AffectedBySideEffect() const { return true; }
2669
2670 private:
2671 const intptr_t class_id_;
2672
2673 DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtInstr);
2674 };
2675
2676
2638 class LoadIndexedInstr : public TemplateDefinition<2> { 2677 class LoadIndexedInstr : public TemplateDefinition<2> {
2639 public: 2678 public:
2640 LoadIndexedInstr(Value* array, Value* index, intptr_t class_id) 2679 LoadIndexedInstr(Value* array, Value* index, intptr_t class_id)
2641 : class_id_(class_id) { 2680 : class_id_(class_id) {
2642 ASSERT(array != NULL); 2681 ASSERT(array != NULL);
2643 ASSERT(index != NULL); 2682 ASSERT(index != NULL);
2644 inputs_[0] = array; 2683 inputs_[0] = array;
2645 inputs_[1] = index; 2684 inputs_[1] = index;
2646 } 2685 }
2647 2686
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
3973 Value* array() const { return inputs_[0]; } 4012 Value* array() const { return inputs_[0]; }
3974 Value* index() const { return inputs_[1]; } 4013 Value* index() const { return inputs_[1]; }
3975 4014
3976 intptr_t array_type() const { return array_type_; } 4015 intptr_t array_type() const { return array_type_; }
3977 4016
3978 bool IsRedundant(RangeBoundary length); 4017 bool IsRedundant(RangeBoundary length);
3979 4018
3980 private: 4019 private:
3981 intptr_t array_type_; 4020 intptr_t array_type_;
3982 4021
4022 // Returns the length offset for array and string types.
4023 static intptr_t LengthOffsetFor(intptr_t class_id);
4024
3983 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 4025 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
3984 }; 4026 };
3985 4027
3986 4028
3987 #undef DECLARE_INSTRUCTION 4029 #undef DECLARE_INSTRUCTION
3988 4030
3989 class Environment : public ZoneAllocated { 4031 class Environment : public ZoneAllocated {
3990 public: 4032 public:
3991 // Iterate the non-NULL values in the innermost level of an environment. 4033 // Iterate the non-NULL values in the innermost level of an environment.
3992 class ShallowIterator : public ValueObject { 4034 class ShallowIterator : public ValueObject {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
4191 ForwardInstructionIterator* current_iterator_; 4233 ForwardInstructionIterator* current_iterator_;
4192 4234
4193 private: 4235 private:
4194 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4236 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4195 }; 4237 };
4196 4238
4197 4239
4198 } // namespace dart 4240 } // namespace dart
4199 4241
4200 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4242 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698