OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3442 private: | 3442 private: |
3443 Handle<Object> name_; | 3443 Handle<Object> name_; |
3444 StrictModeFlag strict_mode_flag_; | 3444 StrictModeFlag strict_mode_flag_; |
3445 }; | 3445 }; |
3446 | 3446 |
3447 | 3447 |
3448 class HLoadContextSlot: public HUnaryOperation { | 3448 class HLoadContextSlot: public HUnaryOperation { |
3449 public: | 3449 public: |
3450 enum Mode { | 3450 enum Mode { |
3451 // Perform a normal load of the context slot without checking its value. | 3451 // Perform a normal load of the context slot without checking its value. |
3452 kLoad, | 3452 kNoCheck, |
3453 // Load and check the value of the context slot. Deoptimize if it's the | 3453 // Load and check the value of the context slot. Deoptimize if it's the |
3454 // hole value. This is used for checking for loading of uninitialized | 3454 // hole value. This is used for checking for loading of uninitialized |
3455 // harmony bindings where we deoptimize into full-codegen generated code | 3455 // harmony bindings where we deoptimize into full-codegen generated code |
3456 // which will subsequently throw a reference error. | 3456 // which will subsequently throw a reference error. |
3457 kLoadCheck | 3457 kCheckDeoptimize, |
3458 // Load and check the value of the context slot. Return undefined if it's | |
3459 // the hole value. This is used for non-harmony const assignments | |
3460 kCheckReturnUndefined | |
3458 }; | 3461 }; |
3459 | 3462 |
3460 HLoadContextSlot(HValue* context, Variable* var) | 3463 HLoadContextSlot(HValue* context, Variable* var) |
3461 : HUnaryOperation(context), slot_index_(var->index()) { | 3464 : HUnaryOperation(context), slot_index_(var->index()) { |
3462 ASSERT(var->IsContextSlot()); | 3465 ASSERT(var->IsContextSlot()); |
3463 mode_ = (var->mode() == LET || var->mode() == CONST_HARMONY) | 3466 switch (var->mode()) { |
3464 ? kLoadCheck : kLoad; | 3467 case LET: |
3468 case CONST_HARMONY: | |
3469 mode_ = kCheckDeoptimize; | |
3470 break; | |
3471 case CONST: | |
3472 mode_ = kCheckReturnUndefined; | |
3473 break; | |
3474 default: | |
3475 mode_ = kNoCheck; | |
3476 } | |
3465 set_representation(Representation::Tagged()); | 3477 set_representation(Representation::Tagged()); |
3466 SetFlag(kUseGVN); | 3478 SetFlag(kUseGVN); |
3467 SetFlag(kDependsOnContextSlots); | 3479 SetFlag(kDependsOnContextSlots); |
3468 } | 3480 } |
3469 | 3481 |
3470 int slot_index() const { return slot_index_; } | 3482 int slot_index() const { return slot_index_; } |
3483 Mode mode() const { return mode_; } | |
3484 | |
3485 bool DeoptimizesOnHole() { | |
3486 return mode_ == kCheckDeoptimize; | |
3487 } | |
3471 | 3488 |
3472 bool RequiresHoleCheck() { | 3489 bool RequiresHoleCheck() { |
3473 return mode_ == kLoadCheck; | 3490 return mode_ != kNoCheck; |
3474 } | 3491 } |
3475 | 3492 |
3476 virtual Representation RequiredInputRepresentation(int index) { | 3493 virtual Representation RequiredInputRepresentation(int index) { |
3477 return Representation::Tagged(); | 3494 return Representation::Tagged(); |
3478 } | 3495 } |
3479 | 3496 |
3480 virtual void PrintDataTo(StringStream* stream); | 3497 virtual void PrintDataTo(StringStream* stream); |
3481 | 3498 |
3482 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) | 3499 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) |
3483 | 3500 |
3484 protected: | 3501 protected: |
3485 virtual bool DataEquals(HValue* other) { | 3502 virtual bool DataEquals(HValue* other) { |
3486 HLoadContextSlot* b = HLoadContextSlot::cast(other); | 3503 HLoadContextSlot* b = HLoadContextSlot::cast(other); |
3487 return (slot_index() == b->slot_index()); | 3504 return (slot_index() == b->slot_index()); |
3488 } | 3505 } |
3489 | 3506 |
3490 private: | 3507 private: |
3491 int slot_index_; | 3508 int slot_index_; |
3492 Mode mode_; | 3509 Mode mode_; |
3493 }; | 3510 }; |
3494 | 3511 |
3495 | 3512 |
3496 class HStoreContextSlot: public HTemplateInstruction<2> { | 3513 class HStoreContextSlot: public HTemplateInstruction<2> { |
3497 public: | 3514 public: |
3498 enum Mode { | 3515 enum Mode { |
3499 // Perform a normal store to the context slot without checking its previous | 3516 // Perform a normal store to the context slot without checking its previous |
3500 // value. | 3517 // value. |
3501 kAssign, | 3518 kNoCheck, |
3502 // Check the previous value of the context slot and deoptimize if it's the | 3519 // Check the previous value of the context slot and deoptimize if it's the |
3503 // hole value. This is used for checking for assignments to uninitialized | 3520 // hole value. This is used for checking for assignments to uninitialized |
3504 // harmony bindings where we deoptimize into full-codegen generated code | 3521 // harmony bindings where we deoptimize into full-codegen generated code |
3505 // which will subsequently throw a reference error. | 3522 // which will subsequently throw a reference error. |
3506 kAssignCheck | 3523 kCheckDeoptimize, |
3524 // Check the previous value and ignore assignment if it isn't a hole value | |
3525 kCheckIgnoreAssignment | |
3507 }; | 3526 }; |
3508 | 3527 |
3509 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) | 3528 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) |
3510 : slot_index_(slot_index), mode_(mode) { | 3529 : slot_index_(slot_index), mode_(mode) { |
3511 SetOperandAt(0, context); | 3530 SetOperandAt(0, context); |
3512 SetOperandAt(1, value); | 3531 SetOperandAt(1, value); |
3513 SetFlag(kChangesContextSlots); | 3532 SetFlag(kChangesContextSlots); |
3514 } | 3533 } |
3515 | 3534 |
3516 HValue* context() { return OperandAt(0); } | 3535 HValue* context() { return OperandAt(0); } |
3517 HValue* value() { return OperandAt(1); } | 3536 HValue* value() { return OperandAt(1); } |
3518 int slot_index() const { return slot_index_; } | 3537 int slot_index() const { return slot_index_; } |
3519 Mode mode() const { return mode_; } | 3538 Mode mode() const { return mode_; } |
3520 | 3539 |
3521 bool NeedsWriteBarrier() { | 3540 bool NeedsWriteBarrier() { |
3522 return StoringValueNeedsWriteBarrier(value()); | 3541 return StoringValueNeedsWriteBarrier(value()); |
3523 } | 3542 } |
3524 | 3543 |
3544 bool DeoptimizesOnHole() { | |
3545 return mode_ == kCheckDeoptimize; | |
3546 } | |
3547 | |
3525 bool RequiresHoleCheck() { | 3548 bool RequiresHoleCheck() { |
3526 return mode_ == kAssignCheck; | 3549 return mode_ == kCheckIgnoreAssignment; |
Steven
2011/12/12 13:12:44
This should better be mode_ != kNoCheck?
indutny
2011/12/12 13:59:05
oh, sorry. this was made by mistake (ok in LoadCon
| |
3527 } | 3550 } |
3528 | 3551 |
3529 virtual Representation RequiredInputRepresentation(int index) { | 3552 virtual Representation RequiredInputRepresentation(int index) { |
3530 return Representation::Tagged(); | 3553 return Representation::Tagged(); |
3531 } | 3554 } |
3532 | 3555 |
3533 virtual void PrintDataTo(StringStream* stream); | 3556 virtual void PrintDataTo(StringStream* stream); |
3534 | 3557 |
3535 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) | 3558 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
3536 | 3559 |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4464 | 4487 |
4465 DECLARE_CONCRETE_INSTRUCTION(In) | 4488 DECLARE_CONCRETE_INSTRUCTION(In) |
4466 }; | 4489 }; |
4467 | 4490 |
4468 #undef DECLARE_INSTRUCTION | 4491 #undef DECLARE_INSTRUCTION |
4469 #undef DECLARE_CONCRETE_INSTRUCTION | 4492 #undef DECLARE_CONCRETE_INSTRUCTION |
4470 | 4493 |
4471 } } // namespace v8::internal | 4494 } } // namespace v8::internal |
4472 | 4495 |
4473 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4496 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |