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

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

Issue 10968059: Support for unboxed 64-bit integer bitwise operations and equality on ia32. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 Instruction* instruction_; 125 Instruction* instruction_;
126 intptr_t use_index_; 126 intptr_t use_index_;
127 127
128 intptr_t reaching_cid_; 128 intptr_t reaching_cid_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(Value); 130 DISALLOW_COPY_AND_ASSIGN(Value);
131 }; 131 };
132 132
133 133
134 enum Representation { 134 enum Representation {
135 kTagged, kUnboxedDouble 135 kTagged,
136 kUnboxedDouble,
137 kUnboxedInteger
136 }; 138 };
137 139
138 140
139 // An embedded container with N elements of type T. Used (with partial 141 // An embedded container with N elements of type T. Used (with partial
140 // specialization for N=0) because embedded arrays cannot have size 0. 142 // specialization for N=0) because embedded arrays cannot have size 0.
141 template<typename T, intptr_t N> 143 template<typename T, intptr_t N>
142 class EmbeddedArray { 144 class EmbeddedArray {
143 public: 145 public:
144 EmbeddedArray() { 146 EmbeddedArray() {
145 for (intptr_t i = 0; i < N; i++) elements_[i] = NULL; 147 for (intptr_t i = 0; i < N; i++) elements_[i] = NULL;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 M(LoadField) \ 236 M(LoadField) \
235 M(StoreVMField) \ 237 M(StoreVMField) \
236 M(InstantiateTypeArguments) \ 238 M(InstantiateTypeArguments) \
237 M(ExtractConstructorTypeArguments) \ 239 M(ExtractConstructorTypeArguments) \
238 M(ExtractConstructorInstantiator) \ 240 M(ExtractConstructorInstantiator) \
239 M(AllocateContext) \ 241 M(AllocateContext) \
240 M(ChainContext) \ 242 M(ChainContext) \
241 M(CloneContext) \ 243 M(CloneContext) \
242 M(CatchEntry) \ 244 M(CatchEntry) \
243 M(BinarySmiOp) \ 245 M(BinarySmiOp) \
244 M(BinaryMintOp) \
245 M(UnarySmiOp) \ 246 M(UnarySmiOp) \
246 M(CheckStackOverflow) \ 247 M(CheckStackOverflow) \
247 M(DoubleToDouble) \ 248 M(DoubleToDouble) \
248 M(SmiToDouble) \ 249 M(SmiToDouble) \
249 M(CheckClass) \ 250 M(CheckClass) \
250 M(CheckSmi) \ 251 M(CheckSmi) \
251 M(Constant) \ 252 M(Constant) \
252 M(CheckEitherNonSmi) \ 253 M(CheckEitherNonSmi) \
253 M(UnboxedDoubleBinaryOp) \ 254 M(UnboxedDoubleBinaryOp) \
254 M(MathSqrt) \ 255 M(MathSqrt) \
255 M(UnboxDouble) \ 256 M(UnboxDouble) \
256 M(BoxDouble) \ 257 M(BoxDouble) \
258 M(UnboxInteger) \
259 M(BoxInteger) \
260 M(UnboxedMintBinaryOp) \
257 M(CheckArrayBound) \ 261 M(CheckArrayBound) \
258 M(Constraint) \ 262 M(Constraint) \
259 263
260 264
261 #define FORWARD_DECLARATION(type) class type##Instr; 265 #define FORWARD_DECLARATION(type) class type##Instr;
262 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 266 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
263 #undef FORWARD_DECLARATION 267 #undef FORWARD_DECLARATION
264 268
265 269
266 // Functions required in all concrete instruction classes. 270 // Functions required in all concrete instruction classes.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 protected: 496 protected:
493 // Fetch deopt id without checking if this computation can deoptimize. 497 // Fetch deopt id without checking if this computation can deoptimize.
494 intptr_t GetDeoptId() const { 498 intptr_t GetDeoptId() const {
495 return deopt_id_; 499 return deopt_id_;
496 } 500 }
497 501
498 private: 502 private:
499 friend class Definition; // Needed for InsertBefore, InsertAfter. 503 friend class Definition; // Needed for InsertBefore, InsertAfter.
500 504
501 // Classes that set deopt_id_. 505 // Classes that set deopt_id_.
506 friend class UnboxIntegerInstr;
502 friend class UnboxDoubleInstr; 507 friend class UnboxDoubleInstr;
503 friend class UnboxedDoubleBinaryOpInstr; 508 friend class UnboxedDoubleBinaryOpInstr;
509 friend class UnboxedMintBinaryOpInstr;
504 friend class MathSqrtInstr; 510 friend class MathSqrtInstr;
505 friend class CheckClassInstr; 511 friend class CheckClassInstr;
506 friend class CheckSmiInstr; 512 friend class CheckSmiInstr;
507 friend class CheckArrayBoundInstr; 513 friend class CheckArrayBoundInstr;
508 friend class CheckEitherNonSmiInstr; 514 friend class CheckEitherNonSmiInstr;
509 friend class LICM; 515 friend class LICM;
510 516
511 intptr_t deopt_id_; 517 intptr_t deopt_id_;
512 intptr_t lifetime_position_; // Position used by register allocator. 518 intptr_t lifetime_position_; // Position used by register allocator.
513 Instruction* previous_; 519 Instruction* previous_;
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 2285
2280 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 2286 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2281 BranchInstr* branch); 2287 BranchInstr* branch);
2282 2288
2283 virtual intptr_t DeoptimizationTarget() const { 2289 virtual intptr_t DeoptimizationTarget() const {
2284 return GetDeoptId(); 2290 return GetDeoptId();
2285 } 2291 }
2286 2292
2287 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 2293 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2288 ASSERT((idx == 0) || (idx == 1)); 2294 ASSERT((idx == 0) || (idx == 1));
2289 return (receiver_class_id() == kDoubleCid) ? kUnboxedDouble : kTagged; 2295 if (receiver_class_id() == kDoubleCid) return kUnboxedDouble;
2296 if (receiver_class_id() == kMintCid) return kUnboxedInteger;
2297 return kTagged;
2290 } 2298 }
2291 2299
2292 private: 2300 private:
2293 const ICData* ic_data_; 2301 const ICData* ic_data_;
2294 const intptr_t token_pos_; 2302 const intptr_t token_pos_;
2295 intptr_t receiver_class_id_; // Set by optimizer. 2303 intptr_t receiver_class_id_; // Set by optimizer.
2296 2304
2297 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr); 2305 DISALLOW_COPY_AND_ASSIGN(EqualityCompareInstr);
2298 }; 2306 };
2299 2307
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 DECLARE_INSTRUCTION(BoxDouble) 3283 DECLARE_INSTRUCTION(BoxDouble)
3276 virtual RawAbstractType* CompileType() const; 3284 virtual RawAbstractType* CompileType() const;
3277 3285
3278 private: 3286 private:
3279 const intptr_t token_pos_; 3287 const intptr_t token_pos_;
3280 3288
3281 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr); 3289 DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr);
3282 }; 3290 };
3283 3291
3284 3292
3293 class BoxIntegerInstr : public TemplateDefinition<1> {
3294 public:
3295 explicit BoxIntegerInstr(Value* value) {
3296 ASSERT(value != NULL);
3297 inputs_[0] = value;
3298 }
3299
3300 Value* value() const { return inputs_[0]; }
3301
3302 virtual bool CanDeoptimize() const { return false; }
3303
3304 virtual bool HasSideEffect() const { return false; }
3305
3306 virtual bool AffectedBySideEffect() const { return false; }
3307 virtual bool AttributesEqual(Instruction* other) const { return true; }
3308
3309 virtual intptr_t ResultCid() const;
3310
3311 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3312 ASSERT(idx == 0);
3313 return kUnboxedInteger;
3314 }
3315
3316 DECLARE_INSTRUCTION(BoxInteger)
3317 virtual RawAbstractType* CompileType() const;
3318
3319 private:
3320 DISALLOW_COPY_AND_ASSIGN(BoxIntegerInstr);
3321 };
3322
3323
3285 class UnboxDoubleInstr : public TemplateDefinition<1> { 3324 class UnboxDoubleInstr : public TemplateDefinition<1> {
3286 public: 3325 public:
3287 UnboxDoubleInstr(Value* value, intptr_t deopt_id) { 3326 UnboxDoubleInstr(Value* value, intptr_t deopt_id) {
3288 ASSERT(value != NULL); 3327 ASSERT(value != NULL);
3289 inputs_[0] = value; 3328 inputs_[0] = value;
3290 deopt_id_ = deopt_id; 3329 deopt_id_ = deopt_id;
3291 } 3330 }
3292 3331
3293 Value* value() const { return inputs_[0]; } 3332 Value* value() const { return inputs_[0]; }
3294 3333
(...skipping 15 matching lines...) Expand all
3310 virtual bool AttributesEqual(Instruction* other) const { return true; } 3349 virtual bool AttributesEqual(Instruction* other) const { return true; }
3311 3350
3312 DECLARE_INSTRUCTION(UnboxDouble) 3351 DECLARE_INSTRUCTION(UnboxDouble)
3313 virtual RawAbstractType* CompileType() const; 3352 virtual RawAbstractType* CompileType() const;
3314 3353
3315 private: 3354 private:
3316 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); 3355 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr);
3317 }; 3356 };
3318 3357
3319 3358
3359 class UnboxIntegerInstr : public TemplateDefinition<1> {
3360 public:
3361 UnboxIntegerInstr(Value* value, intptr_t deopt_id) {
3362 ASSERT(value != NULL);
3363 inputs_[0] = value;
3364 deopt_id_ = deopt_id;
3365 }
3366
3367 Value* value() const { return inputs_[0]; }
3368
3369 virtual bool CanDeoptimize() const {
3370 return (value()->ResultCid() != kMintCid)
3371 && (value()->ResultCid() != kSmiCid);
3372 }
3373
3374 virtual bool HasSideEffect() const { return false; }
3375
3376 virtual intptr_t ResultCid() const;
3377
3378 virtual RawAbstractType* CompileType() const;
3379
3380 virtual Representation representation() const {
3381 return kUnboxedInteger;
3382 }
3383
3384 virtual bool AffectedBySideEffect() const { return false; }
3385 virtual bool AttributesEqual(Instruction* other) const { return true; }
3386
3387 DECLARE_INSTRUCTION(UnboxInteger)
3388
3389 private:
3390 DISALLOW_COPY_AND_ASSIGN(UnboxIntegerInstr);
3391 };
3392
3393
3320 class MathSqrtInstr : public TemplateDefinition<1> { 3394 class MathSqrtInstr : public TemplateDefinition<1> {
3321 public: 3395 public:
3322 MathSqrtInstr(Value* value, StaticCallInstr* instance_call) { 3396 MathSqrtInstr(Value* value, StaticCallInstr* instance_call) {
3323 ASSERT(value != NULL); 3397 ASSERT(value != NULL);
3324 inputs_[0] = value; 3398 inputs_[0] = value;
3325 deopt_id_ = instance_call->deopt_id(); 3399 deopt_id_ = instance_call->deopt_id();
3326 } 3400 }
3327 3401
3328 Value* value() const { return inputs_[0]; } 3402 Value* value() const { return inputs_[0]; }
3329 3403
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 DECLARE_INSTRUCTION(UnboxedDoubleBinaryOp) 3487 DECLARE_INSTRUCTION(UnboxedDoubleBinaryOp)
3414 virtual RawAbstractType* CompileType() const; 3488 virtual RawAbstractType* CompileType() const;
3415 3489
3416 private: 3490 private:
3417 const Token::Kind op_kind_; 3491 const Token::Kind op_kind_;
3418 3492
3419 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpInstr); 3493 DISALLOW_COPY_AND_ASSIGN(UnboxedDoubleBinaryOpInstr);
3420 }; 3494 };
3421 3495
3422 3496
3423 class BinarySmiOpInstr : public TemplateDefinition<2> { 3497 class UnboxedMintBinaryOpInstr : public TemplateDefinition<2> {
3424 public: 3498 public:
3425 BinarySmiOpInstr(Token::Kind op_kind, 3499 UnboxedMintBinaryOpInstr(Token::Kind op_kind,
3426 InstanceCallInstr* instance_call, 3500 Value* left,
3427 Value* left, 3501 Value* right,
3428 Value* right) 3502 InstanceCallInstr* instance_call)
3429 : op_kind_(op_kind), 3503 : op_kind_(op_kind) {
3430 instance_call_(instance_call),
3431 overflow_(true) {
3432 ASSERT(left != NULL); 3504 ASSERT(left != NULL);
3433 ASSERT(right != NULL); 3505 ASSERT(right != NULL);
3434 inputs_[0] = left; 3506 inputs_[0] = left;
3435 inputs_[1] = right; 3507 inputs_[1] = right;
3508 deopt_id_ = instance_call->deopt_id();
3436 } 3509 }
3437 3510
3438 Value* left() const { return inputs_[0]; } 3511 Value* left() const { return inputs_[0]; }
3439 Value* right() const { return inputs_[1]; } 3512 Value* right() const { return inputs_[1]; }
3440 3513
3441 Token::Kind op_kind() const { return op_kind_; } 3514 Token::Kind op_kind() const { return op_kind_; }
3442 3515
3443 InstanceCallInstr* instance_call() const { return instance_call_; }
3444
3445 const ICData* ic_data() const { return instance_call()->ic_data(); }
3446
3447 virtual void PrintOperandsTo(BufferFormatter* f) const; 3516 virtual void PrintOperandsTo(BufferFormatter* f) const;
3448 3517
3449 DECLARE_INSTRUCTION(BinarySmiOp) 3518 virtual bool CanDeoptimize() const { return false; }
3450 virtual RawAbstractType* CompileType() const;
3451
3452 virtual bool CanDeoptimize() const;
3453 3519
3454 virtual bool HasSideEffect() const { return false; } 3520 virtual bool HasSideEffect() const { return false; }
3455 3521
3456 virtual bool AffectedBySideEffect() const { return false; } 3522 virtual bool AffectedBySideEffect() const { return false; }
3457 virtual bool AttributesEqual(Instruction* other) const; 3523
3524 virtual bool AttributesEqual(Instruction* other) const {
3525 return op_kind() == other->AsUnboxedMintBinaryOp()->op_kind();
3526 }
3458 3527
3459 virtual intptr_t ResultCid() const; 3528 virtual intptr_t ResultCid() const;
3529 virtual RawAbstractType* CompileType() const;
3460 3530
3461 void set_overflow(bool overflow) { 3531 virtual Representation representation() const {
3462 overflow_ = overflow; 3532 return kUnboxedInteger;
3463 } 3533 }
3464 3534
3465 void PrintTo(BufferFormatter* f) const; 3535 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
3536 ASSERT((idx == 0) || (idx == 1));
3537 return kUnboxedInteger;
3538 }
3466 3539
3467 virtual bool InferRange(); 3540 virtual intptr_t DeoptimizationTarget() const {
3541 // Direct access since this instuction cannot deoptimize, and the deopt-id
3542 // was inherited from another instuction that could deoptimize.
3543 return deopt_id_;
3544 }
3545
3546 DECLARE_INSTRUCTION(UnboxedMintBinaryOp)
3468 3547
3469 private: 3548 private:
3470 const Token::Kind op_kind_; 3549 const Token::Kind op_kind_;
3471 InstanceCallInstr* instance_call_;
3472 bool overflow_;
3473 3550
3474 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr); 3551 DISALLOW_COPY_AND_ASSIGN(UnboxedMintBinaryOpInstr);
3475 }; 3552 };
3476 3553
3477 3554
3478 class BinaryMintOpInstr : public TemplateDefinition<2> { 3555 class BinarySmiOpInstr : public TemplateDefinition<2> {
Florian Schneider 2012/09/24 13:43:39 This diff looks strange here: I removed BinaryMint
3479 public: 3556 public:
3480 BinaryMintOpInstr(Token::Kind op_kind, 3557 BinarySmiOpInstr(Token::Kind op_kind,
3481 InstanceCallInstr* instance_call, 3558 InstanceCallInstr* instance_call,
3482 Value* left, 3559 Value* left,
3483 Value* right) 3560 Value* right)
3484 : op_kind_(op_kind), 3561 : op_kind_(op_kind),
3485 instance_call_(instance_call) { 3562 instance_call_(instance_call),
3563 overflow_(true) {
3486 ASSERT(left != NULL); 3564 ASSERT(left != NULL);
3487 ASSERT(right != NULL); 3565 ASSERT(right != NULL);
3488 inputs_[0] = left; 3566 inputs_[0] = left;
3489 inputs_[1] = right; 3567 inputs_[1] = right;
3490 } 3568 }
3491 3569
3492 Value* left() const { return inputs_[0]; } 3570 Value* left() const { return inputs_[0]; }
3493 Value* right() const { return inputs_[1]; } 3571 Value* right() const { return inputs_[1]; }
3494 3572
3495 Token::Kind op_kind() const { return op_kind_; } 3573 Token::Kind op_kind() const { return op_kind_; }
3496 3574
3497 InstanceCallInstr* instance_call() const { return instance_call_; } 3575 InstanceCallInstr* instance_call() const { return instance_call_; }
3498 3576
3499 const ICData* ic_data() const { return instance_call()->ic_data(); } 3577 const ICData* ic_data() const { return instance_call()->ic_data(); }
3500 3578
3501 virtual void PrintOperandsTo(BufferFormatter* f) const; 3579 virtual void PrintOperandsTo(BufferFormatter* f) const;
3502 3580
3503 DECLARE_INSTRUCTION(BinaryMintOp) 3581 DECLARE_INSTRUCTION(BinarySmiOp)
3582
3583 void set_overflow(bool overflow) {
3584 overflow_ = overflow;
3585 }
3586
3587 void PrintTo(BufferFormatter* f) const;
3588
3589 virtual bool InferRange();
3590
3504 virtual RawAbstractType* CompileType() const; 3591 virtual RawAbstractType* CompileType() const;
3505 3592
3506 virtual bool CanDeoptimize() const { return true; } 3593 virtual bool CanDeoptimize() const;
3507 3594
3508 virtual bool HasSideEffect() const { return false; } 3595 virtual bool HasSideEffect() const { return false; }
3509 3596
3597 virtual bool AffectedBySideEffect() const { return false; }
3598 virtual bool AttributesEqual(Instruction* other) const;
3599
3510 virtual intptr_t ResultCid() const; 3600 virtual intptr_t ResultCid() const;
3511 3601
3512 private: 3602 private:
3513 const Token::Kind op_kind_; 3603 const Token::Kind op_kind_;
3514 InstanceCallInstr* instance_call_; 3604 InstanceCallInstr* instance_call_;
3605 bool overflow_;
3515 3606
3516 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); 3607 DISALLOW_COPY_AND_ASSIGN(BinarySmiOpInstr);
3517 }; 3608 };
3518 3609
3519 3610
3520 // Handles both Smi operations: BIT_OR and NEGATE. 3611 // Handles both Smi operations: BIT_OR and NEGATE.
3521 class UnarySmiOpInstr : public TemplateDefinition<1> { 3612 class UnarySmiOpInstr : public TemplateDefinition<1> {
3522 public: 3613 public:
3523 UnarySmiOpInstr(Token::Kind op_kind, 3614 UnarySmiOpInstr(Token::Kind op_kind,
3524 InstanceCallInstr* instance_call, 3615 InstanceCallInstr* instance_call,
3525 Value* value) 3616 Value* value)
3526 : op_kind_(op_kind), instance_call_(instance_call) { 3617 : op_kind_(op_kind), instance_call_(instance_call) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
3945 ForwardInstructionIterator* current_iterator_; 4036 ForwardInstructionIterator* current_iterator_;
3946 4037
3947 private: 4038 private:
3948 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4039 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3949 }; 4040 };
3950 4041
3951 4042
3952 } // namespace dart 4043 } // namespace dart
3953 4044
3954 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4045 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698