OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 5073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5084 | 5084 |
5085 // Go up context chain to the script context. | 5085 // Go up context chain to the script context. |
5086 for (int i = 0; i < depth(); ++i) { | 5086 for (int i = 0; i < depth(); ++i) { |
5087 __ movp(rdi, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); | 5087 __ movp(rdi, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); |
5088 context_reg = rdi; | 5088 context_reg = rdi; |
5089 } | 5089 } |
5090 | 5090 |
5091 // Load the PropertyCell at the specified slot. | 5091 // Load the PropertyCell at the specified slot. |
5092 __ movp(cell_reg, ContextOperand(context_reg, slot_reg)); | 5092 __ movp(cell_reg, ContextOperand(context_reg, slot_reg)); |
5093 | 5093 |
5094 // Check that value is not the_hole. | 5094 // Load PropertyDetails for the cell (actually only the cell_type, kind and |
5095 __ movp(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); | 5095 // READ_ONLY bit of attributes). |
5096 __ CompareRoot(cell_value_reg, Heap::kTheHoleValueRootIndex); | |
5097 __ j(equal, &slow_case, FLAG_debug_code ? Label::kFar : Label::kNear); | |
5098 | |
5099 // Load PropertyDetails for the cell (actually only the cell_type and kind). | |
5100 __ SmiToInteger32(cell_details_reg, | 5096 __ SmiToInteger32(cell_details_reg, |
5101 FieldOperand(cell_reg, PropertyCell::kDetailsOffset)); | 5097 FieldOperand(cell_reg, PropertyCell::kDetailsOffset)); |
5102 __ andl(cell_details_reg, | 5098 __ andl(cell_details_reg, |
5103 Immediate(PropertyDetails::PropertyCellTypeField::kMask | | 5099 Immediate(PropertyDetails::PropertyCellTypeField::kMask | |
5104 PropertyDetails::KindField::kMask)); | 5100 PropertyDetails::KindField::kMask | |
5105 | 5101 PropertyDetails::kAttributesReadOnlyMask)); |
5106 | 5102 |
5107 // Check if PropertyCell holds mutable data. | 5103 // Check if PropertyCell holds mutable data. |
5108 Label not_mutable_data; | 5104 Label not_mutable_data; |
5109 __ cmpl(cell_details_reg, | 5105 __ cmpl(cell_details_reg, |
5110 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5106 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
5111 PropertyCellType::kMutable) | | 5107 PropertyCellType::kMutable) | |
5112 PropertyDetails::KindField::encode(kData))); | 5108 PropertyDetails::KindField::encode(kData))); |
5113 __ j(not_equal, ¬_mutable_data); | 5109 __ j(not_equal, ¬_mutable_data); |
5114 __ JumpIfSmi(value_reg, &fast_smi_case); | 5110 __ JumpIfSmi(value_reg, &fast_smi_case); |
5115 __ bind(&fast_heapobject_case); | 5111 __ bind(&fast_heapobject_case); |
5116 __ movp(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); | 5112 __ movp(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); |
5117 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, | 5113 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, |
5118 cell_value_reg, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 5114 cell_value_reg, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
5119 OMIT_SMI_CHECK); | 5115 OMIT_SMI_CHECK); |
5120 // RecordWriteField clobbers the value register, so we need to reload. | 5116 // RecordWriteField clobbers the value register, so we need to reload. |
5121 __ movp(value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); | 5117 __ movp(value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); |
5122 __ Ret(); | 5118 __ Ret(); |
5123 __ bind(¬_mutable_data); | 5119 __ bind(¬_mutable_data); |
5124 | 5120 |
5125 // Check if PropertyCell value matches the new value (relevant for Constant, | 5121 // Check if PropertyCell value matches the new value (relevant for Constant, |
5126 // ConstantType and Undefined cells). | 5122 // ConstantType and Undefined cells). |
5127 Label not_same_value; | 5123 Label not_same_value; |
| 5124 __ movp(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); |
5128 __ cmpp(cell_value_reg, value_reg); | 5125 __ cmpp(cell_value_reg, value_reg); |
5129 __ j(not_equal, ¬_same_value, | 5126 __ j(not_equal, ¬_same_value, |
5130 FLAG_debug_code ? Label::kFar : Label::kNear); | 5127 FLAG_debug_code ? Label::kFar : Label::kNear); |
| 5128 // Make sure the PropertyCell is not marked READ_ONLY. |
| 5129 __ testl(cell_details_reg, |
| 5130 Immediate(PropertyDetails::kAttributesReadOnlyMask)); |
| 5131 __ j(not_zero, &slow_case); |
5131 if (FLAG_debug_code) { | 5132 if (FLAG_debug_code) { |
5132 Label done; | 5133 Label done; |
5133 // This can only be true for Constant, ConstantType and Undefined cells, | 5134 // This can only be true for Constant, ConstantType and Undefined cells, |
5134 // because we never store the_hole via this stub. | 5135 // because we never store the_hole via this stub. |
5135 __ cmpl(cell_details_reg, | 5136 __ cmpl(cell_details_reg, |
5136 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5137 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
5137 PropertyCellType::kConstant) | | 5138 PropertyCellType::kConstant) | |
5138 PropertyDetails::KindField::encode(kData))); | 5139 PropertyDetails::KindField::encode(kData))); |
5139 __ j(equal, &done); | 5140 __ j(equal, &done); |
5140 __ cmpl(cell_details_reg, | 5141 __ cmpl(cell_details_reg, |
5141 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5142 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
5142 PropertyCellType::kConstantType) | | 5143 PropertyCellType::kConstantType) | |
5143 PropertyDetails::KindField::encode(kData))); | 5144 PropertyDetails::KindField::encode(kData))); |
5144 __ j(equal, &done); | 5145 __ j(equal, &done); |
5145 __ cmpl(cell_details_reg, | 5146 __ cmpl(cell_details_reg, |
5146 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5147 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
5147 PropertyCellType::kUndefined) | | 5148 PropertyCellType::kUndefined) | |
5148 PropertyDetails::KindField::encode(kData))); | 5149 PropertyDetails::KindField::encode(kData))); |
5149 __ Check(equal, kUnexpectedValue); | 5150 __ Check(equal, kUnexpectedValue); |
5150 __ bind(&done); | 5151 __ bind(&done); |
5151 } | 5152 } |
5152 __ Ret(); | 5153 __ Ret(); |
5153 __ bind(¬_same_value); | 5154 __ bind(¬_same_value); |
5154 | 5155 |
5155 // Check if PropertyCell contains data with constant type. | 5156 // Check if PropertyCell contains data with constant type (and is not |
| 5157 // READ_ONLY). |
5156 __ cmpl(cell_details_reg, | 5158 __ cmpl(cell_details_reg, |
5157 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5159 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
5158 PropertyCellType::kConstantType) | | 5160 PropertyCellType::kConstantType) | |
5159 PropertyDetails::KindField::encode(kData))); | 5161 PropertyDetails::KindField::encode(kData))); |
5160 __ j(not_equal, &slow_case, Label::kNear); | 5162 __ j(not_equal, &slow_case, Label::kNear); |
5161 | 5163 |
5162 // Now either both old and new values must be SMIs or both must be heap | 5164 // Now either both old and new values must be SMIs or both must be heap |
5163 // objects with same map. | 5165 // objects with same map. |
5164 Label value_is_heap_object; | 5166 Label value_is_heap_object; |
5165 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); | 5167 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5586 kStackSpace, nullptr, return_value_operand, NULL); | 5588 kStackSpace, nullptr, return_value_operand, NULL); |
5587 } | 5589 } |
5588 | 5590 |
5589 | 5591 |
5590 #undef __ | 5592 #undef __ |
5591 | 5593 |
5592 } // namespace internal | 5594 } // namespace internal |
5593 } // namespace v8 | 5595 } // namespace v8 |
5594 | 5596 |
5595 #endif // V8_TARGET_ARCH_X64 | 5597 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |