Chromium Code Reviews| 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 3429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3440 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) | 3440 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) |
| 3441 | 3441 |
| 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 HLoadContextSlot(HValue* context , int slot_index) | 3450 enum Mode { |
| 3451 : HUnaryOperation(context), slot_index_(slot_index) { | 3451 // Perform a normal load of the context slot without checking its value. |
| 3452 kLoad, | |
| 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 | |
| 3455 // harmony bindings where we deoptimize into full-codegen generated code | |
| 3456 // which will subsequently throw a reference error. | |
| 3457 kLoadCheck | |
| 3458 }; | |
| 3459 | |
| 3460 HLoadContextSlot(HValue* context, Variable* var) | |
| 3461 : HUnaryOperation(context), slot_index_(var->index()) { | |
| 3462 ASSERT(var->IsContextSlot()); | |
| 3463 mode_ = (var->mode() == LET || var->mode() == CONST_HARMONY) | |
| 3464 ? kLoadCheck : kLoad; | |
| 3452 set_representation(Representation::Tagged()); | 3465 set_representation(Representation::Tagged()); |
| 3453 SetFlag(kUseGVN); | 3466 SetFlag(kUseGVN); |
| 3454 SetFlag(kDependsOnContextSlots); | 3467 SetFlag(kDependsOnContextSlots); |
| 3455 } | 3468 } |
| 3456 | 3469 |
| 3457 int slot_index() const { return slot_index_; } | 3470 int slot_index() const { return slot_index_; } |
| 3458 | 3471 |
| 3472 bool RequiresHoleCheck() { | |
| 3473 return mode_ == kLoadCheck; | |
| 3474 } | |
| 3475 | |
| 3459 virtual Representation RequiredInputRepresentation(int index) { | 3476 virtual Representation RequiredInputRepresentation(int index) { |
| 3460 return Representation::Tagged(); | 3477 return Representation::Tagged(); |
| 3461 } | 3478 } |
| 3462 | 3479 |
| 3463 virtual void PrintDataTo(StringStream* stream); | 3480 virtual void PrintDataTo(StringStream* stream); |
| 3464 | 3481 |
| 3465 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) | 3482 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) |
| 3466 | 3483 |
| 3467 protected: | 3484 protected: |
| 3468 virtual bool DataEquals(HValue* other) { | 3485 virtual bool DataEquals(HValue* other) { |
| 3469 HLoadContextSlot* b = HLoadContextSlot::cast(other); | 3486 HLoadContextSlot* b = HLoadContextSlot::cast(other); |
| 3470 return (slot_index() == b->slot_index()); | 3487 return (slot_index() == b->slot_index()); |
| 3471 } | 3488 } |
| 3472 | 3489 |
| 3473 private: | 3490 private: |
| 3474 int slot_index_; | 3491 int slot_index_; |
| 3492 Mode mode_; | |
| 3475 }; | 3493 }; |
| 3476 | 3494 |
| 3477 | 3495 |
| 3478 class HStoreContextSlot: public HTemplateInstruction<2> { | 3496 class HStoreContextSlot: public HTemplateInstruction<2> { |
| 3479 public: | 3497 public: |
| 3480 HStoreContextSlot(HValue* context, int slot_index, HValue* value) | 3498 enum Mode { |
| 3481 : slot_index_(slot_index) { | 3499 // Perform a normal store to the context slot without checking its previous |
| 3500 // value. | |
| 3501 kAssign, | |
| 3502 // 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 | |
| 3504 // harmony bindings where we deoptimize into full-codegen generated code | |
| 3505 // which will subsequently throw a reference error. | |
| 3506 kAssignCheck | |
| 3507 }; | |
| 3508 | |
| 3509 HStoreContextSlot(HValue* context, Variable* var, HValue* value) | |
| 3510 : slot_index_(var->index()) { | |
|
fschneider
2011/12/09 08:37:40
I'm not convinced that two constructors are better
Steven
2011/12/09 09:44:56
Agreed.
| |
| 3511 ASSERT(var->IsContextSlot()); | |
| 3512 mode_ = (var->mode() == LET || var->mode() == CONST_HARMONY) | |
| 3513 ? kAssignCheck : kAssign; | |
| 3482 SetOperandAt(0, context); | 3514 SetOperandAt(0, context); |
| 3483 SetOperandAt(1, value); | 3515 SetOperandAt(1, value); |
| 3484 SetFlag(kChangesContextSlots); | 3516 SetFlag(kChangesContextSlots); |
| 3517 } | |
| 3518 | |
| 3519 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) | |
| 3520 : slot_index_(slot_index), mode_(mode) { | |
| 3521 SetOperandAt(0, context); | |
| 3522 SetOperandAt(1, value); | |
| 3523 SetFlag(kChangesContextSlots); | |
| 3485 } | 3524 } |
| 3486 | 3525 |
| 3487 HValue* context() { return OperandAt(0); } | 3526 HValue* context() { return OperandAt(0); } |
| 3488 HValue* value() { return OperandAt(1); } | 3527 HValue* value() { return OperandAt(1); } |
| 3489 int slot_index() const { return slot_index_; } | 3528 int slot_index() const { return slot_index_; } |
| 3529 Mode mode() const { return mode_; } | |
| 3490 | 3530 |
| 3491 bool NeedsWriteBarrier() { | 3531 bool NeedsWriteBarrier() { |
| 3492 return StoringValueNeedsWriteBarrier(value()); | 3532 return StoringValueNeedsWriteBarrier(value()); |
| 3493 } | 3533 } |
| 3494 | 3534 |
| 3535 bool RequiresHoleCheck() { | |
| 3536 return mode_ == kAssignCheck; | |
| 3537 } | |
| 3538 | |
| 3495 virtual Representation RequiredInputRepresentation(int index) { | 3539 virtual Representation RequiredInputRepresentation(int index) { |
| 3496 return Representation::Tagged(); | 3540 return Representation::Tagged(); |
| 3497 } | 3541 } |
| 3498 | 3542 |
| 3499 virtual void PrintDataTo(StringStream* stream); | 3543 virtual void PrintDataTo(StringStream* stream); |
| 3500 | 3544 |
| 3501 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) | 3545 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
| 3502 | 3546 |
| 3503 private: | 3547 private: |
| 3504 int slot_index_; | 3548 int slot_index_; |
| 3549 Mode mode_; | |
| 3505 }; | 3550 }; |
| 3506 | 3551 |
| 3507 | 3552 |
| 3508 class HLoadNamedField: public HUnaryOperation { | 3553 class HLoadNamedField: public HUnaryOperation { |
| 3509 public: | 3554 public: |
| 3510 HLoadNamedField(HValue* object, bool is_in_object, int offset) | 3555 HLoadNamedField(HValue* object, bool is_in_object, int offset) |
| 3511 : HUnaryOperation(object), | 3556 : HUnaryOperation(object), |
| 3512 is_in_object_(is_in_object), | 3557 is_in_object_(is_in_object), |
| 3513 offset_(offset) { | 3558 offset_(offset) { |
| 3514 set_representation(Representation::Tagged()); | 3559 set_representation(Representation::Tagged()); |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4429 | 4474 |
| 4430 DECLARE_CONCRETE_INSTRUCTION(In) | 4475 DECLARE_CONCRETE_INSTRUCTION(In) |
| 4431 }; | 4476 }; |
| 4432 | 4477 |
| 4433 #undef DECLARE_INSTRUCTION | 4478 #undef DECLARE_INSTRUCTION |
| 4434 #undef DECLARE_CONCRETE_INSTRUCTION | 4479 #undef DECLARE_CONCRETE_INSTRUCTION |
| 4435 | 4480 |
| 4436 } } // namespace v8::internal | 4481 } } // namespace v8::internal |
| 4437 | 4482 |
| 4438 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4483 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |