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

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

Issue 345563007: Add Uint32 representation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 void SetReachingType(CompileType* type) { 574 void SetReachingType(CompileType* type) {
575 reaching_type_ = type; 575 reaching_type_ = type;
576 } 576 }
577 577
578 void PrintTo(BufferFormatter* f) const; 578 void PrintTo(BufferFormatter* f) const;
579 579
580 const char* DebugName() const { return "Value"; } 580 const char* DebugName() const { return "Value"; }
581 581
582 bool IsSmiValue() { return Type()->ToCid() == kSmiCid; } 582 bool IsSmiValue() { return Type()->ToCid() == kSmiCid; }
583 583
584 // Returns true if this value binds to the constant: 0xFFFFFFFF.
585 bool BindsTo32BitMaskConstant() const;
586
584 // Return true if the value represents a constant. 587 // Return true if the value represents a constant.
585 bool BindsToConstant() const; 588 bool BindsToConstant() const;
586 589
587 // Return true if the value represents the constant null. 590 // Return true if the value represents the constant null.
588 bool BindsToConstantNull() const; 591 bool BindsToConstantNull() const;
589 592
590 // Assert if BindsToConstant() is false, otherwise returns the constant value. 593 // Assert if BindsToConstant() is false, otherwise returns the constant value.
591 const Object& BoundConstant() const; 594 const Object& BoundConstant() const;
592 595
593 // Compile time constants, Bool, Smi and Nulls do not need to update 596 // Compile time constants, Bool, Smi and Nulls do not need to update
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 M(BinaryFloat64x2Op) \ 785 M(BinaryFloat64x2Op) \
783 M(Float64x2Zero) \ 786 M(Float64x2Zero) \
784 M(Float64x2Constructor) \ 787 M(Float64x2Constructor) \
785 M(Float64x2Splat) \ 788 M(Float64x2Splat) \
786 M(Float32x4ToFloat64x2) \ 789 M(Float32x4ToFloat64x2) \
787 M(Float64x2ToFloat32x4) \ 790 M(Float64x2ToFloat32x4) \
788 M(Simd64x2Shuffle) \ 791 M(Simd64x2Shuffle) \
789 M(Float64x2ZeroArg) \ 792 M(Float64x2ZeroArg) \
790 M(Float64x2OneArg) \ 793 M(Float64x2OneArg) \
791 M(ExtractNthOutput) \ 794 M(ExtractNthOutput) \
795 M(BinaryUint32Op) \
796 M(ShiftUint32Op) \
797 M(UnaryUint32Op) \
798 M(BoxUint32) \
799 M(UnboxUint32) \
800 M(UnboxedIntConverter) \
792 801
793 802
794 #define FORWARD_DECLARATION(type) class type##Instr; 803 #define FORWARD_DECLARATION(type) class type##Instr;
795 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 804 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
796 #undef FORWARD_DECLARATION 805 #undef FORWARD_DECLARATION
797 806
798 807
799 // Functions required in all concrete instruction classes. 808 // Functions required in all concrete instruction classes.
800 #define DECLARE_INSTRUCTION(type) \ 809 #define DECLARE_INSTRUCTION(type) \
801 virtual Tag tag() const { return k##type; } \ 810 virtual Tag tag() const { return k##type; } \
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 friend class JoinEntryInstr; 1135 friend class JoinEntryInstr;
1127 friend class InstanceOfInstr; 1136 friend class InstanceOfInstr;
1128 friend class PolymorphicInstanceCallInstr; 1137 friend class PolymorphicInstanceCallInstr;
1129 friend class SmiToDoubleInstr; 1138 friend class SmiToDoubleInstr;
1130 friend class DoubleToIntegerInstr; 1139 friend class DoubleToIntegerInstr;
1131 friend class BranchSimplifier; 1140 friend class BranchSimplifier;
1132 friend class BlockEntryInstr; 1141 friend class BlockEntryInstr;
1133 friend class RelationalOpInstr; 1142 friend class RelationalOpInstr;
1134 friend class EqualityCompareInstr; 1143 friend class EqualityCompareInstr;
1135 friend class TestCidsInstr; 1144 friend class TestCidsInstr;
1145 friend class BinaryUint32OpInstr;
1146 friend class UnaryUint32OpInstr;
1147 friend class ShiftUint32OpInstr;
1148 friend class UnboxUint32Instr;
1136 1149
1137 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; 1150 virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
1138 1151
1139 enum { 1152 enum {
1140 kNoPlaceId = -1 1153 kNoPlaceId = -1
1141 }; 1154 };
1142 1155
1143 intptr_t deopt_id_; 1156 intptr_t deopt_id_;
1144 intptr_t lifetime_position_; // Position used by register allocator. 1157 intptr_t lifetime_position_; // Position used by register allocator.
1145 Instruction* previous_; 1158 Instruction* previous_;
(...skipping 4141 matching lines...) Expand 10 before | Expand all | Expand 10 after
5287 5300
5288 virtual bool CanDeoptimize() const { 5301 virtual bool CanDeoptimize() const {
5289 return (value()->Type()->ToCid() != kSmiCid) 5302 return (value()->Type()->ToCid() != kSmiCid)
5290 && (value()->Type()->ToCid() != kMintCid); 5303 && (value()->Type()->ToCid() != kMintCid);
5291 } 5304 }
5292 5305
5293 virtual Representation representation() const { 5306 virtual Representation representation() const {
5294 return kUnboxedMint; 5307 return kUnboxedMint;
5295 } 5308 }
5296 5309
5310 intptr_t deopt_id() const { return deopt_id_; }
5297 5311
5298 virtual void InferRange(); 5312 virtual void InferRange();
5299 5313
5300 DECLARE_INSTRUCTION(UnboxInteger) 5314 DECLARE_INSTRUCTION(UnboxInteger)
5301 virtual CompileType ComputeType() const; 5315 virtual CompileType ComputeType() const;
5302 5316
5303 virtual bool AllowsCSE() const { return true; } 5317 virtual bool AllowsCSE() const { return true; }
5304 virtual EffectSet Effects() const { return EffectSet::None(); } 5318 virtual EffectSet Effects() const { return EffectSet::None(); }
5305 virtual EffectSet Dependencies() const { return EffectSet::None(); } 5319 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5306 virtual bool AttributesEqual(Instruction* other) const { return true; } 5320 virtual bool AttributesEqual(Instruction* other) const { return true; }
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
7042 private: 7056 private:
7043 const Token::Kind op_kind_; 7057 const Token::Kind op_kind_;
7044 7058
7045 DISALLOW_COPY_AND_ASSIGN(BinaryFloat64x2OpInstr); 7059 DISALLOW_COPY_AND_ASSIGN(BinaryFloat64x2OpInstr);
7046 }; 7060 };
7047 7061
7048 7062
7049 class BinaryMintOpInstr : public TemplateDefinition<2> { 7063 class BinaryMintOpInstr : public TemplateDefinition<2> {
7050 public: 7064 public:
7051 BinaryMintOpInstr(Token::Kind op_kind, 7065 BinaryMintOpInstr(Token::Kind op_kind,
7052 Value* left, 7066 Value* left,
7053 Value* right, 7067 Value* right,
7054 intptr_t deopt_id) 7068 intptr_t deopt_id)
7055 : op_kind_(op_kind), can_overflow_(true) { 7069 : op_kind_(op_kind), can_overflow_(true) {
7056 SetInputAt(0, left); 7070 SetInputAt(0, left);
7057 SetInputAt(1, right); 7071 SetInputAt(1, right);
7058 // Override generated deopt-id. 7072 // Override generated deopt-id.
7059 deopt_id_ = deopt_id; 7073 deopt_id_ = deopt_id;
7060 } 7074 }
7061 7075
7062 Value* left() const { return inputs_[0]; } 7076 Value* left() const { return inputs_[0]; }
7063 Value* right() const { return inputs_[1]; } 7077 Value* right() const { return inputs_[1]; }
7064 7078
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
8031 enum { 8045 enum {
8032 kLengthPos = 0, 8046 kLengthPos = 0,
8033 kIndexPos = 1 8047 kIndexPos = 1
8034 }; 8048 };
8035 8049
8036 private: 8050 private:
8037 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 8051 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
8038 }; 8052 };
8039 8053
8040 8054
8055 class BinaryUint32OpInstr : public TemplateDefinition<2> {
8056 public:
8057 BinaryUint32OpInstr(Token::Kind op_kind,
8058 Value* left,
8059 Value* right,
8060 intptr_t deopt_id)
8061 : op_kind_(op_kind) {
8062 SetInputAt(0, left);
8063 SetInputAt(1, right);
8064 // Override generated deopt-id.
8065 deopt_id_ = deopt_id;
8066 }
8067
8068 Value* left() const { return inputs_[0]; }
8069 Value* right() const { return inputs_[1]; }
8070
8071 Token::Kind op_kind() const { return op_kind_; }
8072
8073 virtual void PrintOperandsTo(BufferFormatter* f) const;
8074
8075 virtual bool CanDeoptimize() const {
8076 return false;
8077 }
8078
8079 virtual Representation representation() const {
8080 return kUnboxedUint32;
8081 }
8082
8083 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
8084 ASSERT((idx == 0) || (idx == 1));
8085 return kUnboxedUint32;
8086 }
8087
8088 virtual intptr_t DeoptimizationTarget() const {
8089 // Direct access since this instruction cannot deoptimize, and the deopt-id
8090 // was inherited from another instruction that could deoptimize.
8091 return deopt_id_;
8092 }
8093
8094 virtual Definition* Canonicalize(FlowGraph* flow_graph);
8095
8096 DECLARE_INSTRUCTION(BinaryUint32Op)
8097 virtual CompileType ComputeType() const;
8098
8099 virtual bool AllowsCSE() const { return true; }
8100 virtual EffectSet Effects() const { return EffectSet::None(); }
8101 virtual EffectSet Dependencies() const { return EffectSet::None(); }
8102 virtual bool AttributesEqual(Instruction* other) const {
8103 ASSERT(other->IsBinaryUint32Op());
8104 return op_kind() == other->AsBinaryUint32Op()->op_kind();
8105 }
8106
8107 virtual bool MayThrow() const { return false; }
8108
8109 private:
8110 const Token::Kind op_kind_;
8111
8112 DISALLOW_COPY_AND_ASSIGN(BinaryUint32OpInstr);
8113 };
8114
8115
8116 class ShiftUint32OpInstr : public TemplateDefinition<2> {
8117 public:
8118 ShiftUint32OpInstr(Token::Kind op_kind,
8119 Value* left,
8120 Value* right,
8121 intptr_t deopt_id)
8122 : op_kind_(op_kind) {
8123 ASSERT(op_kind == Token::kSHR || op_kind == Token::kSHL);
8124 SetInputAt(0, left);
8125 SetInputAt(1, right);
8126 // Override generated deopt-id.
8127 deopt_id_ = deopt_id;
8128 }
8129
8130 Value* left() const { return inputs_[0]; }
8131 Value* right() const { return inputs_[1]; }
8132
8133 Token::Kind op_kind() const { return op_kind_; }
8134
8135 virtual void PrintOperandsTo(BufferFormatter* f) const;
8136
8137 virtual bool CanDeoptimize() const {
8138 return true;
8139 }
8140
8141 virtual CompileType ComputeType() const;
8142
8143 virtual Representation representation() const {
8144 return kUnboxedUint32;
8145 }
8146
8147 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
8148 ASSERT((idx == 0) || (idx == 1));
8149 return (idx == 0) ? kUnboxedUint32 : kTagged;
8150 }
8151
8152 virtual intptr_t DeoptimizationTarget() const {
8153 // Direct access since this instruction cannot deoptimize, and the deopt-id
8154 // was inherited from another instruction that could deoptimize.
8155 return deopt_id_;
8156 }
8157
8158 DECLARE_INSTRUCTION(ShiftUint32Op)
8159
8160 virtual bool AllowsCSE() const { return true; }
8161 virtual EffectSet Effects() const { return EffectSet::None(); }
8162 virtual EffectSet Dependencies() const { return EffectSet::None(); }
8163 virtual bool AttributesEqual(Instruction* other) const {
8164 return op_kind() == other->AsShiftUint32Op()->op_kind();
8165 }
8166
8167 virtual bool MayThrow() const { return false; }
8168
8169 private:
8170 const Token::Kind op_kind_;
8171
8172 DISALLOW_COPY_AND_ASSIGN(ShiftUint32OpInstr);
8173 };
8174
8175
8176 class UnaryUint32OpInstr : public TemplateDefinition<1> {
8177 public:
8178 UnaryUint32OpInstr(Token::Kind op_kind,
8179 Value* value,
8180 intptr_t deopt_id)
8181 : op_kind_(op_kind) {
8182 ASSERT(op_kind == Token::kBIT_NOT);
8183 SetInputAt(0, value);
8184 // Override generated deopt-id.
8185 deopt_id_ = deopt_id;
8186 }
8187
8188 Value* value() const { return inputs_[0]; }
8189
8190 Token::Kind op_kind() const { return op_kind_; }
8191
8192 virtual void PrintOperandsTo(BufferFormatter* f) const;
8193
8194 virtual bool CanDeoptimize() const {
8195 return false;
8196 }
8197
8198 virtual Representation representation() const {
8199 return kUnboxedUint32;
8200 }
8201
8202 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
8203 ASSERT(idx == 0);
8204 return kUnboxedUint32;
8205 }
8206
8207 virtual intptr_t DeoptimizationTarget() const {
8208 // Direct access since this instruction cannot deoptimize, and the deopt-id
8209 // was inherited from another instruction that could deoptimize.
8210 return deopt_id_;
8211 }
8212
8213 DECLARE_INSTRUCTION(UnaryUint32Op)
8214 virtual CompileType ComputeType() const;
8215
8216 virtual bool AllowsCSE() const { return true; }
8217 virtual EffectSet Effects() const { return EffectSet::None(); }
8218 virtual EffectSet Dependencies() const { return EffectSet::None(); }
8219 virtual bool AttributesEqual(Instruction* other) const {
8220 return op_kind() == other->AsUnaryUint32Op()->op_kind();
8221 }
8222
8223 virtual bool MayThrow() const { return false; }
8224
8225 private:
8226 const Token::Kind op_kind_;
8227
8228 DISALLOW_COPY_AND_ASSIGN(UnaryUint32OpInstr);
8229 };
8230
8231
8232 class BoxUint32Instr : public TemplateDefinition<1> {
8233 public:
8234 explicit BoxUint32Instr(Value* value) {
8235 SetInputAt(0, value);
8236 }
8237
8238 Value* value() const { return inputs_[0]; }
8239
8240 virtual bool CanDeoptimize() const { return false; }
8241
8242 virtual intptr_t DeoptimizationTarget() const {
8243 return Isolate::kNoDeoptId;
8244 }
8245
8246 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
8247 ASSERT(idx == 0);
8248 return kUnboxedUint32;
8249 }
8250
8251 DECLARE_INSTRUCTION(BoxUint32)
8252 virtual CompileType ComputeType() const;
8253
8254 virtual bool AllowsCSE() const { return true; }
8255 virtual EffectSet Effects() const { return EffectSet::None(); }
8256 virtual EffectSet Dependencies() const { return EffectSet::None(); }
8257 virtual bool AttributesEqual(Instruction* other) const { return true; }
8258
8259 virtual bool MayThrow() const { return false; }
8260
8261 private:
8262 DISALLOW_COPY_AND_ASSIGN(BoxUint32Instr);
8263 };
8264
8265
8266 class UnboxUint32Instr : public TemplateDefinition<1> {
8267 public:
8268 UnboxUint32Instr(Value* value, intptr_t deopt_id) {
8269 SetInputAt(0, value);
8270 deopt_id_ = deopt_id;
8271 }
8272
8273 Value* value() const { return inputs_[0]; }
8274
8275 virtual bool CanDeoptimize() const {
8276 return (value()->Type()->ToCid() != kSmiCid)
8277 && (value()->Type()->ToCid() != kMintCid);
8278 }
8279
8280 virtual Representation representation() const {
8281 return kUnboxedUint32;
8282 }
8283
8284
8285 DECLARE_INSTRUCTION(UnboxUint32)
8286 virtual CompileType ComputeType() const;
8287
8288 virtual bool AllowsCSE() const { return true; }
8289 virtual EffectSet Effects() const { return EffectSet::None(); }
8290 virtual EffectSet Dependencies() const { return EffectSet::None(); }
8291 virtual bool AttributesEqual(Instruction* other) const { return true; }
8292
8293 virtual bool MayThrow() const { return false; }
8294
8295 private:
8296 DISALLOW_COPY_AND_ASSIGN(UnboxUint32Instr);
8297 };
8298
8299
8300 class UnboxedIntConverterInstr : public TemplateDefinition<1> {
8301 public:
8302 UnboxedIntConverterInstr(Representation from,
8303 Representation to,
8304 Value* value)
8305 : from_representation_(from),
8306 to_representation_(to) {
8307 ASSERT(from != to);
8308 ASSERT((from == kUnboxedMint) || (from == kUnboxedUint32));
8309 ASSERT((to == kUnboxedMint) || (to == kUnboxedUint32));
8310 SetInputAt(0, value);
8311 }
8312
8313 Value* value() const { return inputs_[0]; }
8314
8315 Representation from() const { return from_representation_; }
8316 Representation to() const { return to_representation_; }
8317
8318 virtual bool CanDeoptimize() const { return false; }
8319
8320 virtual Representation representation() const {
8321 return to();
8322 }
8323
8324 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
8325 ASSERT(idx == 0);
8326 return from();
8327 }
8328
8329 virtual EffectSet Effects() const { return EffectSet::None(); }
8330 virtual EffectSet Dependencies() const { return EffectSet::None(); }
8331 virtual bool AttributesEqual(Instruction* other) const {
8332 ASSERT(other->IsUnboxedIntConverter());
8333 UnboxedIntConverterInstr* converter = other->AsUnboxedIntConverter();
8334 return (converter->from() == from()) && (converter->to() == to());
8335 }
8336
8337 virtual bool MayThrow() const { return false; }
8338
8339 DECLARE_INSTRUCTION(UnboxedIntConverter);
8340
8341 private:
8342 const Representation from_representation_;
8343 const Representation to_representation_;
8344 DISALLOW_COPY_AND_ASSIGN(UnboxedIntConverterInstr);
8345 };
8346
8347
8041 #undef DECLARE_INSTRUCTION 8348 #undef DECLARE_INSTRUCTION
8042 8349
8043 class Environment : public ZoneAllocated { 8350 class Environment : public ZoneAllocated {
8044 public: 8351 public:
8045 // Iterate the non-NULL values in the innermost level of an environment. 8352 // Iterate the non-NULL values in the innermost level of an environment.
8046 class ShallowIterator : public ValueObject { 8353 class ShallowIterator : public ValueObject {
8047 public: 8354 public:
8048 explicit ShallowIterator(Environment* environment) 8355 explicit ShallowIterator(Environment* environment)
8049 : environment_(environment), index_(0) { } 8356 : environment_(environment), index_(0) { }
8050 8357
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
8261 ForwardInstructionIterator* current_iterator_; 8568 ForwardInstructionIterator* current_iterator_;
8262 8569
8263 private: 8570 private:
8264 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 8571 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
8265 }; 8572 };
8266 8573
8267 8574
8268 } // namespace dart 8575 } // namespace dart
8269 8576
8270 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 8577 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698