OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; | 1130 class StoreFieldByIndexBits : public BitField<int, 0, 13> {}; |
1131 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; | 1131 class RepresentationBits : public BitField<uint8_t, 13, 4> {}; |
1132 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; | 1132 class StoreModeBits : public BitField<StoreMode, 17, 2> {}; |
1133 | 1133 |
1134 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); | 1134 DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub); |
1135 }; | 1135 }; |
1136 | 1136 |
1137 | 1137 |
1138 class StoreGlobalStub : public HandlerStub { | 1138 class StoreGlobalStub : public HandlerStub { |
1139 public: | 1139 public: |
1140 StoreGlobalStub(Isolate* isolate, bool is_constant, bool check_global) | 1140 StoreGlobalStub(Isolate* isolate, PropertyCellType type, |
| 1141 Maybe<PropertyCellConstantType> constant_type, |
| 1142 bool check_global) |
1141 : HandlerStub(isolate) { | 1143 : HandlerStub(isolate) { |
1142 set_sub_minor_key(IsConstantBits::encode(is_constant) | | 1144 PropertyCellConstantType encoded_constant_type = |
| 1145 constant_type.FromMaybe(PropertyCellConstantType::kSmi); |
| 1146 set_sub_minor_key(CellTypeBits::encode(type) | |
| 1147 ConstantTypeBits::encode(encoded_constant_type) | |
1143 CheckGlobalBits::encode(check_global)); | 1148 CheckGlobalBits::encode(check_global)); |
1144 } | 1149 } |
1145 | 1150 |
1146 static Handle<HeapObject> property_cell_placeholder(Isolate* isolate) { | 1151 static Handle<HeapObject> property_cell_placeholder(Isolate* isolate) { |
1147 return isolate->factory()->uninitialized_value(); | 1152 return isolate->factory()->uninitialized_value(); |
1148 } | 1153 } |
1149 | 1154 |
| 1155 static Handle<HeapObject> global_map_placeholder(Isolate* isolate) { |
| 1156 return isolate->factory()->termination_exception(); |
| 1157 } |
| 1158 |
1150 Handle<Code> GetCodeCopyFromTemplate(Handle<GlobalObject> global, | 1159 Handle<Code> GetCodeCopyFromTemplate(Handle<GlobalObject> global, |
1151 Handle<PropertyCell> cell) { | 1160 Handle<PropertyCell> cell) { |
| 1161 Code::FindAndReplacePattern pattern; |
1152 if (check_global()) { | 1162 if (check_global()) { |
1153 Code::FindAndReplacePattern pattern; | 1163 pattern.Add(handle(global_map_placeholder(isolate())->map()), |
1154 pattern.Add(isolate()->factory()->meta_map(), | |
1155 Map::WeakCellForMap(Handle<Map>(global->map()))); | 1164 Map::WeakCellForMap(Handle<Map>(global->map()))); |
1156 pattern.Add(Handle<Map>(property_cell_placeholder(isolate())->map()), | |
1157 isolate()->factory()->NewWeakCell(cell)); | |
1158 return CodeStub::GetCodeCopy(pattern); | |
1159 } else { | |
1160 Code::FindAndReplacePattern pattern; | |
1161 pattern.Add(Handle<Map>(property_cell_placeholder(isolate())->map()), | |
1162 isolate()->factory()->NewWeakCell(cell)); | |
1163 return CodeStub::GetCodeCopy(pattern); | |
1164 } | 1165 } |
| 1166 pattern.Add(handle(property_cell_placeholder(isolate())->map()), |
| 1167 isolate()->factory()->NewWeakCell(cell)); |
| 1168 return CodeStub::GetCodeCopy(pattern); |
1165 } | 1169 } |
1166 | 1170 |
1167 Code::Kind kind() const override { return Code::STORE_IC; } | 1171 Code::Kind kind() const override { return Code::STORE_IC; } |
1168 | 1172 |
1169 bool is_constant() const { return IsConstantBits::decode(sub_minor_key()); } | 1173 PropertyCellType cell_type() const { |
| 1174 return CellTypeBits::decode(sub_minor_key()); |
| 1175 } |
| 1176 |
| 1177 PropertyCellConstantType constant_type() const { |
| 1178 DCHECK(PropertyCellType::kConstantType == cell_type()); |
| 1179 return ConstantTypeBits::decode(sub_minor_key()); |
| 1180 } |
1170 | 1181 |
1171 bool check_global() const { return CheckGlobalBits::decode(sub_minor_key()); } | 1182 bool check_global() const { return CheckGlobalBits::decode(sub_minor_key()); } |
1172 | 1183 |
1173 void set_is_constant(bool value) { | |
1174 set_sub_minor_key(IsConstantBits::update(sub_minor_key(), value)); | |
1175 } | |
1176 | |
1177 Representation representation() { | 1184 Representation representation() { |
1178 return Representation::FromKind( | 1185 return Representation::FromKind( |
1179 RepresentationBits::decode(sub_minor_key())); | 1186 RepresentationBits::decode(sub_minor_key())); |
1180 } | 1187 } |
1181 | 1188 |
1182 void set_representation(Representation r) { | 1189 void set_representation(Representation r) { |
1183 set_sub_minor_key(RepresentationBits::update(sub_minor_key(), r.kind())); | 1190 set_sub_minor_key(RepresentationBits::update(sub_minor_key(), r.kind())); |
1184 } | 1191 } |
1185 | 1192 |
1186 private: | 1193 private: |
1187 class IsConstantBits: public BitField<bool, 0, 1> {}; | 1194 class CellTypeBits : public BitField<PropertyCellType, 0, 2> {}; |
1188 class RepresentationBits: public BitField<Representation::Kind, 1, 8> {}; | 1195 class ConstantTypeBits : public BitField<PropertyCellConstantType, 2, 2> {}; |
1189 class CheckGlobalBits: public BitField<bool, 9, 1> {}; | 1196 class RepresentationBits : public BitField<Representation::Kind, 4, 8> {}; |
| 1197 class CheckGlobalBits : public BitField<bool, 12, 1> {}; |
1190 | 1198 |
1191 DEFINE_HANDLER_CODE_STUB(StoreGlobal, HandlerStub); | 1199 DEFINE_HANDLER_CODE_STUB(StoreGlobal, HandlerStub); |
1192 }; | 1200 }; |
1193 | 1201 |
1194 | 1202 |
1195 class CallApiFunctionStub : public PlatformCodeStub { | 1203 class CallApiFunctionStub : public PlatformCodeStub { |
1196 public: | 1204 public: |
1197 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) | 1205 explicit CallApiFunctionStub(Isolate* isolate, bool call_data_undefined) |
1198 : PlatformCodeStub(isolate) { | 1206 : PlatformCodeStub(isolate) { |
1199 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); | 1207 minor_key_ = CallDataUndefinedBits::encode(call_data_undefined); |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 | 2797 |
2790 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR | 2798 #undef DEFINE_CALL_INTERFACE_DESCRIPTOR |
2791 #undef DEFINE_PLATFORM_CODE_STUB | 2799 #undef DEFINE_PLATFORM_CODE_STUB |
2792 #undef DEFINE_HANDLER_CODE_STUB | 2800 #undef DEFINE_HANDLER_CODE_STUB |
2793 #undef DEFINE_HYDROGEN_CODE_STUB | 2801 #undef DEFINE_HYDROGEN_CODE_STUB |
2794 #undef DEFINE_CODE_STUB | 2802 #undef DEFINE_CODE_STUB |
2795 #undef DEFINE_CODE_STUB_BASE | 2803 #undef DEFINE_CODE_STUB_BASE |
2796 } } // namespace v8::internal | 2804 } } // namespace v8::internal |
2797 | 2805 |
2798 #endif // V8_CODE_STUBS_H_ | 2806 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |